Jump to content
krabban333

Issues with EpeContact event handler

Recommended Posts

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

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.

  • Like 2

Share this post


Link to post
Share on other sites

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×