Check Boss Health to Spawn Enemies
-
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
Check Boss Health to Spawn Enemies
I'm trying to figure out what code I would need to use to check the health of a boss and spawn in or open up a door as it reaches certain lifepoint amounts.
Basically wanting to make it so each time the boss drops down 25% of its overall hp it will open a door releasing in a few smaller enemies.
Basically wanting to make it so each time the boss drops down 25% of its overall hp it will open a door releasing in a few smaller enemies.
Re: Check Boss Health to Spawn Enemies
MonsterComponent:getHealth()
Also, you might find the scripting reference to be a useful aid in endeavors like this: http://www.grimrock.net/modding/scripting-reference/
Also, you might find the scripting reference to be a useful aid in endeavors like this: http://www.grimrock.net/modding/scripting-reference/
-
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
Re: Check Boss Health to Spawn Enemies
So I'm attempting to build the script around the MonsterComponent:getHealth() command, and it keeps throwing up errors all over the script.
As you can guess I literally have no Idea what I'm doing when it comes to creating my own scripts, that scripting reference thing ends up just confusing me more than helping. :s
SpoilerShow
function CheckHealth()
if MonsterComponent:getHealth() = 750 then
dungeon_door_stone_1.door:open
else
dungeon_door_stone_1.door:close
end
if MonsterComponent:getHealth() = 750 then
dungeon_door_stone_1.door:open
else
dungeon_door_stone_1.door:close
end
Re: Check Boss Health to Spawn Enemies
Let's assume your monster's id is monster_1. Then script will look like following
Analogically to "door" being a DoorComponent of dungeon_door_stone_1 object, "monster" is MonsterComponent of every monster object
SpoilerShow
function CheckHealth()
if monster_1.monster:getHealth() < 750 then
dungeon_door_stone_1.door:open()
else
dungeon_door_stone_1.door:close()
end
if monster_1.monster:getHealth() < 750 then
dungeon_door_stone_1.door:open()
else
dungeon_door_stone_1.door:close()
end
Re: Check Boss Health to Spawn Enemies
Edit: ..lot beated me...
It's not that far away from working solution, this should do the trick.
It's not that far away from working solution, this should do the trick.
Code: Select all
function CheckHealth()
if MonsterComponent:getHealth() <= 750 then
dungeon_door_stone_1.door:open()
else
dungeon_door_stone_1.door:close()
end
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
-
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
Re: Check Boss Health to Spawn Enemies

SpoilerShow
function CheckHealth()
if monster_1.monster:getHealth() < 750 then
dungeon_door_stone_1.door:open()
else
dungeon_door_stone_1.door:close()
end
if monster_1.monster:getHealth() <500 then
dungeon_door_stone_2.door:open()
else
dungeon_door_stone_2.door:close()
end
if monster_1.monster:getHealth() < 750 then
dungeon_door_stone_1.door:open()
else
dungeon_door_stone_1.door:close()
end
if monster_1.monster:getHealth() <500 then
dungeon_door_stone_2.door:open()
else
dungeon_door_stone_2.door:close()
end
-
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
Re: Check Boss Health to Spawn Enemies
So I plugged in
And where it says end, the editor throws up an error. 'end' expected (to close 'function' at line 1) near '<eof>'
What does that mean
I kept the format the same as the suggested codes above and it seems to have broken.
Code: Select all
function CheckHealth()
if Golem.monster:getHealth() <= 750 then
dungeon_secret_door_49.door:open()
else
dungeon_secret_door_49.door:close()
end
What does that mean

- Zo Kath Ra
- Posts: 940
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Check Boss Health to Spawn Enemies
you need two "end" statementsEmera Nova wrote:So I plugged inAnd where it says end, the editor throws up an error. 'end' expected (to close 'function' at line 1) near '<eof>'Code: Select all
function CheckHealth() if Golem.monster:getHealth() <= 750 then dungeon_secret_door_49.door:open() else dungeon_secret_door_49.door:close() end
What does that meanI kept the format the same as the suggested codes above and it seems to have broken.
one for the "function" statement
and one for the "if" statement
-
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
Re: Check Boss Health to Spawn Enemies
Welp, I didn't think this thru all the way xD, so it has to exactly hit 750 hp otherwise nothing happens.. What do I do if I want to have it open if it's health is below a certain lifepoint range and stay open after that point.
- Zo Kath Ra
- Posts: 940
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Check Boss Health to Spawn Enemies
When/how do you check the boss's health?Emera Nova wrote:Welp, I didn't think this thru all the way xD, so it has to exactly hit 750 hp otherwise nothing happens.. What do I do if I want to have it open if it's health is below a certain lifepoint range and stay open after that point.