Users browsing this thread: 1 Guest(s)
Final Requests for Help

#40
Posts: 51
Threads: 5
Thanks Received: 2
Thanks Given: 0
Joined: Apr 2018
Reputation: 8
Status
Shell
Okay, I have some code to make tools randomly break:

Code:
hirom

org $C1FFE5  ;  freespace
check_command:
CMP #$09
BEQ check_command_end
CMP #$01
BEQ check_command_end
CMP #$08
check_command_end:
RTS

org $C1710F
JSR check_command
NOP
NOP
NOP

org $C21887
JSR check_break
NOP

org $C24DA7
JSR check_command_c2
NOP
NOP
NOP

org $C26469  ;  freespace
check_command_c2:
CMP #$09
BEQ check_command_c2_end
CMP #$01
BEQ check_command_c2_end
CMP #$08
check_command_c2_end:
RTS

check_break:
PHA
PHP
JSR $2B63      ;  Multiply A by 30, size of item data block
REP #$10       ;  Set 16-bit X and Y
TAX
LDA $D85012,X  ;  equipment spell byte.  Bit 7: 1 = remove from inventory upon usage, 0 = nope
BPL no_break   ;  if the flag is not set, this tool never breaks
JSR $4B5A
AND #$1F       ;  1/32 chance of breaking
BNE no_break
LDA #$44       ;  "Orge Nix broke!" dialog. Works for most tools but gets clobbered by the Air Anchor "Move and you're dust!"
STA $3401      
SEP #$10       ;  Set 8-bit X and Y
TYX
LDA #$FF
STA $32F4,X    ;  null item index to add to inventory. This means the item will stay deducted from your inventory.
LDA $3018,X
BRA check_break_end

no_break:
LDA #$10
TSB $B1        ;  set flag to re-add item to inventory at the end of the character's turn
check_break_end:
TSB $3A8C      ;  flag character to have any applicable item in $32F4,X added back to inventory when turn is over.
PLP
PLA
SBC #$A2       ;  carry was clear, so subtract 163
STA $B6        ;  save unique Tool index.  0 = NoiseBlaster, 1 = Bio Blaster, etc.
RTS

Notes:
1. You have to set the "destroy if used" bit on all of the tools you want to have a chance to break.
2. When tools are used, they will temporarily be removed from the inventory, then added back after the character's turn if they didn't break.
3. When a tool breaks, it displays the "Ogre Nix broke!" message. You probably want to edit that message to be more generic or add a new one.
4. If the Air Anchor breaks, the "Move and you're dust!" message clobbers the break message.
  Find
Quote  
[-] The following 3 users say Thank You to Subtraction for this post:
  • C-Dude (07-08-2021), Gi Nattak (06-06-2021), PowerPanda (05-08-2021)



Messages In This Thread
Final Requests for Help - by PowerPanda - 04-05-2021, 11:28 PM
RE: Final Requests for Help - by Subtraction - 04-05-2021, 11:44 PM
RE: Final Requests for Help - by seibaby - 04-06-2021, 07:24 AM
RE: Final Requests for Help - by PowerPanda - 04-06-2021, 09:36 PM
RE: Final Requests for Help - by madsiur - 04-06-2021, 09:56 PM
RE: Final Requests for Help - by Lightning - 04-06-2021, 10:55 AM
RE: Final Requests for Help - by madsiur - 04-06-2021, 08:35 PM
RE: Final Requests for Help - by PowerPanda - 04-06-2021, 10:28 PM
RE: Final Requests for Help - by C-Dude - 04-07-2021, 12:04 AM
RE: Final Requests for Help - by Drakkhen - 04-07-2021, 12:11 AM
RE: Final Requests for Help - by PowerPanda - 04-07-2021, 10:40 AM
RE: Final Requests for Help - by assassin - 04-07-2021, 10:17 AM
RE: Final Requests for Help - by Drakkhen - 04-07-2021, 11:03 AM
RE: Final Requests for Help - by assassin - 04-07-2021, 01:36 PM
RE: Final Requests for Help - by assassin - 04-07-2021, 09:15 PM
RE: Final Requests for Help - by PowerPanda - 04-07-2021, 06:02 PM
RE: Final Requests for Help - by assassin - 04-07-2021, 08:15 PM
RE: Final Requests for Help - by PowerPanda - 04-07-2021, 08:49 PM
RE: Final Requests for Help - by PowerPanda - 04-07-2021, 10:48 PM
RE: Final Requests for Help - by C-Dude - 04-08-2021, 01:49 PM
RE: Final Requests for Help - by PowerPanda - 04-08-2021, 04:51 PM
RE: Final Requests for Help - by C-Dude - 04-08-2021, 11:06 PM
RE: Final Requests for Help - by PowerPanda - 04-08-2021, 11:53 PM
RE: Final Requests for Help - by C-Dude - 04-16-2021, 10:32 PM
RE: Final Requests for Help - by PowerPanda - 04-11-2021, 02:17 PM
RE: Final Requests for Help - by Everything - 04-11-2021, 03:05 PM
RE: Final Requests for Help - by PowerPanda - 04-11-2021, 04:13 PM
RE: Final Requests for Help - by Everything - 04-11-2021, 06:15 PM
RE: Final Requests for Help - by Drakkhen - 04-11-2021, 06:23 PM
RE: Final Requests for Help - by Warrax - 04-12-2021, 03:17 AM
RE: Final Requests for Help - by PowerPanda - 04-11-2021, 08:21 PM
RE: Final Requests for Help - by PowerPanda - 04-18-2021, 01:42 PM
RE: Final Requests for Help - by madsiur - 04-18-2021, 07:34 PM
RE: Final Requests for Help - by PowerPanda - 05-06-2021, 05:27 PM
RE: Final Requests for Help - by SirNewtonFig - 05-06-2021, 08:49 PM
RE: Final Requests for Help - by Lightning - 05-07-2021, 11:19 AM
RE: Final Requests for Help - by SirNewtonFig - 05-07-2021, 01:55 PM
RE: Final Requests for Help - by Lightning - 05-07-2021, 02:51 PM
RE: Final Requests for Help - by SirNewtonFig - 05-09-2021, 08:13 PM
RE: Final Requests for Help - by PowerPanda - 05-07-2021, 06:00 PM
RE: Final Requests for Help - by Subtraction - 05-08-2021, 09:45 AM
RE: Final Requests for Help - by PowerPanda - 05-08-2021, 10:56 AM
RE: Final Requests for Help - by Lightning - 05-10-2021, 01:02 AM
RE: Final Requests for Help - by Subtraction - 05-11-2021, 08:08 AM
RE: Final Requests for Help - by PowerPanda - 05-11-2021, 10:02 AM
RE: Final Requests for Help - by PowerPanda - 05-09-2021, 10:46 PM
RE: Final Requests for Help - by MysticLord - 05-10-2021, 01:36 AM
RE: Final Requests for Help - by PowerPanda - 05-10-2021, 10:05 AM
RE: Final Requests for Help - by MysticLord - 05-10-2021, 05:54 PM
RE: Final Requests for Help - by PowerPanda - 05-10-2021, 09:30 PM
RE: Final Requests for Help - by Subtraction - 05-11-2021, 11:10 PM
RE: Final Requests for Help - by PowerPanda - 05-14-2021, 12:41 PM
RE: Final Requests for Help - by Subtraction - 05-14-2021, 11:59 PM
RE: Final Requests for Help - by Slowmo - 05-15-2021, 11:18 AM
RE: Final Requests for Help - by MysticLord - 05-15-2021, 11:36 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite