Hi there,
I'm trying to write a script that makes destroying tanks a little more realistic. IMHO tanks shouldn't invariably blow up when they're destroyed, thereby killing anyone within 50 feet or so. As I see it, tanks blow up sometimes (ammo storage ignited, fuel explodes, etc) but not always. Anyway, after some thinking I have come to the conclusion that there are (at least) two possible ways to make this work (theoretically at least).
1) Poll the damage of the tank in very short intervals. When its damage == 1, immediately remove all fuel and ammo from the tank (I think that's what makes a tank explode in OFP ... empty tanks just die silently). You have to poll in VERY short intervals, because if you're not quick enough the tank may already be in the process of exploding by the time you go about removing any explosive stuff from it. That's why I'm unsure of whether this approach is feasible.
2) Event handlers. Register a function that gets called when the tank is killed.
_oSomeTank addEventHandler[ "killed", { // insert call to function here } ]
This event fires (hopefully) __AS__THE__TANK__IS__BEING__KILLED, calling the function that removes any fuel and ammo from the tank. However, I'm not at all sure that the event really fires before the tank starts to explode. If it doesn't then of course this is a no-go as well. Does anyone know about good reference material about event handlers? Because my experiments with the killed-event have fruitless so far. Also I find that some of the available event handlers (hit, dammaged) totally don't have the argument interface BIS says they do (obsolete reference material?). For example according to their scripting reference the "hit" eventhandler should return the amount of damage inflicted whereas in reality it returns an object reference to the shooter as well as one to the object having been hit IIRC.
Right, I'm getting carried away ... I was really wanting to ask if anyone has some ideas on how to prevent tanks from exploding.
Regards,
ant