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!
Post Reply
User avatar
spectre900
Posts: 124
Joined: Fri Sep 14, 2012 1:47 am

Re: Ask a simple question, get a simple answer

Post by spectre900 »

Maybe I'm a bit dumb but I don't understand how spawn scrips work. Say I want to spawn a power gem when an enemy ogre called "burt" is killed on say... "level 0,1,3" on the same tile burt died, how do I do that?

I can just add a power_gem_item to drop on death, but that's hardy as good looking as having a grab-able power_gem object do its swirly animation as it spawns.
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

spectre900 wrote:Maybe I'm a bit dumb but I don't understand how spawn scrips work. Say I want to spawn a power gem when an enemy ogre called "burt" is killed on say... "level 0,1,3" on the same tile burt died, how do I do that?

I can just add a power_gem_item to drop on death, but that's hardy as good looking as having a grab-able power_gem object do its swirly animation as it spawns.
You can use
MonsterComponent.onDie(self)
User avatar
Isaac
Posts: 3179
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

spectre900 wrote:Maybe I'm a bit dumb but I don't understand how spawn scrips work. Say I want to spawn a power gem when an enemy ogre called "burt" is killed on say... "level 0,1,3" on the same tile burt died, how do I do that?

I can just add a power_gem_item to drop on death, but that's hardy as good looking as having a grab-able power_gem object do its swirly animation as it spawns.
There are two power gem objects; use the other one via onDie.

Example script:

Code: Select all

crowern_1.monster:addConnector("onDie", self.go.id, "gemSpawn")

function gemSpawn(self)
	self.go:spawn("power_gem")
end
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Is there a list of monster conditions available somewhere ? I am trying to get the same effect as the "Wand of Fear" item.
User avatar
Isaac
Posts: 3179
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Code: Select all

defineObject{
	name = "wand_fear",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/staff_of_fear.fbx",
		},
		{
			class = "Item",
			uiName = "Wand of Fear",
			description = "This wand will strike fear to the hearts of your enemies.",
			gfxIndex = 225,
			gfxIndexPowerAttack = 443,
			impactSound = "impact_blunt",
			weight = 3.5,
			secondaryAction = "causeFear",
		},
		{
			class = "MeleeAttack",
			attackPower = 7,
			accuracy = 0,
			cooldown = 3,
			swipe = "vertical",
		},
		{
			class = "CastSpell",
			name = "causeFear",
			uiName = "Cloud of Nightmares",
			spell = "cause_fear",
			energyCost = 30,
			cooldown = 5,
			requirements = { "concentration", 2 },
		},
	},
}
It's the spell "causeFear".
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: Ask a simple question, get a simple answer

Post by Leki »

Guys... I'm not sure if this is a simple question...
Let me say, in object definition I have smth like:

Code: Select all

onBeginAction = function(self)
   self.go.animation:play("activate")
end
But what if I have more model components (main is without name, rest has defined smth like name = "part_a" etc), how to call animation for specific one? I have some dirty solution, to achieve what I want, but you know me... I wanna an elegant one and this method is probably what I looking for.[/color]
I'm the Gate I'm the Key.
Dawn of Lore
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

It's like the simplest question that's been posted so far. AnimationComponent has a "model" field that specifies the name of the ModelComponent to animate.
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
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: Ask a simple question, get a simple answer

Post by Leki »

minmay wrote:It's like the simplest question that's been posted so far. AnimationComponent has a "model" field that specifies the name of the ModelComponent to animate.
m8, please...
I have to be more specific as I see. Here is the situation:
monster has model component (without name definition - it's, let me say body - includes meshName "smth" - this is defined in monster component later) and model component (name = "weapons")

monster has animation component. if there is not model = "xxxx" defined, when it moves, body is animated, but "weapons" part of model is not. "weapons" will jump to next cell in next frame 0. Adding model = "weapons" into anim comp animetes weapons but body jumps. There is not a way to animate them both with one animation as far I see (I need the name in models to switch of/on different weapons - onActivate script setups gear for the monster etc... so complex behaviour to explain it here)

If you have more animation components, latest one counts, rest is overwritten as far I see.

So I can use onBegin hook to call animation for second model and play them in sychro in some way (if I can call animation for specific part - adding dynamically name into anim component or smth like that), or to use some other solution I have - like spawning weapons as different animated object and controll it from monster script etc...

So any idea how to call animation for specific model in game object, when part of it is already controlled by animation component?
I'm the Gate I'm the Key.
Dawn of Lore
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Use two AnimationComponents with different names, one AnimationComponent for each model you need to animate. If you try to add two components with the same name then the second one will overwrite the first.
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
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: Ask a simple question, get a simple answer

Post by Leki »

minmay wrote:Use two AnimationComponents with different names, one AnimationComponent for each model you need to animate. If you try to add two components with the same name then the second one will overwrite the first.
Sure, I described it in short way - the problem is that "Monster" logic uses only one animation component, not both (or better to say all of them, if you have more models and "animations" for them) of them as far I see. So I'm looking for solution to "call them directly / or by name".
smth like (it's error, oc):

Code: Select all

onBeginAction = function(self)
   self.go.animation("weapons"):play("moveForward")
end
:?:
[/color]
I'm the Gate I'm the Key.
Dawn of Lore
Post Reply

Return to “Mod Creation”