Jump to content
Dallas Medina

How to increase the armor values of a units vest/helmet in the init

Recommended Posts

Currently, I'm using the Star Wars Opposition mod and the Operation TREBUCHET mod, along with ACE3. Just for shits n giggles I'm having the Empire fight the UNSC. 

 

Problem is, NONE of the Star Wars units have ANY armor rating on their equipment, whereas the UNSC armor values for their helmets and vests are almost maxed out. I was blasting away at 4 UNSC troops with a DLT-19 at about 150 meters and they were absorbing 10-15 hits before death. Stromtroopers go down with a single 7.62 shot. 

 

How can I increase the armor values of a units helmet and vest? I'm assuming theres some code to write in the init field.

 

EDIT

I should clarify: I specifically want to increase the ballistic AND explosive resistance of the helmets and vests for stormtroopers, clonetroopers, etc.

Share this post


Link to post
Share on other sites

What I can think of is the hit eventhandler.  But I'm pretty sure thus question has already been answered in mission editing and scripting.  I'd look it up and link it but yea my phone isn't working with me.

Share this post


Link to post
Share on other sites

Look at the last post in this thread:

And this thread in it's entirety:

 

Share this post


Link to post
Share on other sites
On 8/21/2018 at 6:42 AM, stanhope said:

Look at the last post in this thread:

And this thread in it's entirety:

 

Ok... I don't get it. That's a whole lot of code. One seems to be a script, the other is seemingly placed in the units init. I would like one that's placed in the init, so I can copy and paste it to a custom composition I made of stormtroopers.

 

Both seem vastly different. Which one is the correct one that will work?

 

Better yet, I might as well de-PBO the Opposition mod and try to add ballistic and explosive resistance values to all the different armors, since that mod is horribly outdated and seems abandoned. Would that be easier?

Share this post


Link to post
Share on other sites

This is the most elaborate one:
 

Spoiler

// Damage reduction from https://forums.bistudio.com/forums/topic/198136-reducing-player-damage/

player removeAllEventHandlers 'HandleDamage';

// Only damage from last applied handleDamage EH is taken into consideration by the engine
// Apply a new EH so as we can override the damage applied
player addEventHandler [ "HandleDamage", {
	params ["_unit", "_hitSelection", "_damage","_source","_projectile","_hitPartIndex", "_instigator", "_hitPoint"];

	// Damage multipliers.  The damage of each projectile will be multiplied by this number.
	private _damageMultiplierHead = 0.3;
	private _damageMultiplierBody = 0.25;
	private _damageMultiplierLimbs = 0.15;
	private _damageMultiplierOverall = 0.25;

	// Damage limits.  Each projectile will be limited to a max of this much damage.
	private _limitHead = 1.0;
	private _limitBody = 0.25;
	private _limitLimbs = 0.1;
	private _limitOverall = 0.25;

	private _oldDamage = 0;
	if (_hitSelection isEqualTo "") then {_oldDamage = damage _unit} else {_oldDamage = _unit getHit _hitSelection};
	private _newDamage = _damage - _oldDamage max 0;
	private _incomingDamage = _newDamage;
	private _playerHealth = damage _unit;

	// Infantry selections
	// Keep in mind that if revive is enabled then incapacitation may occur at around 0.7 damage.
	// "": The overall damage that determines the damage value of the unit. Unit dies at damage equal to or above 1
	// "face_hub": Unit dies at damage equal to or above 1
	// "neck": Unit dies at damage equal to or above 1
	// "head": Unit dies at damage equal to or above 1
	// "pelvis": Unit dies at damage equal to or above 1
	// "spine1": Unit dies at damage equal to or above 1
	// "spine2": Unit dies at damage equal to or above 1
	// "spine3": Unit dies at damage equal to or above 1
	// "body": Unit dies at damage equal to or above 1
	// "arms": Unit doesn't die with damage to this part
	// "hands": Unit doesn't die with damage to this part
	// "legs": Unit doesn't die with damage to this part

	// Do any other damage calculations here
	// _damage is the previous damage plus any new damage and will be applied
	// as the total damage the unit has for this selection once this EH returns

	// Only modify damage if it is a known projectile (leave falling damage etc alone)
	if (_newDamage > 0 && !(_projectile isEqualTo "")) then {
		// Reduce damage by damage multiplier
		private _damageMultiplier = _damageMultiplierBody;
		private _upperLimit = _limitBody;
		switch (_hitSelection) do {
			case "face_hub";
			case "head": {
				_damageMultiplier = _damageMultiplierHead;
				_upperLimit = _limitHead;
			};
			case "arms";
			case "hands";
			case "legs": {
				_damageMultiplier = _damageMultiplierLimbs;
				_upperLimit = _limitLimbs;
			};
			case "": {
				_damageMultiplier = _damageMultiplierOverall;
				_upperLimit = _limitOverall;
			};
			default { 
				_damageMultiplier = _damageMultiplierBody;
				_upperLimit = _limitBody;
			};
		};
		_newDamage = _newDamage * _damageMultiplier;

		// Place an upper limit on projectile damage done at once
		if (_newDamage > _upperLimit) then {
			_newDamage = _upperLimit;
		};

		_damage = _oldDamage + _newDamage;
	};
	
	// For players ignore damage if they are incapacitated and pass damage to bis revive handler
	if ( isPlayer _unit ) then {
		if ( lifeState _unit == "INCAPACITATED" ) then {
			//if we are incapacitated take no additional damage
			_damage = _oldDamage;
		} else {
			_this set[ 2, _damage ];
			//Call BI REVIVE HandleDamage EH passing new _damage value
			_damage = _this call bis_fnc_reviveEhHandleDamage;
		};
	};


	_damage
	
}];

 

 

