Skip to content

Commit

Permalink
Merge pull request #373 from cbt6/npc-trade
Browse files Browse the repository at this point in the history
Document npc_trade.c
  • Loading branch information
lhearachel authored Feb 13, 2025
2 parents d634ed4 + 809b571 commit 3d96bfb
Show file tree
Hide file tree
Showing 34 changed files with 453 additions and 308 deletions.
15 changes: 8 additions & 7 deletions asm/macros/scrcmd.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "generated/journal_online_events.h"
#include "generated/map_headers.h"
#include "generated/moves.h"
#include "generated/npc_trades.h"
#include "generated/poketch_apps.h"
#include "generated/save_types.h"
#include "generated/sdat.h"
Expand Down Expand Up @@ -2967,27 +2968,27 @@
.short \arg0
.endm

.macro ScrCmd_226 arg0
.macro StartNpcTrade npcTradeID
.short 550
.byte \arg0
.byte \npcTradeID
.endm

.macro ScrCmd_227 arg0
.macro GetNpcTradeSpecies destVar
.short 551
.short \arg0
.short \destVar
.endm

.macro ScrCmd_228 arg0
.macro GetNpcTradeRequestedSpecies destVar
.short 552
.short \arg0
.short \destVar
.endm

.macro ScrCmd_229 arg0
.short 553
.short \arg0
.endm

.macro ScrCmd_22A
.macro FinishNpcTrade
.short 554
.endm

Expand Down
2 changes: 2 additions & 0 deletions generated/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ metang_generators = {
'move_ranges': { 'type': 'mask', 'tag': 'MoveRange', 'extra': ['--no-auto'] },
'movement_actions': { 'type': 'enum', 'tag': 'MovementAction' },
'moves': { 'type': 'enum', 'tag': 'Move' },
'npc_trades': { 'type': 'enum', 'tag': 'NpcTradeID' },
'pal_park_land_area': { 'type': 'enum', 'tag': 'PalParkLandArea' },
'pal_park_water_area': { 'type': 'enum', 'tag': 'PalParkWaterArea' },
'pokemon_body_shapes': { 'type': 'enum', 'tag': 'PokemonBodyShape' },
Expand Down Expand Up @@ -116,6 +117,7 @@ foreach gen_key : metang_generators.keys()
)
endforeach

npc_trades_txt = files('npc_trades.txt')
species_txt = files('species.txt')
text_banks_txt = files('text_banks.txt')
trainers_txt = files('trainers.txt')
Expand Down
5 changes: 5 additions & 0 deletions generated/npc_trades.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NPC_TRADE_KAZZA_ABRA
NPC_TRADE_CHARAP_CHATOT
NPC_TRADE_GASPAR_HAUNTER
NPC_TRADE_FOOPA_MAGIKARP
MAX_NPC_TRADES
2 changes: 1 addition & 1 deletion generated/text_banks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ TEXT_BANK_JOURNAL_ENTRIES
TEXT_BANK_UNK_0367
TEXT_BANK_BATTLE_STRINGS
TEXT_BANK_UNK_0369
TEXT_BANK_UNK_0370
TEXT_BANK_NPC_TRADE_NAMES
TEXT_BANK_FURNITURE_NAMES
TEXT_BANK_UNK_0372
TEXT_BANK_UNK_0373
Expand Down
47 changes: 47 additions & 0 deletions include/overlay006/npc_trade.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef POKEPLATINUM_NPC_TRADE_H
#define POKEPLATINUM_NPC_TRADE_H

#include "field/field_system_decl.h"
#include "overlay006/struct_ov6_02246254.h"

#include "pokemon.h"

typedef struct NpcTradeMon {
u32 species;
u32 hpIV;
u32 atkIV;
u32 defIV;
u32 speedIV;
u32 spAtkIV;
u32 spDefIV;
u32 unused1;
u32 otID;
u32 cool;
u32 beauty;
u32 cute;
u32 smart;
u32 tough;
u32 personality;
u32 heldItem;
u32 otGender;
u32 unused2;
u32 language;
u32 requestedSpecies;
} NpcTradeMon;

typedef struct NpcTradeData {
NpcTradeMon *npcTradeMon;
Pokemon *mon;
TrainerInfo *trainerInfo;
u32 npcTradeID;
u32 heapID;
} NpcTradeData;

NpcTradeData *NpcTrade_Init(u32 heapID, u32 entryID);
void NpcTrade_Free(NpcTradeData *data);
u32 NpcTrade_GetSpecies(const NpcTradeData *data);
u32 NpcTrade_GetRequestedSpecies(const NpcTradeData *data);
void NpcTrade_ReceiveMon(FieldSystem *fieldSystem, NpcTradeData *data, int slot);
void ov6_02246254(FieldSystem *fieldSystem, NpcTradeData *data, int slot, UnkStruct_ov6_02246254 *param3, Pokemon *givingMon, Pokemon *receivingMon);

