onDestroyed issue
Got a problem with this code.
Basically I have 2 beacons and when the second is placed a forcefield appears between and when you walk through that it shocks you.
If you kill the second you placed both beacons are killed, the shock effect ends and the force field effect ends.
But if you kill the first beacon again both beacons are killed and the force field ends BUT the shock effect stays for the rest of the game.
Any ideas where it goes wrong?
Basically I have 2 beacons and when the second is placed a forcefield appears between and when you walk through that it shocks you.
If you kill the second you placed both beacons are killed, the shock effect ends and the force field effect ends.
But if you kill the first beacon again both beacons are killed and the force field ends BUT the shock effect stays for the rest of the game.
Any ideas where it goes wrong?
function ShockPackDeployed::onDestroyed(%this, %obj, %prevState) { %removecount = 0; if(!%obj.iskilled) { %obj.partner.iskilled = true; if(isObject(%obj) && !%obj.iskilled) { %obj.partner.schedule(20, "delete"); $TeamDeployedCount[%obj.team, ShockPack]--; %obj.partner.iskilled = true; } %obj.schedule(20, "delete"); $TeamDeployedCount[%obj.team, ShockPack]--; %obj.trigger.schedule(20, "delete"); %obj.field.getDataBlock().losepower(%obj.field); %obj.field.schedule(20, "delete"); } }
Comments
Also why does it work when the 2nd beacon is killed and not the first?
THANKS FOR THE HELP Thyth
Oh this was the correct code; It was missing this line :P
It isnt a force field though. Its a shockfield basically a slowfield which is generated when you place 2 beacons within a certain proximity of each other. The problem(if I didnt expalin properly I am sorry) was that if I destroy either beacon it should stop the slowfield and the shock which is generated when you contact the slowfield. But it only did it when destroying the second beacon you place. When you destroy the first it only stops the slowfield but the shock stays for the rest of the game, invisible as well.
Just drop into the Ninja-Xr mod and get the engineer armor and test the shockfield pack if it doesnt make sense(working ok now though but you will get the idea of what I am on about a bit better).