Home   Help Search Login Register  

Author Topic: Headshot! or not?  (Read 3541 times)

0 Members and 1 Guest are viewing this topic.

Durbs

  • Guest
Headshot! or not?
« 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~

Offline Squeeze

  • Members
  • *
Re: Headshot! or not?
« Reply #1 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:";
};

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: Headshot! or not?
« Reply #2 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:

Offline Martin

  • Members
  • *
Re: Headshot! or not?
« Reply #3 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, the array passed is : [unit, causedBy, damage]

Offline Squeeze

  • Members
  • *
Re: Headshot! or not?
« Reply #4 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
« Last Edit: 09 Feb 2007, 22:11:55 by Squeeze »

Offline Cheetah

  • Former Staff
  • ****
Re: Headshot! or not?
« Reply #5 on: 09 Feb 2007, 21:51:37 »
Wiki Dammaged EH

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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Martin

  • Members
  • *
Re: Headshot! or not?
« Reply #6 on: 09 Feb 2007, 23:14:00 »
Argh, thought i would have read hit  :whistle:

Offline D_P_

  • Members
  • *
  • YAY! I'm a lama again! ...oh wait.
    • ArmaAddons
Re: Headshot! or not?
« Reply #7 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
just setpos & forgetpos!

Offline sharkattack

  • Former Staff
  • ****
Re: Headshot! or not?
« Reply #8 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 ...
"HOLY SARDINE" - see Shark-Attack meet his match

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Headshot! or not?
« Reply #9 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
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline sharkattack

  • Former Staff
  • ****
Re: Headshot! or not?
« Reply #10 on: 28 May 2007, 18:50:02 »
superb ...
thanx a million LCD  works a treat    :good:
"HOLY SARDINE" - see Shark-Attack meet his match

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Headshot! or not?
« Reply #11 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
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline sharkattack

  • Former Staff
  • ****
Re: Headshot! or not?
« Reply #12 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:
« Last Edit: 30 May 2007, 01:12:22 by shark attack »
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Headshot! or not?
« Reply #13 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.
"When 900 years YOU reach, look as good you will not!"

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Headshot! or not?
« Reply #14 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.
« Last Edit: 31 May 2007, 17:47:56 by Mr.Peanut »
urp!