tank
var/hp = 10
Click()
var/mob/m = usr
m.ShootAtTarget(src) // shoot at self
proc
TakeDamage(var/iDamage)
hp -= iDamage
if (hp <= 0)
Explode()
Explode()
del(src)
mob
var/obj/tank/target
proc
ShootAtTarget(var/obj/tank/t)
t.TakeDamage(10)
Problem description:
Lets say you have a tank(tank1) on the screen and when you click on other tanks, tank1 shoots missiles until the targeted tank is dead. In this case though, you select tank1 itself. Now tank1 shoots missiles at itself until it's dead. In the code above, I was expecting the tank to delete itself from existence but instead, tank1 remains "alive". What's a good way to handle this scenario?
"... or even an object with a variable that points to itself. In rare cases, you may even depend on this behavior. When you are done with such objects, you should either null out the circular reference, or you should forcibly destroy each object with the del instruction. "
Still not sure how to null it out and I thought I was forcibly destroying it with del.