Created
June 26, 2019 01:44
-
-
Save Kaleidosium/58e112ba0ec7885b80a2e69d85d6a636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asm65816 | |
import asmref | |
// Item Auto Revive Party by D-Man | |
/* | |
This script auto revives party members if an item was used during battle that allows the party to auto revive. Auto revives to only the first downed party member. Does not work for NPC character | |
How the item will function is that it'll zero out the Vitality stat of each player's combatant table since Vitaltiy and IQ aren't considered in any of the damage calulations or battle actions. Then, it'll set that byte to 1 to indicate that they have the chance to revive. This will be done for all controllable characters and not to NPC characters like Pokey and King. | |
Notes: | |
UNKNOWN21 in the KO_Target routine is the place where the character's HP are set to 0 and then the text displays their death. | |
ROM Address 0xC277B9 to 0xC277C3 has asmref's BText pattern, I'll use the JSL to jump into this scripts ASM code. | |
Apparently the Check_Dead_Players routine also had some checking and setting player's death and so I need to consider that routine to jump from and execute the Auto_Revive_Checker routine. | |
Dang, I have to make 2 separate ASM codes since the Check_Dead_Players uses a different DPR than the KO_Target one. | |
*/ | |
Use_Text: | |
newline sound(SND_EAT) pause(5) "@{user} used " | |
linebreak " the Life Shroom![03]" | |
newline "@A party member can revive once if they are downed![03]" | |
eob | |
Revive_Text: | |
// Insert your text here when the character's are revived. | |
eob | |
ROM[0xC2BBE6] = JSL (Auto_Revive_Checker_Dead_Players) | |
ROM[0xC277C3] = JSL (Auto_Revive_Checker) | |
/* | |
The ASM Code of the item to set the player's vitality stat in the Combatant Table to 1 when someone uses the item. | |
*/ | |
Item_Code:{ | |
REP (0x31) | |
PHD | |
TDC | |
ADC_i (0xFFFC) | |
TCD | |
// Prepare for-loop. | |
LDA_i (0x0000) // i = 0 | |
STA_d (0x02) // DPR 0x02 = i | |
// This loop will set 1 to all of the character's vitality stat. | |
Loop: | |
LDA_d (0x02) // Load in the interator | |
CMP_i (0x0003) // if (iterator > 3) | |
BCS_a (Return) // end the loop (break) | |
LDY_i (0x004E) // Else, continue. Load in the Combatant Table entry size | |
JSL (Mult_YxA) // Mult the iterator with the entry size | |
CLC | |
ADC_i (0x9FAC) // Add that to the starting address of the Combatant Table | |
TAX // Transfer it to X | |
SEP (0x20) // Make A 8-bit | |
LDA_8 (0x01) // Load 1 into A | |
STA_x (0x0030) // Store 0x01 into the character's Vitality stat in the Combatant Table | |
REP (0x20) // Make A 16-bit | |
INC_d (0x02) // Increment the iterator (i++) | |
BRA_a (Loop) // Loop | |
Return: | |
PLD | |
RTL | |
} | |
/* | |
The ASM Code that will check if the dead player has the possibility to revive. | |
*/ | |
Auto_Revive_Checker:{ | |
JSL (0xC1DC1C) // display text when the person is downed | |
REP (0x31) | |
PHD | |
TDC | |
ADC_i (0xFFEE) | |
TCD | |
LDX_d (0x14) // Load in the character's Combatant Table's entry | |
LDA_x (0x0010) // Load in their ID | |
AND_i (0x00FF) // Get low byte | |
LDY_i (0x004E) // Size of each of the Combatant Table's entries | |
JSL (Mult_YxA) // Multiply A by Y, store back into A | |
CLC | |
ADC_i (0x9FAC) // Add the result to the start of the address of the Combatant Table, giving us the correct player's Combatant Entry | |
TAX // Transfer data in A to X | |
LDA_x (0x0030) // Load in the character's vitality stat (or if they have the ability to revive) | |
AND_i (0x00FF) // Get low Byte | |
CMP_i (0x0001) // Checks to see if they have the chances to revive | |
BNE_a (Return) // If they don't have the it, then skip them and let them die | |
//BText(Revive_Text) // Some text you want to display when they revive. (Optional) | |
SEP (0x20) // Else, then revive them. Make A 8-bit | |
STZ_x (0x0030) // Store 0x00 into the Vitality stat | |
REP (0x20) // Make A 16-bit | |
LDA_d (0x14) // Load in the character's Combatant Table's entry | |
LDX_i (10000) // The amount of HP to heal the target | |
JSL (Revive_Target) // Revive the character | |
// Prepare for-loop. | |
LDA_i (0x0000) // i = 0 | |
STA_d (0x02) // DPR 0x02 = i | |
// This loop will get rid of all of the other character's revive chances | |
Loop: | |
LDA_d (0x02) // Load in the interator | |
CMP_i (0x0003) // if (iterator > 3) | |
BCS_a (Return) // end the loop (break) | |
LDY_i (0x004E) // Else, continue. Load in the Combatant Table entry size | |
JSL (Mult_YxA) // Mult the iterator with the entry size | |
CLC | |
ADC_i (0x9FAC) // Add that to the starting address of the Combatant Table | |
TAX // Transfer it to X | |
SEP (0x20) // Make A 8-bit | |
STZ_x (0x0030) // Store 0x00 into the character's Vitality stat in the Combatant Table | |
REP (0x20) // Make A 16-bit | |
INC_d (0x02) // Increment the iterator (i++) | |
BRA_a (Loop) // Loop | |
Return: | |
PLD | |
RTL | |
} | |
Auto_Revive_Checker_Dead_Players:{ | |
JSL (0xC1DC1C) // display text when the person is downed | |
REP (0x31) | |
PHD | |
TDC | |
ADC_i (0xFFEE) | |
TCD | |
LDX_a (0xA972) // Load in the character's Combatant Table's entry | |
LDA_x (0x0010) // Load in their ID | |
AND_i (0x00FF) // Get low byte | |
LDY_i (0x004E) // Size of each of the Combatant Table's entries | |
JSL (Mult_YxA) // Multiply A by Y, store back into A | |
CLC | |
ADC_i (0x9FAC) // Add the result to the start of the address of the Combatant Table, giving us the correct player's Combatant Entry | |
TAX // Transfer data in A to X | |
LDA_x (0x0030) // Load in the character's vitality stat (or if they have the ability to revive) | |
AND_i (0x00FF) // Get low Byte | |
CMP_i (0x0001) // Checks to see if they have the chances to revive | |
BNE_a (Return) // If they don't have the it, then skip them and let them die | |
//BText(Revive_Text) // Some text you want to display when they revive. (Optional) | |
SEP (0x20) // Else, then revive them. Make A 8-bit | |
STZ_x (0x0030) // Store 0x00 into the Vitality stat | |
REP (0x20) // Make A 16-bit | |
LDA_a (0xA972) // Load in the character's Combatant Table's entry | |
LDX_i (10000) // The amount of HP to heal the target | |
JSL (Revive_Target) // Revive the character | |
// Prepare for-loop. | |
LDA_i (0x0000) // i = 0 | |
STA_d (0x02) // DPR 0x02 = i | |
// This loop will get rid of all of the other character's revive chances | |
Loop: | |
LDA_d (0x02) // Load in the interator | |
CMP_i (0x0003) // if (iterator > 3) | |
BCS_a (Return) // end the loop (break) | |
LDY_i (0x004E) // Else, continue. Load in the Combatant Table entry size | |
JSL (Mult_YxA) // Mult the iterator with the entry size | |
CLC | |
ADC_i (0x9FAC) // Add that to the starting address of the Combatant Table | |
TAX // Transfer it to X | |
SEP (0x20) // Make A 8-bit | |
STZ_x (0x0030) // Store 0x00 into the character's Vitality stat in the Combatant Table | |
REP (0x20) // Make A 16-bit | |
INC_d (0x02) // Increment the iterator (i++) | |
BRA_a (Loop) // Loop | |
Return: | |
PLD | |
RTL | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment