DayZ 1.24
Loading...
Searching...
No Matches
ActionRepairCarChassis Class Reference
Inheritance diagram for ActionRepairCarChassis:
[legend]
Collaboration diagram for ActionRepairCarChassis:
[legend]

Protected Member Functions

void ActionRepairCarChassis ()
 
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)
 

Protected Attributes

 m_LastValidType
 
string m_CurrentDamageZone
 
int m_LastValidComponentIndex
 

Additional Inherited Members

- Private Member Functions inherited from ActionContinuousBase
void OnStartAnimationLoopServer (ActionData action_data)
 
void OnStartAnimationLoopClient (ActionData action_data)
 
void OnEndAnimationLoopServer (ActionData action_data)
 
void OnEndAnimationLoopClient (ActionData action_data)
 
void OnFinishProgressServer (ActionData action_data)
 
void OnFinishProgressClient (ActionData action_data)
 

Detailed Description

Definition at line 19 of file ActionRepairCarChassis.c.

Constructor & Destructor Documentation

◆ ActionRepairCarChassis()

void ActionRepairCarChassis::ActionRepairCarChassis ( )
inlineprotected

Member Function Documentation

◆ ActionCondition()

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

Definition at line 44 of file ActionRepairCarChassis.c.

45 {
46 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
47 return false;
48
49 CarScript car = CarScript.Cast(target.GetObject());
50 if (!car || !player)
51 return false;
52
53 if (GetGame().IsMultiplayer() && GetGame().IsServer())
54 return true;
55
56 if (m_LastValidType != target.Type() || m_LastValidComponentIndex != target.GetComponentIndex() || m_CurrentDamageZone == "")
57 {
58 string damageZone = "";
60 car.GetActionComponentNameList(target.GetComponentIndex(), selections);
61
62 foreach (string selection : selections)
63 {
64 //NOTE: relevant fire geometry and view geometry selection names MUST match in order to get a valid damage zone
65 if (car && DamageSystem.GetDamageZoneFromComponentName(car, selection, damageZone))
66 {
67 if (damageZone == "Engine")
68 continue;
69
70 int zoneHP = car.GetHealthLevel(damageZone);
72 {
74 m_LastValidComponentIndex = target.GetComponentIndex();
75
76 //Determine if using a "Special" item for repairing
78 Fabric tarp = Fabric.Cast(item);
79
80 //Prevent planks and tarp from repairing non related areas
81 if ((tarp || plank) && (damageZone != "BackWood" && damageZone != "BackTarp"))
82 return false;
83
84 return true;
85 }
86 }
87 }
88 }
89
90 return false;
91 }
eBrokenLegs
Definition EBrokenLegs.c:2
proto native CGame GetGame()
const int STATE_RUINED
Definition constants.c:757
const int STATE_WORN
Definition constants.c:760

References GetGame(), m_CurrentDamageZone, m_LastValidComponentIndex, m_LastValidType, GameConstants::STATE_RUINED, and GameConstants::STATE_WORN.

◆ CreateActionData()

override ActionData ActionRepairCarChassis::CreateActionData ( )
inlineprotected

Definition at line 144 of file ActionRepairCarChassis.c.

◆ CreateConditionComponents()

override void ActionRepairCarChassis::CreateConditionComponents ( )
inlineprotected

Definition at line 38 of file ActionRepairCarChassis.c.

39 {
42 }
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 ActionRepairCarChassis::HandleReciveData ( ActionReciveData action_recive_data,
ActionData action_data )
inlineprotected

◆ OnFinishProgressServer()

override void ActionRepairCarChassis::OnFinishProgressServer ( ActionData action_data)
inlineprotected

Definition at line 93 of file ActionRepairCarChassis.c.

94 {
95 Object tgObject = action_data.m_Target.GetObject();
96
97 string damageZone = RepairCarPartActionData.Cast(action_data).m_DamageZone;
98 if (!GetGame().IsMultiplayer())
100
101 if (tgObject && damageZone != "")
102 {
104 if (car)
105 {
107 float zoneMax = car.GetMaxHealth(damageZone, "");
108 float randomValue = Math.RandomFloatInclusive(zoneMax * 0.05, zoneMax * 0.15);
109
110 switch (newDmgLevel)
111 {
114 break;
117 break;
120 break;
121 }
122
123 if (action_data.m_MainItem.HasQuantity())
124 {
125 if (action_data.m_MainItem.GetQuantity() > 1)
126 {
127 int qnt = action_data.m_MainItem.GetQuantity();
128 Fabric usedTarp = Fabric.Cast(action_data.m_MainItem);
129 WoodenPlank usedPlank = WoodenPlank.Cast(action_data.m_MainItem);
130 if (usedTarp || usedPlank)
131 qnt -= 1;
132 else
133 qnt -= action_data.m_MainItem.GetQuantityMax() * 0.25;
134
135 action_data.m_MainItem.SetQuantity(qnt);
136 }
137 else
138 action_data.m_MainItem.Delete();
139 }
140 }
141 }
142 }
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 ActionRepairCarChassis::ReadFromContext ( ParamsReadContext ctx,
out ActionReciveData action_recive_data )
inlineprotected

Definition at line 162 of file ActionRepairCarChassis.c.

163 {
166
167 super.ReadFromContext(ctx, action_recive_data);
169
170 if (HasTarget())
171 {
172 string zone;
173 if (!ctx.Read(zone))
174 return false;
175
176 recieveDataRepair.m_DamageZoneRecived = zone;
177 }
178
179 return true;
180 }
bool HasTarget()
Definition ActionBase.c:210

References HasTarget().

◆ WriteToContext()

override void ActionRepairCarChassis::WriteToContext ( ParamsWriteContext ctx,
ActionData action_data )
inlineprotected

Definition at line 150 of file ActionRepairCarChassis.c.

151 {
152 super.WriteToContext(ctx, action_data);
154
156 {
158 ctx.Write(repairActionData.m_DamageZone);
159 }
160 }
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.

Member Data Documentation

◆ m_CurrentDamageZone

string ActionRepairCarChassis::m_CurrentDamageZone
protected

◆ m_LastValidComponentIndex

int ActionRepairCarChassis::m_LastValidComponentIndex
protected

Definition at line 23 of file ActionRepairCarChassis.c.

Referenced by ActionCondition(), and ActionRepairCarChassis().

◆ m_LastValidType

ActionRepairCarChassis::m_LastValidType
protected

Definition at line 21 of file ActionRepairCarChassis.c.

Referenced by ActionCondition().


The documentation for this class was generated from the following file: