DayZ 1.27
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(GetGame().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 (GetGame().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 (GetGame().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 for (int att = 0; att < GetInventory().AttachmentCount(); att++)
156 {
157 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(att));
158 if (attachment)
159 {
160 if (attachment.IsLockedInSlot())
161 {
162 attachment.UnlockFromParent();
163 }
164
165 attachment.OnActivatedByItem(this);
166 GetInventory().DropEntity(InventoryMode.SERVER, this, attachment);
167 }
168 }
169 }
170
171 void SetState(int state_ID)
172 {
173 m_State = state_ID;
174 }
175
177 {
178 return m_State;
179 }
180
181 void SetWireType( int wireType )
182 {
183 m_WireMaterial = wireType;
184 }
185
187 {
188 return m_WireMaterial;
189 }
190
191
192 override void RefreshState()
193 {
194 super.RefreshState();
195
196 if (GetState() == FOLDED)
197 {
198 FoldTripWire();
199 }
200 }
201
202 override void SetupTrapPlayer( PlayerBase player, bool set_position = true )
203 {
204 super.SetupTrapPlayer( player, set_position );
206 }
207
208 override void StartDeactivate(PlayerBase player)
209 {
210 super.StartDeactivate(player);
211
214 }
215
216 // We do not want players to attach charges before trap is deployed
217 override bool CanReceiveAttachment( EntityAI attachment, int slotId )
218 {
219 if ( GetState() != DEPLOYED )
220 return false;
221
222 return super.CanReceiveAttachment( attachment, slotId );
223 }
224
225 // As players cannot attch charges, we do not display the attachment slot before it is necessary
226 override bool CanDisplayAttachmentSlot( int slot_id )
227 {
228 if ( GetState() != DEPLOYED )
229 return false;
230
231 return super.CanDisplayAttachmentSlot( slot_id );
232 }
233
234 override void EEItemAttached(EntityAI item, string slot_name)
235 {
236 super.EEItemAttached(item, slot_name);
237
238 SetTakeable(false);
239 }
240
241 override void EEItemDetached(EntityAI item, string slot_name)
242 {
243 super.EEItemDetached(item, slot_name);
244
245 SetTakeable(false);
246 }
247
248 override void EEKilled(Object killer)
249 {
250 if (m_TrapTrigger)
251 {
252 StartDeactivate(null);
253 }
254
255 super.EEKilled(killer);
256 }
257
258 // We reset the animation phases to see the tripwire as folded
260 {
261 if ( m_AnimationPhaseGrounded != "" )
262 {
263 SetAnimationPhase( m_AnimationPhaseSet, 1 );
264
266 {
267 SetAnimationPhase( m_AnimationPhaseTriggered, 1 );
268 }
269
270 SetAnimationPhase( m_AnimationPhaseGrounded, 0 );
271 }
272 }
273
274 override void OnInventoryEnter( Man player )
275 {
276 SetState( FOLDED );
277 }
278
279 #ifdef PLATFORM_WINDOWS
280 // How one sees the tripwire when in vicinity
281 override int GetViewIndex()
282 {
283 if ( MemoryPointExists( "invView2" ) )
284 {
285 InventoryLocation il = new InventoryLocation;
286 GetInventory().GetCurrentInventoryLocation( il );
287 InventoryLocationType type = il.GetType();
288 switch ( type )
289 {
290 case InventoryLocationType.CARGO:
291 {
292 return 0;
293 }
294 case InventoryLocationType.ATTACHMENT:
295 {
296 return 1;
297 }
298 case InventoryLocationType.HANDS:
299 {
300 return 0;
301 }
302 case InventoryLocationType.GROUND:
303 {
304 // Different view index depending on deployment state
305 if ( GetState() == DEPLOYED )
306 return 1;
307 else if ( GetState() == TRIGGERED )
308 return 2;
309
310 // When folded
311 return 0;
312 }
313 case InventoryLocationType.PROXYCARGO:
314 {
315 return 0;
316 }
317 default:
318 {
319 if ( GetState() == DEPLOYED )
320 return 1;
321 else if ( GetState() == TRIGGERED )
322 return 2;
323
324 // When folded
325 return 0;
326 }
327 }
328 }
329 return 0;
330 }
331 #endif
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 (GetGame().IsServer())
341 {
343
344 m_TriggerPosition = position;
345 m_TriggerOrientation = orientation;
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 // ====================================
391 // =========== DEPRECATED ===========
392 // ====================================
393
395 {
396 if ( GetInventory().AttachmentCount() > 0)
397 {
398 ItemBase attachment = ItemBase.Cast( GetInventory().GetAttachmentFromIndex(0) );
399
400 if ( attachment )
401 {
402 // Hide all proxies
403 for (int i = 1; i <= 3; i++)
404 {
405 HideSelection("s" + i + "_charge");
406 }
407
408 // Now show the one we need to see
409 string proxy_to_show = string.Format("s%1_charge", GetState() );
410 //Print(proxy_to_show);
411 ShowSelection( proxy_to_show );
412 }
413 }
414 }
415
416#ifdef DEVELOPER
417 //================================================================
418 // DEBUG
419 //================================================================
420
421 //Debug menu Spawn Ground Special
422 override void OnDebugSpawn()
423 {
425 StartActivate(null);
426 }
427
428 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
429 {
430 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Activate", FadeColors.LIGHT_GREY));
431 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Deactivate", FadeColors.LIGHT_GREY));
432 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
433
434 super.GetDebugActions(outputList);
435 }
436
437 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
438 {
439 if (super.OnAction(action_id, player, ctx))
440 return true;
441 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
442 {
443 if (action_id == EActions.ACTIVATE_ENTITY)
444 {
445 StartActivate(null);
446 }
447 else if (action_id == EActions.DEACTIVATE_ENTITY)
448 {
449 SetInactive();
450 }
451 }
452 return false;
453 }
454
455#endif
456}
457
459{
460
461}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения EntityAI.c:97
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
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:1827
override void EEItemAttached(EntityAI item, string slot_name)
Определения BaseBuildingBase.c:1818
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
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:227
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
Определения Hatchback_02.c:403
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения ItemBase.c:7114
bool IsDeployable()
Определения ItemBase.c:9028
string GetDeploySoundset()
Определения FireplaceBase.c:2592
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:8566
override void SetTakeable(bool pState)
Определения ItemBase.c:9042
string GetLoopDeploySoundset()
Определения LargeTent.c:151
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения ItemBase.c:5983
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения ItemBase.c:8848
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения ItemBase.c:7071
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения ItemBase.c:6808
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:186
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:259
override bool CanDisplayAttachmentSlot(int slot_id)
Определения Trap_TripWire.c:226
void SetWireType(int wireType)
Определения Trap_TripWire.c:181
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:394
void TripwireTrap()
Определения Trap_TripWire.c:23
string m_AnimationPhaseTriggered
Определения TrapBase.c:34
float m_DefectRate
Определения TrapBase.c:19
void DeferredEnableTrigger()
Определения TrapBase.c:497
enum SoundTypeTrap SPAWN_FLAGS
void CreateTrigger()
Определения TrapBase.c:475
string m_AnimationPhaseGrounded
Определения TrapBase.c:32
void RefreshState()
Определения TrapBase.c:331
void SetActive()
Определения TrapBase.c:414
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:459
float m_InitWaitTime
Определения TrapBase.c:17
TrapTrigger m_TrapTrigger
Определения TrapBase.c:44
void SetupTrapPlayer(PlayerBase player, bool set_position=true)
Определения TrapBase.c:388
float m_DamagePlayers
Определения TrapBase.c:20
void StartActivate(PlayerBase player)
Определения TrapBase.c:438
void DeleteTrigger()
Определения TrapBase.c:488
void StartDeactivate(PlayerBase player)
Определения Trap_TripWire.c:208
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
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
Определения constants.c:659
proto native int GetType()
returns type of InventoryLocation
InventoryLocation.
Определения InventoryLocation.c:29
Определения InventoryItem.c:731
Определения 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 void Call(func fn, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto bool Write(void value_out)
proto bool Read(void value_in)
Определения Trap_Bear.c:2
Определения EnConvert.c:106
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int STATE_RUINED
Определения constants.c:846
const int SAT_DEBUG_ACTION
Определения constants.c:452
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8
proto native int GetState()
returns one of STATE_...
Определения StaminaHandler.c:31