DayZ 1.27
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 (GetGame().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 (GetGame().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 (!GetGame().IsDedicatedServer())
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
214 #endif
215 }
216
217 override void OnDisarm()
218 {
219 #ifndef SERVER
221 #endif
222 }
223
224 //================================================================
225 // ADVANCED PLACEMENT
226 //================================================================
227
228 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
229 {
230 super.OnPlacementComplete(player, position, orientation);
231
232 if (GetGame().IsServer())
233 {
234 PlayerBase player_PB = PlayerBase.Cast(player);
235 StartActivate(player_PB);
236 }
237 }
238
239 override bool IsDeployable()
240 {
241 return true;
242 }
243
244 override string GetLoopDeploySoundset()
245 {
246 return "beartrap_deploy_SoundSet";
247 }
248
249 override void SetActions()
250 {
251 super.SetActions();
252
256 }
257
258#ifdef DEVELOPER
259 //================================================================
260 // DEBUG
261 //================================================================
262
263 //Debug menu Spawn Ground Special
264 override void OnDebugSpawn()
265 {
266 StartActivate(null);
267 }
268
269 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
270 {
271 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Activate", FadeColors.LIGHT_GREY));
272 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Deactivate", FadeColors.LIGHT_GREY));
273 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
274
275 super.GetDebugActions(outputList);
276 }
277
278 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
279 {
280 if (super.OnAction(action_id, player, ctx))
281 return true;
282 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
283 {
284 if (action_id == EActions.ACTIVATE_ENTITY)
285 {
286 StartActivate(null);
287 }
288 else if (action_id == EActions.DEACTIVATE_ENTITY)
289 {
290 SetInactive();
291 }
292 }
293 return false;
294 }
295#endif
296}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения EntityAI.c:97
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Определения ActionDeployObject.c:9
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
vector GetOrientation()
Определения AreaDamageManager.c:306
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
EActions
Определения EActions.c:2
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
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения ItemBase.c:7071
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:281
string m_AnimationPhaseGrounded
Определения TrapBase.c:32
const float UPDATE_TIMER_INTERVAL
Определения TrapBase.c:15
EntityAI GetClosestCarWheel(EntityAI victim)
Определения TrapBase.c:623
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
float m_DamagePlayers
Определения TrapBase.c:20
void StartActivate(PlayerBase player)
Определения TrapBase.c:438
float m_DamageOthers
Определения TrapBase.c:21
Определения CivilianSedan.c:2
Определения InventoryItem.c:413
Super root of all classes in Enforce script.
Определения EnScript.c:11
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:603
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения Building.c:6
Определения constants.c:659
Определения 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:169
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:244
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:217
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения Trap_Bear.c:228
override void OnUpdate(EntityAI victim)
Определения Trap_Bear.c:55
override bool CanBeDisarmed()
Определения Trap_Bear.c:25
override bool IsDeployable()
Определения Trap_Bear.c:239
override void SetActions()
Определения Trap_Bear.c:249
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
Определения Trap_Bear.c:2
Определения ZombieFemaleBase.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
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
Определения constants.c:846
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