Author Topic: Radius impluse to drag people in.  (Read 649 times)

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: [Select]
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);
      }



    }

}

and here is how i used it in the code
Code: [Select]
SummonVictims(%obj, %pos, 10, 10,"Shadow", -2100);