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

Go to the source code of this file.

Classes

class  RepairCarEngineActionReciveData
 
class  ActionRepairCarEngineCB
 

Functions

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

RepairCarEngineActionReciveData m_DamageZone
 
ActionRepairCarEngineCB m_LastValidType
 
string m_CurrentDamageZone = ""
 
int m_LastValidComponentIndex = -1
 

Function Documentation

◆ ActionCondition()

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

Definition at line 42 of file ActionRepairCarEngine.c.

43 {
44 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
45 return false;
46
47 Object targetObject = target.GetObject();
48 Object targetParent = target.GetParent();
51
52 if (!car || !player)
53 return false;
54
55 if (car.EngineIsOn())
56 return false;
57
58 if (GetGame().IsMultiplayer() && GetGame().IsServer())
59 return true;
60
61 if (m_LastValidType != target.Type() || m_LastValidComponentIndex != target.GetComponentIndex() || m_CurrentDamageZone == "")
62 {
63 string damageZone = "";
65 targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections, LOD.NAME_VIEW);
66
67 foreach (string selection : selections)
68 {
69 //NOTE: relevant fire geometry and view geometry selection names MUST match in order to get a valid damage zone
70 if (carEntity && DamageSystem.GetDamageZoneFromComponentName(carEntity, selection, damageZone))
71 {
72 if (damageZone == "Engine")
73 {
74 int zoneHP = car.GetHealthLevel(damageZone);
76 {
78 m_LastValidComponentIndex = target.GetComponentIndex();
79
80 return true;
81 }
82 }
83 }
84 }
85 }
86
87 return false;
88 }
int m_LastValidComponentIndex
ActionRepairCarEngineCB m_LastValidType
string m_CurrentDamageZone
eBrokenLegs
Definition EBrokenLegs.c:2
LOD class.
Definition gameplay.c:203
static const string NAME_VIEW
Definition gameplay.c:206
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, LOD::NAME_VIEW, GameConstants::STATE_RUINED, and GameConstants::STATE_WORN.

◆ ActionRepairCarEngine()

void ActionRepairCarEngine ( )

Definition at line 25 of file ActionRepairCarEngine.c.

26 {
27 m_CallbackClass = ActionRepairTentPartCB;
29 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
30 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
31 m_FullBody = true;
32 m_LockTargetOnUse = false;
33 m_Text = "#repair";
34 }
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().

◆ CreateActionData()

override ActionData CreateActionData ( )

Definition at line 130 of file ActionRepairCarEngine.c.

◆ CreateConditionComponents()

override void CreateConditionComponents ( )

Definition at line 36 of file ActionRepairCarEngine.c.

37 {
40 }
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 90 of file ActionRepairCarEngine.c.

91 {
92 Object tgObject = action_data.m_Target.GetObject();
93
94 string damageZone = RepairCarPartActionData.Cast(action_data).m_DamageZone;
95 if (!GetGame().IsMultiplayer())
97
98 if (tgObject && damageZone != "")
99 {
101 if (car)
102 {
104 float zoneMax = car.GetMaxHealth(damageZone, "");
105 float randomValue = Math.RandomFloatInclusive(zoneMax * 0.05, zoneMax * 0.15);
106
107 switch (newDmgLevel)
108 {
111 break;
112
115 break;
116
119 break;
120
121 default:
122 break;
123 }
124
125 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, UADamageApplied.BUILD);
126 }
127 }
128 }
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 UADamageApplied::BUILD, 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 148 of file ActionRepairCarEngine.c.

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

References HasTarget().

◆ WriteToContext()

override void WriteToContext ( ParamsWriteContext ctx,
ActionData action_data )

Definition at line 136 of file ActionRepairCarEngine.c.

137 {
138 super.WriteToContext(ctx, action_data);
140
142 {
144 ctx.Write(repairActionData.m_DamageZone);
145 }
146 }
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 ActionRepairCarEngine.c.

Referenced by ActionCondition(), OnFinishProgressServer(), and WriteToContext().

◆ m_DamageZone

◆ m_LastValidComponentIndex

int m_LastValidComponentIndex = -1

Definition at line 23 of file ActionRepairCarEngine.c.

Referenced by ActionCondition().

◆ m_LastValidType

ActionRepairCarEngineCB m_LastValidType

Referenced by ActionCondition().