Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

zimberzimber wrote:So, scaling local_srt instead of game_matrix fixed the model getting larger, but the attached model will still get scaled down.
Um, yeah, that's the point of parentNode. The child component adopts the transformation of the parent node. Location, rotation, and scale.

re: this stairs mess, if for some reason you are unwilling to just use a ladder, I recommend you use a pair of PlatformComponents (update their y position and the party's position every frame when the party is on them) instead of StairsComponent. StairsComponent will have a really weird interaction with items and with a pair of PlatformComponents you don't have to take the player's controls away.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

Isaac wrote:Experimental stairwell object. ...

*Project includes a new [variant] dungeon stairs model.

https://www.dropbox.com/s/v1mkijllq4yct ... s.zip?dl=0
Something seems to be wrong with the file. I can download it, unzip the folders, but not the files... ??
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

I'm not sure what the problem with it was; but I saw it too, when I downloaded it from the link. Corrupted archive.
I've re-uploaded it, and the link works for me now; I downloaded the file from from it, and extracted the folders.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

minmay wrote:
zimberzimber wrote:So, scaling local_srt instead of game_matrix fixed the model getting larger, but the attached model will still get scaled down.
Um, yeah, that's the point of parentNode. The child component adopts the transformation of the parent node. Location, rotation, and scale.
Figures.
Anything that can be done about the deforming I mentioned in the edit?
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

zimberzimber wrote:
minmay wrote:
zimberzimber wrote:So, scaling local_srt instead of game_matrix fixed the model getting larger, but the attached model will still get scaled down.
Um, yeah, that's the point of parentNode. The child component adopts the transformation of the parent node. Location, rotation, and scale.
Figures.
Anything that can be done about the deforming I mentioned in the edit?
Can you post the .blend? [or just a good description]

*You want a scaled figure, holding a commensurately scaled weapon, yes?
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

My internet access is limited for the next ~week, so I'll post how I got to this.

Imported tunnel_ogre model with the LoG2 plugin into Blender2.71
Imported tunnel_ogre_get_hit animation
Selected local_srt, scaled it down to -0.5, applied scale
And the model bends.

Pivot centre was set to 3D cursor, and it was centered. Changing it to anything else didn't help.
Scaling everything under local_srt (not local_srt itself) still bends the model
Scaling RootNode instead, doesn't cause the bending, but the monster will scale back to its original size if you are to attach a model to a node.
My asset pack [v1.10]
Features a bit of everything! :D
brzrkr
Posts: 11
Joined: Wed Aug 10, 2016 4:05 pm

Re: Ask a simple question, get a simple answer

Post by brzrkr »

Hello.

I was looking for a way to resurrect a certain monster in case it was killed, but I couldn't find any method or function to do so. Using setHealth() doesn't seem to work if the monster is downright dead.

I also found that the onDie() hook says that "if it returns false, the monster is resurrected" but I don't know how to do that. Obviously calling the hook directly doesn't work and results in an error.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

brzrkr wrote:Hello.

I was looking for a way to resurrect a certain monster in case it was killed, but I couldn't find any method or function to do so. Using setHealth() doesn't seem to work if the monster is downright dead.

I also found that the onDie() hook says that "if it returns false, the monster is resurrected" but I don't know how to do that. Obviously calling the hook directly doesn't work and results in an error.
Add this to the monster component. (Where you define the monsters stats like health and protection)

Code: Select all

onDie = function(self)
return false
end,
Care to give some context on the monster and the reason behind its ressurection?
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

If it returns false... the monster doesn't die at all ~no effect.

To resurrect a monster on the spot, you can use the onDie hook to spawn another one after they die.
SpoilerShow
*To use: The full monster definition [below] must be placed in a referenced script in the project folder; usually "mod_assets/scripts/monsters.lua" .
(Then use the new variant monster on the map; and it cannot die.)

excerpt:

Code: Select all

onDie = function(self) self.go:spawn(self.go.name) end,
full:

Code: Select all

defineObject{
	name = "undead_respawn",
	baseObject = "undead",
	components = {
		{
			class = "Monster",
			meshName = "undead_mesh",
			footstepSound = "skeleton_footstep",
			hitSound = "skeleton_hit",
			dieSound = "undead_die",
			hitEffect = "hit_dust",
			capsuleHeight = 0.7,
			capsuleRadius = 0.25,
			collisionRadius = 0.6,
			health = 475,
			immunities = { "sleep" },
			resistances = { ["poison"] = "immune" },
			traits = { "undead" },
			evasion = 0,
			exp = 200,
			onInit = function(self)
				self:performAction("rise")
			end,
			onDie = function(self) self.go:spawn(self.go.name) end,
			headRotation = vec(0, 0, 90),
		},
	},
}
excerpt:

Code: Select all

onDie = function(self) self.go:playSound("zarchton_diving_alert") findEntity(self.go:spawn(self.go.name).id).monster:performAction('riseFromWater') end,
full:

Code: Select all

defineObject{
	name = "zarchton_respawn",
	baseObject = "zarchton",
	components = {
		{
			class = "Monster",
			meshName = "zarchton_mesh",
			hitSound = "zarchton_hit",
			dieSound = "zarchton_die",
			footstepSound = "zarchton_footstep",
			hitEffect = "hit_blood",
			capsuleHeight = 0.2,
			capsuleRadius = 0.7,
			health = 90,
			evasion = 0,
			exp = 75,
			--lootDrop = { 100, "zarchton_harpoon"},
			resistances = { ["shock"] = "weak" },
			onDie = function(self) self.go:playSound("zarchton_diving_alert") findEntity(self.go:spawn(self.go.name).id).monster:performAction('riseFromWater') end,
		},
		{
			class = "MonsterAction",
			name = "riseFromWater",
			animation = "riseFromWater",
		},
	},
}
A practical change to the scripts, would be to pass the onDie hook to a user script on the map. This allows for easy editing, and the the means to revoke the immortality.
Create a script_entity; name it "immortality_switch".
Change the undead onDie hook [above] to this:
SpoilerShow

Code: Select all

			onDie = function(self) if immortality_switch.script:check(self) then
								--original code		
								self.go:spawn(self.go.name)

						 end	
					end,
Then create a script_entity on the map. and name it "immortality_switch".
Paste the following into it:

Code: Select all

respawn = true

function check(self)
	return respawn
end

function disable()	
	respawn = bool
end
function enable()
	respawn = true
end
Calling immortality_switch.script:disable() ~disables respawning.
______________________________________________________________
brzrkr
Posts: 11
Joined: Wed Aug 10, 2016 4:05 pm

Re: Ask a simple question, get a simple answer

Post by brzrkr »

zimberzimber wrote:
brzrkr wrote:Hello.

I was looking for a way to resurrect a certain monster in case it was killed, but I couldn't find any method or function to do so. Using setHealth() doesn't seem to work if the monster is downright dead.

I also found that the onDie() hook says that "if it returns false, the monster is resurrected" but I don't know how to do that. Obviously calling the hook directly doesn't work and results in an error.
Add this to the monster component. (Where you define the monsters stats like health and protection)

Code: Select all

onDie = function(self)
return false
end,
Care to give some context on the monster and the reason behind its ressurection?
The monster is behind a door opened with a button, it's immobile and it's there as a means for the player to damage himself to activate further things. I chose a monster because the initial reaction is to try and kill it, while the player will have to first understand that he actually has to let some party members die to proceed. I set the monster to have very high health, so it being killed is unlikely, but to catch any situation where the player may become stuck I want to resurrect the monster when the aforementioned button is pressed.
As I have put the monster there with the visual editor and not as part of a script, I can't seem to use that snippet you gave me. I'd like to avoid adding monsters via code when possible, since it allows me to have a clearer look in the dungeon editor and have things be a little bit easier.

I should probably mention I'm not an experienced coder and I'm mostly learning as I go, on top of the basic knowledge of lua I already have. Changing the first line to [monsterID].monster.onDie = function(self) doesn't seem to work, I get an error saying I'm trying to modify a read-only property.
Post Reply