Put that code in the onPlayerRespawn.sqf of your mission.  (If your mission doesn't have one make one)

 

In this code you can tweak the following lines to get different damage outputs:
    private _damageMultiplierHead = 0.3;
    private _damageMultiplierBody = 0.25;
    private _damageMultiplierLimbs = 0.15;
    private _damageMultiplierOverall = 0.25;


    private _limitHead = 1.0;
    private _limitBody = 0.25;
    private _limitLimbs = 0.1;
    private _limitOverall = 0.25;

 

The first 4 are damage multipliers.  So if you set the value to 0.3 a unit will only take 30% of the damage it'd normally take. 
The bottom 4 are damage limits.  This limits the maximum damage a unit can take to a certain part of his body.  So if you set it to 0.25 you can get hit 4 times by a bullet that would normally instantly kill you.

  • Thanks 1

Share this post


Link to post
Share on other sites
58 minutes ago, stanhope said:

This is the most elaborate one:
 

  Reveal hidden contents


// Damage reduction from https://forums.bistudio.com/forums/topic/198136-reducing-player-damage/

player removeAllEventHandlers 'HandleDamage';

// Only damage from last applied handleDamage EH is taken into consideration by the engine
// Apply a new EH so as we can override the damage applied
player addEventHandler [ "HandleDamage", {
	params ["_unit", "_hitSelection", "_damage","_source","_projectile","_hitPartIndex", "_instigator", "_hitPoint"];

	// Damage multipliers.  The damage of each projectile will be multiplied by this number.
	private _damageMultiplierHead = 0.3;
	private _damageMultiplierBody = 0.25;
	private _damageMultiplierLimbs = 0.15;
	private _damageMultiplierOverall = 0.25;

	// Damage limits.  Each projectile will be limited to a max of this much damage.
	private _limitHead = 1.0;
	private _limitBody = 0.25;
	private _limitLimbs = 0.1;
	private _limitOverall = 0.25;

	private _oldDamage = 0;
	if (_hitSelection isEqualTo "") then {_oldDamage = damage _unit} else {_oldDamage = _unit getHit _hitSelection};
	private _newDamage = _damage - _oldDamage max 0;
	private _incomingDamage = _newDamage;
	private _playerHealth = damage _unit;

	// Infantry selections
	// Keep in mind that if revive is enabled then incapacitation may occur at around 0.7 damage.
	// "": The overall damage that determines the damage value of the unit. Unit dies at damage equal to or above 1
	// "face_hub": Unit dies at damage equal to or above 1
	// "neck": Unit dies at damage equal to or above 1
	// "head": Unit dies at damage equal to or above 1
	// "pelvis": Unit dies at damage equal to or above 1
	// "spine1": Unit dies at damage equal to or above 1
	// "spine2": Unit dies at damage equal to or above 1
	// "spine3": Unit dies at damage equal to or above 1
	// "body": Unit dies at damage equal to or above 1
	// "arms": Unit doesn't die with damage to this part
	// "hands": Unit doesn't die with damage to this part
	// "legs": Unit doesn't die with damage to this part

	// Do any other damage calculations here
	// _damage is the previous damage plus any new damage and will be applied
	// as the total damage the unit has for this selection once this EH returns

	// Only modify damage if it is a known projectile (leave falling damage etc alone)
	if (_newDamage > 0 && !(_projectile isEqualTo "")) then {
		// Reduce damage by damage multiplier
		private _damageMultiplier = _damageMultiplierBody;
		private _upperLimit = _limitBody;
		switch (_hitSelection) do {
			case "face_hub";
			case "head": {
				_damageMultiplier = _damageMultiplierHead;
				_upperLimit = _limitHead;
			};
			case "arms";
			case "hands";
			case "legs": {
				_damageMultiplier = _damageMultiplierLimbs;
				_upperLimit = _limitLimbs;
			};
			case "": {
				_damageMultiplier = _damageMultiplierOverall;
				_upperLimit = _limitOverall;
			};
			default { 
				_damageMultiplier = _damageMultiplierBody;
				_upperLimit = _limitBody;
			};
		};
		_newDamage = _newDamage * _damageMultiplier;

		// Place an upper limit on projectile damage done at once
		if (_newDamage > _upperLimit) then {
			_newDamage = _upperLimit;
		};

		_damage = _oldDamage + _newDamage;
	};
	
	// For players ignore damage if they are incapacitated and pass damage to bis revive handler
	if ( isPlayer _unit ) then {
		if ( lifeState _unit == "INCAPACITATED" ) then {
			//if we are incapacitated take no additional damage
			_damage = _oldDamage;
		} else {
			_this set[ 2, _damage ];
			//Call BI REVIVE HandleDamage EH passing new _damage value
			_damage = _this call bis_fnc_reviveEhHandleDamage;
		};
	};


	_damage
	
}];

 

 

Put that code in the onPlayerRespawn.sqf of your mission.  (If your mission doesn't have one make one)

 

In this code you can tweak the following lines to get different damage outputs:
    private _damageMultiplierHead = 0.3;
    private _damageMultiplierBody = 0.25;
    private _damageMultiplierLimbs = 0.15;
    private _damageMultiplierOverall = 0.25;


    private _limitHead = 1.0;
    private _limitBody = 0.25;
    private _limitLimbs = 0.1;
    private _limitOverall = 0.25;

 

The first 4 are damage multipliers.  So if you set the value to 0.3 a unit will only take 30% of the damage it'd normally take. 
The bottom 4 are damage limits.  This limits the maximum damage a unit can take to a certain part of his body.  So if you set it to 0.25 you can get hit 4 times by a bullet that would normally instantly kill you.

That seems like it will effect every single unit (which is bad, because the UNSC troops in the OPTRE mod already have maxed-out ballistic and explosive values for their helmets and vests), or just the player. Either way, I have an AI squad of Stormtroopers. They literally die in a single shot because the uniform and vest that makes up the stormtrooper armor has ZERO ballistic or explosive resistance, due to the laziness of the people that made SWOP.

 

I need a code I can place in the init field of the AI, not a script. I tried this addEventhandler ["HandleDamage",{ params ["_unit","_selection","_damage"]; _damage * 0.3; }]; and they were still killed by a single chest shot, even a leg shot. I tried it again with a value of 0.01, same result. Instant death from a single gunshot. Again, I am using ACE3 if that matters.

Share this post


Link to post
Share on other sites

Right, make a new file in your mission called "damageReduction.sqf"

Put this code into it:

Spoiler

params[ "_unit" ];

// Damage reduction from https://forums.bistudio.com/forums/topic/198136-reducing-player-damage/

// Exit if we are a player and not local
// Otherwise add EH for AI every where just in case their locality
// changes due to moving into a players group
// the EH will only fire where the AI is local
if ( isPlayer _unit && { !local _unit } ) exitWith {};

if ( isPlayer _unit ) then {
	_unit removeAllEventHandlers 'HandleDamage';
};

// Only damage from last applied handleDamage EH is taken into consideration by the engine
// Apply a new EH so as we can override the damage applied
_unit addEventHandler [ "HandleDamage", {
	params ["_unit", "_hitSelection", "_damage","_source","_projectile","_hitPartIndex", "_instigator", "_hitPoint"];

	// Damage multipliers.  The damage of each projectile will be multiplied by this number.
	private _damageMultiplierHead = 0.3;
	private _damageMultiplierBody = 0.25;
	private _damageMultiplierLimbs = 0.15;
	private _damageMultiplierOverall = 0.25;

	// Damage limits.  Each projectile will be limited to a max of this much damage.
	private _limitHead = 1.0;
	private _limitBody = 0.25;
	private _limitLimbs = 0.1;
	private _limitOverall = 0.25;

	private _oldDamage = 0;
	if (_hitSelection isEqualTo "") then {_oldDamage = damage _unit} else {_oldDamage = _unit getHit _hitSelection};
	private _newDamage = _damage - _oldDamage max 0;
	private _incomingDamage = _newDamage;
	private _playerHealth = damage _unit;

	// Infantry selections
	// Keep in mind that if revive is enabled then incapacitation may occur at around 0.7 damage.
	// "": The overall damage that determines the damage value of the unit. Unit dies at damage equal to or above 1
	// "face_hub": Unit dies at damage equal to or above 1
	// "neck": Unit dies at damage equal to or above 1
	// "head": Unit dies at damage equal to or above 1
	// "pelvis": Unit dies at damage equal to or above 1
	// "spine1": Unit dies at damage equal to or above 1
	// "spine2": Unit dies at damage equal to or above 1
	// "spine3": Unit dies at damage equal to or above 1
	// "body": Unit dies at damage equal to or above 1
	// "arms": Unit doesn't die with damage to this part
	// "hands": Unit doesn't die with damage to this part
	// "legs": Unit doesn't die with damage to this part

	// Do any other damage calculations here
	// _damage is the previous damage plus any new damage and will be applied
	// as the total damage the unit has for this selection once this EH returns

	// Only modify damage if it is a known projectile (leave falling damage etc alone)
	if (_newDamage > 0 && !(_projectile isEqualTo "")) then {
		// Reduce damage by damage multiplier
		private _damageMultiplier = _damageMultiplierBody;
		private _upperLimit = _limitBody;
		switch (_hitSelection) do {
			case "face_hub";
			case "head": {
				_damageMultiplier = _damageMultiplierHead;
				_upperLimit = _limitHead;
			};
			case "arms";
			case "hands";
			case "legs": {
				_damageMultiplier = _damageMultiplierLimbs;
				_upperLimit = _limitLimbs;
			};
			case "": {
				_damageMultiplier = _damageMultiplierOverall;
				_upperLimit = _limitOverall;
			};
			default { 
				_damageMultiplier = _damageMultiplierBody;
				_upperLimit = _limitBody;
			};
		};
		_newDamage = _newDamage * _damageMultiplier;

		// Place an upper limit on projectile damage done at once
		if (_newDamage > _upperLimit) then {
			_newDamage = _upperLimit;
		};

		_damage = _oldDamage + _newDamage;
	};
	
	// For players ignore damage if they are incapacitated and pass damage to bis revive handler
	if ( isPlayer _unit ) then {
		if ( lifeState _unit == "INCAPACITATED" ) then {
			//if we are incapacitated take no additional damage
			_damage = _oldDamage;
		} else {
			_this set[ 2, _damage ];
			//Call BI REVIVE HandleDamage EH passing new _damage value
			_damage = _this call bis_fnc_reviveEhHandleDamage;
		};
	};
	_damage
}];

 

 

In the init field of the units you want to have reduced damage put the following:

[this] execVM "damageReduction.sqf";

Share this post


Link to post
Share on other sites

"script damageReduction.sqf not found"

 

This is why I hate scripts and don't mess with them. They are ridiculously complicated and never work. I need a code that I can place in the init field of the unit.

 

Better yet the guys that made Star Wars Opposition just update the damn thing..........

 

 

I'll ask again, and this time more clearly: what code can I place in an AI UNITS INIT FIELD TO INCREASE THE BALLISTIC AND EXPLOSIVE RESISTANCE OF THEIR HELMET, VEST, AND UNIFORM? There's gotta be something, like "this setVestArmor 10" or "this setHelmetResist 5" or whatever. I've been searching all over steam and these forums and can't find anything.

Share this post


Link to post
Share on other sites

You don't know thing about scripts or SQF in general do you? The only reason you can't get it to work is because you have no clue what you're doing and don't seem to want to learn.

Put this in the init field but remove all the comments first:

Spoiler

 



_unit = this;

// Damage reduction from https://forums.bistudio.com/forums/topic/198136-reducing-player-damage/

// Exit if we are a player and not local
// Otherwise add EH for AI every where just in case their locality
// changes due to moving into a players group
// the EH will only fire where the AI is local
if ( isPlayer _unit && { !local _unit } ) exitWith {};

if ( isPlayer _unit ) then {
	_unit removeAllEventHandlers 'HandleDamage';
};

// Only damage from last applied handleDamage EH is taken into consideration by the engine
// Apply a new EH so as we can override the damage applied
_unit addEventHandler [ "HandleDamage", {
	params ["_unit", "_hitSelection", "_damage","_source","_projectile","_hitPartIndex", "_instigator", "_hitPoint"];

	// Damage multipliers.  The damage of each projectile will be multiplied by this number.
	private _damageMultiplierHead = 0.3;
	private _damageMultiplierBody = 0.25;
	private _damageMultiplierLimbs = 0.15;
	private _damageMultiplierOverall = 0.25;

	// Damage limits.  Each projectile will be limited to a max of this much damage.
	private _limitHead = 1.0;
	private _limitBody = 0.25;
	private _limitLimbs = 0.1;
	private _limitOverall = 0.25;

	private _oldDamage = 0;
	if (_hitSelection isEqualTo "") then {_oldDamage = damage _unit} else {_oldDamage = _unit getHit _hitSelection};
	private _newDamage = _damage - _oldDamage max 0;
	private _incomingDamage = _newDamage;
	private _playerHealth = damage _unit;

	// Infantry selections
	// Keep in mind that if revive is enabled then incapacitation may occur at around 0.7 damage.
	// "": The overall damage that determines the damage value of the unit. Unit dies at damage equal to or above 1
	// "face_hub": Unit dies at damage equal to or above 1
	// "neck": Unit dies at damage equal to or above 1
	// "head": Unit dies at damage equal to or above 1
	// "pelvis": Unit dies at damage equal to or above 1
	// "spine1": Unit dies at damage equal to or above 1
	// "spine2": Unit dies at damage equal to or above 1
	// "spine3": Unit dies at damage equal to or above 1
	// "body": Unit dies at damage equal to or above 1
	// "arms": Unit doesn't die with damage to this part
	// "hands": Unit doesn't die with damage to this part
	// "legs": Unit doesn't die with damage to this part

	// Do any other damage calculations here
	// _damage is the previous damage plus any new damage and will be applied
	// as the total damage the unit has for this selection once this EH returns

	// Only modify damage if it is a known projectile (leave falling damage etc alone)
	if (_newDamage > 0 && !(_projectile isEqualTo "")) then {
		// Reduce damage by damage multiplier
		private _damageMultiplier = _damageMultiplierBody;
		private _upperLimit = _limitBody;
		switch (_hitSelection) do {
			case "face_hub";
			case "head": {
				_damageMultiplier = _damageMultiplierHead;
				_upperLimit = _limitHead;
			};
			case "arms";
			case "hands";
			case "legs": {
				_damageMultiplier = _damageMultiplierLimbs;
				_upperLimit = _limitLimbs;
			};
			case "": {
				_damageMultiplier = _damageMultiplierOverall;
				_upperLimit = _limitOverall;
			};
			default { 
				_damageMultiplier = _damageMultiplierBody;
				_upperLimit = _limitBody;
			};
		};
		_newDamage = _newDamage * _damageMultiplier;

		// Place an upper limit on projectile damage done at once
		if (_newDamage > _upperLimit) then {
			_newDamage = _upperLimit;
		};

		_damage = _oldDamage + _newDamage;
	};
	
	// For players ignore damage if they are incapacitated and pass damage to bis revive handler
	if ( isPlayer _unit ) then {
		if ( lifeState _unit == "INCAPACITATED" ) then {
			//if we are incapacitated take no additional damage
			_damage = _oldDamage;
		} else {
			_this set[ 2, _damage ];
			//Call BI REVIVE HandleDamage EH passing new _damage value
			_damage = _this call bis_fnc_reviveEhHandleDamage;
		};
	};
	_damage
}];

 

1 hour ago, Dallas Medina said:

There's gotta be something, like "this setVestArmor 10" or "this setHelmetResist 5" or whatever. I've been searching all over steam and these forums and can't find anything.

No there isn't.  That's what the event handler handledamage and hit are for.

  • Like 1

Share this post


Link to post
Share on other sites

Those values are defined in the object's config. If you want to change those values, not only are you going to have to learn about scripting, you are going to have to learn how to work with configs. 

 

6 hours ago, Dallas Medina said:

...due to the laziness of the people that made SWOP.

 

Wow. I'm no fan of their ethics, but they have done a lot of work. How much work are you willing to put in?

 

Share this post


Link to post
Share on other sites
5 hours ago, Dallas Medina said:

"script damageReduction.sqf not found"

 

This is why I hate scripts and don't mess with them. They are ridiculously complicated and never work. I need a code that I can place in the init field of the unit.

 

Better yet the guys that made Star Wars Opposition just update the damn thing..........

 

 

I'll ask again, and this time more clearly: what code can I place in an AI UNITS INIT FIELD TO INCREASE THE BALLISTIC AND EXPLOSIVE RESISTANCE OF THEIR HELMET, VEST, AND UNIFORM? There's gotta be something, like "this setVestArmor 10" or "this setHelmetResist 5" or whatever. I've been searching all over steam and these forums and can't find anything.

 

You can't. There is no command/function to increase the armor, and first of all, something inexistent.

You can just add a script for reducing the damage on the body parts, as @stanhope patiently wrote.

As you're not familiar with scripting, and this point is also underlined by stanhope, be aware you can't copy/paste as is, scripts with comment // inside them.

 

I suggest you:

this addEventHandler [ "HandleDamage", {
  params ["_unit", "_hitSelection", "_damage","_source","_projectile","_hitPartIndex", "_instigator", "_hitPoint"];

  private _damageMultiplierHead = 0.3;
  private _damageMultiplierBody = 0.25;
  private _damageMultiplierLimbs = 0.15;
  private _damageMultiplierOverall = 0.25;
  private _limitHead = 1.0;
  private _limitBody = 0.25;
  private _limitLimbs = 0.1;
  private _limitOverall = 0.25;
  private _oldDamage = 0;
  if (_hitSelection isEqualTo "") then {_oldDamage = damage _unit} else {_oldDamage = _unit getHit _hitSelection};
  private _newDamage = _damage - _oldDamage max 0;
  private _incomingDamage = _newDamage;
  private _playerHealth = damage _unit;

  if (_newDamage > 0 && !(_projectile isEqualTo "")) then {
    private _damageMultiplier = _damageMultiplierBody;
    private _upperLimit = _limitBody;
    switch (_hitSelection) do {
      case "face_hub";
      case "head": {
        _damageMultiplier = _damageMultiplierHead;
        _upperLimit = _limitHead;
      };
      case "arms";
      case "hands";
      case "legs": {
        _damageMultiplier = _damageMultiplierLimbs;
        _upperLimit = _limitLimbs;
      };
      case "": {
        _damageMultiplier = _damageMultiplierOverall;
        _upperLimit = _limitOverall;
      };
      default {
        _damageMultiplier = _damageMultiplierBody;
        _upperLimit = _limitBody;
      };
    };
    _newDamage = _newDamage * _damageMultiplier;
    if (_newDamage > _upperLimit) then {
      _newDamage = _upperLimit;
    };

    _damage = _oldDamage + _newDamage;
  };

  if ( isPlayer _unit ) then {
    if ( lifeState _unit == "INCAPACITATED" ) then {
      _damage = _oldDamage;
    } else {
      _this set[ 2, _damage ];
      _damage = _this call bis_fnc_reviveEhHandleDamage;
    };
  };
  _damage
}]

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

×