public bool CheckRangeToTarget(Weapon w, GameplayObject target) { if (target == null || !target.Active || target.Health <= 0) return false; if (this.engineState == MoveState.Warp) return false; Ship targetship = target as Ship; ShipModule targetModule = target as ShipModule; if (targetship == null && targetModule != null) targetship = targetModule.GetParent(); if (targetship != null) { if (targetship.engineState == MoveState.Warp || targetship.dying || !targetship.Active || targetship.ExternalSlots.Count <= 0 || !w.TargetValid(targetship.Role) ) return false; } Vector2 PickedPos = target.Center; //radius = target.Radius; //added by gremlin attackrun compensator float modifyRangeAR = 50f; Vector2 pos = PickedPos; if (w.PrimaryTarget && !w.isBeam && this.GetAI().CombatState == CombatState.AttackRuns && this.maxWeaponsRange < 2000 && w.SalvoCount > 0) { modifyRangeAR = this.speed; if (modifyRangeAR < 50) modifyRangeAR = 50; } if (Vector2.Distance(pos, w.moduleAttachedTo.Center) > w.GetModifiedRange() + modifyRangeAR)//+radius) { return false; } return true; }
//Added by McShooterz public bool CheckIfInsideFireArc(Weapon w, Ship ship) { Vector2 PickedPos = ship.Center; float radius = ship.radius; GlobalStats.WeaponArcChecks = GlobalStats.WeaponArcChecks + 1; float modifyRangeAR = 50f; float distance =Vector2.Distance(w.moduleAttachedTo.Center, PickedPos) ; if (!w.isBeam && this.GetAI().CombatState == CombatState.AttackRuns && w.SalvoTimer > 0 && distance / w.SalvoTimer < w.GetOwner().speed) //&& this.maxWeaponsRange < 2000 { modifyRangeAR = this.speed * w.SalvoTimer; if (modifyRangeAR < 50) modifyRangeAR = 50; } if (distance > w.GetModifiedRange() + modifyRangeAR + radius) { return false; } float halfArc = w.moduleAttachedTo.FieldOfFire / 2f; Vector2 toTarget = PickedPos - w.Center; float radians = (float)Math.Atan2((double)toTarget.X, (double)toTarget.Y); float angleToMouse = 180f - MathHelper.ToDegrees(radians); float facing = w.moduleAttachedTo.facing + MathHelper.ToDegrees(base.Rotation); if (facing > 360f) { facing = facing - 360f; } float difference = 0f; difference = Math.Abs(angleToMouse - facing); if (difference > halfArc) { if (angleToMouse > 180f) { angleToMouse = -1f * (360f - angleToMouse); } if (facing > 180f) { facing = -1f * (360f - facing); } difference = Math.Abs(angleToMouse - facing); } //float modifyRangeAR = 50f; //if (!w.isBeam && this.GetAI().CombatState == CombatState.AttackRuns && this.maxWeaponsRange < 2000 && w.SalvoTimer > 0) //{ // modifyRangeAR = this.speed * w.SalvoTimer; //} if (difference < halfArc )//&& Vector2.Distance(w.moduleAttachedTo.Center, PickedPos) < w.GetModifiedRange() + modifyRangeAR) { return true; } return false; }
//Added by McShooterz public bool CheckIfInsideFireArc(Weapon w, Vector2 PickedPos, float Rotation) { if(Vector2.Distance(w.moduleAttachedTo.Center, PickedPos) > w.GetModifiedRange() + 50f) { return false; } float halfArc = w.moduleAttachedTo.FieldOfFire / 2f; Vector2 toTarget = PickedPos - w.Center; float radians = (float)Math.Atan2((double)toTarget.X, (double)toTarget.Y); float angleToMouse = 180f - MathHelper.ToDegrees(radians); float facing = w.moduleAttachedTo.facing + MathHelper.ToDegrees(Rotation); if (facing > 360f) { facing = facing - 360f; } float difference = 0f; difference = Math.Abs(angleToMouse - facing); if (difference > halfArc) { if (angleToMouse > 180f) { angleToMouse = -1f * (360f - angleToMouse); } if (facing > 180f) { facing = -1f * (360f - facing); } difference = Math.Abs(angleToMouse - facing); } if (difference < halfArc )//&& Vector2.Distance(w.moduleAttachedTo.Center, PickedPos) < w.GetModifiedRange() + 50f) { return true; } return false; }
public bool CheckIfInsideFireArc(Weapon w, Vector3 PickedPos ) { //added by gremlin attackrun compensator float modifyRangeAR = 50f; Vector2 pos = new Vector2(PickedPos.X, PickedPos.Y); if (!w.isBeam && this.GetAI().CombatState == CombatState.AttackRuns && this.maxWeaponsRange < 2000 && w.SalvoCount > 0) { modifyRangeAR = this.speed; if (modifyRangeAR < 50) modifyRangeAR = 50; } if (Vector2.Distance(pos, w.moduleAttachedTo.Center) > w.GetModifiedRange() + modifyRangeAR ) { return false; } float halfArc = w.moduleAttachedTo.FieldOfFire / 2f; Vector2 toTarget = pos - w.Center; float radians = (float)Math.Atan2((double)toTarget.X, (double)toTarget.Y); float angleToMouse = 180f - MathHelper.ToDegrees(radians); float facing = w.moduleAttachedTo.facing + MathHelper.ToDegrees(base.Rotation); if (facing > 360f) { facing = facing - 360f; } float difference = 0f; difference = Math.Abs(angleToMouse - facing); if (difference > halfArc) { if (angleToMouse > 180f) { angleToMouse = -1f * (360f - angleToMouse); } if (facing > 180f) { facing = -1f * (360f - facing); } difference = Math.Abs(angleToMouse - facing); } if (difference < halfArc)// && Vector2.Distance(base.Position, pos) < w.GetModifiedRange() + modifyRangeAR) { return true; } return false; }