DayZ 1.24
Loading...
Searching...
No Matches
ActionRepairCarPart.c File Reference

Go to the source code of this file.

Classes

class  RepairCarPartActionReciveData
 
class  ActionRepairCarPartCB
 

Functions

void ActionRepairCarPart ()
 
override void CreateConditionComponents ()
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override void OnFinishProgressServer (ActionData action_data)
 
override ActionData CreateActionData ()
 
override void WriteToContext (ParamsWriteContext ctx, ActionData action_data)
 
override bool ReadFromContext (ParamsReadContext ctx, out ActionReciveData action_recive_data)
 
override void HandleReciveData (ActionReciveData action_recive_data, ActionData action_data)
 

Variables

RepairCarPartActionReciveData m_DamageZone
 
ActionRepairCarPartCB m_LastValidType
 
string m_CurrentDamageZone = ""
 
int m_LastValidComponentIndex = -1
 

Function Documentation

◆ ActionCondition()

override bool ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )

Definition at line 43 of file ActionRepairCarPart.c.

44 {
45 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
46 return false;
47
48 Object targetObject = target.GetObject();
49 Object targetParent = target.GetParent();
51
52 if (!carDoor || !player)
53 return false;
54
55 if (GetGame().IsMultiplayer() && GetGame().IsServer())
56 return true;
57
58 if (carDoor)
59 {
60 //Check if item is attached to car -> If so, block repair if door is closed
61 if (targetParent != null)
62 {
64 bool isPresent = carDoor.GetInventory().GetCurrentInventoryLocation(loc);
65
66 if (!isPresent || loc.GetSlot() == -1)
67 return false;
68
69 string slotName = InventorySlots.GetSlotName(loc.GetSlot());
71 return false;
72 }
73
74 //Check health level of door
75 int zoneHP = carDoor.GetHealthLevel("");
77 }
78
79 return false;
80 }
CarDoorState
Definition CarScript.c:2
PlayerSpawnPreset slotName
eBrokenLegs
Definition EBrokenLegs.c:2
override int GetCarDoorsState(string slotType)
InventoryLocation.
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
proto native CGame GetGame()
const int STATE_RUINED
Definition constants.c:757
const int STATE_WORN
Definition constants.c:760

References CarScript::GetCarDoorsState(), GetGame(), InventorySlots::GetSlotName(), slotName, GameConstants::STATE_RUINED, and GameConstants::STATE_WORN.

◆ ActionRepairCarPart()

void ActionRepairCarPart ( )

Definition at line 25 of file ActionRepairCarPart.c.

26 {
27 m_CallbackClass = ActionRepairCarPartCB;
29
30 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
31 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
32 m_FullBody = true;
33 m_LockTargetOnUse = false;
34 m_Text = "#repair";
35 }
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
bool m_LockTargetOnUse
Definition ActionBase.c:51
float m_SpecialtyWeight
Definition ActionBase.c:68
int m_StanceMask
Definition ActionBase.c:53
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597

References m_FullBody, m_LockTargetOnUse, m_SpecialtyWeight, m_StanceMask, m_Text, and UASoftSkillsWeight::PRECISE_LOW.

Referenced by ActionConstructor::RegisterActions(), and EpoxyPutty::SetActions().

◆ CreateActionData()

override ActionData CreateActionData ( )

Definition at line 132 of file ActionRepairCarPart.c.

◆ CreateConditionComponents()

override void CreateConditionComponents ( )

Definition at line 37 of file ActionRepairCarPart.c.

38 {
41 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
const float REPAIR

References m_ConditionItem, m_ConditionTarget, and UAMaxDistances::REPAIR.

◆ HandleReciveData()

override void HandleReciveData ( ActionReciveData action_recive_data,
ActionData action_data )

◆ OnFinishProgressServer()

override void OnFinishProgressServer ( ActionData action_data)

Definition at line 82 of file ActionRepairCarPart.c.

83 {
84 Object tgObject = action_data.m_Target.GetObject();
85
86 string damageZone = RepairCarPartActionData.Cast(action_data).m_DamageZone;
87 if (!GetGame().IsMultiplayer())
89
90 if (tgObject)
91 {
93 if (carDoor)
94 {
96 float zoneMax = carDoor.GetMaxHealth("", "");
97 float randomValue = Math.RandomFloatInclusive(zoneMax * 0.05, zoneMax * 0.15);
98
99 switch (newDmgLevel)
100 {
103 break;
104
107 break;
108
111 break;
112
113 default:
114 break;
115 }
116
117 if (action_data.m_MainItem.HasQuantity())
118 {
119 if (action_data.m_MainItem.GetQuantity() > 1)
120 {
121 int qnt = action_data.m_MainItem.GetQuantity();
122 qnt -= action_data.m_MainItem.GetQuantityMax() * 0.25;
123 action_data.m_MainItem.SetQuantity(qnt);
124 }
125 else
126 action_data.m_MainItem.Delete();
127 }
128 }
129 }
130 }
string m_CurrentDamageZone
Definition EnMath.c:7
const float DAMAGE_BADLY_DAMAGED_VALUE
Definition constants.c:772
const float DAMAGE_RUINED_VALUE
Definition constants.c:773
const float DAMAGE_DAMAGED_VALUE
Definition constants.c:771
const int STATE_DAMAGED
Definition constants.c:759
const int STATE_BADLY_DAMAGED
Definition constants.c:758
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

References Math::Clamp(), GameConstants::DAMAGE_BADLY_DAMAGED_VALUE, GameConstants::DAMAGE_DAMAGED_VALUE, GameConstants::DAMAGE_RUINED_VALUE, GetGame(), m_CurrentDamageZone, Math::RandomFloatInclusive(), GameConstants::STATE_BADLY_DAMAGED, GameConstants::STATE_DAMAGED, GameConstants::STATE_RUINED, and GameConstants::STATE_WORN.

◆ ReadFromContext()

override bool ReadFromContext ( ParamsReadContext ctx,
out ActionReciveData action_recive_data )

Definition at line 150 of file ActionRepairCarPart.c.

151 {
154
155 super.ReadFromContext(ctx, action_recive_data);
157
158 if (HasTarget())
159 {
160 string zone;
161 if (!ctx.Read(zone))
162 return false;
163
164 reciveDataRepair.m_DamageZoneRecived = zone;
165 }
166
167 return true;
168 }
bool HasTarget()
Definition ActionBase.c:210

References HasTarget().

◆ WriteToContext()

override void WriteToContext ( ParamsWriteContext ctx,
ActionData action_data )

Definition at line 138 of file ActionRepairCarPart.c.

139 {
140 super.WriteToContext(ctx, action_data);
142
144 {
146 ctx.Write(repairActionData.m_DamageZone);
147 }
148 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), HasTarget(), and m_CurrentDamageZone.

Variable Documentation

◆ m_CurrentDamageZone

string m_CurrentDamageZone = ""

Definition at line 22 of file ActionRepairCarPart.c.

◆ m_DamageZone

◆ m_LastValidComponentIndex

int m_LastValidComponentIndex = -1

Definition at line 23 of file ActionRepairCarPart.c.

◆ m_LastValidType

ActionRepairCarPartCB m_LastValidType