Author Topic: Find and Damaging all players/vehicles in an area  (Read 482 times)

#1 Does anyone know how to find all the players(bots included) and vehicles in a radius from a point?
#2 How do I apply damage to the above once found?

My attempt:

Code: [Select]
%ray = containerFindFirst($TypeMasks::VehicleObjectType | $TypeMasks::PlayerObjectType,%obj.getPosition(), %obj.radius,%obj.radius,%obj.radius); //obj.radius = 100


%col = getWord(%ray, 0);
while(isObject(%col))
{
echo(%col);
%col.Damage(%obj,%col.getPosition(),%obj.radiusDamage,%obj.radiusDamageType);

%ray = containerFindNext();
%col = getWord(%ray, 0);
}

problems with my current method:
1. the point has to be practically inside the object to work
2. no damage is done to the found objects

Code: [Select]
function damageAll(%center,%radius,%damage)
{
    initContainerRadiusSearch(%center,%radius,$TypeMasks::PlayerObjectType);
    while(%player = ContainerSearchNext())
    {
        %player.addHealth(-1 * %damage);
    }
    initContainerRadiusSearch(%center,%radius,$TypeMasks::VehicleObjectType);
    while(%vehicle = ContainerSearchNext())
    {
        %vehicle.addHealth(-1 * %damage);
        //or however the hell you damage vehicles
    }
}
« Last Edit: May 10, 2012, 05:24:40 PM by Treynolds416 »

Thank you very much, works like a charm.
As a side note initContainerSearch ought to be initContainerRadiusSearch.

Thank you very much, works like a charm.
As a side note initContainerSearch ought to be initContainerRadiusSearch.
No prob, and I'll fix that typo