Skip to content

Commit

Permalink
Fix combat-art list
Browse files Browse the repository at this point in the history
  • Loading branch information
MokhaLeee committed Jan 2, 2025
1 parent ff53e75 commit 12cc141
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
1 change: 1 addition & 0 deletions Wizardry/Common/KernelLib/KernelLib.event
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Source/mapanim.lyn.event"
#include "Source/pad.lyn.event"
#include "Source/utf8.lyn.event"
#include "Source/wexp.lyn.event"
//#include "Source/UnitList.lyn.event"
// #include "data.event"

Expand Down
23 changes: 23 additions & 0 deletions Wizardry/Common/KernelLib/Source/wexp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <common-chax.h>
#include <kernel-lib.h>

int WRankToWExp(int wrank)
{
static const u8 wrank_to_exp_ref[] = {
[WPN_LEVEL_0] = WPN_EXP_0,
[WPN_LEVEL_E] = WPN_EXP_E,
[WPN_LEVEL_D] = WPN_EXP_D,
[WPN_LEVEL_C] = WPN_EXP_C,
[WPN_LEVEL_B] = WPN_EXP_B,
[WPN_LEVEL_A] = WPN_EXP_A,
[WPN_LEVEL_S] = WPN_EXP_S,
};

switch (wrank) {
case WPN_LEVEL_0 ... WPN_LEVEL_S:
return wrank_to_exp_ref[wrank];

default:
return WPN_EXP_S;
}
}
21 changes: 12 additions & 9 deletions Wizardry/Core/CombatArt/Source/CombatArtList.c
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
#include "common-chax.h"
#include "skill-system.h"
#include "combat-art.h"
#include "kernel-lib.h"
#include "constants/combat-arts.h"

extern struct CombatArtList sCombatArtList;

STATIC_DECLAR void CalcCombatArtListExt(struct Unit *unit, int item)
void CalcCombatArtListExt(struct Unit *unit, int item)
{
int i;
u8 cid;
int wtype = GetItemType(item);
u8 pid = UNIT_CHAR_ID(unit);
u8 jid = UNIT_CLASS_ID(unit);
u8 *tmp_list = gGenericBuffer;
struct SkillList *slist = GetUnitSkillList(unit);

CpuFill16(0, tmp_list, 0x100);

/* Skill table */
for (i = 1; i < MAX_SKILL_NUM; i++) {
cid = gpCombatArtSkillTable[i];
if (slist) {
for (i = 0; i < slist->amt; i++) {
cid = gpCombatArtSkillTable[slist->sid[i]];

if (COMBART_VALID(cid))
if (SkillTester(unit, i))
if (COMBART_VALID(cid))
tmp_list[cid] = true;
}
}

/* Weapon table */
Expand All @@ -32,7 +35,7 @@ STATIC_DECLAR void CalcCombatArtListExt(struct Unit *unit, int item)

/* ROM table */
for (i = WPN_LEVEL_E; i <= WPN_LEVEL_S; i++) {
if (unit->ranks[ITYPE_SWORD] >= i) {
if (unit->ranks[ITYPE_SWORD] >= WRankToWExp(i)) {
cid = gpCombatArtDefaultTable->cid_sword[i];
if (COMBART_VALID(cid))
tmp_list[cid] = true;
Expand All @@ -46,7 +49,7 @@ STATIC_DECLAR void CalcCombatArtListExt(struct Unit *unit, int item)
tmp_list[cid] = true;
}

if (unit->ranks[ITYPE_LANCE] >= i) {
if (unit->ranks[ITYPE_LANCE] >= WRankToWExp(i)) {
cid = gpCombatArtDefaultTable->cid_lance[i];
if (COMBART_VALID(cid))
tmp_list[cid] = true;
Expand All @@ -60,7 +63,7 @@ STATIC_DECLAR void CalcCombatArtListExt(struct Unit *unit, int item)
tmp_list[cid] = true;
}

if (unit->ranks[ITYPE_AXE] >= i) {
if (unit->ranks[ITYPE_AXE] >= WRankToWExp(i)) {
cid = gpCombatArtDefaultTable->cid_axe[i];
if (COMBART_VALID(cid))
tmp_list[cid] = true;
Expand All @@ -74,7 +77,7 @@ STATIC_DECLAR void CalcCombatArtListExt(struct Unit *unit, int item)
tmp_list[cid] = true;
}

if (unit->ranks[ITYPE_BOW] >= i) {
if (unit->ranks[ITYPE_BOW] >= WRankToWExp(i)) {
cid = gpCombatArtDefaultTable->cid_bow[i];
if (COMBART_VALID(cid))
tmp_list[cid] = true;
Expand Down
7 changes: 6 additions & 1 deletion include/kernel-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void MapAnim_CommonEnd(void);
u32 k_udiv(u32 a, u32 b);
u32 k_umod(u32 a, u32 b);

static inline u32 perc_of(u32 num, u32 perc)
static inline u32 perc_of(u32 num, u32 perc)
{
return k_udiv(num * perc, 100);
}
Expand Down Expand Up @@ -160,6 +160,11 @@ char *Utf8ToNarrowFonts(char *str);
char NarrowFontsUtf8ToAscii(const char *str);
char NarrowFontsUnicodeToAscii(u32 unicod);

/**
* wexp.c
*/
int WRankToWExp(int wrank);

/**
* Misc
*/
Expand Down

0 comments on commit 12cc141

Please sign in to comment.