#endif // POKEPLATINUM_NPC_TRADE_H
17 changes: 0 additions & 17 deletions include/overlay006/ov6_02246184.h

This file was deleted.

6 changes: 0 additions & 6 deletions include/overlay006/struct_ov6_02246204_decl.h

This file was deleted.

4 changes: 2 additions & 2 deletions include/unk_0206C660.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef POKEPLATINUM_UNK_0206C660_H
#define POKEPLATINUM_UNK_0206C660_H

#include "overlay006/struct_ov6_02246204_decl.h"
#include "overlay006/npc_trade.h"

#include "field_task.h"

void sub_0206C740(FieldTask *param0, UnkStruct_ov6_02246204 *param1, int param2, u32 param3);
void sub_0206C740(FieldTask *param0, NpcTradeData *data, int param2, u32 param3);

#endif // POKEPLATINUM_UNK_0206C660_H
2 changes: 1 addition & 1 deletion platinum.us/filesys.sha1
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ ecdb14e0bc6619f114549e6126c8b6934cfc3aeb *res/prebuilt/battle/b_pl_stage/pl_bsdp
cec363028fa6bc6240f9c8da7ab8f9e8bb1b1465 *res/prebuilt/contest/graphic/contest_obj.narc
7fa87d90ba039f67221a43782bf6a1a1107d5947 *res/prebuilt/demo/title/op_demo.narc
d7e86fadf59a54f922fc7cf65ae65fa326b8429e *res/prebuilt/demo/title/titledemo.narc
32a0989a18cc7f3eb17c5949adecb3f057a84eea *res/prebuilt/fielddata/pokemon_trade/fld_trade.narc
32a0989a18cc7f3eb17c5949adecb3f057a84eea *res/field/trades/fld_trade.narc
d4b6f9731b808a613338005f59959325ce1e3ac9 *res/prebuilt/resource/eng/zukan/zukan.narc
7e85af57b27fa4a0829b24550fc6c0dd275cf994 *res/prebuilt/resource/eng/batt_rec/batt_rec_gra.narc
2994f2955035001a22a1f225c68bfa809e4c85bf *res/prebuilt/resource/eng/wifi_lobby_minigame/wlmngm_tool.narc
Expand Down
2 changes: 1 addition & 1 deletion platinum.us/main.lsf
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ Overlay overlay6
Object main.nef.p/src_overlay006_swarm.c.o
Object main.nef.p/src_overlay006_ov6_02243258.c.o
Object main.nef.p/src_overlay006_roamer_after_battle.c.o
Object main.nef.p/src_overlay006_ov6_02246184.c.o
Object main.nef.p/src_overlay006_npc_trade.c.o
Object main.nef.p/src_overlay006_ov6_02246444.c.o
Object main.nef.p/src_overlay006_ov6_022465FC.c.o
Object main.nef.p/src_overlay006_ov6_02246A30.c.o
Expand Down
9 changes: 8 additions & 1 deletion platinum.us/rom.rsf
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,14 @@ RomSpec
File contest/graphic/contest_obj.narc
File demo/title/op_demo.narc
File demo/title/titledemo.narc
File fielddata/pokemon_trade/fld_trade.narc

Root /fielddata/pokemon_trade
HostRoot res/field/trades
File fld_trade.narc

Root /
HostRoot res/prebuilt

File resource/eng/zukan/zukan.narc
File resource/eng/batt_rec/batt_rec_gra.narc
File resource/eng/wifi_lobby_minigame/wlmngm_tool.narc
Expand Down
1 change: 1 addition & 0 deletions res/field/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
subdir('encounters')
subdir('events')
subdir('scripts')
subdir('trades')
8 changes: 4 additions & 4 deletions res/field/scripts/scripts_eterna_city_condominiums_1f.s
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ _0168:
FadeScreen 6, 1, 1, 0
WaitFadeScreen
GoToIfEq 0x800C, 0xFF, _01D9
ScrCmd_226 1
StartNpcTrade NPC_TRADE_CHARAP_CHATOT
SetVar 0x8004, 0x800C
ScrCmd_198 0x8004, 0x8005
ScrCmd_228 0x800C
GetNpcTradeRequestedSpecies 0x800C
GoToIfNe 0x8005, 0x800C, _01CC
ScrCmd_229 0x8004
ScrCmd_22A
FinishNpcTrade
SetFlag 134
Message 10
WaitABXPadPress
Expand All @@ -128,7 +128,7 @@ _0168:
End

