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?

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

  • You're not deleting the physical zone.
  • Sorry I am new to the coding what is the word for the physical? I have not needed to remove it before.

    Also why does it work when the 2nd beacon is killed and not the first?
  • Fixed it. You pointed me in the right direction, which I think was better than giving me the answer right there as I learnt from it :D

    THANKS FOR THE HELP Thyth :D

    Oh this was the correct code;
    function ShockPackDeployed::onDestroyed(%this, %obj, %prevState)
    {
      %removecount = 0;
      if(!%obj.iskilled)
      {
        %obj.iskilled = true;
        if(isObject(%obj.partner) && !%obj.partner.iskilled)
        {
          %obj.partner.schedule(20, "delete");
          $TeamDeployedCount[%obj.team, ShockPack]--;
          %obj.partner.iskilled = true;
          %obj.partner.trigger.schedule(20, "delete");
        }
        %obj.schedule(20, "delete");
        $TeamDeployedCount[%obj.team, ShockPack]--;
        %obj.field.getDataBlock().losepower(%obj.field);
        %obj.field.schedule(20, "delete");
        %obj.trigger.schedule(20, "delete");
      }
    }
    
    It was missing this line :P
    %obj.partner.trigger.schedule(20, "delete");
    
  • so... are you able to place a forcefield, and then delete it? and then replace it? All serverside?
  • of course you can.
  • Yeah.

    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).
Sign In or Register to comment.