Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionturnoffweaponflashlight.c
Go to the documentation of this file.
2 {
3  ItemBase m_flashlight;
4 
6  {
7  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_ITEM_OFF;//CMD_ACTIONMOD_INTERACTONCE
8  m_Text = "#switch_off";
9  }
10 
11  override void CreateConditionComponents()
12  {
15  }
16 
17  override bool HasTarget()
18  {
19  return false;
20  }
21 
22  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
23  {
24  if ( item.IsInherited(Rifle_Base) )
25  {
26  //m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_LIGHTFLARE;
27  m_flashlight = ItemBase.Cast(item.FindAttachmentBySlotName("weaponFlashlight"));
28  }
29  else if (item.IsInherited(Pistol_Base))
30  {
31  //m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_LITCHEMLIGHT;
32  m_flashlight = ItemBase.Cast(item.FindAttachmentBySlotName("pistolFlashlight"));
33  }
34  else //is not valid item
35  return false;
36 
37  if ( m_flashlight && m_flashlight.HasEnergyManager() && m_flashlight.GetCompEM().CanSwitchOff() ) //TODO review conditions for turning off
38  {
39  return true;
40  }
41 
42  return false;
43  }
44 
45  override void OnExecuteServer( ActionData action_data )
46  {
47  if ( m_flashlight.HasEnergyManager() )
48  {
49  if ( m_flashlight.GetCompEM().IsSwitchedOn() )
50  {
51  m_flashlight.GetCompEM().SwitchOff();
52  }
53  Weapon_Base.Cast(action_data.m_MainItem).FlashlightOff(); //currently seems to be doing nothing
54  }
55  }
56 };
ItemBase
Definition: inventoryitem.c:730
ActionTurnOffWeaponFlashlight
Definition: actionturnoffweaponflashlight.c:1
CCTNone
Definition: cctnone.c:1
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
Rifle_Base
base for rifles @NOTE name copies config base class
Definition: sks.c:69
Pistol_Base
base for semi auto weapons @NOTE name copies config base class
Definition: pistolalt_base.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
ActionSingleUseBase
Definition: actionsingleusebase.c:41
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56