Blockland Forums > Modification Help

Radius impluse to drag people in.

Pages: (1/1)

Android:

Hello, I am trying to make a spell which will drag people in from a radius, this is what i have so far but it does not tend to work any thoughts on why it does not work?


--- Code: ---function SummonVictims(%sourceObject, %position, %radius, %damage, %damageType, %impulse)
{

InitContainerRadiusSearch(%position, %radius, $TypeMasks::ShapeBaseObjectType);

%halfRadius = %radius / 2;
while ((%targetObject = containerSearchNext()) != 0) {
%coverage = calcExplosionCoverage(%position, %targetObject,
          $TypeMasks::InteriorObjectType |  $TypeMasks::TerrainObjectType |
          $TypeMasks::ForceFieldObjectType | $TypeMasks::VehicleObjectType);
      if (%coverage == 0)
        continue;

%dist = containerSearchCurrRadiusDist();
  %distScale = (%dist < %halfRadius)? 1.0:
         1.0 - ((%dist - %halfRadius) / %halfRadius);

      // Apply the impulse & damage
      if (%impulse && %targetObject.getClassname() $= "Player")
{
        %impulseVec = VectorSub(%targetObject.getWorldBoxCenter(), %position);
          %impulseVec = VectorNormalize(%impulseVec);
          %impulseVec = VectorScale(%impulseVec, %impulse * %distScale);
          %targetObject.applyImpulse(%position, %impulseVec);
%targetObject.damage(%sourceObject, %position, %damage * %coverage * %distScale, %damageType);
      }



    }

}
--- End code ---

and here is how i used it in the code

--- Code: ---SummonVictims(%obj, %pos, 10, 10,"Shadow", -2100);
--- End code ---


Pages: (1/1)

Go to full version