Page 1 of 1
Create Monster for boss to drain
Posted: Mon Jun 15, 2015 1:57 pm
by Emera Nova
I'm currently putting together a move I'd like to use for bosses and other such things, basically it'll spawn in a monster that you have (x) amount of time to kill if you fail to kill that monster the script will kill it and add health to the boss.
So far what I have out is
Code: Select all
function createmonster()
if findEntity("mummyspawn") ~= nil then
spawn("mummy",7,19,18,2,1,"mummyspawn")
else
end
end
Which is currently not doing anything, my guess is the if findEntity line is saying if u don't find this monster don't do anything.. Which is almost what I need it to do. I need it to see if the monster exists if it does do nothing to it. If it doesn't exist create a new one.
Re: Create Monster for boss to drain
Posted: Mon Jun 15, 2015 2:10 pm
by Zo Kath Ra
Emera Nova wrote:
Code: Select all
function createmonster()
if findEntity("mummyspawn") ~= nil then
spawn("mummy",7,19,18,2,1,"mummyspawn")
else
end
end
Your code spawns a monster with the ID "mummyspawn" if there already is one with that ID.
What you want is this:
Code: Select all
function createmonster()
if findEntity("mummyspawn") == nil then
spawn("mummy",7,19,18,2,1,"mummyspawn")
end
end
Re: Create Monster for boss to drain
Posted: Mon Jun 15, 2015 3:25 pm
by Emera Nova
ahhh xD I knew that ~= was what was fucking it up.. I tried just = by itself and that didn't work..
Next problem, what is the script command to addHealth to something but not just straight up set the health?
I tried to use
Code: Select all
function destroyObject()
if findEntity("mummyspawn") ~= nil then
mummyspawn:destroy()
Testmonster.monster:addHealth(25)
end
end
As stated above I'm making it so u have to kill this monster before the boss ends up killing it off and gaining health off of it. I know that you can setHealth but I don't want to reset the bosses health I just want to give it back some lifepoints so setHealth won't work..
Edit: I've also just noticed that I'll need to check if both the boss and the spawned monster still exist before giving out health..
Code: Select all
function increasehealth()
if findEntity("Testmonster","mummyspawn") ~= nil then
Testmonster.monster:setHealth(100)
if findEntity("mummyspawn") ~= nil then
mummyspawn:destroy()
end
end
end
I thought adding in the mummyspawn along with the testmonster as seen above would make it so it checks for both but it didn't.. So Not only do I need to know how to add health instead of setting it but I need to be able to check for 2 monsters and if both are present then add the health to the boss while destroying the spawedmonster.
Re: Create Monster for boss to drain
Posted: Mon Jun 15, 2015 3:58 pm
by Emera Nova
I appear to have figured out how to check for both monsters to be present.
Code: Select all
function increasehealth()
if findEntity("Testmonster") ~= nil then
if findEntity("mummyspawn") ~= nil then
Testmonster.monster:setHealth(100)
if findEntity("mummyspawn") ~= nil then
mummyspawn:destroy()
end
end
end
end
When I run this it will only set the health if both of them were int he room at the same time, if the spwned one is killed before it runs it will keep the bosses hp the same.
Now I just need to know how to add health and not set health.
Re: Create Monster for boss to drain
Posted: Mon Jun 15, 2015 4:57 pm
by Zo Kath Ra
There's a Champion:regainHealth(amount) function, but there's no such function for MonsterComponent.
Code: Select all
function increasehealth()
if (findEntity("Testmonster") ~= nil) and (findEntity("mummyspawn") ~= nil) then
Testmonster.monster:setHealth(Testmonster.monster:getHealth() + mummyspawn.monster:getHealth())
mummyspawn:destroy()
end
end
end