Shared life pools
Posted: Wed Sep 28, 2016 5:14 am
So I'm currently working on getting two different enemies to share health in an odd way. Basically the script I have going atm looks like this
then I have another code doing
The goal is to make it so the player has to switch between attacking the two creatures to bring down their lifepools. If they dont attack both of them constantly they get healed up to the highest health between the two of them.
What its currently doing is when Zen_1 takes damage and the script runs it will deal that damage to Zen_2 instead of healing itself up to what ever health Zen_2 is at. However if you attack Zen_2 it will heal itself up to what Zen_1's health is if its lower than Zen_1.
Code: Select all
function increasehealth()
if (findEntity("Zen_1") ~= nil) and (findEntity("Zen_2") ~= nil) then
Zen_1.monster:setHealth(Zen_2.monster:getHealth())
end
end
Code: Select all
function increasehealth()
if (findEntity("Zen_1") ~= nil) and (findEntity("Zen_2") ~= nil) then
Zen_2.monster:setHealth(Zen_1.monster:getHealth())
end
end
What its currently doing is when Zen_1 takes damage and the script runs it will deal that damage to Zen_2 instead of healing itself up to what ever health Zen_2 is at. However if you attack Zen_2 it will heal itself up to what Zen_1's health is if its lower than Zen_1.