Adding poison with multiple instances
Posted: Wed May 27, 2015 1:30 pm
Trying to wrap my ahead around a such that I can 'poison' a person, and if I do it again EXTEND the original duration, and allow others their own instances.
This is my first solution and am looking for pointers or other helpful information.
This is my first solution and am looking for pointers or other helpful information.
Syntax: Select all
#called on the victim, such as victim.poison(attacker, 5, 3, 6)
def poison(self, attacker, amount, interval, total=0):
#PlayerDataDictionary stores things such as maximum hp, max speed ,etc
if PlayerDataDictionary[self.steamid].poison:
for instance in PlayerDataDictionary[self.steamid].poison:
if instance[1] != [attacker, amount, interval]:
#safeDamage is a point_hurt wrapper
myTimer = TickRepeat(safeDamage, self, attacker, amount)
#Tracking timers to end them all at round_end
timers.append(myTimer)
myTimer.start(interval, total)
PlayerDataDictionary[self.steamid].poison.append([myTimer, [attacker, amount, interval]])
else:
instance[0].extend(total)
else:
myTimer = TickRepeat(safeDamage, self, attacker, amount)
timers.append(myTimer)
myTimer.start(interval, total)
PlayerDataDictionary[self.steamid].poison.append([myTimer, [attacker, amount, interval]])