Sometimes you need to call a function when an enemy is killed.
All chars have a function in their data that processes their deaths: launches
death animation, drops their weapons, etc. You need to tap into this function.
(It is called an ImDead func).
After enemy is created, add this after the
# In DefFuncs:
print "Ork1 is dead..hahahahaha. Opening door"
When "Ork1" is killed, "Door1" will open.
mention here about Scheduled functions. Sometimes you want to delay function
** don't forget the , after the args. (gate1din))
But say you have group of enemies (3 Orks?) in a room. You
can't get out and you have to slay them all before the exit door will open. This
type of scenario occurs lots in the game. Ok, you use the ImDead code above.
BUT how do you know which one will die last? You can't rely on them being killed
in order. The answer is use a variable as a counter:
Group1Orksdead = 0 # declare you var
global Group1Orksdead # declare the var as a global var
Group1Orksdead = Group1Orksdead +1
print "Another one bites the dust"
if Group1Orksdead ==3:
Bladex.AddScheduledFunc(Bladex.GetTime() + 5.0, door1.OpenDoor,())
print "Group1 Orks all dead - open exit door"
Make it so that all three Orks have the Group1OrksDED func
assigned to the ImDead routine. As each dies the function is called and the
value of the Group1Orksdead var is increased by 1. As the last Ork is killed
(don't matter which one) this value is increased to three and the 'if' clause
becomes TRUE. The scheduled func is called and exit door opens 5.0 secs
Actually, there is a ready made method in darfuncs.py that does
the same thing. I thought I would demostrate the counter principle as it is
usefule in lots of other cases.
# define the group
# add enemies to group
The DoSomething func is called when all group members are