Jump to content
Sign in to follow this  
-ami- mofo

Spawn units in MP with damage handler

Recommended Posts

Hi guys,

 

I already have this in my init.sqf which works fine on the damage handling of editor placed units.

 

Quote

if ( side _x == INDEPENDENT ) then {
        _x removeAllEventHandlers "HandleDamage";
        _x addEventHandler ["HandleDamage",{
            _damage = (_this select 2)*1.5;
            _damage
        }];
    };
}forEach allUnits;

 

 

What I'd like to do though is have any spawned units spawn with the same damage handling. Currently any units spawned have the default damage.

 

I'm spawning units via the BIS fnc...

 

Quote

grp = [getmarkerpos "M1", independent, 6] call bis_fnc_spawngroup; grp

 

Hoping it's an easy fix.

 

Thanks.

 

Share this post


Link to post
Share on other sites

Since grp returns the created group by that function, just run the same loop on all units in that group (which is represented by the global variable grp in the script you provided). Since grp is overwritten by the most recent group created, as long as the forEach loop comes immediately after you should have no issues. Should look like this:

 

grp = [getmarkerpos "M1", independent, 6] call bis_fnc_spawngroup; 

 {
        _x removeAllEventHandlers "HandleDamage";
        _x addEventHandler ["HandleDamage",{
            _damage = (_this select 2)*1.5;
            _damage
        }];
}forEach units grp;

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  

×