@@ -14710,7 +14710,8 @@ void ai_frame(int objnum)
1471014710 }
1471114711}
1471214712
14713- static void ai_control_info_check(ai_info *aip, ship_info *sip, physics_info *pi)
14713+ // set and removes any maneuver flags for ai maneuver overrides
14714+ static void ai_control_info_flags_upkeep(ai_info* aip, ship_info* sip, physics_info* pi)
1471414715{
1471514716 if (aip->ai_override_flags.none_set())
1471614717 return;
@@ -14741,6 +14742,37 @@ static void ai_control_info_check(ai_info *aip, ship_info *sip, physics_info *pi
1474114742 }
1474214743 else
1474314744 {
14745+ if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Dont_bank_when_turning] || sip->flags[Ship::Info_Flags::Dont_bank_when_turning])
14746+ AI_ci.control_flags |= CIF_DONT_BANK_WHEN_TURNING;
14747+ if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Dont_clamp_max_velocity] || sip->flags[Ship::Info_Flags::Dont_clamp_max_velocity])
14748+ AI_ci.control_flags |= CIF_DONT_CLAMP_MAX_VELOCITY;
14749+ if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Instantaneous_acceleration] || sip->flags[Ship::Info_Flags::Instantaneous_acceleration])
14750+ AI_ci.control_flags |= CIF_INSTANTANEOUS_ACCELERATION;
14751+ }
14752+
14753+ // set physics flag according to whether we are instantaneously accelerating
14754+ if (AI_ci.control_flags & CIF_INSTANTANEOUS_ACCELERATION)
14755+ pi->flags |= PF_MANEUVER_NO_DAMP;
14756+ else
14757+ pi->flags &= ~PF_MANEUVER_NO_DAMP;
14758+ }
14759+
14760+ // applies any rotational or lateral maneuver values to the AI's CI
14761+ static void ai_control_info_apply(ai_info *aip)
14762+ {
14763+ if (aip->ai_override_flags.none_set())
14764+ return;
14765+
14766+ bool lateral_maneuver = false;
14767+ bool rotational_maneuver = false;
14768+
14769+ if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Lateral_never_expire] || !timestamp_elapsed(aip->ai_override_lat_timestamp))
14770+ lateral_maneuver = true;
14771+
14772+ if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Rotational_never_expire] || timestamp_elapsed(aip->ai_override_rot_timestamp))
14773+ rotational_maneuver = true;
14774+
14775+ if (lateral_maneuver || rotational_maneuver) {
1474414776 if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Full_rot])
1474514777 {
1474614778 AI_ci.pitch = aip->ai_override_ci.pitch;
@@ -14750,17 +14782,11 @@ static void ai_control_info_check(ai_info *aip, ship_info *sip, physics_info *pi
1475014782 else
1475114783 {
1475214784 if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Pitch])
14753- {
1475414785 AI_ci.pitch = aip->ai_override_ci.pitch;
14755- }
1475614786 if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Heading])
14757- {
1475814787 AI_ci.heading = aip->ai_override_ci.heading;
14759- }
1476014788 if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Roll])
14761- {
1476214789 AI_ci.bank = aip->ai_override_ci.bank;
14763- }
1476414790 }
1476514791
1476614792 if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Full_lat])
@@ -14772,32 +14798,13 @@ static void ai_control_info_check(ai_info *aip, ship_info *sip, physics_info *pi
1477214798 else
1477314799 {
1477414800 if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Up])
14775- {
1477614801 AI_ci.vertical = aip->ai_override_ci.vertical;
14777- }
1477814802 if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Sideways])
14779- {
1478014803 AI_ci.sideways = aip->ai_override_ci.sideways;
14781- }
1478214804 if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Forward])
14783- {
1478414805 AI_ci.forward = aip->ai_override_ci.forward;
14785- }
1478614806 }
14787-
14788- if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Dont_bank_when_turning] || sip->flags[Ship::Info_Flags::Dont_bank_when_turning])
14789- AI_ci.control_flags |= CIF_DONT_BANK_WHEN_TURNING;
14790- if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Dont_clamp_max_velocity] || sip->flags[Ship::Info_Flags::Dont_clamp_max_velocity])
14791- AI_ci.control_flags |= CIF_DONT_CLAMP_MAX_VELOCITY;
14792- if (aip->ai_override_flags[AI::Maneuver_Override_Flags::Instantaneous_acceleration] || sip->flags[Ship::Info_Flags::Instantaneous_acceleration])
14793- AI_ci.control_flags |= CIF_INSTANTANEOUS_ACCELERATION;
1479414807 }
14795-
14796- // set physics flag according to whether we are instantaneously accelerating
14797- if (AI_ci.control_flags & CIF_INSTANTANEOUS_ACCELERATION)
14798- pi->flags |= PF_NO_DAMP;
14799- else
14800- pi->flags &= ~PF_NO_DAMP;
1480114808}
1480214809
1480314810int Last_ai_obj = -1;
@@ -14857,9 +14864,12 @@ void ai_process( object * obj, int ai_index, float frametime )
1485714864 if (shipp->flags[Ship::Ship_Flags::Dying] && sip->flags[Ship::Info_Flags::Large_ship_deathroll])
1485814865 rfc = false;
1485914866
14867+ // regardless if we're acting on them, upkeep maneuver flags
14868+ ai_control_info_flags_upkeep(aip, sip, &obj->phys_info);
14869+
1486014870 if (rfc) {
1486114871 // Wanderer - sexp based override goes here - only if rfc is valid though
14862- ai_control_info_check (aip, sip, &obj->phys_info );
14872+ ai_control_info_apply (aip);
1486314873 physics_read_flying_controls( &obj->orient, &obj->phys_info, &AI_ci, frametime);
1486414874 }
1486514875
0 commit comments