Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionturnoffwhileonground.c
Go to the documentation of this file.
2 {
4  {
5  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_INTERACTONCE;
6  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
7  m_Text = "#switch_off";
8  }
9 
10  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
11  {
12  EntityAI target_entity = EntityAI.Cast( target.GetObject() );
13 
15  target_entity.GetInventory().GetCurrentInventoryLocation(loc);
16 
17  return ( player.IsAlive() && target_entity.HasEnergyManager() && target_entity.GetCompEM().CanSwitchOff()) && loc.GetType() == InventoryLocationType.GROUND );
18  }
19 
20  override void OnExecuteServer( ActionData action_data )
21  {
22  EntityAI target_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
23 
24  if ( target_entity.GetCompEM().CanSwitchOff() )
25  {
26  target_entity.GetCompEM().SwitchOff();
27 
28  InformPlayers( action_data.m_Player, action_data.m_Target, UA_FINISHED ); //Success
29  }
30  else
31  {
32  InformPlayers( action_data.m_Player, action_data.m_Target, UA_FAILED ); //Already turned off
33  }
34  }
35 }
ItemBase
Definition: inventoryitem.c:730
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
InformPlayers
protected void InformPlayers(PlayerBase player, ActionTarget target, int state)
DEPRECATED delivers message ids to clients based on given context.
ActionInteractBase
Definition: actioninteractbase.c:54
PlayerBase
Definition: playerbaseclient.c:1
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
m_Text
protected string m_Text
Definition: actionbase.c:49
ActionTurnOffWhileOnGround
Definition: actionturnoffwhileonground.c:1
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
EntityAI
Definition: building.c:5
UA_FAILED
const int UA_FAILED
Definition: constants.c:433