Author Topic: ContainerRaycast only killing 1 thing per search  (Read 731 times)

I am not sure how it is just killing one person at a time..

initContainerRadiusSearch(%this.getPosition(),25,$TypeMasks::PlayerObjectType);
   while((%searchObj = containerSearchNext()) != 0)
   {
      talk("FOUND " @ %searchObj);
      if(%searchObj.getState() !$= "Dead")   
         if(%searchObj != %this)
         {
            %searchObj.spawnExplosion(vehicleFinalExplosionProjecti le,getWord(%searchObj.getScale(),2));
            %searchObj.addHealth(-2500);
            %searchObjs++;
         }
   }
« Last Edit: February 15, 2014, 03:37:26 PM by Advanced Bot »

   while((%searchObj = containerSearchNext()) !$= 0)
Possibly this line. Don't use $= to compare items if they're numerical, just use != instead

I've had issues with !$= 0 before. Try not to do that, maybe?

Possibly this line. Don't use $= to compare items if they're numerical, just use != instead
I believe they do the same thing.

Anyway, that doesn't work either, I am not sure exactly how it is not searching through all of them. (I have like 8 bots around me, the range is 15)

Other things I have tried for while()

while(isObject(%searchObj = ContainerSearchNext()) != 0)
while(firstWord(%searchObj = ContainerSearchNext()) != 0)
« Last Edit: February 15, 2014, 03:15:16 PM by Advanced Bot »


No they don't.

It'd be fine if he put the 0 in quotations. !$= "0"

Just use this instead.

while (isObject(%obj = containerSearchNext()))

It'd be fine if he put the 0 in quotations. !$= "0"

That makes no different in the slightest.

Possibly this line. Don't use $= to compare items if they're numerical, just use != instead

Using $= instead of == only makes a difference if one of values contains letters.

Something was odd, I have tried all of this, yet it does not work, I try this:

while((%target = containerSearchNext()) != 0)
   {
      if(%target.getState() !$= "Dead")   
         if(%target != %this)
            %searchObjsGroup[%searchObjs++] = %target;
   }

   if(%searchObjs > 0)
   {
      for(%i=0;%i<%searchObjs;%i++)
      {
         %target = %searchObjsGroup[%i];
         if(isObject(%target))
         {
            %target.spawnExplosion(vehicleFinalExplosionProjecti le,getWord(%target.getScale(),2));
            %target.addHealth(-2500);
         }
      }
   }


This works on all the objects around me, when I also took the spawnExplosion and the addHealth event out, it searched them all..

Just try this:

initContainerRadiusSearch(position, radius, $TypeMasks::PlayerObjectType);

while (isObject(%obj = containerSearchNext()))
{
    %obj.kill();
}

Explosions use radius searches to detect which bricks to kill. This is overriding yours, meaning that it detects that the (finished) explosion search is finished.

Compile a list of bots, then run through them AFTER the search.

Using $= instead of == only makes a difference if one of values contains letters.
$= forces the numerical value to be translated to a string value for comparison. It's the equivalent of doing
Code: [Select]
int nOne = 5; int nTwo = 5; char one[10]; char two[10]; sprintf_s(one, 10, "%i", nOne); sprintf_s(two, 10, "%i", nTwo); if(strCmp(one, two) == 0) { whatever(); }instead of
Code: [Select]
int nOne = 5; int nTwo = 5; if(nOne == nTwo) { whatever(); }
Using $= for numerical comparison is horrible.

Yes, I understand you meant functionality wise. I wasn't saying you're wrong.
« Last Edit: February 15, 2014, 06:08:07 PM by $trinick »