Browse Source

revert R behavior (#45)

* revert R behaviour as original version
* simulate the 'buggy' behavior of A in the original game
Pal Lockheart 6 years ago
parent
commit
224cb0a0cc
4 changed files with 55 additions and 6 deletions
  1. 1 0
      battle.c
  2. 3 0
      battle.h
  3. 50 5
      fight.c
  4. 1 1
      macos/Pal.xcodeproj/project.pbxproj

+ 1 - 0
battle.c

@@ -1376,6 +1376,7 @@ PAL_StartBattle(
    g_Battle.fRepeat = FALSE;
    g_Battle.fForce = FALSE;
    g_Battle.fFlee = FALSE;
+   g_Battle.fPrevAutoAtk = FALSE;
 #endif
 
 #ifdef PAL_ALLOW_KEYREPEAT

+ 3 - 0
battle.h

@@ -107,6 +107,7 @@ typedef struct tagBATTLEPLAYER
    WORD               wCurrentFrame;        // current frame number
    FIGHTERSTATE       state;                // state of this player
    BATTLEACTION       action;               // action to perform
+   BATTLEACTION       prevAction;           // action of the previous turn
    BOOL               fDefending;           // TRUE if player is defending
    WORD               wPrevHP;              // HP value prior to action
    WORD               wPrevMP;              // MP value prior to action
@@ -187,6 +188,8 @@ typedef struct tagBATTLE
    BOOL             fRepeat;              // TRUE if player pressed Repeat
    BOOL             fForce;               // TRUE if player pressed Force
    BOOL             fFlee;                // TRUE if player pressed Flee
+   BOOL             fPrevAutoAtk;         // TRUE if auto-attack was used in the previous turn
+   BOOL             fPrevPlayerAutoAtk;   // TRUE if auto-attack was used by previous player in the same turn
 #endif
 } BATTLE;
 

+ 50 - 5
fight.c

@@ -1385,12 +1385,25 @@ PAL_BattleStartFrame(
 
          if (i > gpGlobals->wMaxPartyMemberIndex)
          {
+            //
+            // Backup all actions once not repeating.
+            //
+            if (!g_Battle.fRepeat)
+            {
+               for (i = 0; i <= gpGlobals->wMaxPartyMemberIndex; i++)
+               {
+                  g_Battle.rgPlayer[i].prevAction = g_Battle.rgPlayer[i].action;
+               }
+            }
+
             //
             // actions for all players are decided. fill in the action queue.
             //
             g_Battle.fRepeat = FALSE;
             g_Battle.fForce = FALSE;
             g_Battle.fFlee = FALSE;
+            g_Battle.fPrevAutoAtk = g_Battle.UI.fAutoAttack;
+            g_Battle.fPrevPlayerAutoAtk = FALSE;
 
             g_Battle.iCurAction = 0;
 
@@ -1673,6 +1686,18 @@ PAL_BattleStartFrame(
             {
                g_Battle.rgPlayer[i].action.ActionType = kBattleActionAttackMate;
             }
+            else if (g_Battle.rgPlayer[i].action.ActionType == kBattleActionAttack &&
+               g_Battle.rgPlayer[i].action.wActionID != 0)
+            {
+               g_Battle.fPrevPlayerAutoAtk = TRUE;
+            }
+            else if (g_Battle.fPrevPlayerAutoAtk)
+            {
+               g_Battle.UI.wCurPlayerIndex = i;
+               g_Battle.UI.wSelectedIndex = g_Battle.rgPlayer[i].action.sTarget;
+               g_Battle.UI.wActionType = kBattleActionAttack;
+               PAL_BattleCommitAction(FALSE);
+            }
 
             //
             // Perform the action for this player.
@@ -1694,6 +1719,7 @@ PAL_BattleStartFrame(
       if (g_InputState.dwKeyPress & kKeyRepeat)
       {
          g_Battle.fRepeat = TRUE;
+         g_Battle.UI.fAutoAttack = g_Battle.fPrevAutoAtk;
       }
       else if (g_InputState.dwKeyPress & kKeyForce)
       {
@@ -1749,13 +1775,32 @@ PAL_BattleCommitAction(
          g_Battle.UI.wActionType;
       g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.sTarget =
          (SHORT)g_Battle.UI.wSelectedIndex;
-      g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.wActionID =
-         g_Battle.UI.wObjectID;
+
+      if (g_Battle.UI.wActionType == kBattleActionAttack)
+      {
+         g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.wActionID =
+            (g_Battle.UI.fAutoAttack ? 1 : 0);
+      }
+      else
+      {
+         g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.wActionID =
+            g_Battle.UI.wObjectID;
+	  }
+#ifndef PAL_CLASSIC
+      g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].prevAction =
+         g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action;
+#endif
    }
-   else if (g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.ActionType == kBattleActionPass)
+   else
    {
-      g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.ActionType = kBattleActionAttack;
-      g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.sTarget = -1;
+      g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action =
+         g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].prevAction;
+
+      if (g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.ActionType == kBattleActionPass)
+      {
+         g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.ActionType = kBattleActionAttack;
+         g_Battle.rgPlayer[g_Battle.UI.wCurPlayerIndex].action.sTarget = -1;
+      }
    }
 
    //

+ 1 - 1
macos/Pal.xcodeproj/project.pbxproj

@@ -355,7 +355,7 @@
 		71E23E8C13F6D1AD001287B6 /* synth.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; name = synth.h; path = libmad/synth.h; sourceTree = "<group>"; };
 		71E23E8D13F6D1AD001287B6 /* timer.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; name = timer.c; path = libmad/timer.c; sourceTree = "<group>"; };
 		71E23E8E13F6D1AD001287B6 /* timer.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; name = timer.h; path = libmad/timer.h; sourceTree = "<group>"; };
-		71E27E030D8C7E2F0048BA16 /* fight.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; path = fight.c; sourceTree = "<group>"; };
+		71E27E030D8C7E2F0048BA16 /* fight.c */ = {isa = PBXFileReference; fileEncoding = 0; indentWidth = 3; lastKnownFileType = sourcecode.c.c; path = fight.c; sourceTree = "<group>"; tabWidth = 3; usesTabs = 0; };
 		71E27E040D8C7E2F0048BA16 /* fight.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = fight.h; sourceTree = "<group>"; };
 		71F0F6D10DAA63B400F88C16 /* ending.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; path = ending.c; sourceTree = "<group>"; };
 		71F0F6D20DAA63B400F88C16 /* ending.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = ending.h; sourceTree = "<group>"; };