Jump to content
Sign in to follow this  
celery

Script-based body armor

Recommended Posts

When I looked at the eventhandler list I found HandleDamage, an eventhandler that filters a unit's damage through a custom script. I wanted to play around with it for a couple of minutes but I got distracted for a couple of hours and made a primitive body armor script.

I added the eventhandler to a unit:

this addeventhandler ["HandleDamage",{_this exec "bodyarmor.sqs"}]

bodyarmor.sqs

;Body armor script by Celery

_exectime=time
_unit=_this select 0
_bodypart=_this select 1
_damage=_this select 2
_source=_this select 3
_ammo=_this select 4



?_bodypart=="head_hit":CLY_headhit=[_exectime,_unit,_bodypart,_damage,_source,_ammo]
?_bodypart=="body":CLY_bodyhit=[_exectime,_unit,_bodypart,_damage,_source,_ammo]
?_bodypart=="hands":CLY_handshit=[_exectime,_unit,_bodypart,_damage,_source,_ammo]
?_bodypart=="legs":CLY_legshit=[_exectime,_unit,_bodypart,_damage,_source,_ammo]

;Proceed to the next stage when all body parts are accounted for
?(CLY_headhit select 0)==_exectime and (CLY_bodyhit select 0)==_exectime and (CLY_handshit select 0)==_exectime and (CLY_legshit select 0)==_exectime:goto "damage"
exit

#damage
_headd=CLY_headhit select 3
_bodyd=CLY_bodyhit select 3
_handsd=CLY_handshit select 3
_legsd=CLY_legshit select 3

;Find the body part that was hit (normally all of them get some damage)
_bigger=_headd max _bodyd
_bigger=_bigger max _handsd
_bigger=_bigger max _legsd

;Different body parts have different damage multipliers (otherwise every legshot would be fatal)
;In this case the body is protected with armor, giving it a damage threshold of 2
?_bigger==_headd:_damage=_headd*0.5-damage _unit;goto "finaldamage"
?_bigger==_bodyd:_damage=(_bodyd-damage _unit*0.75-2)*0.5;goto "finaldamage"
?_bigger==_handsd:_damage=_handsd*0.25-damage _unit*0.1;goto "finaldamage"
?_bigger==_legsd:_damage=_legsd*0.25-damage _unit*0.1;goto "finaldamage"

exit

#finaldamage

?_damage<0:exit
_unit setDamage damage _unit+_damage
exit

Basically it adds a damage threshold to the main body (torso), stopping almost every bullet save for a few lucky ones. Naturally 7.62 and larger calibers penetrate it, albeit at around ½ strength. The above script is quite close to the capabilities of the new "Dragon Skin" ballistic vest.

The structure of the script is like that because the eventhandler triggers 5 times for each hit, each time for a different body part. The damage received somehow seems to increase depending on how damaged the unit already is so there's a deduction in damage based on the unit's health.

I'm aware that the script causes an error message due to some variable humbug and it's not exactly ready for serious use in the format (SQS) and state (unoptimised, no proper damage distribution) it's in at the moment. However I don't have time to develop this script further at the moment so everyone is welcome to make a proper body armor script based off this one! :)

To any skilled scripters out there, please improve this script and post your upgraded version in this thread so that we can use it to make missions better.

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  

×