Blockland Forums > Modification Help
Find and Damaging all players/vehicles in an area
Pages: (1/1)
zmaster:
#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: --- %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);
}
--- End code ---
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
Treynolds416:
--- Code: ---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
}
}
--- End code ---
zmaster:
Thank you very much, works like a charm.
As a side note initContainerSearch ought to be initContainerRadiusSearch.
Treynolds416:
--- Quote from: zmaster on April 17, 2012, 04:12:06 PM ---Thank you very much, works like a charm.
As a side note initContainerSearch ought to be initContainerRadiusSearch.
--- End quote ---
No prob, and I'll fix that typo
Pages: (1/1)