From 39eb68210c3d3469fb382598a3fbb8d61bce1810 Mon Sep 17 00:00:00 2001 From: Martin Palko Date: Sun, 7 Jun 2020 11:19:15 -0400 Subject: [PATCH 1/6] Fixed compile errors on 'Boxing' mechanic - Fixed use of missing 'BodyFacing' variable in the drawing code - Fixed use of missing 'Establish_Contact' method, used 'Transmit_Message(RADIO_HELLO...' instead d2f1d8 --- TIBERIANDAWN/INFANTRY.CPP | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TIBERIANDAWN/INFANTRY.CPP b/TIBERIANDAWN/INFANTRY.CPP index 1db1082..962dc9c 100644 --- a/TIBERIANDAWN/INFANTRY.CPP +++ b/TIBERIANDAWN/INFANTRY.CPP @@ -635,7 +635,7 @@ void InfantryClass::Draw_It(int x, int y, WindowNumberType window) #ifdef BOXING // BG hack to get him to face right when he's supposed to. - if (IsBoxing && BodyFacing<128) shapenum += 47; + if (IsBoxing && facing < Facing_To_32(DIR_S)) shapenum += 47; #endif /* @@ -1143,7 +1143,7 @@ void InfantryClass::AI(void) if (Is_Target_Infantry(TarCom) && (Distance(TarCom)<=0x80) && (Coord_Y(Coord) == Coord_Y(object->Coord))) { // Too close to shoot, so start hand-to-hand combat - if (Establish_Contact((TechnoClass *)object)) { + if (Transmit_Message(RADIO_HELLO, (TechnoClass *)object) == RADIO_ROGER) { if (Transmit_Message(RADIO_PREPARE_TO_BOX) == RADIO_ROGER) { IsBoxing = true; Do_Action(DO_ON_GUARD,true); From 7095efe1ad77d517b52c305cf6a7fbcfed704687 Mon Sep 17 00:00:00 2001 From: Martin Palko Date: Sun, 7 Jun 2020 11:19:57 -0400 Subject: [PATCH 2/6] Fixed facing when boxing - Target was only being set after call to 'Do_Action(DO_ON_GUARD...' which caused facing to be calculated incorrectly, as the target was invalid at the time of the call. 0731dc --- TIBERIANDAWN/INFANTRY.CPP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TIBERIANDAWN/INFANTRY.CPP b/TIBERIANDAWN/INFANTRY.CPP index 962dc9c..44f46a0 100644 --- a/TIBERIANDAWN/INFANTRY.CPP +++ b/TIBERIANDAWN/INFANTRY.CPP @@ -2776,8 +2776,8 @@ RadioMessageType InfantryClass::Receive_Message(RadioClass * from, RadioMessageT if (IsBoxing) break; #endif if (Contact_With_Whom() == from) { - Do_Action(DO_ON_GUARD, true); Assign_Target(Contact_With_Whom()->As_Target()); + Do_Action(DO_ON_GUARD, true); return(RADIO_ROGER); } return(RADIO_NEGATIVE); From 6c445969bf1d07541e6fc3dfaa4b693fba0a260f Mon Sep 17 00:00:00 2001 From: Martin Palko Date: Sun, 7 Jun 2020 16:51:59 -0400 Subject: [PATCH 3/6] Fixed reading of Punch and Kick damage values - Randomized reading of infantry punch and kick damage arrays provided a max value that one too high, and was our of the range of the array. --- TIBERIANDAWN/INFANTRY.CPP | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TIBERIANDAWN/INFANTRY.CPP b/TIBERIANDAWN/INFANTRY.CPP index 44f46a0..10f5064 100644 --- a/TIBERIANDAWN/INFANTRY.CPP +++ b/TIBERIANDAWN/INFANTRY.CPP @@ -2786,7 +2786,7 @@ RadioMessageType InfantryClass::Receive_Message(RadioClass * from, RadioMessageT ** Just received a kick! Take some damage. */ case RADIO_KICK: - damage = Infantry_Kick_Damage[Random_Pick(0, (int)(sizeof(Infantry_Kick_Damage) / sizeof(Infantry_Kick_Damage[0])))]; + damage = Infantry_Kick_Damage[Random_Pick(0, (int)(sizeof(Infantry_Kick_Damage) / sizeof(Infantry_Kick_Damage[0])) - 1)]; if (Take_Damage(damage, 0, WARHEAD_FOOT, this) == RESULT_DESTROYED) return(RADIO_STATIC); return(RADIO_ROGER); @@ -2794,7 +2794,7 @@ RadioMessageType InfantryClass::Receive_Message(RadioClass * from, RadioMessageT ** Just recieved a punch! Take some damage. */ case RADIO_PUNCH: - damage = Infantry_Punch_Damage[Random_Pick(0, (int)(sizeof(Infantry_Punch_Damage) / sizeof(Infantry_Punch_Damage[0])))]; + damage = Infantry_Punch_Damage[Random_Pick(0, (int)(sizeof(Infantry_Punch_Damage) / sizeof(Infantry_Punch_Damage[0])) - 1)]; if (Take_Damage(damage, 0, WARHEAD_FIST, this) == RESULT_DESTROYED) return(RADIO_STATIC); return(RADIO_ROGER); From a524bb91cb82ccf3cb5c3b9abc4ab5d56f0da52a Mon Sep 17 00:00:00 2001 From: Martin Palko Date: Sun, 7 Jun 2020 19:28:06 -0400 Subject: [PATCH 4/6] Fixed infantry not playing death animation after boxing - This issue occurred when an infantry was killed back by the explosive death of a unit it just won a boxing match against --- TIBERIANDAWN/INFANTRY.CPP | 43 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/TIBERIANDAWN/INFANTRY.CPP b/TIBERIANDAWN/INFANTRY.CPP index 10f5064..855720a 100644 --- a/TIBERIANDAWN/INFANTRY.CPP +++ b/TIBERIANDAWN/INFANTRY.CPP @@ -188,26 +188,26 @@ void InfantryClass::Debug_Dump(MonoClass *mono) const { Validate(); mono->Set_Cursor(0, 0);mono->Print( - "ÚName:ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂMission:ÄÄÄÂTarCom:ÂNavCom:ÂRadio:ÂCoord:ÄÄÂHeadTo:ÄÂSt:Ä¿\n" - "³ ³ ³ ³ ³ ³ ³ ³ ³\n" - "ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂNÂYÂHealth:ÄÂBody:ÂTurret:ÂSpeed:ÂPath:ÁÄÄÄÄÄÄÂCargo:ÄÄÄÄÁÄÄÄÄ´\n" - "³Active........³ ³ ³ ³ ³ ³ ³ ³ ³\n" - "³Limbo.........³ ³ ÃÄÄÄÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´\n" - "³Owned.........³ ³ ³Last Message: ³\n" - "³Discovered....³ ³ ÃTimer:ÂArm:ÂTrack:ÂTiberium:ÂFlash:ÂStage:ÂTeam:ÄÄÄÄÂArch:´\n" - "³Selected......³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³\n" - "³Teathered.....³ ³ ÃÄÄÄÄÄÄÁÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÙ\n" - "³Locked on Map.³ ³ ³ \n" - "³Is Prone......³ ³ ³ \n" - "³Is A Loner....³ ³ ³ \n" - "³Deploying.....³ ³ ³ \n" - "³Rotating......³ ³ ³ \n" - "³Firing........³ ³ ³ \n" - "³Driving.......³ ³ ³ \n" - "³To Look.......³ ³ ³ \n" - "³Recoiling.....³ ³ ³ \n" - "³To Display....³ ³ ³ \n" - "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÁÄÙ \n"); + "�Name:���������������Mission:����TarCom:�NavCom:�Radio:�Coord:���HeadTo:��St:Ä¿\n" + "� � � � � � � � �\n" + "����������������N�Y�Health:��Body:�Turret:�Speed:�Path:��������Cargo:��������Ĵ\n" + "�Active........� � � � � � � � �\n" + "�Limbo.........� � ����������������������������������������������������������Ĵ\n" + "�Owned.........� � �Last Message: �\n" + "�Discovered....� � �Timer:�Arm:�Track:�Tiberium:�Flash:�Stage:�Team:�����Arch:�\n" + "�Selected......� � � � � � � � � � �\n" + "�Teathered.....� � ������������������������������������������������������������\n" + "�Locked on Map.� � � \n" + "�Is Prone......� � � \n" + "�Is A Loner....� � � \n" + "�Deploying.....� � � \n" + "�Rotating......� � � \n" + "�Firing........� � � \n" + "�Driving.......� � � \n" + "�To Look.......� � � \n" + "�Recoiling.....� � � \n" + "�To Display....� � � \n" + "�������������������� \n"); mono->Set_Cursor(1, 1);mono->Printf("%s:%s", House->Class->IniName, Class->IniName); mono->Text_Print("X", 16 + (IsProne?2:0), 10); mono->Set_Cursor(33, 7);mono->Printf("%2d", Fear); @@ -2364,7 +2364,8 @@ BulletClass * InfantryClass::Fire_At(TARGET target, int which) ** Fighting done for some reason, so pick up gun */ IsBoxing = false; - Do_Action(DO_READY_WEAPON,true); + if (Strength) // Make sure we haven't died in the meantime + Do_Action(DO_READY_WEAPON,true); } } else { #endif From 32b74ccefe095a418617dbdc0ec1192e50d3c510 Mon Sep 17 00:00:00 2001 From: Martin Palko Date: Sun, 7 Jun 2020 19:31:56 -0400 Subject: [PATCH 5/6] Uncommented IsBoxing check - Similar to when infantry are firing, they shouldn't be moving when they are boxing --- TIBERIANDAWN/INFANTRY.CPP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TIBERIANDAWN/INFANTRY.CPP b/TIBERIANDAWN/INFANTRY.CPP index 855720a..c105476 100644 --- a/TIBERIANDAWN/INFANTRY.CPP +++ b/TIBERIANDAWN/INFANTRY.CPP @@ -1269,7 +1269,7 @@ void InfantryClass::AI(void) /* ** Perform movement operations at this time. */ - if (!IsFiring /*&& !IsBoxing*/) { + if (!IsFiring && !IsBoxing) { if (!IsDriving) { /* From f25029fe5da82d05f62a1032953c9ab906c163e9 Mon Sep 17 00:00:00 2001 From: Martin Palko Date: Sun, 7 Jun 2020 19:33:18 -0400 Subject: [PATCH 6/6] Fixed infantry being stuck in boxing state For a number of reasons, infantry can become stuck in one of the boxing states, while they have been told to stop boxing. This check catches those cases. --- TIBERIANDAWN/INFANTRY.CPP | 63 ++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/TIBERIANDAWN/INFANTRY.CPP b/TIBERIANDAWN/INFANTRY.CPP index c105476..07ee17d 100644 --- a/TIBERIANDAWN/INFANTRY.CPP +++ b/TIBERIANDAWN/INFANTRY.CPP @@ -188,26 +188,26 @@ void InfantryClass::Debug_Dump(MonoClass *mono) const { Validate(); mono->Set_Cursor(0, 0);mono->Print( - "�Name:���������������Mission:����TarCom:�NavCom:�Radio:�Coord:���HeadTo:��St:Ä¿\n" - "� � � � � � � � �\n" - "����������������N�Y�Health:��Body:�Turret:�Speed:�Path:��������Cargo:��������Ĵ\n" - "�Active........� � � � � � � � �\n" - "�Limbo.........� � ����������������������������������������������������������Ĵ\n" - "�Owned.........� � �Last Message: �\n" - "�Discovered....� � �Timer:�Arm:�Track:�Tiberium:�Flash:�Stage:�Team:�����Arch:�\n" - "�Selected......� � � � � � � � � � �\n" - "�Teathered.....� � ������������������������������������������������������������\n" - "�Locked on Map.� � � \n" - "�Is Prone......� � � \n" - "�Is A Loner....� � � \n" - "�Deploying.....� � � \n" - "�Rotating......� � � \n" - "�Firing........� � � \n" - "�Driving.......� � � \n" - "�To Look.......� � � \n" - "�Recoiling.....� � � \n" - "�To Display....� � � \n" - "�������������������� \n"); + "ÚName:ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂMission:ÄÄÄÂTarCom:ÂNavCom:ÂRadio:ÂCoord:ÄÄÂHeadTo:ÄÂSt:Ä¿\n" + "³ ³ ³ ³ ³ ³ ³ ³ ³\n" + "ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂNÂYÂHealth:ÄÂBody:ÂTurret:ÂSpeed:ÂPath:ÁÄÄÄÄÄÄÂCargo:ÄÄÄÄÁÄÄÄÄ´\n" + "³Active........³ ³ ³ ³ ³ ³ ³ ³ ³\n" + "³Limbo.........³ ³ ÃÄÄÄÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´\n" + "³Owned.........³ ³ ³Last Message: ³\n" + "³Discovered....³ ³ ÃTimer:ÂArm:ÂTrack:ÂTiberium:ÂFlash:ÂStage:ÂTeam:ÄÄÄÄÂArch:´\n" + "³Selected......³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³\n" + "³Teathered.....³ ³ ÃÄÄÄÄÄÄÁÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÙ\n" + "³Locked on Map.³ ³ ³ \n" + "³Is Prone......³ ³ ³ \n" + "³Is A Loner....³ ³ ³ \n" + "³Deploying.....³ ³ ³ \n" + "³Rotating......³ ³ ³ \n" + "³Firing........³ ³ ³ \n" + "³Driving.......³ ³ ³ \n" + "³To Look.......³ ³ ³ \n" + "³Recoiling.....³ ³ ³ \n" + "³To Display....³ ³ ³ \n" + "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÁÄÙ \n"); mono->Set_Cursor(1, 1);mono->Printf("%s:%s", House->Class->IniName, Class->IniName); mono->Text_Print("X", 16 + (IsProne?2:0), 10); mono->Set_Cursor(33, 7);mono->Printf("%2d", Fear); @@ -1047,6 +1047,29 @@ void InfantryClass::AI(void) return; } + /* + ** Catch infantry that may be stuck in Boxing animations and get them out of it + */ + if (!IsBoxing) + { + switch (Doing) + { + case DO_FIGHT_READY: + case DO_ON_GUARD: + case DO_PUNCH: + case DO_KICK: + case DO_PUNCH_HIT1: + case DO_PUNCH_HIT2: + case DO_KICK_HIT1: + case DO_KICK_HIT2: + Do_Action(DO_READY_WEAPON, true); + break; + + default: + break; + } + } + /* ** Act on new orders if the unit is at a good position to do so. */