krabban333 3 Posted October 5, 2023 Hi, I'm trying to add an event handler for projectiles fired by the player, but I'm getting the error Error Foreign error: Unknown enum value: "EpeContact" Any ideas on why this happens? Dumping the _projectile variable returns an object, so I'm kinda lost. Thanks in advance! Here's my code: _player addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; _projectile addEventHandler ["EpeContact", { params ["_object1", "_object2", "_selection1", "_selection2", "_force", "_reactVect", "_worldPos"]; }]; }]; Share this post Link to post Share on other sites
pierremgi 4779 Posted October 6, 2023 You can't do that. EHs with "EpeContact..." apply on collision of PhysX objects (CfgVehicles class "simulation" ends by X), so not all objects! For projectiles, see this interesting KK's blog. It's rather old and doesn't mention the new EHs for projectile (since v2.10) These new EHs are probably your solution. 2 Share this post Link to post Share on other sites
krabban333 3 Posted October 6, 2023 Thanks, was an interesting read! Long story short; I'm working on a surrender scriptmod where if a surrendered unit is fired upon they will start fleeing. I managed to solve my issue by using the EH HitPart for the projectile. The finished code looks like this: // Check if a player fires at a surrendered or cowering unit fnc_addPlayerFiredHandler = { { _player = _x; if (isNil {_player getVariable "logicAdded"}) then { // On player fire event _player addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; // Throttle fire event if (!(_unit getVariable ["onCooldown", false])) then { [_unit, 0.6] call fnc_addGeneralCooldown; // On projectile hit event _projectile addEventHandler ["HitPart", { params ["_projectile", "_target", "_shooter", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"]; [_shooter, _position] spawn fnc_handleBulletImpact; }]; }; }]; _player setVariable ["logicAdded", true]; }; } forEach PLAYERS; }; Share this post Link to post Share on other sites