Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In the same cluster as the target ... we dodge, turn to face the aim point and fire if close enough
- Vector vecLeadPosition;
- float t = solveForLead(this, m_commandTargets[c_cmdPlan], m_mountedWeapons[0], &vecLeadPosition);
- float lifespan = m_mountedWeapons[0]->GetLifespan();
- bool bIisInRange = false;
- if (t <= lifespan)
- bIisInRange = true;
- // get needed qualities of the shooter
- Vector shipPosition = this->GetPosition();
- Vector shipAimDirection = this->GetOrientation().GetForward();
- // get needed qualities of the shooter weapon
- IprojectileTypeIGC* pt = m_mountedWeapons[0]->GetProjectileType();
- float fProjectileSpeed = pt->GetSpeed();
- // get needed qualities of the shootee
- Vector targetPosition = m_commandTargets[c_cmdPlan]->GetPosition();
- float fTargetRadius = m_commandTargets[c_cmdPlan]->GetRadius();
- // compute the distance between the ships
- float fDistanceBetweenShips = (targetPosition - shipPosition).Length();
- // compute the distance at which a hit could occur
- float fLengthAlongTargetVector = t * fProjectileSpeed;
- // compute values needed for determining weapon in-range
- float fCosAngle = vecLeadPosition * shipAimDirection;
- float fA = fLengthAlongTargetVector;
- float fH = fA / fCosAngle;
- float fHASquared = (fH * fH) - (fA * fA);
- float fRadiusSquared = fTargetRadius * fTargetRadius;
- bool bWillHit = (fHASquared <= fRadiusSquared) ? true : false;
- // project a tracking point at the target range
- Vector trackingRelativeToShip = shipAimDirection * fDistanceBetweenShips;
- Vector trackingPosition = shipPosition + trackingRelativeToShip;
- float fShootSkill = m_fShootSkill; //imago 10/14 made these adjustable
- float fTurnSkill = m_fTurnSkill;
- int state = 0;
- bool bDodge = Dodge(this, NULL, &state);
- float da = turnToFace(vecLeadPosition, dT, this, &m_controls, fTurnSkill);
- m_controls.jsValues[c_axisThrottle] = 0.5f + ((pi - da) / (2.0f * pi));
- const float c_fMaxOffAngle = 0.90f; //TODO skillz
- //float lifespan = m_mountedWeapons[0]->GetLifespan();
- // commenting this to get strafe behavior from the drones BSW 10/28/1999
- //imago 10/14
- //if ((!bDodge) && (t <= lifespan * 0.25f) && fTurnSkill > 0.75f)
- if (bWillHit = true)
- {
- //We are close and not dodging anything so ...
- //strafe
- state |= leftButtonIGC; //todo skillz - add randomness
- if (da < pi * 0.5f)
- {
- if (da > c_fMaxOffAngle)
- {
- //too close ... back off
- state |= backwardButtonIGC;
- }
- else
- state |= forwardButtonIGC;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement