Home   Help Search Login Register  

Author Topic: Head Shot!  (Read 3056 times)

0 Members and 1 Guest are viewing this topic.

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Head Shot!
« on: 28 Mar 2005, 22:55:50 »
I've recently run into a problem, I was going to make an Unreal Tornament style engine And one of the things I wished was to have it when you shoot any player if you hit him in the head it says "Head Shot!" Easy. The only problem is the dammaged eventhandler does not return who shot the person! Making it so everytime some1 gets a head shot everyone sees the message! Here is my very simple scripting:

Heres the trigger stuff
Code: [Select]
"_x addEventHandler [{dammaged},{_this exec {Dammaged.sqs}}]" foreach thislist
And Dammaged.sqs

Code: [Select]
_unit = _this select 0
_area = _this select 1
?(_area != "hlava"):exit

titletext ["Head Shot","Plain",0.1]
exit

It seems the only way to fix this would be to also add a hit event handler however I cannot figure out how to make it keep the dammaged init into another script without major bugs.

-Any help greatly appreciated.
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Head Shot!
« Reply #1 on: 29 Mar 2005, 01:10:30 »
Hmm... just throwing out a few ideas here, without giving any specifics to back it up, but...

What if you set a global variable from the dammaged eventhandler, and then in the hit or killed eventhandler, you check to see if that variable is set or not? In general this could be a very complicated process, but I think it might be fairly simple to do in your case, since (a) this only applies to players and (b) it only applies to headshots, which always kill the unit. Maybe something like this:

dammaged EH:
  ? (guy who got shot) is a player && was shot in head : Head_Shots = Head_Shots + [guy who got shot]

hit / killed EH:

;make sure global var gets set first
~0.5
? (guy who got killed) IN Head_Shots : hint "headshot!"; Head_Shots = Head_Shots - [guy who got killed]

I would think that this should, although there may be some problems with locality in MP (especially if hit and dammaged EHs run on different locations).
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:Head Shot!
« Reply #2 on: 29 Mar 2005, 02:45:20 »
Yes, Thats the problem. I cant figure a way to transfer the offender to the dammaged script as dammaged does not give this information.

Therefore I cant figure out who "Guy who shot guy" is.
« Last Edit: 29 Mar 2005, 02:45:42 by RujiK »
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Head Shot!
« Reply #3 on: 29 Mar 2005, 04:14:31 »
I'm saying to transfer the fact that the victim was hit in the head (discovered in the "dammaged" EH) to a "hit" or "killed" EH (which can tell you WHO shot the victim). You are trying to do it the other way around, but I think it is simpler to do it this way.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

S0GSEAL

  • Guest
Re:Head Shot!
« Reply #4 on: 19 Nov 2005, 03:50:19 »
so guys did u fixed it?:P

i would love to try it><

tnx

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Head Shot!
« Reply #5 on: 19 Nov 2005, 18:19:45 »
Mmm.  I am not sure it was right to move this from the Advanced board.  There is some complex stuff here.  

The Dammaged EH enables you to know where the unit was damaged - but not by who, and the Hit EH enables you to know who did the hiting - but not what part of the body was hit.  So what is needed is a set of Dammaged EHs and Hit EHs assigned to units that will run scripts that need to be smart enough to link each damaged unit script to the correct hit script, when there could be a lot of dammaged  Events and Hit Events being actioned at the same time in the middle of a battle.

Something like:
Create empty global arrays in init.sqs:
RecentlyHit = []
RecentlyHitBy = []

the script called by the Hit EH:
RecentlyHit = RecentlyHit + [_this select 0]
RecentlyHitBy = RecentlyHitBy + [_this select 1]
~1
RecentlyHit = RecentlyHit - [_this select 0]
RecentlyHitBy = RecentlyHitBy - [_this select 1]
exit


Then in the Dammaged EH script:
start with a small delay

~0.1


then find the position of _this select 0 in the array RecentlyHit and the unit that did the damaging will be in the same place in the array RecentlyHitBy


Anyway just a few random thoughts.  i am sure it will need a fair bit of work from here.

EDIT:
I have just noticed that this thread has been pretty dormant for 8 months - I presume they either solved it or did something else. Oh well.
« Last Edit: 19 Nov 2005, 20:41:16 by THobson »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Head Shot!
« Reply #6 on: 19 Nov 2005, 19:20:43 »
Well, you pretty much die in 100% certainty whenever you get shot in the head in OFP so why not just use the 'killed' eventHandler (like GB suggested already)..

It returns who did the killing so you will know who shot the head shot....
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Head Shot!
« Reply #7 on: 19 Nov 2005, 20:39:49 »
Well there's me getting carried away solving a complex problem, and it is just a simple one all along :o
« Last Edit: 20 Nov 2005, 16:06:01 by THobson »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Head Shot!
« Reply #8 on: 20 Nov 2005, 16:05:50 »
On reflection.  The killed EH doesn't help because it doesn't tell you where the unit was hit.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Head Shot!
« Reply #9 on: 20 Nov 2005, 16:56:52 »
Ach, I was to vague in me post... :P

What GB said is valid.

You use something like a unit specific global variable (format function comes in handy) in the "dammaged" event and if it's a head shot you set that global variable true which then allows the "killed" event on the same unit to 'act'...

So (purely theoretical) "dammged" event:
Code: [Select]
? _this select 1 == "hlava" && !(alive) _this select 0: call format ["mytag_headShot_%1=true",_this select 0]
And (equally theoretical) "killed" event:
Code: [Select]
~.1
? !(call format ["mytag_headShot_%1",_this select 0]): exit
<insert headshot related stuff here>

I'm sure my format syntax is all assed up, but you get the picture ::)
And no quarantees on the rest either :P  *hands washed*
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

S0GSEAL

  • Guest
Re:Head Shot!
« Reply #10 on: 23 Nov 2005, 06:46:11 »
omg my head will blow up:) from these stuff......can any1 tell me if script is done?


btw guys..i have addon that show..the health bar..and when some1 shoots at u..it shows the only spots: head, chest, arms, legs. maybe it will help like when AI or person shoot u in the head...u can add to that addon like HEAD SHOT....dunno if im right :/

chupchup

  • Guest
Re:Head Shot!
« Reply #11 on: 25 Nov 2005, 15:50:52 »
A workaround for this is to get the Dammaged EH to run a dirtoobject function for each player (except the victim) where the player is object1 and the headshot target is object2. Create a global array in the init called something original like PlayerList and add all the unit names [p1,p2,etc...] In the script running off the EH:
Create a loop that calls the dirtoobj function for each selection of PlayerList and getdirs that unit. If both variables are equal (might require small error +/- 5deg), you have found the shooter.

[most of the time]

Try it out, might even work!

S0GSEAL

  • Guest
Re:Head Shot!
« Reply #12 on: 26 Nov 2005, 02:39:01 »
can u make example mission?:P

im only starting:)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Head Shot!
« Reply #13 on: 26 Nov 2005, 11:36:44 »
Why don't you have a go with the code I put in Reply #5 I still think it is worth trying.

S0GSEAL

  • Guest
Re:Head Shot!
« Reply #14 on: 27 Nov 2005, 14:07:24 »
lol i try...but still dont fully get it:)

-edit-
nope didnt get it to work..coz dont understand anything..

can any1 make example mission plz :'(
« Last Edit: 27 Nov 2005, 23:52:05 by S0GSEAL »