Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
anusmangler

Friendly units just a bit harder to kill

Recommended Posts

I don't know if its possible but more the likely....I would like to have units JUST a weeeee bit harder to kill for friendlies....I know its not real life sim but nothing is worse then loading up your ammo bearer getting to where ever the enemy is and him being the first one to die right out infront of the car from a random round....forcing you to run back a forth from his body to get the magazines you need. Any way of modifying their "HP" just a bit more then other units.

Share this post


Link to post
Share on other sites

Can always adjust AI accuracy, speed, and steadiness to make that random bullet less likely. :P

Share this post


Link to post
Share on other sites

not working with the negitive values...unless im doing it wrong.... this setdamage -100;.....anything else?

Share this post


Link to post
Share on other sites
;2595837']Can always adjust AI accuracy' date=' speed, and steadiness to make that random bullet less likely. :P[/quote']

Could you tell me how to do this?

Share this post


Link to post
Share on other sites

       _x setSkill ["general",1];
       _x setSkill ["aimingAccuracy",0.1];
       _x setSkill ["aimingShake",1];
       _x setSkill ["aimingSpeed",0.1];
       _x setSkill ["endurance",0.3];
       _x setSkill ["spotDistance",0.2];
       _x setSkill ["spotTime",0.7];
       _x setSkill ["courage",1];
       _x setSkill ["reloadspeed",0.5];
       _x setSkill ["commanding",1];

I don't know how to exactly where to apply this to your situation I used a spawn wave mechanism

Share this post


Link to post
Share on other sites
Check out the "Handle Damage" EventHandler.

You can use this with the addEventHandler command in the units Init field.

Seems like the way to go. Someone might have a better solution, but something along these lines should work:

initServer.sqf

/*initServer.sqf*/

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

That'll make all WEST units 25% tougher to kill. You can then adjust that multiplier to your liking. You could also exclude yourself with another if-then condition, using either playableUnits (multiplayer only) or isPlayer.

Share this post


Link to post
Share on other sites

Why this while (true) loop?

Once a EH is added to a Unit it stays until the unit gets killed.

If you spawn in Units later while mission is running, just add the eventhandler after spawn.

Allways in scripting: Loops (while, waituntil, for, foreach and even triggers are loops that checks the condition every 0.5 sec) are bad if not used wise and only if there is no other option, they kill performance. Use as many EventHandlers as you can.

Just a little scripting hint ;)

E: but the rest of your code ist ok like that:

    {
        if ( side _x == WEST) then 
            {
                    if (_x isKindOf "Man") then
                    {
                     _x addEventHandler ["HandleDamage",{_damage = (_this select 2)*0.75; _damage}];
                    };
        };
    }forEach allUnits;

Edited by Lappihuan

Share this post


Link to post
Share on other sites

HandleDamage EH might be the answer for you though I doubt the posted code will work as intented as I had problems with a similar solution.

However, this worked for me:

{_x addEventHandler [
	"HandleDamage",{
		_unit = _this select 0;
		_selection = _this select 1;
		_passedDamage = _this select 2;
		_source = _this select 3;
		_projectile = _this select 4;

		_oldDamage = 0;

		switch(_selection)do{
			case("head"):{_oldDamage = _unit getHitPointDamage "HitHead";};
			case("body"):{_oldDamage = _unit getHitPointDamage "HitBody";};
			case("hands"):{_oldDamage = _unit getHitPointDamage "HitHands";};
			case("legs"):{_oldDamage = _unit getHitPointDamage "HitLegs";};
			case(""):{_oldDamage = damage _unit;};
			default{};
		};

		_return = _oldDamage + ((_passedDamage - _oldDamage) / 20);			
		_return
	}
];
} forEach [guy1, guy2, guyX]; 

  • Thanks 1

Share this post


Link to post
Share on other sites
Sign in to follow this  

×