DayZ 1.24
Loading...
Searching...
No Matches
FlashGrenade.c
Go to the documentation of this file.
1class FlashGrenade extends Grenade_Base
2{
3 const float FX_RANGE_MAX_MULT = 1.0;
4
5 override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
6 {
8
10
11 if (player)
12 {
13 vector headPos = player.GetDamageZonePos("Head"); // animated position in the middle of the zone
14 float ammoRangeKill = GetGame().ConfigGetFloat(string.Format("CfgAmmo %1 indirectHitRange", ammoType));
15 float ammoRangeMaxMult = 4.0;
16
17 string indirectHitRangeMultiplier = string.Format("CfgAmmo %1 indirectHitRangeMultiplier", ammoType);
18 if (GetGame().ConfigIsExisting(indirectHitRangeMultiplier))
19 {
21 ammoRangeMaxMult = Math.Clamp(GetGame().ConfigGetFloat(indirectHitRangeMultiplier), 1.0, float.MAX);
22 }
23
26
27 float dist = vector.Distance(headPos, pos);
28 float distSq = vector.DistanceSq(headPos, pos);
30
31 if (distSq <= radiusMaxSq)
32 {
33 // ignore collisions with parent if fireplace
35 EntityAI parent = invItem.GetHierarchyParent();
37
38 if (!parent || !parent.IsFireplace())
39 parent = null;
40 else if (parent)
41 excluded.Insert(parent);
42
44 excluded.Insert(this); //Ignore self for visibility check
45
46 //There shouldn't be cases justifying we go further than first entry (if in fireplace, self does not impact)
48 rayParams.flags = CollisionFlags.ALLOBJECTS;
50
53 for (int i = 0; i < results.Count(); i++)
54 {
55 if (results[i].obj && !results[i].obj.IsInherited(ItemBase))
56 hitObjects.Insert(results[i].obj);
57 }
58
59 //If player is not first index, object is between player and grenade
60 if (hitObjects.Count() && PlayerBase.Cast(hitObjects[0]))
61 {
62 float effectCoef;
64 {
65 effectCoef = 1.0; //edge case, landed right on the edge
66 }
68 effectCoef = Math.Clamp(effectCoef, 0.1, 100.0);
69
70 player.OnPlayerReceiveFlashbangHitStart(MiscGameplayFunctions.IsPlayerOrientedTowardPos(player, pos, 60));
71 player.GetFlashbangEffect().SetupFlashbangValues(effectCoef, effectCoef, effectCoef);
72 }
73 }
74 }
75 }
76
78 {
79 SetAmmoType("FlashGrenade_Ammo");
80 SetFuseDelay(2);
81 SetGrenadeType(EGrenadeType.ILLUMINATING);
83 }
84
85 protected override void CreateLight()
86 {
88 }
89
90 void ~FlashGrenade() {}
91}
const int MAX
Definition EnConvert.c:27
ExplosiveLight m_Light
light
void SetParticleExplosion(int particle)
void SetAmmoType(string pAmmoType)
void FlashGrenadeLight()
EGrenadeType
Definition Grenade_Base.c:2
PlayerBase GetPlayer()
class JsonUndergroundAreaTriggerData GetPosition
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
void SetFuseDelay(float delay)
void FlashGrenade()
void SetGrenadeType(EGrenadeType type)
override void CreateLight()
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
Definition FlashGrenade.c:5
void ~FlashGrenade()
Definition EnMath.c:7
static const int GRENADE_M84
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
CollisionFlags
Definition EnDebug.c:141
static proto float SqrFloat(float f)
Returns squared value.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.