Users browsing this thread: 2 Guest(s)
Antinomia: FF6

#69
Posts: 86
Threads: 6
Thanks Received: 14
Thanks Given: 2
Joined: Jul 2020
Reputation: 8
Status
None
Still working on part 3 (which ended up being part 3.1 and 3.2, with 3.1 now being done) of the Leo re-recruitment, but I wanted to share the code for the two custom event commands I ended up needing to write for this.

The first is a re-write of event $81, which is never actually used by the game at all.  This is the "take item X from inventory" event.  The problem is that all it did was scan your inventory for the specified item, and if it found it, decremented its quantity by 1.  Unlike the "take X GP from party" event, it did NOT flag that the specified item was not found.  So if you wanted to do an event where a character was, like, "Give me a potion", there was no way to determine whether you could actually give him a potion or not.  This new version uses the unused event flag $1BD to flag that the item in question is not in your inventory so you can use it to branch.  This code is longer than the original $81 code so I had to relocate it.  The usage would be 81 XX where XX is the item ID, and then check the $1BD flag, and if it's clear, you can branch to a "thanks for the item!" dialog, and if it's set you can branch to a "you don't have that item" dialog or something.

Code:
AD B7 1E    LDA $1EB7    (Load event byte $1EB7 into A)
29 DF        AND #$DF    (Mask with 1101 1111 to clear bit 5. $1EB7:5 = $1BD)
8D B7 1E    STA $1EB7    (Store the new value)
A6 00         LDX $00        (Zero out X)
BD 69 18     LDA $1869,X    (Load item at offset X from inventory list starting at $1869)
C5 EB         CMP $EB        (Compare that item ID with the item ID given as parameter 1 in $EB)
F0 10         BEQ #$10    (If it's the same, item is in inventory, skip to the decrement function below)
E8         INX        (Otherwise, increment X by 1)
E0 00 01     CPX $#0100    (Is X > 255? If so, we've reached the end of the inventory list)
D0 F3         BNE $#F3    (If it's not, jump back to the load item X and try again)
AD B7 1E     LDA $1EB7    (If we have reached the end of the list without finding our item, load $1EB7 again)
09 20         ORA #$20    (Mask it with 0010 0000 to set bit 5, i.e. set $1BD)
8D B7 1E     STA $1EB7    (And store it)
80 0D         BRA $#0D    (Jump to the end of the function)
DE 69 19     DEC $1969,X    (Decrement the quantity of the item at index X)
BD 69 19     LDA $1969,X    (Load the new quantity of this item)
D0 05         BNE #$05    (If it's not zero, jump to the end of the function)
A9 FF         LDA $#FF    (Otherwise create an "empty" item)
9D 69 18     STA $1869,X    (And store it at that index in the item list)
A9 02         LDA $#02    (This function used up 2 event queue bytes)
4C 5C 9B    JMP $9B5C    (Return to event queue)

The other function that I made was more home-brewed, and involves being able to permanently increase a given character's base stats through an event.  I assigned it to $76, but it can be any of the dozen or so unused event codes.  This takes two parameters: Character ID $00-$0F, and stat ID $00-$03, where the stat IDs are:
$00 = Vigor
$01 = Speed
$02 = Stamina
$03 = Magic Power
The command increases the given base stat for the given character by 1.  So, using my assigned event code as an example, 76 06 03 would increase Celes's Magic Power by 1 inside of an event.  The intent is to call it in a $B0 loop if you want to increase it by more than 1, so B0 05 76 06 03 B1 would increase Celes's Magic Power by 5.  This only takes absolute character IDs, not the $31-$34 party character IDs.  It limits the stats to 127 because some calculations use stat*2 which makes the stat overflow and become terrible above that value.  This code does not otherwise error-check that you gave it a valid character ID or stat ID, so use wisely.

