spawning a monster onDie
spawning a monster onDie
Hello,
can a monster be spawned after the death of another monster, and a the same place of the dying monster?
can a monster be spawned after the death of another monster, and a the same place of the dying monster?
Re: spawning a monster onDie
Yessir. There are at least 2 ways to accomplish this. Let's say you want to Spawn an Ice Guardian when a Uggardian dies:bongobeat wrote:Hello,
can a monster be spawned after the death of another monster, and a the same place of the dying monster?
1) To do this without ever typing a single line of LUA Script, simply place the Ice Guardian in a Single Square room (so he can't move) and place a Teleporter on top of him. Set the Teleporter's Initial State to Deactivate. Now with the Uggardian, in the Script Editor click on his Connector and the OnDie method becomes available. Tie that OnDie method to the Teleporter, make sure it triggers it to Activate. Lastly, set the Teleporter's location to wherever you want the Ice Guardian to end up after the Uggardian dies. You can set up many monsters this way, and get even more creative with how they respawn, where they respawn, and how often this can occur if you tie everything to Counters, Spawners, and Timers. All with zero code!
2) You can Spawn monsters at Runtime using the Spawn() method by creating a Function that sets the OnDie behavior of a monster. Below is example Script that Spawns the Uggardian from a LUA Function, and then after it dies it looks at a Master Counter result to decide if the Uggardian will respawn (along with a Flame Elemental for funsies), or if a hidden Ice Guardian will be moved in to position to attack the party. This uses a combination of the example in Step 1 above (minus the Teleporter) along with script to Spawn a creature at Runtime. This script also checks the position the Ice Guardian should face based on the direction the Party is looking at the time of the Uggardian's death.
Code: Select all
function NewUggardian()
local mob;
do mob = spawn("uggardian", party.level, 11, 15, 1, 0);
mob.monster:addConnector("onDie", "script_entity_18","UggDeath")
mob.monster:setLevel(3);
mob.monster:setMaxHealth(600);
end
end
function UggDeath()
local secondMobFacing = 1; -- Default to East
-- if North then South
if party.facing == 0 then secondMobFacing = 2; end
-- if East then West
if party.facing == 1 then secondMobFacing = 3; end
-- if South then North
if party.facing == 2 then secondMobFacing = 0; end
if master_counter.counter:getValue() <= 0 then
-- move the hidden Ice Guardian in to attack position
ice_guardian_1:setPosition(party.x,party.y,secondMobFacing,party.elevation,party.level);
else
-- respawn the original Uggardian
NewUggardian();
-- for funsies, spawn a Fire Elemental as well
spawn("fire_elemental", party.level, 12, 15, 1)
-- Prompt the players
hudPrint("The creature has returned!");
end
end
To run that script above all you have to do is begin by calling NewUggardian() somehow (like from a Floor Trigger when the party enters a room). Hope this helps, cheers!
Re: spawning a monster onDie
3) To get the same results as those two terrible methods, while being significantly less terrible, put this in the monster's onDie hook instead:
Code: Select all
onDie = function(self)
self.go:spawn("fjeld_warg")
end,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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: spawning a monster onDie
aww, minmay the Mod Troll is on the attack. Poor lil fella.Mod Troll wrote:To get the same results as those two terrible methods, while being significantly less terrible
Your script does not achieve the same result at all, key differences:
1) My script allows you to set the Monster level, your script Spawns the default Level 1
2) My script allows you to set the Monster health, your script Spawns the default Health
3) My script Respawns 2 monsters at once in one scenario, or a second monster in a different, yours spawns 1 no matter what
If you are having trouble understanding why they are different, refer to this:
http://www.grimrock.net/modding/scripting-reference/
Re: spawning a monster onDie
lol "Mod" where the hell did that come from? can someone just ban you already so you stop ruining other people's mods with broken scripts
but for the benefit of other readers: code in the onDie hook allows doing the exact same things:etc
but for the benefit of other readers: code in the onDie hook allows doing the exact same things:
Code: Select all
onDie = function(self)
local warg = spawn("fjeld_warg",self.go.level,self.go.x,self.go.y,(party.facing+2)%4,self.go.elevation)
warg.monster:setLevel(3)
warg.monster:setMaxHealth(600)
warg.monster:setHealth(600)
end,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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: spawning a monster onDie
This is a "Mod Creation" forum and you like insulting people on it, hence you are the Mod Troll...
There's nothing broken about the script I wrote, you are just upset because you have some personal issues. Save your whining for your little Skype sessions with Isaac and crew (I heard about those LOL).
As for your script, you decided to make it look so much more like mine, only you sacrificed readability in order to shove everything in to a single line. Neither your code nor my code is broken, but yours is definitely shaped like oatmeal. Go troll someone else, lil fella.
There's nothing broken about the script I wrote, you are just upset because you have some personal issues. Save your whining for your little Skype sessions with Isaac and crew (I heard about those LOL).
As for your script, you decided to make it look so much more like mine, only you sacrificed readability in order to shove everything in to a single line. Neither your code nor my code is broken, but yours is definitely shaped like oatmeal. Go troll someone else, lil fella.
Re: spawning a monster onDie
ok this is pretty funny I admitAzel wrote:Save your whining for your little Skype sessions with Isaac and crew (I heard about those LOL).
but really can you keep your trolling to the regular forum instead of trying to sabotage other people's mods? it's a pretty dickish thing to do and i'm pretty sure nobody except you thinks it's funny
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: spawning a monster onDie
I fail to see how my original response in this thread is trolling or how it "sabotages" peoples mods. All I know for certain is that you get angry when someone other than you or your little crew contributes code. You can "say" my script is bad but you have failed to illustrate how, which actually makes you the troll. You are far too arrogant for someone who has a tiny bit of borrowed abilities. My intentions are good, your intentions seem quite petty and egotistical, which is why you can't help but insult others who try to contribute on this forum. If you don't like my posts, or my script, you can just ignore them. Pretty easy.
Re: spawning a monster onDie
hermmm, thanks all for your help. Don't get angry, keep cool
I'm gonna try that, I think I will use minmay script, it seems more easier to do.
I want to do that, for only 1 monster, that the party has to fight, then he respawn a npc version of the 1st monster, which will talk to the party.
Azel, I'm not sure that I understand all with the teleporter solution. This method can't spawn the 2nd monster on the exact place where the 1st monster dies, you don't know where the party will kill the first monster. Or I did not understand what you are saying.
I'm gonna try that, I think I will use minmay script, it seems more easier to do.
I want to do that, for only 1 monster, that the party has to fight, then he respawn a npc version of the 1st monster, which will talk to the party.
Azel, I'm not sure that I understand all with the teleporter solution. This method can't spawn the 2nd monster on the exact place where the 1st monster dies, you don't know where the party will kill the first monster. Or I did not understand what you are saying.
Re: spawning a monster onDie
Oh yeah, the Teleporter wouldn't be able to do it in the exact location where the original monster died; unless you added Script. The smaller script minmay gave is definitely better for a straight 1-to-1 scenario: monster dies, monster spawns. Sorry if I confused you, I tend to like to make things a bit more adventurous, so to speak. Cheers!