Jump to content
Sign in to follow this  
1para{god-father}

Kill all units in a Radius

Recommended Posts

I need to test some missions, to see if the tasks work and respawns etc... is there a way I can kill every unit in a radius around me say 200x200 ? apart from me :) just OpFor

Cheers

Share this post


Link to post
Share on other sites

Put this into your init.sqs:

//--- East
{
if (side _x == east) then {
	_x setdamage 1.0;
};
} foreach allunits;

At least this kills every opfor.

I don't know, why a east-trigger with:

{_x setdamage 1.0} foreach units in thislist;

doesn't work anymore....

Edited by Egosa-U

Share this post


Link to post
Share on other sites

I spawn as a civilian and satchel charge the enemies and objectives when testing.

Altho for some reason after i plant the satchel i walk away whistling innocently

Share this post


Link to post
Share on other sites

One way would be to attach an action to yourself which does that:

player addAction ["Kill Opfor", "kill.sqf", [east, 200]];

In kill.sqf


_params = _this select 3;
_side = _params select 0;
_radius = _params select 1;

_nearMen = nearestObjects [player, ["Man"], _radius];
{
 if (side _x == _side) then {
   _x setDamage 1.0;
 };
} forEach (_nearMen - [player]);

Share this post


Link to post
Share on other sites

Slight modification that should be more resource efficient for larger radii:

_params = _this select 3;
_side = _params select 0;
_radius = _params select 1;

_nearMen = player nearEntities ["Man", _radius];
{
 if (side _x == _side) then {
   _x setDamage 1.0;
 };
} forEach (_nearMen - [player]);

Share this post


Link to post
Share on other sites

Our group plays a modified Advance and Secure, largely based on =BTC's= excellent code.

The problem we have encountered of some islands is that enemy units will sometimes spawn inside of or under buildings and thus prevent the area from being deemed "clear" and allowing us to move on.

We have confirmed through using Zapat's EYE 1.0 to determine what units are where on the island.

As well, following the suggestions found here in this forum, i am using the proceeding suggestions to make a "clear_area.sqf" script to kill units once found. The script is called as a "AddAction" from our Mobile HQ and has a limited range of 25 meters - added to the vehicle's init field is this;

EMP_Device = (vehicle MHQ_Land_A) addAction ["<t color='#FF0000'>Detonate EMP Device", "scripts\EMP\clear_area.sqf", [east, 25]];

This allows the action to appear in bright red text as an action from the interaction menu when you approach the vehicle.

The script that is called, "clear_area.sqf", is below;

//Deadfast's Zone Clearing Script//
//Kill all Opfor in a specified radius//

playSound "emp_blast";

_params = _this select 3;
_side = _params select 0;
_radius = _params select 1;

_nearMen = player nearEntities [["Man", "Air", "Car", "Tank"], _radius];
{
 if (side _x == _side) then {
   _x setDamage 1.0;
 };
} forEach (_nearMen - [player]);  

lastly, the mission directory has the sound file "emp_blast.ogg" in a directory labelled "sound" and the description.ext file has the following cfg;

/////Class CfgSounds/////
class CfgSounds
{
// List of sounds (.ogg files without the .ogg extension)
sounds[] = {emp_blast};

// Definition for each sound
class emp_blast
{
	name = "emp_blast"; // Name for mission editor
	sound[] = {\sound\emp_blast.ogg, db +20, 1.0};
	titles[] = {0, ""};
};
};
/////End of Resource/////

All this to say, it works perfectly client side but fails to work when run on a dedicated server. When I run it client side on my own PC, an impressive EMP blast noise happens, all the enemy of the specified types dies dramatically and such and there is much rejoicing in BluVille. When I run it on a dedicated server, I alone am the only one who hears the impressive EMP blast and the enemy refuses to die - nothing happens to them.

I am certain that there's likely something about locality or global stuff that i am woefully unaware of and i'm hoping that someone here can help out.

Thanks and hope someone has an answer.

Theopolus

Edited by Theopolus
error in title

Share this post


Link to post
Share on other sites

I don't do any MP scripting but I have read the odd thing now and again so this my be totally wrong.

I believe you can't use player on a dedicated server it doesn't know what it is.

it may work if you can name the player but as your calling it through an addaction try using the caller.

//Deadfast's Zone Clearing Script//
//Kill all Opfor in a specified radius//

playSound "emp_blast";

_player = _this select 1;// caller
_params = _this select 3;
_side = _params select 0;
_radius = _params select 1;

_nearMen = _player nearEntities [["Man", "Air", "Car", "Tank"], _radius];
{
 if (side _x == _side) then {
   _x setDamage 1.0;
 };
} forEach (_nearMen - [_player]);

although that may well kill all other playable units. If that is a problem you could try making an array of playable units and remove that from the array as well.

On the other hand it may be possible to make the original code it run on just the clients by adding this at the beginning of the script

if (!isServer and !isDedicated) exitwith {};

I really am just guessing so none of it will probably work.

Share this post


Link to post
Share on other sites

Thanks to F2K Sel for your response.

We gave that a try - no dice.

We then did this;

//Deadfast's Zone Clearing Script//
//Kill all Opfor in a specified radius//
//MHQ_Land addAction ["Clear Area of Opfor", "clear_area.sqf", [east, 50]];

playSound "emp_blast";

_params = _this select 3;
_side = _params select 0;
_radius = _params select 1;

_nearMen = [u]MHQ_Land[/u] nearEntities [["Man", "Air", "Car", "Tank"], _radius];
{
 if (side _x == _side) then {
   _x setDamage 1.0;
 };
} forEach (_nearMen);  

The key difference being that we put the effect on "MHQ_Land" rather than player, the end result was probably some kind of ability to avoid problems with locality on the dedicated server.

End result was that it worked - KABOOM! Dead tanks and such.

Thanks again and hope this helps someone if they're looking for a similar script.

Theopolus.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×