Skip to content

Commit

Permalink
Some changes to q-move and attack move for aircraft. Another attempt …
Browse files Browse the repository at this point in the history
…to kill the crash bug with MIGs.
  • Loading branch information
ChthonVII committed Jun 24, 2022
1 parent 403da38 commit cafa23c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 18 deletions.
47 changes: 30 additions & 17 deletions REDALERT/AIRCRAFT.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ int AircraftClass::Mission_Hunt(void)
}
Fire_At(targ, 0);

// Chthon CFE Note: rank 3 MIGS/Yals fire two missiles per ammo pip (fudge this by restoring 1 ammo between shots) (check for two-shooter in case it's removed via rules.ini edit)
// Chthon CFE Note: rank 3 MIGS/Yaks fire two missiles per ammo pip (fudge this by restoring 1 ammo between shots) (check for two-shooter in case it's removed via rules.ini edit)
if ((VeterancyRank == 3) && ((*this == AIRCRAFT_MIG) || (*this == AIRCRAFT_YAK)) && Class->Is_Two_Shooter()){
Ammo++;
}
Expand Down Expand Up @@ -1807,16 +1807,16 @@ int AircraftClass::Mission_Move(void)
if (distance < 0x00C0) {
// Make q-moves work
if (HasNavQueue()){
if (AttackMove && !Ammo){
//Memorize_Navigation_List();
Clear_Navigation_List();
}
else {
//if (AttackMove && !Ammo){
////Memorize_Navigation_List();
//Clear_Navigation_List();
//}
//else {
Assign_Destination(TARGET_NONE);
Assign_Target(TARGET_NONE);
Enter_Idle_Mode();
return(1);
}
//}
}

// Attack Move rework by ChthonVII -- If we're reached the destination, exit attack move and go home
Expand Down Expand Up @@ -1909,7 +1909,7 @@ int AircraftClass::Mission_Move(void)
case VALIDATE_LZ:
// Attack Move rework by ChthonVII -- If "smarter aircraft" mode is also enabled, don't attack move if you don't have any ammo to start with
if (AttackMove && ActiveCFEPatchConfig.EnableSmarterAircraft && !IsALoaner && !Ammo){
//Memorize_Navigation_List();
Memorize_Navigation_List();
ResetAttackMove();
Clear_Navigation_List();
Enter_Idle_Mode();
Expand Down Expand Up @@ -1962,15 +1962,15 @@ int AircraftClass::Mission_Move(void)

// Make q-moves work
if (HasNavQueue()){
if (AttackMove && !Ammo){
//Memorize_Navigation_List();
Clear_Navigation_List();
} else {
//if (AttackMove && !Ammo){
////Memorize_Navigation_List();
//Clear_Navigation_List();
//} else {
Assign_Destination(TARGET_NONE);
Assign_Target(TARGET_NONE);
Enter_Idle_Mode();
return(1);
}
//}
}

// Attack Move rework by ChthonVII -- helicopters should go home at the end of an attack-move rather than landing
Expand Down Expand Up @@ -2064,10 +2064,23 @@ void AircraftClass::Enter_Idle_Mode(bool )
}
*/
if (!Target_Legal(NavCom)){
if (Handle_Navigation_List()){
Assign_Mission(MISSION_MOVE);
Commence();
return;
if (!AttackMove || Ammo){ // if attackmove but no ammo, then fall through to next block to memorize and clear queue
if (Handle_Navigation_List()){
Assign_Mission(MISSION_MOVE);
if (!IsLanding && !IsTakingOff){
Commence();
// if already airborn, change status to skip takeoff
if (Height == FLIGHT_LEVEL){
if (Class->IsFixedWing){
Status = 1; //FLY_TOWARD_TARGET
}
//else { // helicopters still need to validate LZ
// Status = 2; //FLY_TO_LZ
//}
}
}
return;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion REDALERT/AIRCRAFT.H
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class AircraftClass : public FootClass, public FlyClass
*/
bool Passenger;

private:
//private: // Chthon CFE Note: these need to be public so we can check them from elsewhere

/*
** Aircraft can be in either state of landing, taking off, or in steady altitude.
Expand All @@ -205,6 +205,8 @@ class AircraftClass : public FootClass, public FlyClass
unsigned IsLanding:1;
unsigned IsTakingOff:1;

private:

/*
** It is very common for aircraft to be homing in on a target. When this flag is
** true, the aircraft will constantly adjust its facing toward the TarCom. When the
Expand Down
17 changes: 17 additions & 0 deletions REDALERT/TECHNO.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -7799,6 +7799,23 @@ void TechnoClass::AttackMoveEnterMoveMode(){
//if (Is_Foot()){
//((FootClass*)this)->SkipNavQueueUpdate = false; // OK to process the nav queue when we go idle because move mode ends .
//}
// aircraft can commence though -- and should so we can skip status ahead past takeoff
if (What_Am_I() == RTTI_AIRCRAFT){
AircraftClass* meplane = (AircraftClass*)this;
if (!meplane->IsLanding && !meplane->IsTakingOff){
Commence();
if (meplane->Height == FLIGHT_LEVEL){
if (meplane->Class->IsFixedWing){
Status = 1; //FLY_TOWARD_TARGET
}
//else { // helicopters still need to validate LZ
// Status = 2; //FLY_TO_LZ
//}
}
}
}

return;
}

void TechnoClass::AttackMoveEnterAttackMode(){
Expand Down

0 comments on commit cafa23c

Please sign in to comment.