Page MenuHomeFeedback Tracker

Event to determine when InventoryItem is thrown
New, NormalPublic

Description

There's no clean way to determine when an item is thrown via InventoryItem::ThrowPhysically, currently I have the following, which only is handled from the hand event which doesn't cover item's thrown via script, non-players.

// 3_Game
modded class HandActionThrow
{
	override void Action(HandEventBase e)
	{
		super.Action(e);

		DayZPlayer player = DayZPlayer.Cast(e.m_Player);
		if (player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE)
		{
			InventoryItem item;
			if (Class.CastTo(item, e.GetSrcEntity()))
			{
				HandEventThrow throwEvent = HandEventThrow.Cast(e);
				vector force = throwEvent.GetForce();

				Param params = new Param2<DayZPlayer, vector>(player, force);
				GetGame().GameScript.CallFunctionParams(item, "OnThrowPhysically", null, params);
			}
		}
	}
}

// 4_World
modded class ItemBase
{
	void OnThrowPhysically(DayZPlayer player, vector force)
	{
		PrintFormat("ItemBase::OnThrowPhysically - {type=%1,player=%2,force=%3}", GetType(), player, force);
	}
}

Details

Severity
Minor
Resolution
Open
Reproducibility
N/A
Operating System
Windows 11 x64
Category
General

Event Timeline