Updated July 24, 2005
HOME PAGE > AUTHORS > PROSPERO > BOD PYTHON SCRIPTING (15)
Tut15. Death of Enemies.![]()
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
creation code:
ork1.Data.OldImDeadFunc=ork1.ImDeadFunc
ork1.ImDeadFunc= Ork1DED
# In DefFuncs:
def Ork1DED(entity)
me=Bladex.GetEntity(entity)
if me.Data.OldImDeadFunc(entity)
me.Data.OldImDeadFunc(entity)
print "Ork1 is dead..hahahahaha. Opening door"
door1.OpenDoor()
Group1Orksdead = 0 # declare you var
def Group1OrksDED(entity):
global Group1Orksdead # declare the var as a global var
me=Bladex.GetEntity(entity)
if me.Data.OldImDeadFunc(entity)
me.Data.OldImDeadFunc(entity)
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"
# define the group Group1Ork=darfuncs.E_Grup() Group1Ork.OnDeath= DoSomething # add enemies to group Group1Ork.AddGuy(ork1.Name) Group1Ork.OnDeath= DoSomething Group1Ork.AddGuy(ork2.Name) Group1Ork.OnDeath= DoSomething Group1Ork.AddGuy(ork3.Name) Group1Ork.OnDeath= DoSomething