DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Trap_TripWire.c
См. документацию.
1// Wire type is used in the case of decrafting to give back the correct base Ingredient
3{
4 WIRE = 0,
6 ROPE = 2
7}
8
10{
11 // Current state of the tripwire
12 static const int FOLDED = 3;
13 static const int DEPLOYED = 2;
14 static const int TRIGGERED = 1;
15
17 private int m_WireMaterial;
18
22
24 {
25 m_DamagePlayers = 0; //How much damage player gets when caught
26 m_InitWaitTime = 0.0; //After this time after deployment, the trap is activated
27 m_DefectRate = 15;
28 m_NeedActivation = false;
29 m_AnimationPhaseGrounded = "inventory";
30 m_AnimationPhaseSet = "placing";
31 m_AnimationPhaseTriggered = "triggered";
32 m_InfoActivationTime = string.Format("#STR_TripwireTrap0%1#STR_TripwireTrap1", m_InitWaitTime.ToString()); // nefunguje dynamicke vyrazy mimo funkcii
33
34 RegisterNetSyncVariableInt("m_State");
35 }
36
38 {
39 super.OnStoreSave(ctx);
40
41 ctx.Write( m_State );
42 }
43
44 //----------------------------------------------------------------
45 override bool OnStoreLoad(ParamsReadContext ctx, int version)
46 {
47 if ( !super.OnStoreLoad(ctx, version) )
48 return false;
49
50 int state = FOLDED;
51 if ( !ctx.Read( state ) )
52 state = FOLDED;
53
54 SetState( state );
56
57 return true;
58 }
59
60 override void CreateTrigger()
61 {
62 m_TrapTrigger = TripWireTrigger.Cast(g_Game.CreateObjectEx("TripWireTrigger", GetPosition(), SPAWN_FLAGS));
63 vector mins = "-0.75 0.3 -0.01";
64 vector maxs = "0.75 0.32 0.01";
65 m_TrapTrigger.SetOrientation(GetOrientation());
66 m_TrapTrigger.SetExtents(mins, maxs);
67 m_TrapTrigger.SetParentObject(this);
68
70 }
71
72 override void OnSteppedOn(EntityAI victim)
73 {
74 if (!victim)
75 {
76 return;
77 }
78
79 if (!victim.GetAllowDamage())
80 {
81 return;
82 }
83
84 // We must deal some damage, here 5 shock as melee damage in order to trigger hit animation
85 if (g_Game.IsServer())
86 {
87 victim.ProcessDirectDamage(DamageType.CLOSE_COMBAT, this, "", "TripWireHit", "0 0 0", 1);
89 SetInactive(false);
90 }
91
92 // We play the trap trigger sound
93 #ifndef SERVER
94 #ifndef NO_GUI
95 EffectSound sound = SEffectManager.PlaySound("TripwireTrap_Trigger_SoundSet", GetPosition());
96 sound.SetAutodestroy(true);
97 #endif
98 #endif
99 }
100
101 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
102 {
103 super.OnItemLocationChanged(old_owner, new_owner);
104
105 PlayerBase player = PlayerBase.Cast(new_owner);
106 if (player)
107 {
108 StartDeactivate(player);
109 return;
110 }
111 }
112
113 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
114 {
115 super.EEItemLocationChanged(oldLoc, newLoc);
116
118 {
119 if (oldLoc.GetType() == InventoryLocationType.GROUND && newLoc.GetType() == InventoryLocationType.GROUND)
120 {
121 SetActive();
122 m_TrapTrigger.SetPosition(m_TriggerPosition);
123 m_TrapTrigger.SetOrientation(m_TriggerOrientation);
124 }
125
127 }
128
129 if (oldLoc.GetType() == InventoryLocationType.GROUND && newLoc.GetType() == InventoryLocationType.CARGO)
130 {
131 SetInactive();
134 RefreshState();
135 }
136 }
137
138 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
139 {
140 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
141
142 if (g_Game.IsServer())
143 {
144 if (newLevel == GameConstants.STATE_RUINED)
145 {
147 RefreshState();
148 }
149 }
150 }
151
152 override void SetInactive(bool stop_timer = true)
153 {
154 super.SetInactive(stop_timer);
155
156 // de-attach attachments after "activating them"
157 GameInventory inventory = GetInventory();
158 for (int att = 0; att < inventory.AttachmentCount(); ++att)
159 {
160 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(att));
161 if (attachment)
162 {
163 if (attachment.IsLockedInSlot())
164 {
165 attachment.UnlockFromParent();
166 }
167
168 attachment.OnActivatedByItem(this);
169 inventory.DropEntity(InventoryMode.SERVER, this, attachment);
170 }
171 }
172 }
173
174 void SetState(int state_ID)
175 {
176 m_State = state_ID;
177 }
178
180 {
181 return m_State;
182 }
183
184 void SetWireType( int wireType )
185 {
186 m_WireMaterial = wireType;
187 }
188
190 {
191 return m_WireMaterial;
192 }
193
194 override void RefreshState()
195 {
196 super.RefreshState();
197
198 if (GetState() == FOLDED)
199 {
200 FoldTripWire();
201 }
202 }
203
204 override void SetupTrapPlayer( PlayerBase player, bool set_position = true )
205 {
206 super.SetupTrapPlayer( player, set_position );
208 }
209
210 override void StartDeactivate(PlayerBase player)
211 {
212 super.StartDeactivate(player);
213
216 }
217
218 // We do not want players to attach charges before trap is deployed
219 override bool CanReceiveAttachment( EntityAI attachment, int slotId )
220 {
221 if ( GetState() != DEPLOYED )
222 return false;
223
224 return super.CanReceiveAttachment( attachment, slotId );
225 }
226
227 // As players cannot attch charges, we do not display the attachment slot before it is necessary
228 override bool CanDisplayAttachmentSlot( int slot_id )
229 {
230 if ( GetState() != DEPLOYED )
231 return false;
232
233 return super.CanDisplayAttachmentSlot( slot_id );
234 }
235
236 override void EEItemAttached(EntityAI item, string slot_name)
237 {
238 super.EEItemAttached(item, slot_name);
239
240 SetTakeable(false);
241 }
242
243 override void EEItemDetached(EntityAI item, string slot_name)
244 {
245 super.EEItemDetached(item, slot_name);
246
247 SetTakeable(false);
248 }
249
250 override void EEKilled(Object killer)
251 {
252 if (m_TrapTrigger)
253 {
254 StartDeactivate(null);
255 }
256
257 super.EEKilled(killer);
258 }
259
260 // We reset the animation phases to see the tripwire as folded
262 {
263 if ( m_AnimationPhaseGrounded != "" )
264 {
265 SetAnimationPhase( m_AnimationPhaseSet, 1 );
266
268 {
269 SetAnimationPhase( m_AnimationPhaseTriggered, 1 );
270 }
271
272 SetAnimationPhase( m_AnimationPhaseGrounded, 0 );
273 }
274 }
275
276 override void OnInventoryEnter( Man player )
277 {
278 SetState( FOLDED );
279 }
280
281 // How one sees the tripwire when in vicinity
282 override int GetViewIndex()
283 {
284 if ( MemoryPointExists( "invView2" ) )
285 {
287 GetInventory().GetCurrentInventoryLocation( il );
288 InventoryLocationType type = il.GetType();
289 switch ( type )
290 {
291 case InventoryLocationType.CARGO:
292 {
293 return 0;
294 }
295 case InventoryLocationType.ATTACHMENT:
296 {
297 return 1;
298 }
299 case InventoryLocationType.HANDS:
300 {
301 return 0;
302 }
303 case InventoryLocationType.GROUND:
304 {
305 // Different view index depending on deployment state
306 if ( GetState() == DEPLOYED )
307 return 1;
308 else if ( GetState() == TRIGGERED )
309 return 2;
310
311 // When folded
312 return 0;
313 }
314 case InventoryLocationType.PROXYCARGO:
315 {
316 return 0;
317 }
318 default:
319 {
320 if ( GetState() == DEPLOYED )
321 return 1;
322 else if ( GetState() == TRIGGERED )
323 return 2;
324
325 // When folded
326 return 0;
327 }
328 }
329 }
330 return 0;
331 }
332
333 //================================================================
334 // ADVANCED PLACEMENT
335 //================================================================
336
337 // On placement complete, set state, play sound, create trigger and synch to client
338 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
339 {
340 if (g_Game.IsServer())
341 {
343
347 }
348
349 super.OnPlacementComplete(player, position, orientation);
350 }
351
352 override void OnPlacementCancelled(Man player)
353 {
354 super.OnPlacementCancelled(player);
355
357
359 }
360
361 override bool IsDeployable()
362 {
363 return true;
364 }
365
366 // Tripwire cannot be taken if deployed with attachment
367 override bool IsTakeable()
368 {
369 return GetState() != DEPLOYED || (GetInventory().AttachmentCount() == 0 && GetState() == DEPLOYED);
370 }
371
372 override string GetDeploySoundset()
373 {
374 return "tripwire_deploy_SoundSet";
375 }
376
377 override string GetLoopDeploySoundset()
378 {
379 return "tripwiretrap_deploy_SoundSet";
380 }
381
382 override void SetActions()
383 {
384 super.SetActions();
385
388 }
389
390 override void OnTriggeredByFall(Contact extra)
391 {
393 SetInactive(false);
394 }
395
397 {
398 EffectSound sound = SEffectManager.PlaySound("TripwireTrap_Trigger_SoundSet", GetPosition());
399 sound.SetAutodestroy(true);
400 }
401
402 // ====================================
403 // =========== DEPRECATED ===========
404 // ====================================
405
407 {
408 if ( GetInventory().AttachmentCount() > 0)
409 {
410 ItemBase attachment = ItemBase.Cast( GetInventory().GetAttachmentFromIndex(0) );
411
412 if ( attachment )
413 {
414 // Hide all proxies
415 for (int i = 1; i <= 3; i++)
416 {
417 HideSelection("s" + i + "_charge");
418 }
419
420 // Now show the one we need to see
421 string proxy_to_show = string.Format("s%1_charge", GetState() );
422 //Print(proxy_to_show);
423 ShowSelection( proxy_to_show );
424 }
425 }
426 }
427
428#ifdef DEVELOPER
429 //================================================================
430 // DEBUG
431 //================================================================
432
433 //Debug menu Spawn Ground Special
434 override void OnDebugSpawn()
435 {
437 StartActivate(null);
438 }
439
440 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
441 {
442 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Activate", FadeColors.LIGHT_GREY));
443 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Deactivate", FadeColors.LIGHT_GREY));
444 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
445
446 super.GetDebugActions(outputList);
447 }
448
449 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
450 {
451 if (super.OnAction(action_id, player, ctx))
452 return true;
453 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
454 {
455 if (action_id == EActions.ACTIVATE_ENTITY)
456 {
457 StartActivate(null);
458 }
459 else if (action_id == EActions.DEACTIVATE_ENTITY)
460 {
461 SetInactive();
462 }
463 }
464 return false;
465 }
466
467#endif
468}
469
471{
472
473}
Param4< int, int, string, int > TSelectableActionInfoWithColor
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
override bool CanDisplayAttachmentSlot(int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:1048
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Определения ActionDeployObject.c:9
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
vector GetOrientation()
Определения AreaDamageManager.c:306
override void EEItemDetached(EntityAI item, string slot_name)
Определения BaseBuildingBase.c:1812
override void EEItemAttached(EntityAI item, string slot_name)
Определения BaseBuildingBase.c:1803
bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения CodeLockComponent.c:264
void OnStoreSave(ParamsWriteContext ctx)
Определения CodeLockComponent.c:257
override void OnDebugSpawn()
Определения ContaminatedArea.c:73
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения DayZAnimal.c:136
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения DayZAnimal.c:125
DayZGame g_Game
Определения DayZGame.c:4074
vector position
Определения DustKickupEffects.c:20
vector orientation
Определения DustKickupEffects.c:21
EActions
Определения EActions.c:2
override void EEKilled(Object killer)
Определения ExplosivesBase.c:72
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения ExplosivesBase.c:112
override bool IsTakeable()
Определения ExplosivesBase.c:209
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
bool IsDeployable()
Определения ItemBase.c:4348
string GetLoopDeploySoundset()
Определения LargeTent.c:151
override void SetTakeable(bool pState)
Определения ItemBase.c:4362
string GetDeploySoundset()
Определения LargeTent.c:146
void OnInventoryEnter(Man player)
Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter.
Определения ItemBase.c:3902
enum EObjectTemperatureState m_State
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения RemoteDetonator.c:262
void SetState(bool state)
Определения StaminaHandler.c:32
bool m_ResultOfAdvancedPlacing
Определения Trap_TripWire.c:19
int m_WireMaterial
Определения Trap_TripWire.c:17
static const int TRIGGERED
Определения Trap_TripWire.c:14
enum eWireMaterial FOLDED
int GetWireType()
Определения Trap_TripWire.c:189
override int GetViewIndex()
Определения Trap_TripWire.c:282
static const int DEPLOYED
Определения Trap_TripWire.c:13
eWireMaterial
Определения Trap_TripWire.c:3
@ WIRE
Определения Trap_TripWire.c:4
@ ROPE
Определения Trap_TripWire.c:6
@ BARBED_WIRE
Определения Trap_TripWire.c:5
void FoldTripWire()
Определения Trap_TripWire.c:261
void SetWireType(int wireType)
Определения Trap_TripWire.c:184
override void OnPlacementCancelled(Man player)
Определения Trap_TripWire.c:352
vector m_TriggerOrientation
Определения Trap_TripWire.c:21
vector m_TriggerPosition
Определения Trap_TripWire.c:20
void UpdateProxySelections()
Определения Trap_TripWire.c:406
void TripwireTrap()
Определения Trap_TripWire.c:23
string m_AnimationPhaseTriggered
Определения TrapBase.c:34
float m_DefectRate
Определения TrapBase.c:19
void DeferredEnableTrigger()
Определения TrapBase.c:496
enum SoundTypeTrap SPAWN_FLAGS
void CreateTrigger()
Определения TrapBase.c:474
string m_AnimationPhaseGrounded
Определения TrapBase.c:32
void RefreshState()
Определения TrapBase.c:330
void OnTriggeredByFall(Contact extra)
SERVER: decide what "triggered by falling" means for this trap.
Определения TrapBase.c:713
void SetActive()
Определения TrapBase.c:413
bool m_NeedActivation
Определения TrapBase.c:18
void OnSteppedOn(EntityAI victim)
Определения TrapBase.c:282
string m_InfoActivationTime
Определения TrapBase.c:40
string m_AnimationPhaseSet
Определения TrapBase.c:33
void SetInactive(bool stop_timer=true)
Определения TrapBase.c:458
float m_InitWaitTime
Определения TrapBase.c:17
TrapTrigger m_TrapTrigger
Определения TrapBase.c:44
void SetupTrapPlayer(PlayerBase player, bool set_position=true)
Определения TrapBase.c:387
float m_DamagePlayers
Определения TrapBase.c:20
void StartActivate(PlayerBase player)
Определения TrapBase.c:437
void DeleteTrigger()
Определения TrapBase.c:487
void OnTriggeredByFallEffectsClient()
CLIENT: one-shot visual/audio feedback for the fall-trigger, called via the BoolSignal sync.
Определения Trap_TripWire.c:396
void StartDeactivate(PlayerBase player)
Определения Trap_TripWire.c:210
Определения Contact.c:10
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:607
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
proto native EntityAI GetAttachmentFromIndex(int index)
proto native int AttachmentCount()
Returns count of attachments attached to this item.
bool DropEntity(InventoryMode mode, EntityAI owner, notnull EntityAI item)
script counterpart to engine's class Inventory
proto native int GetType()
returns type of InventoryLocation
InventoryLocation.
Определения InventoryLocation.c:30
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
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:178
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
proto bool Write(void value_out)
proto bool Read(void value_in)
Определения Trap_Bear.c:2
Определения EnConvert.c:119
Keffiyeh_LightBlue SetActions
Определения consumables.c:149
Serializer ParamsReadContext
Определения gameplay.c:15
Serializer ParamsWriteContext
Определения gameplay.c:16
const int STATE_RUINED
Определения 3_Game/DayZ/constants.c:909
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:486
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetState()
returns one of STATE_...
Определения StaminaHandler.c:31