Code:
A5EB    LDA $EB     (load parameter, character ID)
8D0242    STA $4202     (store as multiplier)
A925    LDA #$25    (set to 37 bytes of char data each)
8D0342    STA $4203    (store as multiplier)
A5EC    LDA $EC        (load parameter, stat offset)
C221    REP #$21    (set A to 16 bits, clear carry)
EA    NOP        (2-cycle NOP to allow multiplication to complete)
6D1642    ADC $4216    (add 37*ID + $EC offset)
AA    TAX        (put this value in X)
7B    TDC        (clear A)
E220    SEP #20        (set A to 8 bits)
BD1A16    LDA $161A,X    (load current stat, offset by X)
C97F    CMP #$7F    (check if already 127)
F004    BEQ #$04    (skip next two commands if it is)
1A    INC         (increment the value by 1)
9D1A16    STA $161A,X    (store new stat value
A903    LDA #$03    (This command was 3 bytes)
4C5C9B    JMP $9B5C    (Return to event queue)
  Find
Quote  



Messages In This Thread
Antinomia: FF6 - by Fast Moon - 09-10-2020, 08:47 PM
RE: Antinomia: FF6 - by Gi Nattak - 09-11-2020, 08:32 PM
RE: Antinomia: FF6 - by madsiur - 09-12-2020, 01:38 PM
RE: Antinomia: FF6 - by SSJ Rick - 09-15-2020, 11:21 PM
RE: Antinomia: FF6 - by Fast Moon - 09-26-2020, 07:38 PM
RE: Antinomia: FF6 - by CrumpledMedal - 10-02-2020, 10:29 PM
RE: Antinomia: FF6 - by Fast Moon - 10-03-2020, 08:33 AM
RE: Antinomia: FF6 - by Fast Moon - 10-05-2020, 10:52 AM
RE: Antinomia: FF6 - by Fast Moon - 10-09-2020, 08:45 PM
RE: Antinomia: FF6 - by Fast Moon - 10-21-2020, 08:08 PM
RE: Antinomia: FF6 - by Fast Moon - 11-12-2020, 09:27 PM
RE: Antinomia: FF6 - by Fast Moon - 11-27-2020, 12:30 PM
RE: Antinomia: FF6 - by Gi Nattak - 11-27-2020, 12:57 PM
RE: Antinomia: FF6 - by SSJ Rick - 11-29-2020, 04:16 PM
RE: Antinomia: FF6 - by Fast Moon - 11-29-2020, 07:24 PM
RE: Antinomia: FF6 - by NPCnextdoor - 11-29-2020, 08:08 PM
RE: Antinomia: FF6 - by Fast Moon - 12-29-2020, 06:40 PM
RE: Antinomia: FF6 - by Fast Moon - 01-28-2021, 10:05 PM
RE: Antinomia: FF6 - by Fast Moon - 01-30-2021, 06:02 PM
RE: Antinomia: FF6 - by C-Dude - 01-30-2021, 06:13 PM
RE: Antinomia: FF6 - by Fast Moon - 01-30-2021, 08:47 PM
RE: Antinomia: FF6 - by casualtom - 01-30-2021, 09:06 PM
RE: Antinomia: FF6 - by Fast Moon - 02-14-2021, 08:13 PM
RE: Antinomia: FF6 - by Fast Moon - 03-01-2021, 11:10 PM
RE: Antinomia: FF6 - by PowerPanda - 03-02-2021, 03:27 PM
RE: Antinomia: FF6 - by Fast Moon - 03-02-2021, 06:07 PM
RE: Antinomia: FF6 - by PowerPanda - 03-03-2021, 09:31 AM
RE: Antinomia: FF6 - by Negazeia - 03-05-2021, 05:13 AM
RE: Antinomia: FF6 - by Fast Moon - 03-05-2021, 12:59 PM
RE: Antinomia: FF6 - by C-Dude - 03-05-2021, 02:32 PM
RE: Antinomia: FF6 - by Negazeia - 03-05-2021, 02:06 PM
RE: Antinomia: FF6 - by Fast Moon - 03-05-2021, 08:30 PM
RE: Antinomia: FF6 - by PowerPanda - 03-06-2021, 01:17 AM
RE: Antinomia: FF6 - by Fast Moon - 03-06-2021, 09:33 AM
RE: Antinomia: FF6 - by C-Dude - 03-05-2021, 09:02 PM
RE: Antinomia: FF6 - by Fast Moon - 03-05-2021, 09:35 PM
RE: Antinomia: FF6 - by Negazeia - 03-06-2021, 06:09 AM
RE: Antinomia: FF6 - by PowerPanda - 03-06-2021, 01:09 PM
RE: Antinomia: FF6 - by Fast Moon - 03-06-2021, 04:47 PM
RE: Antinomia: FF6 - by C-Dude - 03-06-2021, 07:09 PM
RE: Antinomia: FF6 - by Fast Moon - 03-06-2021, 07:34 PM
RE: Antinomia: FF6 - by PowerPanda - 03-06-2021, 10:41 PM
RE: Antinomia: FF6 - by Fast Moon - 03-07-2021, 09:34 AM
RE: Antinomia: FF6 - by PowerPanda - 03-08-2021, 11:46 AM
RE: Antinomia: FF6 - by Fast Moon - 03-08-2021, 06:43 PM
RE: Antinomia: FF6 - by PowerPanda - 03-08-2021, 09:42 PM
RE: Antinomia: FF6 - by Fast Moon - 03-09-2021, 08:48 AM
RE: Antinomia: FF6 - by Fast Moon - 03-19-2021, 09:00 PM
RE: Antinomia: FF6 - by PowerPanda - 03-20-2021, 09:53 AM
RE: Antinomia: FF6 - by Endarire - 09-04-2021, 07:14 PM
RE: Antinomia: FF6 - by Fast Moon - 11-05-2021, 09:15 PM
RE: Antinomia: FF6 - by PowerPanda - 11-07-2021, 05:40 PM
RE: Antinomia: FF6 - by Fast Moon - 09-02-2022, 09:43 PM
RE: Antinomia: FF6 - by Fast Moon - 09-06-2022, 10:12 PM
RE: Antinomia: FF6 - by Fast Moon - 09-16-2022, 08:14 PM
RE: Antinomia: FF6 - by Gi Nattak - 09-16-2022, 09:05 PM
RE: Antinomia: FF6 - by Fast Moon - 09-17-2022, 02:17 PM
RE: Antinomia: FF6 - by Fast Moon - 09-27-2022, 09:56 PM
RE: Antinomia: FF6 - by Fast Moon - 11-20-2022, 08:30 PM
RE: Antinomia: FF6 - by C-Dude - 11-20-2022, 08:53 PM
RE: Antinomia: FF6 - by Fast Moon - 11-20-2022, 09:18 PM
RE: Antinomia: FF6 - by Fast Moon - 11-22-2022, 08:59 PM
RE: Antinomia: FF6 - by PowerPanda - 11-23-2022, 12:37 AM
RE: Antinomia: FF6 - by Fast Moon - 11-23-2022, 06:46 PM
RE: Antinomia: FF6 - by casualtom - 11-24-2022, 02:29 AM
RE: Antinomia: FF6 - by PowerPanda - 11-24-2022, 07:19 PM
RE: Antinomia: FF6 - by Fast Moon - 01-14-2023, 09:51 PM
RE: Antinomia: FF6 - by Fast Moon - 01-20-2023, 07:21 PM
RE: Antinomia: FF6 - by Fast Moon - 01-27-2023, 08:59 PM
RE: Antinomia: FF6 - by Fast Moon - 02-12-2023, 10:39 PM
RE: Antinomia: FF6 - by Fast Moon - 02-15-2023, 10:02 PM
RE: Antinomia: FF6 - by Fast Moon - 02-23-2023, 09:41 PM
RE: Antinomia: FF6 - by Fast Moon - 02-27-2023, 10:25 PM
RE: Antinomia: FF6 - by Fast Moon - 03-04-2023, 07:16 PM
RE: Antinomia: FF6 - by Fast Moon - 03-15-2023, 06:40 PM
RE: Antinomia: FF6 - by Fast Moon - 03-29-2023, 07:06 PM
RE: Antinomia: FF6 - by PowerPanda - 03-30-2023, 09:55 AM
RE: Antinomia: FF6 - by Fast Moon - 03-30-2023, 04:44 PM
RE: Antinomia: FF6 - by C-Dude - 03-30-2023, 07:47 PM
RE: Antinomia: FF6 - by PowerPanda - 03-31-2023, 10:04 AM
RE: Antinomia: FF6 - by Fast Moon - 04-01-2023, 07:27 PM
RE: Antinomia: FF6 - by Fast Moon - 04-11-2023, 09:05 PM
RE: Antinomia: FF6 - by Fast Moon - 04-15-2023, 06:46 PM
RE: Antinomia: FF6 - by C-Dude - 04-15-2023, 07:32 PM
RE: Antinomia: FF6 - by Fast Moon - 04-15-2023, 09:32 PM
RE: Antinomia: FF6 - by Fast Moon - 04-22-2023, 08:24 PM
RE: Antinomia: FF6 - by LockeColeFF - 04-28-2023, 01:32 PM
RE: Antinomia: FF6 - by Fast Moon - 04-29-2023, 08:20 PM
RE: Antinomia: FF6 - by Fast Moon - 05-03-2023, 06:35 PM
RE: Antinomia: FF6 - by Fast Moon - 05-06-2023, 08:17 AM
RE: Antinomia: FF6 - by Fast Moon - 05-08-2023, 01:30 AM
RE: Antinomia: FF6 - by CrumpledMedal - 05-09-2023, 07:56 PM
RE: Antinomia: FF6 - by Fast Moon - 05-09-2023, 09:53 PM
RE: Antinomia: FF6 - by CrumpledMedal - 05-09-2023, 10:59 PM
RE: Antinomia: FF6 - by Fast Moon - 05-13-2023, 02:51 PM
RE: Antinomia: FF6 - by Fast Moon - 05-22-2023, 10:41 PM
RE: Antinomia: FF6 - by Fast Moon - 05-27-2023, 07:48 PM
RE: Antinomia: FF6 - by PowerPanda - 05-30-2023, 01:01 PM
RE: Antinomia: FF6 - by Fast Moon - 05-30-2023, 06:22 PM
RE: Antinomia: FF6 - by Fast Moon - 06-03-2023, 12:39 PM
RE: Antinomia: FF6 - by Fast Moon - 07-22-2023, 05:09 PM

Forum Jump:

Users browsing this thread: 2 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite