// 11Mar2013-04:41UTC chinajade public bool WeaponAim(WoWObject selectedTarget) { AimedLocation = null; // If target is moving, lead it... var wowUnit = selectedTarget as WoWUnit; if (Query.IsViable(wowUnit) && wowUnit.IsMoving) { var projectileFlightTime = CalculateTimeOfProjectileFlight(selectedTarget.Location); var anticipatedLocation = selectedTarget.AnticipatedLocation(projectileFlightTime); WoWMovement.StopFace(); return(WeaponAim(anticipatedLocation)); } if (!Query.IsViable(selectedTarget)) { QBCLog.Warning("No target for WeaponAim!"); WoWMovement.StopFace(); return(false); } if (!UtilAimPreReqsPassed()) { return(false); } // Show user what we're targeting... Utility.Target(selectedTarget); var spell = FindVehicleAbilitySpell(); // Terrain is targeted when firing weapon. // Commented out until repairs are made. //if (spell != null && spell.CanTargetTerrain) //{ // // make sure target is within range of spell // if ( Me.Location.Distance(selectedTarget.Location) > spell.MaxRange) // return false; // AimedLocation = selectedTarget.Location; // return true; //} // Calculate the azimuth... // TODO: Take vehicle rotations (pitch, roll) into account var azimuth = CalculateBallisticLaunchAngle(selectedTarget.Location); //// Debugging--looking for pitch/roll contributions... //// NB: It currently looks like the GetWorldMatrix() does not populate enough info to make //// this calculation. //if (azimuth.HasValue) //{ // var pitch = StyxWoW.Memory.Read<float>(WoWMovement.ActiveMover.BaseAddress + 0x820 + 0x24); // QBCLog.Debug("{0} {1:F3}/ {2:F3} pitch: {3:F3}", WoWMovement.ActiveMover.Name, azimuth, azimuth - pitch, pitch); // QBCDebug.ShowVehicleArticulationChain(WoWMovement.ActiveMover); //} if (!azimuth.HasValue || !WeaponArticulation.AzimuthSet(azimuth.Value)) { return(false); } // For heading, we just face the location... if (!WeaponArticulation.HeadingSet(selectedTarget)) { return(false); } AimedLocation = selectedTarget.Location; return(true); }