Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionactivatetrap.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
5  m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.DEFAULT_DEPLOY);
6  }
7 
8  override void InitActionComponent()
9  {
10  super.InitActionComponent();
11 
12  RegisterAnimationEvent("CraftingAction", UA_IN_CRAFTING);
13  }
14 }
15 
17 {
19  {
20  m_CallbackClass = ActionActivateTrapCB;
21  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
22  m_FullBody = true;
23  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
24  m_Sound = "craft_universal_0";
26 
27  m_Text = "#activate";
28  }
29 
30  override void CreateConditionComponents()
31  {
34  }
35 
36  override typename GetInputType()
37  {
39  }
40 
41  override bool HasProgress()
42  {
43  return true;
44  }
45 
46  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
47  {
48  ItemBase targetItem = ItemBase.Cast(target.GetObject());
49  if (targetItem && targetItem.IsBeingPlaced())
50  return false;
51 
52  Object targetObject = target.GetObject();
53  if (targetObject != null)
54  {
55  if (targetObject.IsInherited(TrapBase))
56  {
57  TrapBase trap = TrapBase.Cast(targetObject);
58  if (trap.IsActivable())
59  return true;
60  }
61  else if (targetObject.IsInherited(TrapSpawnBase))
62  {
63  TrapSpawnBase spawnTrap = TrapSpawnBase.Cast(targetObject);
64 
65  if (spawnTrap && !spawnTrap.IsActive())
66  return spawnTrap.IsPlaceableAtPosition(spawnTrap.GetPosition());
67  }
68  }
69 
70  return false;
71  }
72 
73  override void OnStartAnimationLoop( ActionData action_data )
74  {
75  super.OnStartAnimationLoop( action_data );
76 
77  if ( !GetGame().IsMultiplayer() || GetGame().IsServer() )
78  {
79  TrapBase trap = TrapBase.Cast( action_data.m_Target.GetObject() );
80  if ( trap )
81  {
82  Param1<bool> play = new Param1<bool>( true );
83  GetGame().RPCSingleParam( trap, SoundTypeTrap.ACTIVATING, play, true );
84  }
85  }
86  }
87 
88  override void OnEnd( ActionData action_data )
89  {
90  if ( !GetGame().IsMultiplayer() || GetGame().IsServer() )
91  {
92  TrapBase trap = TrapBase.Cast( action_data.m_Target.GetObject());
93  if ( trap )
94  {
95  Param1<bool> play = new Param1<bool>( false );
96  GetGame().RPCSingleParam( trap, SoundTypeTrap.ACTIVATING, play, true );
97  }
98  }
99  }
100 
101  override void OnEndAnimationLoop(ActionData action_data)
102  {
103  super.OnEndAnimationLoop(action_data);
104 
105  if (!GetGame().IsMultiplayer() || GetGame().IsServer())
106  {
107  TrapBase trap = TrapBase.Cast( action_data.m_Target.GetObject());
108  Param1<bool> play = new Param1<bool>(false);
109  GetGame().RPCSingleParam(trap, SoundTypeTrap.ACTIVATING, play, true);
110  }
111  }
112 
113  override void OnFinishProgressServer(ActionData action_data)
114  {
115  Object targetObject = action_data.m_Target.GetObject();
116  if (targetObject != null)
117  {
118  vector orientation = action_data.m_Player.GetOrientation();
119  vector position = targetObject.GetPosition();
120 
121  if (targetObject.IsInherited(TrapBase))
122  {
123  TrapBase trap = TrapBase.Cast(targetObject);
124  trap.OnPlacementComplete(action_data.m_Player, position, orientation);
125  trap.StartActivate(action_data.m_Player);
126  }
127  else if (targetObject.IsInherited(TrapSpawnBase))
128  {
129  TrapSpawnBase spawnTrap = TrapSpawnBase.Cast( targetObject );
130  spawnTrap.OnPlacementComplete(action_data.m_Player, position, orientation);
131  }
132  }
133  }
134 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
CreateConditionComponents
override void CreateConditionComponents()
Definition: actionactivatetrap.c:30
m_Sound
EffectSound m_Sound
Definition: hungersoundhandler.c:18
CCINotPresent
Definition: ccinotpresent.c:1
CAContinuousTime
Definition: cacontinuoustime.c:1
ContinuousInteractActionInput
Definition: actioninput.c:521
HasProgress
override bool HasProgress()
Definition: actionactivatetrap.c:41
UASoftSkillsWeight
Definition: actionconstants.c:118
ActionActivateTrap
ActionActivateTrapCB ActionContinuousBaseCB ActionActivateTrap()
Definition: actionactivatetrap.c:18
OnStartAnimationLoop
override void OnStartAnimationLoop(ActionData action_data)
Definition: actionactivatetrap.c:73
TrapSpawnBase
Definition: trap_fishnet.c:1
OnEnd
override void OnEnd(ActionData action_data)
Definition: actionactivatetrap.c:88
UAMaxDistances
Definition: actionconstants.c:104
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
ActionActivateTrapCB
Definition: actionactivatetrap.c:1
RegisterAnimationEvent
class DayZCreatureAnimInterface RegisterAnimationEvent(string event_name, string function_name)
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CCTNonRuined
Definition: cctnonruined.c:1
Object
Definition: objecttyped.c:1
OnFinishProgressServer
override void OnFinishProgressServer(ActionData action_data)
Definition: actionactivatetrap.c:113
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
OnEndAnimationLoop
override void OnEndAnimationLoop(ActionData action_data)
Definition: actionactivatetrap.c:101
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
SoundTypeTrap
SoundTypeTrap
Definition: trapbase.c:1
GetInputType
override GetInputType()
Definition: actionactivatetrap.c:36
ActionContinuousBase
Definition: actioncontinuousbase.c:132
ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition: actionactivatetrap.c:46
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
UA_IN_CRAFTING
const int UA_IN_CRAFTING
Definition: constants.c:453
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
TrapBase
Definition: trap_bear.c:1