gc8 970 Posted August 24, 2020 Hi I'm using HitPart to count damage done to a door but I get weird projectile distance return when shooting the door with AT weapon. I get this kind of log entries with one AT shot: 16:42:13 "damage is 'door_1' dist: 11337.4 distp: 18.1446 (150)" 16:42:13 "damage is 'door_1' dist: 11337.4 distp: 18.1446 (150)" 16:42:13 "damage is 'door_1' dist: 6.56717 distp: 18.1446 (495)" The distance (dist) is either 11337.4 (way too long) or 6.56 (still too long). Distance to player (distp) seems ok If I shoot with rifle the distance is what expected (around 2): 16:42:36 "damage is 'door_1' dist: 2.30221 distp: 18.1446 (10)" Test code: _bldg addEventHandler ["HitPart", { { _x params ["_bldg", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"]; _hit = _ammo # 0; _ammoName = _ammo # 4; if(count _selection > 0) then { _sel = (_selection # 0); if("door" in (tolower _sel)) then { private _pos = _bldg selectionPosition format ["%1_trigger", _sel]; private _doorpos = _bldg modelToWorld _pos; private _dp = getposATL _projectile; private _distToExplosion = _doorpos distance _dp; diag_log format["damage is '%1' dist: %2 distp: %3 (%4)", _sel,_distToExplosion,_doorpos distance player, _hit]; }; }; } foreach _this; }]; (I'm testing on Takistan map) Does anyone know why this is happening and how to fix? I hope the HitPart just isn't bugged... thx! Share this post Link to post Share on other sites
pierremgi 4738 Posted August 24, 2020 probably because this EH runs multiple times in one AT shot. You should try to use the direct fire with the "_isDirect" parameter. Huge distance just means that, somewhere during the EH code, the projectile is gone (objNull), then the reference is the map origin [0,0,0]. You can add something like: while {!isnull _projectile} do {_dp = getPos _projectile}; (I didn't check if this kind of ammo disappear at once when hit, or if there is some remaining ballistic for a non-null object) 1 1 Share this post Link to post Share on other sites
gc8 970 Posted August 25, 2020 @pierremgi Good point, the projectile was in fact null for the longest distance but for the 6.5 distance it's [425523: empty.p3d]. And that empty also has the biggest damage (hit) so I wonder what that means is the other splash damage and other direct? The 6.5 dist shot is direct according to _isDirect. but still the question , why 6.5 dist? Share this post Link to post Share on other sites
gc8 970 Posted August 31, 2020 Do you guys think that when I hit the door with missile the distance to the door is reported to be over 6 meters because of the blast radius? If so I think this needs to be fixed in the engine there has to be other way to determine the distance to impact position Share this post Link to post Share on other sites
h - 169 Posted August 31, 2020 Use the _position given to you by the event itself, don't getpos the projectile. At least for me the distance returned is closer to 0 using this: _bldg addEventHandler ["HitPart", { { _x params ["_bldg", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"]; if (_isDirect) then { _hit = _ammo # 0; _ammoName = _ammo # 4; if (count _selection > 0) then { _sel = (_selection # 0); if("door" in (tolower _sel)) then { private _pos = _bldg selectionPosition format ["%1_trigger", _sel]; private _doorpos = _bldg modelToWorldVisual _pos; private _dp = ASLToAGL _position; private _distToExplosion = _doorpos distance _dp; diag_log format["damage is '%1' dist: %2 distp: %3 (%4)", _sel,_distToExplosion,_doorpos distance player, _hit]; }; }; }; } foreach _this; }]; You may get two direct hits if the ammo uses submunition. 1 Share this post Link to post Share on other sites
gc8 970 Posted August 31, 2020 1 hour ago, h - said: Use the _position given to you by the event itself, don't getpos the projectile. Thx! I had tried it too but I was missing the ASLToAGL. So now with that I get reasonable dist, thx for that! Share this post Link to post Share on other sites