Jump to content
Sign in to follow this  
Azza FHI

making ai take more damage

Recommended Posts

Anyone know how to make enemy ai take twice the damage? We are using robert hammers m4 pack but they are underpowered...

Share this post


Link to post
Share on other sites

This is a script used for testing, replaces fired bullet with another type:

_soldat = _this select 0;

TAG_fnc_kugelErsetzen = 
{
_kgl = _this select 0;
_vel = velocity _kgl;
_pos1 = getPosATL _kgl;
_nKgl = "B_127x108_Ball" createVehiclelocal _pos1;
_nKgl setVelocity _vel;
};

_soldat addEventHandler 
["fired", 
	{
	if (_this select 1 == (primaryWeapon (_this select 0))) then 
		{
		[_this select 6] call TAG_fnc_kugelErsetzen;
		}
	}];

/*
"B_762x51_Ball"
"B_127x108_Ball"
"B_20mm"
*/

Share this post


Link to post
Share on other sites

You can add a damage handler to the AI

example (assuming the enemy are EAST):

add to init.sqf

{
if ( side _x == EAST ) then {
	_x removeAllEventHandlers "HandleDamage";
	_x addEventHandler ["HandleDamage",{
		_damage = (_this select 2)*2; // <-- the *2 multiples the damage by 2
		_damage
	}];
};
}forEach allUnits;

Share this post


Link to post
Share on other sites
You can add a damage handler to the AI

example (assuming the enemy are EAST):

add to init.sqf

{
if ( side _x == EAST ) then {
	_x removeAllEventHandlers "HandleDamage";
	_x addEventHandler ["HandleDamage",{
		_damage = (_this select 2)*2; // <-- the *2 multiples the damage by 2
		_damage
	}];
};
}forEach allUnits;

Thank you for this! This works amazingly. It's so nice watching guys drop after 2-3 shots and a headshot doing the job the first time. I need help with one thing. My unit use MCC a lot to make missions and this doesn't work on spawned units like that unless I make it run from some sort of trigger. How would I go about making it loop every 5 or so minutes. I tried adding "while {true} do and a sleep at the end but I didn't do it right. I'm still new to scripting and haven't started learning conditions and event handlers yet.

Edited by Fight9

Share this post


Link to post
Share on other sites

Put this loop into a file called initServer.sqf in the mission folder or execVM the loop file from initServer.sqf.

while {true} do 
{
    {
     if ( side _x == EAST) then 
            {
                    if (_x isKindOf "Man") then
                    {
     	              _x removeAllEventHandlers "HandleDamage";
	              _x addEventHandler ["HandleDamage",{_damage = (_this select 2)*2; _damage}];
                    };
     };
    }forEach allUnits;
sleep 300;
};

or

[] execVM "damageLoop.sqf";

https://community.bistudio.com/wiki/Event_Scripts

Edited by Falsche9

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  

×