DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Trap_LandMine.c
См. документацию.
5
6class LandMineTrap extends TrapBase
7{
11 protected ref Timer m_DeleteTimer;
12
13 private const int BROKEN_LEG_PROB = 90;
14 private const int BLEED_SOURCE_PROB = 50;
15 private const int MAX_BLEED_SOURCE = 1;
16
18 {
19 m_DefectRate = 15;
20 m_DamagePlayers = 0; //How much damage player gets when caught
21 m_InitWaitTime = 10; //After this time after deployment, the trap is activated
22 m_InfoActivationTime = string.Format("#STR_LandMineTrap0%1#STR_LandMineTrap1", m_InitWaitTime.ToString());
23
25
26 //Order is important and must match clothing array in DamageClothing method
28 m_ClothingDmg.Insert(60); //Trousers
29 m_ClothingDmg.Insert(100); //BackPack
30 m_ClothingDmg.Insert(40); //Vest
31 m_ClothingDmg.Insert(10); //HeadGear
32 m_ClothingDmg.Insert(10); //Mask
33 m_ClothingDmg.Insert(40); //Body
34 m_ClothingDmg.Insert(50); //Feet
35 m_ClothingDmg.Insert(5); //Gloves
36 }
37
43
44 override void StartActivate(PlayerBase player)
45 {
46 super.StartActivate(player);
47
48 if (!GetGame().IsDedicatedServer())
49 {
51 {
52 m_SafetyPinSound = SEffectManager.PlaySound("landmine_safetyPin_SoundSet", GetPosition(), 0, 0, false);
53 m_SafetyPinSound.SetAutodestroy(true);
54 }
55
57 m_TimerLoopSound = SEffectManager.PlaySound("landmine_timer2_SoundSet", GetPosition(), 0, 0, true);
58 }
59 }
60
61 override void OnActivatedByItem(notnull ItemBase item)
62 {
63 SetHealth("", "", 0.0);
64 DeleteThis();
65 }
66
67 override void OnActivate()
68 {
69 if (!GetGame().IsDedicatedServer())
70 {
72 {
73 m_TimerLoopSound.SetAutodestroy(true);
74 m_TimerLoopSound.SoundStop();
75 }
76
77 if (GetGame().GetPlayer())
78 {
80 }
81 }
82 }
83
84 override bool CanExplodeInFire()
85 {
86 return true;
87 }
88
89 override void OnUpdate(EntityAI victim)
90 {
91 if (victim && victim.IsInherited(CarScript))
92 {
93 EntityAI wheel = GetClosestCarWheel(victim);
94 if (wheel)
95 {
96 OnServerSteppedOn(wheel, "");
97 }
98 }
99 }
100
101 override void OnSteppedOn(EntityAI victim)
102 {
103 int i;
104
105 if (GetGame().IsServer() && victim)
106 {
107 if (!victim.GetAllowDamage())
108 {
109 return;
110 }
111
112 if (victim.IsInherited(CarScript))
113 {
115 Param1<EntityAI> params = new Param1<EntityAI>(victim);
116 m_UpdateTimer.Run(UPDATE_TIMER_INTERVAL, this, "OnUpdate", params, true);
117
118 return;
119 }
120 else
121 {
122 //Check if we have a player
123 PlayerBase victim_PB = PlayerBase.Cast(victim);
124 if (victim_PB && victim_PB.IsAlive())
125 {
126 int randNum; //value used for probability evaluation
127 randNum = Math.RandomInt(0, 100);
128 if (randNum <= BROKEN_LEG_PROB)
129 {
130 float damage = victim_PB.GetMaxHealth("RightLeg", ""); //deal 100% damage to break legs
131 victim_PB.DamageAllLegs( damage );
132 }
133
134 randNum = Math.RandomInt(0, 100);
135 if (randNum < BLEED_SOURCE_PROB)
136 {
137 for (i = 0; i < MAX_BLEED_SOURCE; i++)
138 {
139 //We add two bleeding sources max to lower half
140 randNum = Math.RandomIntInclusive(0, PlayerBase.m_BleedingSourcesLow.Count() - 1);
141
142 victim_PB.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection(PlayerBase.m_BleedingSourcesLow[randNum]);
143 }
144 }
145
146 DamageClothing(victim_PB);
147 }
148 else
149 {
150 ItemBase victim_IB = ItemBase.Cast(victim);
151 if (victim_IB)
152 {
153 MiscGameplayFunctions.DealAbsoluteDmg(victim_IB, DAMAGE_TRIGGER_MINE);
154 }
155 }
156
157 Explode(DamageType.EXPLOSION);
158 }
159
160 DeleteThis();
161 }
162
163 super.OnSteppedOn(victim);
164 }
165
166 override void OnSteppedOut(EntityAI victim)
167 {
168 if (victim.IsInherited(CarScript))
169 {
170 if (m_UpdateTimer && m_UpdateTimer.IsRunning())
171 {
172 m_UpdateTimer.Stop();
173 }
174 }
175 }
176
177 protected void OnServerSteppedOn(Object obj, string damageZone)
178 {
179 if (obj.IsInherited(CarWheel))
180 {
181 obj.ProcessDirectDamage(DamageType.CLOSE_COMBAT, this, "", "LandMineExplosion_CarWheel", "0 0 0", 1);
182 Explode(DamageType.EXPLOSION);
183
184 if (m_UpdateTimer.IsRunning())
185 m_UpdateTimer.Stop();
186
187 }
188
189 SetInactive(false);
190 Synch(EntityAI.Cast(obj));
191 }
192
194 {
196 m_DeleteTimer.Run(1, this, "DeleteSafe");
197 }
198
199 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
200 {
201 super.OnItemLocationChanged(old_owner, new_owner);
202 }
203
204 override void EEKilled(Object killer)
205 {
206 super.EEKilled(killer);
207
208 Explode(DamageType.EXPLOSION);
209 }
210
212 {
213 if (!GetGame().IsDedicatedServer())
214 {
215 EffectSound sound = SEffectManager.PlaySound("landmineActivate_SoundSet", GetPosition(), 0, 0, false);
216 sound.SetAutodestroy(true);
217 }
218 }
219
220 override void Explode(int damageType, string ammoType = "")
221 {
222 if (ammoType == "")
223 {
224 ammoType = ConfigGetString("ammoType");
225 }
226
227 if (ammoType == "")
228 {
229 ammoType = "Dummy_Heavy";
230 }
231
232 if ( GetGame().IsServer() )
233 {
234 SynchExplosion();
235 vector offset = Vector(0, 0.1, 0); //Vertical offset applied to landmine explosion (in meters)
236 DamageSystem.ExplosionDamage(this, NULL, ammoType, GetPosition() + offset, damageType); //Offset explosion on Y axis
237 DeleteThis();
238 }
239 }
240
241 override bool CanBeDisarmed()
242 {
243 return true;
244 }
245
246 override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
247 {
248 super.OnRPC(sender, rpc_type, ctx);
249
250 Param1<bool> p = new Param1<bool>(false);
251
252 if (!ctx.Read(p))
253 return;
254
255 bool play = p.param1;
256 switch (rpc_type)
257 {
258 case SoundTypeMine.DISARMING:
259 if (play)
261 else
263
264 break;
265 }
266 }
267
269 {
270 if (!m_DisarmingLoopSound || !m_DisarmingLoopSound.IsSoundPlaying())
271 {
272 m_DisarmingLoopSound = SEffectManager.PlaySound("landmine_deploy_SoundSet", GetPosition());
273 }
274 }
275
277 {
278 m_DisarmingLoopSound.SoundStop();
279 }
280
281 //================================================================
282 // ADVANCED PLACEMENT
283 //================================================================
284
285 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
286 {
287 super.OnPlacementComplete(player, position, orientation);
288
289 if (GetGame().IsServer())
290 {
291 PlayerBase player_PB = PlayerBase.Cast(player);
292 StartActivate(player_PB);
293 }
294 }
295
296 override bool IsDeployable()
297 {
298 return true;
299 }
300
301 override string GetLoopDeploySoundset()
302 {
303 return "landmine_deploy_SoundSet";
304 }
305
306 override void SetActions()
307 {
308 super.SetActions();
309
314 }
315
316#ifdef DEVELOPER
317 //================================================================
318 // DEBUG
319 //================================================================
320
321 //Debug menu Spawn Ground Special
322 override void OnDebugSpawn()
323 {
324 StartActivate(null);
325 }
326
327 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
328 {
329 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Activate", FadeColors.LIGHT_GREY));
330 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Deactivate", FadeColors.LIGHT_GREY));
331 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
332
333 super.GetDebugActions(outputList);
334 }
335
336 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
337 {
338 if (super.OnAction(action_id, player, ctx))
339 return true;
340 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
341 {
342 if (action_id == EActions.ACTIVATE_ENTITY)
343 {
344 StartActivate(null);
345 }
346 else if (action_id == EActions.DEACTIVATE_ENTITY)
347 {
348 SetInactive();
349 }
350 }
351 return false;
352 }
353#endif
354}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения EntityAI.c:97
AttachActionData ActionData ActionAttach()
Определения ActionAttach.c:9
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Определения ActionDeployObject.c:9
void ActionDetach()
Определения ActionDetach.c:10
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
EActions
Определения EActions.c:2
override void EEKilled(Object killer)
Определения ExplosivesBase.c:100
ref Timer m_DeleteTimer
Определения ExplosivesBase.c:28
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
Определения Hatchback_02.c:403
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения ItemBase.c:7114
bool CanExplodeInFire()
Определения ItemBase.c:7305
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения ItemBase.c:5983
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения ItemBase.c:7071
PlayerBase GetPlayer()
Определения ModifierBase.c:51
override void OnRPC(ParamsReadContext ctx)
Определения PlayerStatBase.c:69
ref Timer m_UpdateTimer
Определения RadialMenu.c:20
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
void LandMineTrap()
Определения Trap_LandMine.c:17
ref EffectSound m_DisarmingLoopSound
Определения Trap_LandMine.c:10
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
void PlayDisarmingLoopSound()
Определения Trap_LandMine.c:268
ref EffectSound m_SafetyPinSound
Определения Trap_LandMine.c:9
void ~LandMineTrap()
Определения Trap_LandMine.c:38
void DeleteThis()
Определения Trap_LandMine.c:193
void PlaySoundActivate()
Определения Trap_LandMine.c:211
SoundTypeMine
Определения Trap_LandMine.c:2
@ DISARMING
Определения Trap_LandMine.c:3
const int BROKEN_LEG_PROB
Определения Trap_LandMine.c:13
const int MAX_BLEED_SOURCE
Определения Trap_LandMine.c:15
const int BLEED_SOURCE_PROB
Определения Trap_LandMine.c:14
void StopDisarmingLoopSound()
Определения Trap_LandMine.c:276
enum SoundTypeMine m_TimerLoopSound
float m_DefectRate
Определения TrapBase.c:19
ref array< int > m_ClothingDmg
Определения TrapBase.c:46
void Synch(EntityAI victim)
keeping "step" here for consistency only
Определения TrapBase.c:281
const float UPDATE_TIMER_INTERVAL
Определения TrapBase.c:15
const int DAMAGE_TRIGGER_MINE
Определения TrapBase.c:14
EntityAI GetClosestCarWheel(EntityAI victim)
Определения TrapBase.c:623
string m_InfoActivationTime
Определения TrapBase.c:40
void SetInactive(bool stop_timer=true)
Определения TrapBase.c:459
float m_InitWaitTime
Определения TrapBase.c:17
void DamageClothing(PlayerBase player)
Определения TrapBase.c:664
float m_DamagePlayers
Определения TrapBase.c:20
void StartActivate(PlayerBase player)
Определения TrapBase.c:438
bool m_AddDeactivationDefect
Определения TrapBase.c:24
Определения CivilianSedan.c:2
Определения InventoryItem.c:413
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения Building.c:6
Определения InventoryItem.c:731
Определения EnMath.c:7
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
The class that will be instanced (moddable)
Определения gameplay.c:389
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
Определения EffectManager.c:169
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Определения EffectManager.c:271
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
proto bool Read(void value_in)
Определения DayZPlayerImplement.c:63
void OnServerSteppedOn(Object obj, string damageZone)
Определения Trap_Bear.c:136
override void OnSteppedOn(EntityAI victim)
Определения Trap_Bear.c:67
override string GetLoopDeploySoundset()
Определения Trap_Bear.c:244
override void OnActivate()
Определения Trap_Bear.c:210
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения Trap_Bear.c:228
override bool CanBeDisarmed()
Определения Trap_Bear.c:25
override bool IsDeployable()
Определения Trap_Bear.c:239
override void SetActions()
Определения Trap_Bear.c:249
override void OnSteppedOut(EntityAI victim)
Определения Trap_Bear.c:125
Определения Trap_Bear.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54
const int SAT_DEBUG_ACTION
Определения constants.c:452
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
proto native void OnUpdate()
Определения tools.c:349
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8