Forum Jump :

Author Message


Posts: 10
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2014-09-08 02:56        
     
I am trying to make a mission where damage taken by player characters is highly reduced. I have looked around and I have tried a few things (source - http://www.ofpec.com/forum/index.php?topic=29789.0)

I was using this
this addEventHandler ["HIT",{(_this select 0) setDamage (0.75 * damage (_this select 0));}];
I was testing it with a health hud script enabled and from what I can tell this does not allow damage to be cumulative it just resets the damage to the player for every hit so effectively your health would bounce between 70% - 90% while being shot at close range never killing you.

Is there a way to use getdamage and the add it to setdamage inside of a hit event handler? Also I would like to prevent insta-death from one head shot also.

Any help would be greatly appreciated!


Author Message

Crix  



Posts: 122
Rank:


Level: Member

Country: de
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2014-09-08 15:00        
     
Hey,

The "HandleDamage"-EventHandler Triggers for each selection (Head, Legs, etc.) seperatly. To decrease or increase the Overall damage taken you have to store the old section damage and then add the new one.

this addeventhandler ["HandleDamage", { 
		_unit 			= _this select 0; 
		_selection 		= _this select 1; 
		_passedDamage 	= _this select 2; 
		_source			= _this select 3; 
		_projectile 	= _this select 4; 
		
		_oldDamage = 0; 
		_damageMultiplier = 1;
		
		
		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) *_damageMultiplier); 
		
		_return 
	}];
Change the _damageMultiplier to your likings.
See if that works for you.

Cheers,
Crix

This post was edited by Crix (2014-09-09 10:12, ago)


Advertisement


Author Message


Posts: 10
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2014-09-08 22:15        
     
Thank you! This works great. I am using a multiplier of 0.25 and now a player can survive a direct hit from a sniper.

Just curious do you think it would be possible add different damage modifiers to different areas of the body called out in the script? I imagine that you could make body armor more realistic/effective this way.


Author Message

Crix  



Posts: 122
Rank:


Level: Member

Country: de
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2014-09-09 10:27        
     
Hey,

First of all I did a mistake in my earlier post:
Crix:
The "Hit"-EventHandler Triggers for each selection (Head, Legs, etc.) seperatly.
WRONG! - I was talking about the "HandleDamage"-EH(!), not the "Hit"-EventHandler. So it is the "HandleDamage"-EH that Triggers for each selection seperatly. The "Hit"-EH just returns the damage done by the hit.

Now to your follow up question:
Unfortunatly - as mentioned above - the "HandleDamage"-EH will Trigger for each selection even if the selection has not been hit. In other words: "Legs" will take damage even if "Head" was hit. However this damage is kinda small compared to the damage "Head" took and only has to be taken into account if the unit took about 20 shots in the head. In this case he should be dead anyways, right?

this addeventhandler ["HandleDamage", 
{ 
	private ["_return"];
	_unit 			= _this select 0; 
	_selection 		= _this select 1; 
	_passedDamage 	        = _this select 2; 
	_source			= _this select 3; 
	_projectile 	        = _this select 4; 
	
	_oldDamage = 0; 
	
	_bodyMultiplier  	= 0; 
	_legsMultiplier  	= 0.25; 
	_handsMultiplier 	= 0.25;
	_headMultiplier  	= 0.75;
	_overAllMultiplier 	= 0.25; 
	
	switch (_selection) do
	{ 
		case("head")	:
		{
			_oldDamage 	= _unit getHitPointDamage "HitHead";
			_return 	= _oldDamage + ((_passedDamage - _oldDamage) * _headMultiplier); 
		}; 
		case("body")	:
		{
			_oldDamage 	= _unit getHitPointDamage "HitBody";
			_return 	= _oldDamage + ((_passedDamage - _oldDamage) * _bodyMultiplier); 
		}; 
		case("hands")	:
		{
			_oldDamage 	= _unit getHitPointDamage "HitHands";
			_return 	= _oldDamage + ((_passedDamage - _oldDamage) * _handsMultiplier); 
		}; 
		case("legs")	:
		{
			_oldDamage 	= _unit getHitPointDamage "HitLegs";
			_return 	= _oldDamage + ((_passedDamage - _oldDamage) * _legsMultiplier); 
		}; 
		case("")		:
		{
			_oldDamage = damage _unit;
			_return 	= _oldDamage + ((_passedDamage - _oldDamage) * _overAllMultiplier); 
		}; 
		default{}; 
	}; 
	
	_return
}];

So in this particular Scenario the target unit should die when taking a single headshot (6.5mm) and last about 20 shots in the chest.
Again, play around with the _Multipliers until you found something suitable.

Cheers,
Crix


Author Message


Posts: 10
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2014-09-09 23:09        
     
Thanks! Great bit of code.

Cheers


Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#6 Posted at 2014-10-01 21:42        
     
cool script will it affect only players or AI as well? im useing some mods like AGM and would like to be able to tweek the amount of damage players take form AI. the above code would work but i would change it to like 10 shots to the chest and 15 for the limbs. just to give my guys a fighting chance from the iron site sniper AI's :)


Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 33
In-game name: Tajin

 
#7 Posted at 2014-10-02 09:28        
     
# shadowmarine578 : just to give my guys a fighting chance from the iron site sniper AI's :)

I'd suggest adjusting your difficulty settings on the server instead.
Changing the overall precision of enemy AI helps quite a bit.

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.





Tags: Damage, Hit, Setdamage