Skip to content

Commit

Permalink
in progress commit for treasure chests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie-A committed Oct 9, 2024
1 parent 95c3247 commit c05309d
Show file tree
Hide file tree
Showing 17 changed files with 692 additions and 591 deletions.
13 changes: 12 additions & 1 deletion worlds/ff4fe/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,16 @@ async def received_items_check(self, ctx: SNIContext):
ctx.location_names[item_received.location]))
return
if item_received.player == ctx.slot and item_received.location >= 0:
if item_received_name in items.sellable_item_names and item_received.location >= 0:
if item_received_game_data.tier <= junk_tier_data[0]:
snes_logger.info(f"{item_received_name} automatically converted to GP per junk settings.")
if "Monster in a Box" not in item_received_location_name:
self.increment_items_received(ctx, items_received_amount)
return
if item_received_name in items.sellable_item_names and item_received.location >= 0:
if item_received_game_data.tier <= junk_tier_data[0]:
time_is_money = False if time_is_money_data[0] != 0 else True
item_price = min(item_received_game_data.price // 2, 63500 if not time_is_money else 0)
item_price = min(item_received_game_data.price // 2, 127000 if not time_is_money else 0)
current_gp_data = await snes_read(ctx, Rom.gp_byte_location, Rom.gp_byte_size)
if current_gp_data is None:
return
Expand Down Expand Up @@ -293,6 +296,13 @@ async def received_items_check(self, ctx: SNIContext):

async def check_victory(self, ctx):
from SNIClient import snes_buffered_write, snes_read
for sentinel in Rom.sentinel_addresses: # Defend against RAM initialized to 0xFF everywhere.
sentinel_data = await snes_read(ctx, sentinel, 1)
if sentinel_data is None:
return
sentinel_value = sentinel_data[0]
if sentinel_value == 0xFF:
return
victory_data = await snes_read(ctx, Rom.victory_byte_location, 1)
if victory_data is None:
return
Expand Down Expand Up @@ -322,6 +332,7 @@ async def resolve_key_items(self, ctx):
return
hook_received_value = key_item_received_data[0]
hook_received_value = hook_received_value | flag_bit
hook_received_value = hook_received_value & Rom.airship_flyable_flag[1]
snes_buffered_write(ctx, flag_byte, bytes([hook_received_value]))
elif key_items_flag_byte is None:
flag_bit = Rom.special_flag_key_items[key_item][1]
Expand Down
7 changes: 7 additions & 0 deletions worlds/ff4fe/FreeEnterpriseForAP/FreeEnt/core_rando.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,15 @@ def apply(env):
placement = None
if placement is None:
reward = ItemReward("#item.Cure1")
env.add_toggle(f"ap_{slot.name}")
else:
reward = ItemReward(placement.const)
script_text = env.meta["text_pointers"].pop()
bank = int(script_text[10], 16)
pointer = script_text[20:24]
pointer = pointer[1:] if pointer[3] != ")" else pointer[1:3]
env.add_script(f"consts(ap_reward_slot) {{${pointer} {slot.name}}} ")
env.add_script(f'{script_text} {{Found {ap_item["player_name"]}\'s \n{ap_item["item_name"]}. }}')
rewards_assignment[slot] = reward
found_valid_assignment = True
elif env.options.flags.has('key_items_vanilla'):
Expand Down
4 changes: 4 additions & 0 deletions worlds/ff4fe/FreeEnterpriseForAP/FreeEnt/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
scripts/extra_item_descriptions.f4c
scripts/stats.f4c
scripts/level_up_summary.f4c
scripts/treasure_ap.f4c
scripts/treasure_discard.f4c
scripts/config_init.f4c
scripts/shadow_party.f4c
Expand Down Expand Up @@ -557,6 +558,9 @@ def build(romfile, options, force_recompile=False):

formatted_flags = (env.options.flags.to_string(pretty=True, wrap_width=68).replace('\n', '\n '))

from .text_banks import text_pointer_list
env.meta["text_pointers"] = text_pointer_list

env.spoilers.add_raw(
f"VERSION: {env.options.get_version_str()}",
'',
Expand Down
5 changes: 5 additions & 0 deletions worlds/ff4fe/FreeEnterpriseForAP/FreeEnt/scripts/antlion.f4c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ event($45) //Antlion battle
player bow head
pause 4
player wave in
// %if ap_antlion_item%
music #DummyFanfare
message #ap_reward_slot.antlion_item
// %else%
[#B #Text_LoadRewardNameFromSlot #reward_slot.antlion_item 0]
message #msg.fe_ReceivedFanfare
// %end%
[#B #Objectives_TickRewardSlot #reward_slot.antlion_item]
[#B #Rando_DeliverRewardFromSlot #reward_slot.antlion_item]

Expand Down
9 changes: 6 additions & 3 deletions worlds/ff4fe/FreeEnterpriseForAP/FreeEnt/scripts/fabul.f4c
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,13 @@ event($48) //Fabul battle
p #FabulKing face left
pause 4
map message 1 // take this
// %if ap_fabul_item%
music #DummyFanfare
message #ap_reward_slot.fabul_item
// %else%
[#B #Text_LoadRewardNameFromSlot #reward_slot.fabul_item 0]
sound #GetItem
message #msg.fe_Received

message #msg.fe_ReceivedFanfare
// %end%
[#B #Objectives_TickRewardSlot #reward_slot.fabul_item]
[#B #Rando_DeliverRewardFromSlot #reward_slot.fabul_item]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,14 @@ event($62) //Cecil's transformation, Tellah remembering
p #MirrorParty face up
}

// %if ap_ordeals_item%
music #DummyFanfare
message #ap_reward_slot.ordeals_item
// %else%
[#B #Text_LoadRewardNameFromSlot #reward_slot.ordeals_item 0]
sound #GetItem
message #msg.fe_Received
// %end%
[#B #Objectives_TickRewardSlot #reward_slot.ordeals_item]
[#B #Rando_DeliverRewardFromSlot #reward_slot.ordeals_item]

Expand Down
6 changes: 5 additions & 1 deletion worlds/ff4fe/FreeEnterpriseForAP/FreeEnt/scripts/opening.f4c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ event($10) //Opening events
}
pause 2
message $1D // From the king
// %if ap_starting_item%
message #ap_reward_slot.starting_item
// %else%
[#B #Text_LoadRewardNameFromSlot #reward_slot.starting_item 0]
sound #GetItem
message #msg.fe_Received
// %end%
sound #GetItem
[#B #Objectives_TickRewardSlot #reward_slot.starting_item]
[#B #Rando_DeliverRewardFromSlot #reward_slot.starting_item]

Expand Down
64 changes: 64 additions & 0 deletions worlds/ff4fe/FreeEnterpriseForAP/FreeEnt/scripts/treasure_ap.f4c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
msfpatch {
.addr $009788
jml $=TreasureAP__GetDialog
nop
nop
}

msfpatch {
TreasureAP__GetDialog:
lda $08FC // load treasure index into x
stz $07
sta $06
rep #$20
lda $06
asl a
adc $06
tax
sep #$20
lda $348000,x // load bank into bank byte
sta $06DD
lda $348001,x // load dialog index into event bytes
sta $06B2
lda $348002,x // load dialog index into event bytes
sta $06B3

lda $06B2
stz $0773
asl a
rol $0773
sta $0772
ldx $0772

lda $06DD
cmp #$01
beq $+Bank1
lda $13A500, x
sta $063D
lda $13A501, x
sta $063E
bra $+Finish
%Bank1:
lda $06B3
cmp #$01
beq $+HiBank
lda $108000, x
sta $063D
lda $108001, x
sta $063E
bra $+Finish
%HiBank:
lda $108080
sta $063D
lda $108081
sta $063E
%Finish:
ldx $063D
stx $0772 // might be longcall vars instead

lda #$0000
ldy #$B0D1
jsl $=LongCall // displaced code

jml $00978C // pray it works
}
Loading

0 comments on commit c05309d

Please sign in to comment.