internal void ComputeEffects(DefenseShields shield, Vector3D impactPos, int prevLod, float shieldPercent, bool activeVisible) { Shield = shield; if (Shield?.ShellActive != null) { ComputeSides(); } else { return; } _matrix = Shield.ShieldShapeMatrix; if (Session.Instance.Settings.ClientConfig.ShowHitRings && impactPos != Vector3D.NegativeInfinity && impactPos != Vector3D.PositiveInfinity) { CreateImpactRing(shield, impactPos, _lod); } _flash = shieldPercent <= 10; if (_flash && _mainLoop < 30) { shieldPercent += 10; } var newActiveColor = UtilsStatic.GetShieldColorFromFloat(shieldPercent); _activeColor = newActiveColor; ImpactPosState = impactPos; _active = activeVisible && _activeColor != Session.Instance.Color90; if (prevLod != _lod) { var ib = _backing.IndexBuffer[_lod]; Array.Resize(ref _preCalcNormLclPos, ib.Length / 3); Array.Resize(ref _triColorBuffer, ib.Length / 3); } StepEffects(); /* * if (refreshAnim && _refresh && ImpactsFinished && prevLod == _lod) RefreshColorAssignments(prevLod); * if (ImpactsFinished && prevLod == _lod) return; * * ImpactColorAssignments(prevLod); */ //// vec3 localSpherePositionOfImpact; // foreach (vec3 triangleCom in triangles) { // var surfDistance = Math.acos(dot(triangleCom, localSpherePositionOfImpact)); // } // surfDistance will be the distance, along the surface, between the impact point and the triangle // Equinox - It won't distort properly for anything that isn't a sphere // localSpherePositionOfImpact = a direction // triangleCom is another direction // Dot product is the cosine of the angle between them // Acos gives you that angle in radians // Multiplying by the sphere radius(1 for the unit sphere in question) gives the arc length. }
internal void ComputeEffects(MatrixD matrix, Vector3D impactPos, MyEntity shellPassive, MyEntity shellActive, int prevLod, float shieldPercent, bool activeVisible, bool refreshAnim) { if (ShellActive == null) { ComputeSides(shellActive); } _flash = shieldPercent <= 10; if (_flash && _mainLoop < 30) { shieldPercent += 10; } var newActiveColor = UtilsStatic.GetShieldColorFromFloat(shieldPercent); _activeColor = newActiveColor; _matrix = matrix; ImpactPosState = impactPos; _active = activeVisible && _activeColor != Session.Instance.Color90; if (prevLod != _lod) { var ib = _backing.IndexBuffer[_lod]; Array.Resize(ref _preCalcNormLclPos, ib.Length / 3); Array.Resize(ref _triColorBuffer, ib.Length / 3); } StepEffects(); if (refreshAnim && _refresh && ImpactsFinished && prevLod == _lod) { RefreshColorAssignments(prevLod); } if (ImpactsFinished && prevLod == _lod) { return; } ImpactColorAssignments(prevLod); //// vec3 localSpherePositionOfImpact; // foreach (vec3 triangleCom in triangles) { // var surfDistance = Math.acos(dot(triangleCom, localSpherePositionOfImpact)); // } // surfDistance will be the distance, along the surface, between the impact point and the triangle // Equinox - It won't distort properly for anything that isn't a sphere // localSpherePositionOfImpact = a direction // triangleCom is another direction // Dot product is the cosine of the angle between them // Acos gives you that angle in radians // Multiplying by the sphere radius(1 for the unit sphere in question) gives the arc length. }
public void Execute() { if (Entity == null || !Entity.InScene || Entity.MarkedForClose) { return; } var computedDamage = UtilsStatic.ComputeAmmoDamage(Entity); var damage = computedDamage * Shield.DsState.State.ModulateKinetic; if (computedDamage < 0) { damage = computedDamage; } var rayDir = Vector3D.Normalize(Entity.Physics.LinearVelocity); var ray = new RayD(Entity.PositionComp.WorldVolume.Center, rayDir); var intersect = CustomCollision.IntersectEllipsoid(ref Shield.DetectMatrixOutsideInv, Shield.DetectionMatrix, ref ray); var hitDist = intersect ?? 0; var hitPos = ray.Position + (ray.Direction * -hitDist); if (Session.Instance.MpActive) { Shield.AddShieldHit(Entity.EntityId, damage, Session.Instance.MPExplosion, null, true, hitPos); Entity.Close(); Entity.InScene = false; } else { Shield.EnergyHit = DefenseShields.HitType.Energy; Shield.WorldImpactPosition = hitPos; Shield.ImpactSize = damage; UtilsStatic.CreateFakeSmallExplosion(hitPos); Entity.Close(); Entity.InScene = false; } Shield.WebDamage = true; Shield.Absorb += damage; Shield.EnergyDamage += damage; Session.Instance.MissilePool.Return(this); }
public AmmoInfo2(bool explosive, float damage, float radius, float speed, float mass, float backKickForce) { Explosive = explosive; Damage = damage; Radius = radius; Speed = (float)Math.Truncate(speed); Mass = mass; BackKickForce = (float)Math.Truncate(backKickForce); var backCompat = UtilsStatic.GetDmgMulti(backKickForce); if (Math.Abs(backCompat) >= 0.001) //back compat, != 0 might get weird { KineticWeapon = !Explosive; BypassWeapon = false; DmgMulti = backCompat; if (Mass < 0 && Radius <= 0) //ye olde heal check { HealingWeapon = true; } } else if (BackKickForce < 0) //emulates the weirdest old behavior { KineticWeapon = !Explosive; BypassWeapon = false; DmgMulti = 0; ShieldDamage = float.NegativeInfinity; //bls gob no if (Mass < 0 && Radius <= 0) { ShieldDamage = -ShieldDamage; } return; } else //new API { var slice = Math.Abs(backKickForce - Math.Truncate(backKickForce)) * 10; var opNum = (int)Math.Truncate(slice); ////gets first decimal digit DmgMulti = (float)Math.Truncate((slice - Math.Truncate(slice)) * 10); ////gets second decimal digit var uuid = (int)Math.Round(Math.Abs(speed - Math.Truncate(speed)) * 1000); ////gets UUID if (uuid != 537 || backKickForce >= 131072 || speed >= 16384) { ////confirms UUID or if backkick/speed are out of range of float precision KineticWeapon = !Explosive; HealingWeapon = false; BypassWeapon = false; DmgMulti = 1; } else if (opNum == 8) ////8 is bypass, ignores all other flags { KineticWeapon = !Explosive; HealingWeapon = false; BypassWeapon = true; DmgMulti = 1; } else //eval flags { if (Convert.ToBoolean(opNum & 1)) ////bitcheck first bit; 0 is fractional, 1 is whole num { if (Math.Abs(DmgMulti) <= 0.001d) ////fractional and mult 0 = no damage { DmgMulti = 10; } } else { DmgMulti /= 10; } KineticWeapon = Convert.ToBoolean(opNum & 2); //second bit; 0 is energy, 1 is kinetic HealingWeapon = Convert.ToBoolean(opNum & 4); //third bit; 0 is damaging, 1 is healing } } if (Explosive) { ShieldDamage = (Damage * (Radius * 0.5f)) * 7.5f * DmgMulti; } else { ShieldDamage = Mass * Speed * DmgMulti; } // shieldDamage = Mass * Math.Pow(Speed,2) * DmgMulti / 2; //kinetic equation if (HealingWeapon) { ShieldDamage = -ShieldDamage; } }