DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
FlashGrenade.c
См. документацию.
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 {
7 super.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
8
9 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
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
24 float ammoRangeMax = ammoRangeKill * ammoRangeMaxMult;
25 ammoRangeMax = Math.Clamp(ammoRangeMax * FX_RANGE_MAX_MULT, ammoRangeKill, ammoRangeMax);
26
27 float dist = vector.Distance(headPos, pos);
28 float distSq = vector.DistanceSq(headPos, pos);
29 float radiusMaxSq = Math.SqrFloat(ammoRangeMax);
30
31 if (distSq <= radiusMaxSq)
32 {
33 // ignore collisions with parent if fireplace
34 InventoryItem invItem = InventoryItem.Cast(source);
35 EntityAI parent = invItem.GetHierarchyParent();
36 array<Object> excluded = new array<Object>;
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)
47 RaycastRVParams rayParams = new RaycastRVParams(pos, headPos, excluded[0]);
48 rayParams.flags = CollisionFlags.ALLOBJECTS;
49 DayZPhysics.RaycastRVProxy(rayParams, results, excluded);
50
52 array<Object> hitObjects = new array<Object>;
53 for (int i = 0; i < results.Count(); i++)
54 {
55 if (results[i].obj && !results[i].obj.IsInherited(ItemBase))
56 {
57 hitObjects.Insert(results[i].obj);
58 }
59 }
60
61 //If player is not first index, object is between player and grenade
62 if (hitObjects.Count() && PlayerBase.Cast(hitObjects[0]))
63 {
64 float effectCoef;
65 if (ammoRangeMax == ammoRangeKill)
66 {
67 effectCoef = 1.0; //edge case, landed right on the edge
68 }
69 effectCoef = 1 - ((dist - ammoRangeKill) / (ammoRangeMax - ammoRangeKill));
70 effectCoef = Math.Clamp(effectCoef, 0.1, 100.0);
71
72 player.OnPlayerReceiveFlashbangHitStart(MiscGameplayFunctions.IsPlayerOrientedTowardPos(player, pos, 60));
73 player.GetFlashbangEffect().SetupFlashbangValues(effectCoef, effectCoef, effectCoef);
74 }
75 }
76 }
77 }
78
80 {
81 SetAmmoType("FlashGrenade_Ammo");
82 SetFuseDelay(2);
83 SetGrenadeType(EGrenadeType.ILLUMINATING);
85 }
86
87 protected override void CreateLight()
88 {
90 }
91
92 void ~FlashGrenade() {}
93}
const int MAX
Определения EnConvert.c:27
void SetParticleExplosion(int particle)
Определения ExplosivesBase.c:324
void SetAmmoType(string pAmmoType)
Определения ExplosivesBase.c:313
void FlashGrenadeLight()
Определения Grenade_Base.c:17
EGrenadeType
Определения Grenade_Base.c:2
class Land_Buoy extends House m_Light
PlayerBase GetPlayer()
Определения ModifierBase.c:51
proto native float ConfigGetFloat(string path)
Get float value from config on path.
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
Определения DayZPhysics.c:124
Определения Building.c:6
Определения ExplosivesBase.c:2
void SetFuseDelay(float delay)
Определения Grenade_Base.c:107
void FlashGrenade()
Определения FlashGrenade.c:79
void SetGrenadeType(EGrenadeType type)
Определения Grenade_Base.c:112
const float FX_RANGE_MAX_MULT
Определения FlashGrenade.c:3
override void CreateLight()
Определения FlashGrenade.c:87
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
Определения FlashGrenade.c:5
void ~FlashGrenade()
Определения FlashGrenade.c:92
void Grenade_Base()
Определения Grenade_Base.c:294
Определения ItemBase.c:15
Определения InventoryItem.c:731
Определения EnMath.c:7
Определения ObjectTyped.c:2
static const int GRENADE_M84
Определения ParticleList.c:128
Определения ParticleList.c:12
Определения PlayerBaseClient.c:2
CollisionFlags flags
Определения DayZPhysics.c:63
Определения DayZPhysics.c:50
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
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.
Определения EnConvert.c:106
proto native CGame GetGame()
CollisionFlags
Определения 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'.
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9