OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Durbs on 06 Feb 2007, 18:40:49

Title: Headshot! or not?
Post by: Durbs on 06 Feb 2007, 18:40:49
Hi all,

I have a question - hope it's not too complicated - I'm looking for an easy solution  :)
I want to add an eventhandler to a unit that will only become activated when he's shot in the head....Can anyone help?

Thanks in advance~
Title: Re: Headshot! or not?
Post by: Squeeze on 06 Feb 2007, 22:58:01
add this line to the unit you want shot in the head
Code: [Select]
this addEventHandler ["dammaged", {_this execVM "myScript.sqf"}]
then in myscript.sqf you would add your eventhandler
myscript.sqf
Code: [Select]
//arg: [unit,bodypart,dammage]

_unit = _this select 0;
_head = _this select 1;
_damm = _this select 2;

if(_head != "head_hit") then
{
hint "Missed Head";
}
else
{
Hint"Shot in Head,Add code here:";
};
Title: Re: Headshot! or not?
Post by: IGWedge on 07 Feb 2007, 20:57:02
So is it possible to add to this to specify all hitpoints
ie...legs, arms, chest etc.
This could be very useful for me and the tournament im running for training.

Possibly a points structure for each hitpoint??

I am very poor at scripting and coding. :( :confused:
Title: Re: Headshot! or not?
Post by: Martin on 09 Feb 2007, 18:15:26
I dont understand how you can detect the hidden part of the target through the eventhandler hit, because following the Biki (http://community.bistudio.com/wiki/Operation_Flashpoint:_EventHandlers_List#Hit), the array passed is : [unit, causedBy, damage]
Title: Re: Headshot! or not?
Post by: Squeeze on 09 Feb 2007, 21:29:44
@IGWedge
replace this line of code
Code: [Select]
hint "Missed Head";with this line and the body part that is shot will be displayed, unless you shot the head.
Code: [Select]
hintc format ["%1",_head];
@Martin
this is a dammaged  eventhandler
Title: Re: Headshot! or not?
Post by: Cheetah on 09 Feb 2007, 21:51:37
Wiki Dammaged EH (http://community.bistudio.com/wiki/ArmA:_Event_Handlers#Dammaged)

More information concerning the damaged EH:

The outputted array contains three values: unit, selectionName and damage.

It's a powerfull EH.
Title: Re: Headshot! or not?
Post by: Martin on 09 Feb 2007, 23:14:00
Argh, thought i would have read hit  :whistle:
Title: Re: Headshot! or not?
Post by: D_P_ on 02 Mar 2007, 03:57:19
Is there a way to have the script run so that only a headshot would kill the unit? And any other bodyshot do no damage?
I tried playing around with the code above but couldn't seem to get it to work :(
If anyone has any sugestions~ that would be sweet. Thanks
Title: Re: Headshot! or not?
Post by: sharkattack on 28 May 2007, 17:40:05
im having similar troubles only i need to detect dammage to the body to activate a script
any  pointers
i read about dammaged event handler ... sure this i what i need ... how exactly  would i set it up  to  detect bodyshot ...
Title: Re: Headshot! or not?
Post by: LCD on 28 May 2007, 18:07:21
dis in da init line of unit need 2 b shot

Code: [Select]
this addEventHandler ["dammaged", _this execVM "myScript.sqs"}]

dis is "myScript.sqs"

Code: [Select]
_unit = _this select 0;
_hitPart = _this select 1;
_damm = _this select 2;

? (_hitPart == "body")  : [] exec "script.sqs";

exit

dat in da script shud do da work

LCD OUT
Title: Re: Headshot! or not?
Post by: sharkattack on 28 May 2007, 18:50:02
superb ...
thanx a million LCD  works a treat    :good:
Title: Re: Headshot! or not?
Post by: LCD on 29 May 2007, 01:29:35
denada ;)

just make a nice SP mision so i can play it :P i dont really have time 4 MP.... :P

LCD OUT
Title: Re: Headshot! or not?
Post by: sharkattack on 30 May 2007, 01:09:17
check out tiptoe boys II [SP]
complete with secret objectives
any feedback  more than welcome ...
and again many thanx  for  help   :good:
Title: Re: Headshot! or not?
Post by: Wolfrug on 31 May 2007, 11:17:09
Regarding the "no damage unless hit in head" bit :  :no: I've tried this myself as well, to no avail. It seems ArmA is even twitchier than OFP with the whole "dead - not dead" bit. In OFP if you got killed and then revived, it gave you the death dialog and you were...well...dead (even if your avatar still ran around). Whereas AI could continue on killing stuff.

Alas, what I've tried in the editor (using among others the dammaged eventhandler, and also something as simple as "?!alive unit1 then unit1 setdamage 0") : once a unit in ArmA is dead, it's dead, and it ain't coming back.  :( If anyone else has another experience of this, please do tell (testing done in 1.07+)

This could potentially be worked around somehow (create a new unit and name it the old unit's name, transfer all the equipment etc.), but that'd be a bit of a bitch really. Sigh. Maybe a future patch?

Wolfrug out.
Title: Re: Headshot! or not?
Post by: Mr.Peanut on 31 May 2007, 17:41:41
Use the "KILLED" and "HIT" eventhandlers instead for invulnerability:
Code: [Select]
this addEventHandler["KILLED",{(_this select 0) setDamage 0}];this addEventHandler["HIT",{(_this select 0) setDamage 0}]
A trigger will not always work because you may be dead between trigger fires(I forget if they are every 0.1, 0.2 or 0.5 seconds), but an eventhandler will work 95% of the time. A tank shell or sat may occasionally defeat it.