Coding Tip #5
Today’s tip:
Let’s say you want a target to teleport to safety when his health drops to a specified point. Well, that’s simple!
regAlmostDead(object, fn, health = 1, user = 0)
that’s the function that’ll be used to set up this little diddy.
regAlmostDead('villain', 'vteleport', health = 10)
So what does this mean? It means that when object, villain, health reaches or falls below 10, it will activate the function named vteleport.
def vteleport:
print 'buh-bye'
teleport('villain', 'newspot')
and that’s that. Once the villain hits the 10 hp spot, the function will play and he or she will be whisked away to a marker known as “newspot”. Of course, you could get really fancy with the code and add fx, but here’s the base.