DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Trap_Bear.c
См. документацию.
1class BearTrap extends TrapBase
2{
3 static const int RAYCAST_SOURCES_COUNT = 5;
4 // Raycasts start positions:
5 // Positions are local to model. Vertical offset prevents ground collision.
7 "0.0 0.1 0.0", // center
8 "0.2 0.1 0.2", // north east
9 "-.2 0.1 0.2", // north west
10 "0.2 0.1 -0.2", // south east
11 "-0.2 0.1 -0.2" // south west
12 };
13
14 void BearTrap()
15 {
16 m_DamagePlayers = 5; // How much damage player gets when caught
17 m_DamageOthers = 5; // How much damage other entities(CreatureAI) gets when caught
18 m_DefectRate = 0;
19 m_InitWaitTime = 0.0; // After this time after deployment, the trap is activated
20 m_AnimationPhaseGrounded = "placing";
21 m_AnimationPhaseSet = "BearTrap_Set";
22 m_AnimationPhaseTriggered = "placing";
23 }
24
25 override bool CanBeDisarmed()
26 {
27 return true;
28 }
29
30 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
31 {
32 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
33
34 if (g_Game.IsServer())
35 {
36 if (newLevel == GameConstants.STATE_RUINED)
37 {
39 }
40 }
41 }
42
43 override void CreateTrigger()
44 {
45 super.CreateTrigger();
46
47 vector mins = "-0.1 -0.05 -0.1";
48 vector maxs = "0.1 0.4 0.1";
49
50 m_TrapTrigger.SetOrientation(GetOrientation());
51 m_TrapTrigger.SetExtents(mins, maxs);
52 m_TrapTrigger.SetParentObject(this);
53 }
54
55 override void OnUpdate(EntityAI victim)
56 {
57 if (victim && victim.IsInherited(CarScript))
58 {
59 EntityAI wheel = GetClosestCarWheel(victim);
60 if (wheel)
61 {
62 OnServerSteppedOn(wheel, "");
63 }
64 }
65 }
66
67 override void OnSteppedOn(EntityAI victim)
68 {
69 if (g_Game.IsServer() && victim)
70 {
71 if (!victim.GetAllowDamage())
72 return;
73
74 if (victim.IsInherited(CarScript))
75 {
77 Param1<EntityAI> params = new Param1<EntityAI>(victim);
78 m_UpdateTimer.Run(UPDATE_TIMER_INTERVAL, this, "OnUpdate", params, true);
79
80 return;
81 }
82 else
83 {
84 foreach (vector raycastSourcePosition: m_RaycastSources)
85 {
86 vector raycastStart = ModelToWorld(raycastSourcePosition);
87 vector raycastEnd = "0 0.5 0" + raycastStart;
88
89 RaycastRVParams rayInput = new RaycastRVParams(raycastStart, raycastEnd, this);
90 rayInput.flags = CollisionFlags.ALLOBJECTS;
91 rayInput.type = ObjIntersectFire;
92 rayInput.radius = 0.05;
94
95 if (DayZPhysics.RaycastRVProxy(rayInput, results))
96 {
97 foreach (RaycastRVResult result: results)
98 {
99 if (result.obj && !result.obj.IsDamageDestroyed() && !result.obj.IsAnyInherited({ItemBase, Plant}))
100 {
101 OnServerSteppedOn(result.obj, result.obj.GetDamageZoneNameByComponentIndex(result.component));
102 return;
103 }
104 }
105 }
106 }
107
108 OnServerSteppedOn(victim, "zone_leg_random");
109 }
110 }
111 else if (!g_Game.IsHeadlessOrDedicatedServer())
112 {
113 if (victim)
114 {
115 if (victim.IsInherited(PlayerBase))
116 {
117 victim.SpawnDamageDealtEffect();
118 }
119
121 }
122 }
123 }
124
125 override void OnSteppedOut(EntityAI victim)
126 {
127 if (victim.IsInherited(CarScript))
128 {
129 if (m_UpdateTimer && m_UpdateTimer.IsRunning())
130 {
131 m_UpdateTimer.Stop();
132 }
133 }
134 }
135
136 protected void OnServerSteppedOn(Object obj, string damageZone)
137 {
138 if (obj.IsInherited(CarWheel))
139 {
140 obj.ProcessDirectDamage(DamageType.CLOSE_COMBAT, this, damageZone, "BearTrapHit_CarWheel", "0 0 0", 1);
141 if (m_UpdateTimer.IsRunning())
142 {
143 m_UpdateTimer.Stop();
144 }
145
146 SetInactive(false);
147 Synch(EntityAI.Cast(obj));
148
149 return;
150 }
151
152 if (obj.IsDamageDestroyed())
153 return;
154
155 string zoneUsed = damageZone;
156 if (damageZone == "zone_leg_random")
157 {
158 zoneUsed = "LeftLeg";
159 if (Math.RandomIntInclusive(0, 1) == 1)
160 zoneUsed = "RightLeg";
161 }
162
164 ZombieBase zombie;
165 if (obj.IsInherited(PlayerBase) || (Class.CastTo(zombie,obj) && !zombie.IsCrawling() && Math.RandomIntInclusive(0, 1) == 1))
166 {
168 }
169
170 obj.ProcessDirectDamage(DamageType.CLOSE_COMBAT, this, zoneUsed, "BearTrapHit", "0 0 0", 1);
171
172 SetInactive(false);
173 Synch(EntityAI.Cast(obj));
174 }
175
176 // Causes the player to start limping. This is temporary and should at some point be replaced by broken legs
177 void CauseVictimToStartLimping(Object obj, string damagedZone)
178 {
179 PlayerBase player;
180 ZombieBase zombie;
181 if (Class.CastTo(player,obj))
182 {
183 player.DamageAllLegs(player.GetMaxHealth() * 2); //reduce legs health (not regular DamageSystem damage, does not transfer!)
184 }
185 else if (Class.CastTo(zombie,obj))
186 {
187 zombie.SetHealth("LeftLeg", "Health", 0.0);
188 zombie.SetHealth("RightLeg", "Health", 0.0);
189 }
190 }
191
193 {
194 EffectSound sound = SEffectManager.PlaySound("beartrapCloseDamage_SoundSet", GetPosition(), 0, 0, false);
195 sound.SetAutodestroy(true);
196 }
197
199 {
200 EffectSound sound = SEffectManager.PlaySound("beartrapClose_SoundSet", GetPosition(), 0, 0, false);
201 sound.SetAutodestroy(true);
202 }
203
205 {
206 EffectSound sound = SEffectManager.PlaySound("beartrapOpen_SoundSet", GetPosition(), 0, 0, false);
207 sound.SetAutodestroy(true);
208 }
209
210 override void OnActivate()
211 {
212 #ifndef SERVER
213 #ifndef NO_GUI
215 #endif
216 #endif
217 }
218
219 override void OnDisarm()
220 {
221 #ifndef SERVER
222 #ifndef NO_GUI
224 #endif
225 #endif
226 }
227
228 //================================================================
229 // ADVANCED PLACEMENT
230 //================================================================
231
232 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
233 {
234 super.OnPlacementComplete(player, position, orientation);
235
236 if (g_Game.IsServer())
237 {
238 PlayerBase player_PB = PlayerBase.Cast(player);
239 StartActivate(player_PB);
240 }
241 }
242
243 override bool IsDeployable()
244 {
245 return true;
246 }
247
248 override string GetLoopDeploySoundset()
249 {
250 return "beartrap_deploy_SoundSet";
251 }
252
253 override void SetActions()
254 {
255 super.SetActions();
256
260 }
261
262 override void OnTriggeredByFall(Contact extra)
263 {
264 SetInactive(false); // springs the trap, RefreshState() handles the jaw animation
265 }
266
268 {
270 }
271
272#ifdef DEVELOPER
273 //================================================================
274 // DEBUG
275 //================================================================
276
277 //Debug menu Spawn Ground Special
278 override void OnDebugSpawn()
279 {
280 StartActivate(null);
281 }
282
283 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
284 {
285 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Activate", FadeColors.LIGHT_GREY));
286 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Deactivate", FadeColors.LIGHT_GREY));
287 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
288
289 super.GetDebugActions(outputList);
290 }
291
292 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
293 {
294 if (super.OnAction(action_id, player, ctx))
295 return true;
296 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
297 {
298 if (action_id == EActions.ACTIVATE_ENTITY)
299 {
300 StartActivate(null);
301 }
302 else if (action_id == EActions.DEACTIVATE_ENTITY)
303 {
304 SetInactive();
305 }
306 }
307 return false;
308 }
309#endif
310}
Param4< int, int, string, int > TSelectableActionInfoWithColor
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Определения ActionDeployObject.c:9
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
vector GetOrientation()
Определения AreaDamageManager.c:306
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
ref Timer m_UpdateTimer
Определения RadialMenu.c:20
string m_AnimationPhaseTriggered
Определения TrapBase.c:34
float m_DefectRate
Определения TrapBase.c:19
void Synch(EntityAI victim)
keeping "step" here for consistency only
Определения TrapBase.c:290
string m_AnimationPhaseGrounded
Определения TrapBase.c:32
const float UPDATE_TIMER_INTERVAL
Определения TrapBase.c:15
EntityAI GetClosestCarWheel(EntityAI victim)
Определения TrapBase.c:622
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
float m_DamagePlayers
Определения TrapBase.c:20
void StartActivate(PlayerBase player)
Определения TrapBase.c:437
float m_DamageOthers
Определения TrapBase.c:21
Определения Truck_02.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения Contact.c:10
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
Определения DayZPhysics.c:124
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
Определения EnMath.c:7
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
float radius
radius along the ray tested
Определения DayZPhysics.c:57
int type
Определения DayZPhysics.c:73
CollisionFlags flags
Определения DayZPhysics.c:63
Определения DayZPhysics.c:50
Определения DayZPhysics.c:99
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
void PlaySoundOpen()
Определения Trap_Bear.c:204
void OnServerSteppedOn(Object obj, string damageZone)
Определения Trap_Bear.c:136
override void OnSteppedOn(EntityAI victim)
Определения Trap_Bear.c:67
override void CreateTrigger()
Определения Trap_Bear.c:43
override string GetLoopDeploySoundset()
Определения Trap_Bear.c:248
override void OnActivate()
Определения Trap_Bear.c:210
static const vector m_RaycastSources[RAYCAST_SOURCES_COUNT]
Определения Trap_Bear.c:6
void PlaySoundBiteEmpty()
Определения Trap_Bear.c:198
void BearTrap()
Определения Trap_Bear.c:14
void PlaySoundBiteLeg()
Определения Trap_Bear.c:192
override void OnDisarm()
Определения Trap_Bear.c:219
override void OnTriggeredByFallEffectsClient()
Определения Trap_Bear.c:267
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения Trap_Bear.c:232
override void OnUpdate(EntityAI victim)
Определения Trap_Bear.c:55
override bool CanBeDisarmed()
Определения Trap_Bear.c:25
override bool IsDeployable()
Определения Trap_Bear.c:243
override void SetActions()
Определения Trap_Bear.c:253
void CauseVictimToStartLimping(Object obj, string damagedZone)
Определения Trap_Bear.c:177
static const int RAYCAST_SOURCES_COUNT
Определения Trap_Bear.c:3
override void OnSteppedOut(EntityAI victim)
Определения Trap_Bear.c:125
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения Trap_Bear.c:30
override void OnTriggeredByFall(Contact extra)
Определения Trap_Bear.c:262
Определения Trap_Bear.c:2
Определения ZombieFemaleBase.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:119
Serializer ParamsReadContext
Определения gameplay.c:15
CollisionFlags
Определения EnDebug.c:141
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int STATE_RUINED
Определения 3_Game/DayZ/constants.c:909
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
Определения 3_Game/DayZ/constants.c:486
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473