OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started 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~
-
add this line to the unit you want shot in the head
this addEventHandler ["dammaged", {_this execVM "myScript.sqf"}]
then in myscript.sqf you would add your eventhandler
myscript.sqf
//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:";
};
-
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:
-
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]
-
@IGWedge
replace this line of code
hint "Missed Head";
with this line and the body part that is shot will be displayed, unless you shot the head.
hintc format ["%1",_head];
@Martin
this is a dammaged eventhandler
-
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.
- Unit: the unit who got damaged
- selectionName: part of the unit damaged either "head_hit","legs","hands" or "body"
- damage: amount of damage done with the shot / grenade
It's a powerfull EH.
-
Argh, thought i would have read hit :whistle:
-
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
-
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 ...
-
dis in da init line of unit need 2 b shot
this addEventHandler ["dammaged", _this execVM "myScript.sqs"}]
dis is "myScript.sqs"
_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
-
superb ...
thanx a million LCD works a treat :good:
-
denada ;)
just make a nice SP mision so i can play it :P i dont really have time 4 MP.... :P
LCD OUT
-
check out tiptoe boys II [SP]
complete with secret objectives
any feedback more than welcome ...
and again many thanx for help :good:
-
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.
-
Use the "KILLED" and "HIT" eventhandlers instead for invulnerability:
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.