Skip to content

Commit cfa4204

Browse files
committed
TSA: th185 spellcard patching
1 parent 6a6cfde commit cfa4204

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

thcrap_tsa/src/spells.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,42 @@ int BP_spell_owner(x86_reg_t *regs, json_t *bp_info)
142142
return 1;
143143
}
144144

145+
char th185_spell_id[8] = {};
146+
147+
int BP_th185_spell_id(x86_reg_t* regs, json_t* bp_info) {
148+
*th185_spell_id = 0;
149+
const char* sub_name = (char*)json_object_get_immediate(bp_info, regs, "sub_name");
150+
if (strcmp(sub_name, "Boss01tBossCard1") == 0) {
151+
strcpy(th185_spell_id, "0_1");
152+
return breakpoint_cave_exec_flag(bp_info);
153+
}
154+
if (strlen(sub_name) != 15
155+
|| strncmp(sub_name, "Boss", 4)
156+
|| strncmp(sub_name + 6, "BossCard", 8)
157+
|| sub_name[4] > '9' || sub_name[4] < '0'
158+
|| sub_name[5] > '9' || sub_name[5] < '0'
159+
|| sub_name[14] > '9' || sub_name[14] < '0') {
160+
return breakpoint_cave_exec_flag(bp_info);
161+
}
162+
char* p = th185_spell_id;
163+
if (sub_name[4] > '0')
164+
*p++ = sub_name[4];
165+
*p++ = sub_name[5];
166+
*p++ = '_';
167+
*p++ = sub_name[14];
168+
return breakpoint_cave_exec_flag(bp_info);
169+
}
170+
171+
int BP_th185_spell_name(x86_reg_t* regs, json_t* bp_info) {
172+
if (*th185_spell_id) {
173+
json_t* spell_name = json_object_get(jsondata_game_get("spells.js"), th185_spell_id);
174+
if (json_is_string(spell_name))
175+
*json_object_get_pointer(bp_info, regs, "spell_name") = (size_t)json_string_value(spell_name);
176+
*th185_spell_id = 0;
177+
}
178+
return breakpoint_cave_exec_flag(bp_info);
179+
}
180+
145181
void spells_mod_init(void)
146182
{
147183
jsondata_game_add("spells.js");

thcrap_tsa/thcrap_tsa.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ EXPORTS
5252
BP_spell_name
5353
BP_spell_comment_line
5454
BP_spell_owner
55+
BP_th185_spell_id
56+
BP_th185_spell_name
5557
spells_mod_init
5658

5759
; Dialog

0 commit comments

Comments
 (0)