Jump to content
R4IDER

Understanding HitPart Event Handler

Recommended Posts

Hi,

Usually when dealing with event handlers you can use select to get the bit for information you require however with the HitPart event handler it seems you can't select individual bits information but instead only everything. What I am trying to do is select the part of the body that was hit but I am not sure how to go about doing this when so much information is returned.

this addEventHandler ["HitPart", { _EX1 = _this select 0; hint format["%1", _EX1] }];

Share this post


Link to post
Share on other sites

Most of the time bullet going through several bodyparts so you recieving like 3 or so values after one hit.

You can see it if you use "player globalChat format..." instead of hint.

Share this post


Link to post
Share on other sites

I think he's trying to isolate one of the elements.

Hitpart is new to me and seems to return an array inside an array so to retrieve an element you need to dig a little.

The final select is the pointer to the element, change that to the number you require.

this addEventHandler ["HitPart", { _EX1 = _this select 0; hint format["%1", _EX1 select 0] }];// returns unit B 1-1-c:1 or unit name if named

https://community.bistudio.com/wiki/ArmA_2:_Event_Handlers#HitPart

Share this post


Link to post
Share on other sites

Using the following line you can see the body part hit.

this addEventHandler ["HitPart", { _EX1 = ((_this select 0) select 5); hint format["%1", _EX1] }];

Share this post


Link to post
Share on other sites

Hiya guys,

 

I'm a little rusty on the HitPart eventHandler - how would one check to see if a particular part was hit using the 'if' and '==' commands? I was considering adding an object with the HitPart eventhandler in the init. config, which triggered a script when that part was damaged?  

Share this post


Link to post
Share on other sites

Holy necro batman.

Works with all eventhandlers:

this addeventHandler ["HitPart",{hint str _this}];

Now just shoot at the object to display the relevant hitpart.

Then use the hitpart in an if then statement.

 

Cheers

Share this post


Link to post
Share on other sites

 

Holy necro batman.

Works with all eventhandlers:

this addeventHandler ["HitPart",{hint str _this}];

Now just shoot at the object to display the relevant hitpart.

Then use the hitpart in an if then statement.

 

Cheers

 

Lol, thanks mate! Much appreciated! Ha ha, nothing like digging up 3 year old threads! :P

Share this post


Link to post
Share on other sites

According to Wiki (https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HitPart) hitpart event should have parameters like this:

_object addEventHandler [
    "HitPart",
    {
        params ["_target","_shooter","_bullet","_position","_velocity","_selection","_ammo","_direction","_radius","_surface","_direct"];
    	
		//code
	}
];

Instead of, it returns this:

_object addEventHandler [
    "HitPart",
    {
		(_this select 0) params ["_target","_shooter","_bullet","_position","_velocity","_selection","_ammo","_direction","_radius","_surface","_direct"];
    	
		//code
	}
];

@killzone_kid any confirmation about this ? Testing on version: 1.66.139586

  • Like 1

Share this post


Link to post
Share on other sites

New format of EH page ate the structure and sample that was there a while ago it seems. I added some notes

  • Like 2

Share this post


Link to post
Share on other sites
On ‎1‎/‎6‎/‎2017 at 7:14 AM, M1ke_SK said:

According to Wiki (https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HitPart) hitpart event should have parameters like this:

 

I thought you could run the "HitPart" EH by adding it to the shooter according to this;

 

"While you can add "HitPart" handler to a remote unit, the respectful addEventHandler command must be executed on the shooter's PC and will only fire on shooter's PC as well. The event will not fire if the shooter is not local, even if the target itself is local. Additionally, if the unit gets damaged by any means other than shooter's shooting, "HitPart" will not fire. Because of this, this event handler is most suitable for when the shooter needs feedback on his shooting, such as target practicing or hitmarker creation.

 

If so, how to I get the "HitPart" EH to execute? I tried the following for a MP game for each player that is the shooter:

 

onPlayerRespawn.sqf

player addMPEventHandler  ["HitPart",{hint str _this}];

..but I assume it does not fire because it is not local?

Edited by beako
to clarify my request

Share this post


Link to post
Share on other sites
On 5/12/2016 at 5:30 PM, Grumpy Old Man said:

Holy necro batman.

Works with all eventhandlers:


this addeventHandler ["HitPart",{hint str _this}];

Now just shoot at the object to display the relevant hitpart.

Then use the hitpart in an if then statement.

 

Cheers

Hey does this work with Simple Targets? I'm trying to use hitpart to tell me where on a target my bullet hit. Do you have any idea how to do that?

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

×