_01CC:
ScrCmd_22A
FinishNpcTrade
Message 11
WaitABXPadPress
CloseMessage
Expand Down
8 changes: 4 additions & 4 deletions res/field/scripts/scripts_oreburgh_city_north_house_1f.s
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ _003B:
FadeScreen 6, 1, 1, 0
WaitFadeScreen
GoToIfEq 0x800C, 0xFF, _00AC
ScrCmd_226 0
StartNpcTrade NPC_TRADE_KAZZA_ABRA
SetVar 0x8004, 0x800C
ScrCmd_198 0x8004, 0x8005
ScrCmd_228 0x800C
GetNpcTradeRequestedSpecies 0x800C
GoToIfNe 0x8005, 0x800C, _009F
ScrCmd_229 0x8004
ScrCmd_22A
FinishNpcTrade
SetFlag 133
Message 1
WaitABXPadPress
Expand All @@ -43,7 +43,7 @@ _003B:
End

_009F:
ScrCmd_22A
FinishNpcTrade
Message 2
WaitABXPadPress
CloseMessage
Expand Down
8 changes: 4 additions & 4 deletions res/field/scripts/scripts_route_226_house.s
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ _0060:
FadeScreen 6, 1, 1, 0
WaitFadeScreen
GoToIfEq 0x800C, 0xFF, _00D1
ScrCmd_226 3
StartNpcTrade NPC_TRADE_FOOPA_MAGIKARP
SetVar 0x8004, 0x800C
ScrCmd_198 0x8004, 0x8005
ScrCmd_228 0x800C
GetNpcTradeRequestedSpecies 0x800C
GoToIfNe 0x8005, 0x800C, _00C4
ScrCmd_229 0x8004
ScrCmd_22A
FinishNpcTrade
SetFlag 245
Message 3
WaitABXPadPress
Expand All @@ -58,7 +58,7 @@ _0060:
End

_00C4:
ScrCmd_22A
FinishNpcTrade
Message 4
WaitABXPadPress
CloseMessage
Expand Down
8 changes: 4 additions & 4 deletions res/field/scripts/scripts_snowpoint_city_west_house.s
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ _0060:
FadeScreen 6, 1, 1, 0
WaitFadeScreen
GoToIfEq 0x800C, 0xFF, _00D1
ScrCmd_226 2
StartNpcTrade NPC_TRADE_GASPAR_HAUNTER
SetVar 0x8004, 0x800C
ScrCmd_198 0x8004, 0x8005
ScrCmd_228 0x800C
GetNpcTradeRequestedSpecies 0x800C
GoToIfNe 0x8005, 0x800C, _00C4
ScrCmd_229 0x8004
ScrCmd_22A
FinishNpcTrade
SetFlag 244
Message 3
WaitABXPadPress
Expand All @@ -60,7 +60,7 @@ _0060:
End

_00C4:
ScrCmd_22A
FinishNpcTrade
Message 4
WaitABXPadPress
CloseMessage
Expand Down
29 changes: 29 additions & 0 deletions res/field/trades/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
npc_trades_bin_gen = generator(
npc_trades_py,
arguments: [ '@INPUT@', '@OUTPUT@', ],
output: '@BASENAME@'
)

npc_trades_consts = fs.read(npc_trades_txt).splitlines()
npc_trades_files = []
foreach npc_trade: npc_trades_consts
if npc_trade.startswith('MAX_')
continue
endif
npc_trades_files += files(npc_trade.to_lower() + '.json')
endforeach

npc_trades_order = files('npc_trades.order')
npc_trades_narc = custom_target('fld_trade.narc',
output: 'fld_trade.narc',
input: npc_trades_bin_gen.process(npc_trades_files, env: json2bin_env),
depends: [ py_consts_generators ],
command: [
narc_exe, 'create',
'--order', npc_trades_order,
'--output', '@OUTPUT0@',
'@PRIVATE_DIR@',
]
)

nitrofs_files += npc_trades_narc
22 changes: 22 additions & 0 deletions res/field/trades/npc_trade_charap_chatot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"species": "SPECIES_CHATOT",
"hpIV": 15,
"atkIV": 20,
"defIV": 15,
"speedIV": 25,
"spAtkIV": 25,
"spDefIV": 15,
"unused1": 77,
"otID": 44142,
"cool": 20,
"beauty": 20,
"cute": 20,
"smart": 20,
"tough": 20,
"personality": 2151,
"heldItem": "ITEM_LEPPA_BERRY",
"otGender": "GENDER_MALE",
"unused2": 50,
"language": 2,
"requestedSpecies": "SPECIES_BUIZEL"
}
22 changes: 22 additions & 0 deletions res/field/trades/npc_trade_foopa_magikarp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"species": "SPECIES_MAGIKARP",
"hpIV": 15,
"atkIV": 25,
"defIV": 15,
"speedIV": 20,
"spAtkIV": 25,
"spDefIV": 15,
"unused1": 33,
"otID": 53277,
"cool": 0,
"beauty": 0,
"cute": 0,
"smart": 0,
"tough": 0,
"personality": 1116,
"heldItem": "ITEM_LUM_BERRY",
"otGender": "GENDER_MALE",
"unused2": 0,
"language": 5,
"requestedSpecies": "SPECIES_FINNEON"
}
Loading

0 comments on commit 3d96bfb

Please sign in to comment.