9 int m_RaycastCachedIndex;
14 m_RaycastEndOffset =
"0 0.5 0";
17 m_RaycastCachedIndex = -1;
20 override void OnTriggerCreated()
22 super.OnTriggerCreated();
29 m_RaycastSources.Clear();
32 int nrOfSources = raycast_sources.Count();
33 for (
int v = 0; v < nrOfSources; ++v)
35 m_RaycastSources.Insert(raycast_sources[v].ToVector());
41 m_RaycastSources = raycast_sources;
44 void SetRaycastLength(
float length)
46 m_RaycastEndOffset =
Vector(0, length, 0);
49 override void OnStayFinishServerEvent()
51 super.OnStayFinishServerEvent();
59 data.Hitzone = GetRaycastedHitZone(
object);
64 protected void ClearCache()
66 m_RaycastCache.Clear();
67 m_RaycastCachedIndex = -1;
70 protected string GetRaycastedHitZone(
Object victim)
72 int nrOfCachedResults = m_RaycastSources.Count();
73 for (
int c = 0; c < nrOfCachedResults; ++c )
76 if ( cachedRes.obj == victim )
77 return victim.GetDamageZoneNameByComponentIndex(cachedRes.component);
80 int nrOfSources = m_RaycastSources.Count();
88 params.type = ObjIntersectIFire;
91 for (
int i = m_RaycastCachedIndex + 1; i < nrOfSources; ++i )
93 m_RaycastCachedIndex = i;
95 params.begPos = trigger.ModelToWorld( m_RaycastSources[i] );
96 params.endPos = params.begPos + m_RaycastEndOffset;
100 for (
int j = 0; j < victims.Count(); ++j )
104 if (res.obj == victim)
105 hitzone = victim.GetDamageZoneNameByComponentIndex(res.component);
107 if (res.obj.IsAnyInherited(m_DamageableTypes))
108 m_RaycastCache.Insert(res);
111 if ( !( hitzone ==
"") )
118 return GetFallbackHitZone(victim);
121 protected string GetFallbackHitZone(
Object victim)
123 Error(
string.Format(
"[WARNING] :: [%1] :: [AreaDamageComponentRaycasted] :: No proper HitZone found for damaging %2, using fallback.",
130 if (
Math.RandomIntInclusive(0, 1) == 1 )
137 victim.GetDamageZones(damageZones);
139 int nrOfDmgZones = damageZones.Count();
141 if (nrOfDmgZones > 0)
143 for (
int z = 0; z < nrOfDmgZones; ++z)
145 if ( damageZones[z].Contains(
"Foot") || damageZones[z].Contains(
"Leg") )
146 return damageZones[z];
149 return damageZones.GetRandomElement();