DayZ 1.29
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 EffectSound sound = SEffectManager.PlaySound("TripwireTrap_Trigger_SoundSet", GetPosition());
95 sound.SetAutodestroy(true);
96 #endif
97 }
98
99 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
100 {
101 super.OnItemLocationChanged(old_owner, new_owner);
102
103 PlayerBase player = PlayerBase.Cast(new_owner);
104 if (player)
105 {
106 StartDeactivate(player);
107 return;
108 }
109 }
110
111 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
112 {
113 super.EEItemLocationChanged(oldLoc, newLoc);
114
116 {
117 if (oldLoc.GetType() == InventoryLocationType.GROUND && newLoc.GetType() == InventoryLocationType.GROUND)
118 {
119 SetActive();
120 m_TrapTrigger.SetPosition(m_TriggerPosition);
121 m_TrapTrigger.SetOrientation(m_TriggerOrientation);
122 }
123
125 }
126
127 if (oldLoc.GetType() == InventoryLocationType.GROUND && newLoc.GetType() == InventoryLocationType.CARGO)
128 {
129 SetInactive();
132 RefreshState();
133 }
134 }
135
136 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
137 {
138 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
139
140 if (g_Game.IsServer())
141 {
142 if (newLevel == GameConstants.STATE_RUINED)
143 {
145 RefreshState();
146 }
147 }
148 }
149
150 override void SetInactive(bool stop_timer = true)
151 {
152 super.SetInactive(stop_timer);
153
154 // de-attach attachments after "activating them"
155 GameInventory inventory = GetInventory();
156 for (int att = 0; att < inventory.AttachmentCount(); ++att)
157 {
158 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(att));
159 if (attachment)
160 {
161 if (attachment.IsLockedInSlot())
162 {
163 attachment.UnlockFromParent();
164 }
165
166 attachment.OnActivatedByItem(this);
167 inventory.DropEntity(InventoryMode.SERVER, this, attachment);
168 }
169 }
170 }
171
172 void SetState(int state_ID)
173 {
174 m_State = state_ID;
175 }
176
178 {
179 return m_State;
180 }
181
182 void SetWireType( int wireType )
183 {
184 m_WireMaterial = wireType;
185 }
186
188 {
189 return m_WireMaterial;
190 }
191
192
193 override void RefreshState()
194 {
195 super.RefreshState();
196
197 if (GetState() == FOLDED)
198 {
199 FoldTripWire();
200 }
201 }
202
203 override void SetupTrapPlayer( PlayerBase player, bool set_position = true )
204 {
205 super.SetupTrapPlayer( player, set_position );
207 }
208
209 override void StartDeactivate(PlayerBase player)
210 {
211 super.StartDeactivate(player);
212
215 }
216
217 // We do not want players to attach charges before trap is deployed
218 override bool CanReceiveAttachment( EntityAI attachment, int slotId )
219 {
220 if ( GetState() != DEPLOYED )
221 return false;
222
223 return super.CanReceiveAttachment( attachment, slotId );
224 }
225
226 // As players cannot attch charges, we do not display the attachment slot before it is necessary
227 override bool CanDisplayAttachmentSlot( int slot_id )
228 {
229 if ( GetState() != DEPLOYED )
230 return false;
231
232 return super.CanDisplayAttachmentSlot( slot_id );
233 }
234
235 override void EEItemAttached(EntityAI item, string slot_name)
236 {
237 super.EEItemAttached(item, slot_name);
238
239 SetTakeable(false);
240 }
241
242 override void EEItemDetached(EntityAI item, string slot_name)
243 {
244 super.EEItemDetached(item, slot_name);
245
246 SetTakeable(false);
247 }
248
249 override void EEKilled(Object killer)
250 {
251 if (m_TrapTrigger)
252 {
253 StartDeactivate(null);
254 }
255
256 super.EEKilled(killer);
257 }
258
259 // We reset the animation phases to see the tripwire as folded
261 {
262 if ( m_AnimationPhaseGrounded != "" )
263 {
264 SetAnimationPhase( m_AnimationPhaseSet, 1 );
265
267 {
268 SetAnimationPhase( m_AnimationPhaseTriggered, 1 );
269 }
270
271 SetAnimationPhase( m_AnimationPhaseGrounded, 0 );
272 }
273 }
274
275 override void OnInventoryEnter( Man player )
276 {
277 SetState( FOLDED );
278 }
279
280 #ifdef PLATFORM_WINDOWS
281 // How one sees the tripwire when in vicinity
282 override int GetViewIndex()
283 {
284 if ( MemoryPointExists( "invView2" ) )
285 {
286 InventoryLocation il = new InventoryLocation;
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 #endif
333
334 //================================================================
335 // ADVANCED PLACEMENT
336 //================================================================
337
338 // On placement complete, set state, play sound, create trigger and synch to client
339 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
340 {
341 if (g_Game.IsServer())
342 {
344
345 m_TriggerPosition = position;
346 m_TriggerOrientation = orientation;
348 }
349
350 super.OnPlacementComplete(player, position, orientation);
351 }
352
353 override void OnPlacementCancelled(Man player)
354 {
355 super.OnPlacementCancelled(player);
356
358
360 }
361
362 override bool IsDeployable()
363 {
364 return true;
365 }
366
367 // Tripwire cannot be taken if deployed with attachment
368 override bool IsTakeable()
369 {
370 return GetState() != DEPLOYED || (GetInventory().AttachmentCount() == 0 && GetState() == DEPLOYED);
371 }
372
373 override string GetDeploySoundset()
374 {
375 return "tripwire_deploy_SoundSet";
376 }
377
378 override string GetLoopDeploySoundset()
379 {
380 return "tripwiretrap_deploy_SoundSet";
381 }
382
383 override void SetActions()
384 {
385 super.SetActions();
386
389 }
390
391 // ====================================
392 // =========== DEPRECATED ===========
393 // ====================================
394
396 {
397 if ( GetInventory().AttachmentCount() > 0)
398 {
399 ItemBase attachment = ItemBase.Cast( GetInventory().GetAttachmentFromIndex(0) );
400
401 if ( attachment )
402 {
403 // Hide all proxies
404 for (int i = 1; i <= 3; i++)
405 {
406 HideSelection("s" + i + "_charge");
407 }
408
409 // Now show the one we need to see
410 string proxy_to_show = string.Format("s%1_charge", GetState() );
411 //Print(proxy_to_show);
412 ShowSelection( proxy_to_show );
413 }
414 }
415 }
416
417#ifdef DEVELOPER
418 //================================================================
419 // DEBUG
420 //================================================================
421
422 //Debug menu Spawn Ground Special
423 override void OnDebugSpawn()
424 {
426 StartActivate(null);
427 }
428
429 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
430 {
431 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Activate", FadeColors.LIGHT_GREY));
432 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Deactivate", FadeColors.LIGHT_GREY));
433 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
434
435 super.GetDebugActions(outputList);
436 }
437
438 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
439 {
440 if (super.OnAction(action_id, player, ctx))
441 return true;
442 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
443 {
444 if (action_id == EActions.ACTIVATE_ENTITY)
445 {
446 StartActivate(null);
447 }
448 else if (action_id == EActions.DEACTIVATE_ENTITY)
449 {
450 SetInactive();
451 }
452 }
453 return false;
454 }
455
456#endif
457}
458
460{
461
462}
Param4< int, int, string, int > TSelectableActionInfoWithColor
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Определения ActionDeployObject.c:9
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void SetActions()
Определения AdvancedCommunication.c:213
vector GetOrientation()
Определения AreaDamageManager.c:306
override void EEItemDetached(EntityAI item, string slot_name)
Определения BaseBuildingBase.c:1871
override void EEItemAttached(EntityAI item, string slot_name)
Определения BaseBuildingBase.c:1862
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:3942
EActions
Определения EActions.c:2
override void EEKilled(Object killer)
Определения ExplosivesBase.c:100
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения ExplosivesBase.c:140
override bool IsTakeable()
Определения ExplosivesBase.c:235
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
Определения Hatchback_02.c:414
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
bool IsDeployable()
Определения ItemBase.c:9270
string GetDeploySoundset()
Определения FireplaceBase.c:2611
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:8813
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
string GetLoopDeploySoundset()
Определения LargeTent.c:151
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения ItemBase.c:6124
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения ItemBase.c:9090
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения ItemBase.c:6976
void OnStoreSave(ParamsWriteContext ctx)
Определения ModifiersManager.c:229
bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения ModifiersManager.c:265
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:187
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:260
override bool CanDisplayAttachmentSlot(int slot_id)
Определения Trap_TripWire.c:227
void SetWireType(int wireType)
Определения Trap_TripWire.c:182
override void OnPlacementCancelled(Man player)
Определения Trap_TripWire.c:353
vector m_TriggerOrientation
Определения Trap_TripWire.c:21
vector m_TriggerPosition
Определения Trap_TripWire.c:20
void UpdateProxySelections()
Определения Trap_TripWire.c:395
void TripwireTrap()
Определения Trap_TripWire.c:23
string m_AnimationPhaseTriggered
Определения TrapBase.c:34
float m_DefectRate
Определения TrapBase.c:19
void DeferredEnableTrigger()
Определения TrapBase.c:487
enum SoundTypeTrap SPAWN_FLAGS
void CreateTrigger()
Определения TrapBase.c:465
string m_AnimationPhaseGrounded
Определения TrapBase.c:32
void RefreshState()
Определения TrapBase.c:321
void SetActive()
Определения TrapBase.c:404
bool m_NeedActivation
Определения TrapBase.c:18
void OnSteppedOn(EntityAI victim)
Определения TrapBase.c:273
string m_InfoActivationTime
Определения TrapBase.c:40
string m_AnimationPhaseSet
Определения TrapBase.c:33
void SetInactive(bool stop_timer=true)
Определения TrapBase.c:449
float m_InitWaitTime
Определения TrapBase.c:17
TrapTrigger m_TrapTrigger
Определения TrapBase.c:44
void SetupTrapPlayer(PlayerBase player, bool set_position=true)
Определения TrapBase.c:378
float m_DamagePlayers
Определения TrapBase.c:20
void StartActivate(PlayerBase player)
Определения TrapBase.c:428
void DeleteTrigger()
Определения TrapBase.c:478
void StartDeactivate(PlayerBase player)
Определения Trap_TripWire.c:209
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
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:169
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
Serializer ParamsReadContext
Определения gameplay.c:15
Serializer ParamsWriteContext
Определения gameplay.c:16
const int STATE_RUINED
Определения 3_Game/DayZ/constants.c:851
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
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