DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionPickupChicken.c
Go to the documentation of this file.
2{
4 {
5 m_Text = "#take";
6 }
7
8 override typename GetInputType()
9 {
11 }
12
14 {
17 }
18
19 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
20 {
21 if ( player.GetCommand_Vehicle() )
22 return false;
23
25 if ( Class.CastTo( chicken, target.GetObject() ) )
26 {
27 return !chicken.IsAlive();
28 }
29 return false;
30 }
31
32 override void OnExecuteServer( ActionData action_data )
33 {
34 // We will switch the item
35 Animal_GallusGallusDomesticus targetChicken = Animal_GallusGallusDomesticus.Cast( action_data.m_Target.GetObject() );
36 if ( targetChicken )
37 {
38 DeadChicken_ColorBase deadChicken = DeadChicken_ColorBase.Cast( action_data.m_Player.GetHumanInventory().CreateInHands( targetChicken.GetDeadItemName() ) );
39
40 if ( deadChicken == null )
41 {
42 deadChicken = DeadChicken_ColorBase.Cast( action_data.m_Player.GetHumanInventory().CreateInInventory( targetChicken.GetDeadItemName() ) );
43
44 if ( deadChicken == null )
45 deadChicken = DeadChicken_ColorBase.Cast( GetGame().CreateObjectEx( targetChicken.GetDeadItemName(), targetChicken.GetPosition(), ECE_PLACE_ON_SURFACE, RF_ORIGINAL ) );
46 }
47 targetChicken.Delete();
48 }
49 }
50};
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
protected string m_Text
Definition ActionBase.c:49
class ActionTargets ActionTarget
const int RF_ORIGINAL
const int ECE_PLACE_ON_SURFACE
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionTarget m_Target
Definition ActionBase.c:32
override void OnExecuteServer(ActionData action_data)
override void CreateConditionComponents()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override string GetDeadItemName()
Definition AnimalBase.c:200
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.