diff --git a/Data/SkillSys/SkillExtraInfo.c b/Data/SkillSys/SkillExtraInfo.c index 40933415e..15ca84d7c 100644 --- a/Data/SkillSys/SkillExtraInfo.c +++ b/Data/SkillSys/SkillExtraInfo.c @@ -4,7 +4,7 @@ const struct SkillExtraInfo gSkillExtraInfo[MAX_SKILL_NUM + 1] = { #if (defined(SID_HpBonus) && COMMON_SKILL_VALID(SID_HpBonus)) - [SID_HpBonus] = {{ 2 }}, + [SID_HpBonus] = {{ 5 }}, #endif #if (defined(SID_StrBonus) && COMMON_SKILL_VALID(SID_StrBonus)) diff --git a/Debug/Event/Source/debug-event.c b/Debug/Event/Source/debug-event.c index 4af3d76d2..35d660f08 100644 --- a/Debug/Event/Source/debug-event.c +++ b/Debug/Event/Source/debug-event.c @@ -415,8 +415,8 @@ static const EventScr EventScr_Beginning[] = { Evt_AddSkill(SID_FlierGuidance, CHARACTER_VANESSA) #endif -#if defined(SID_MovBonus) && (COMMON_SKILL_VALID(SID_MovBonus)) - Evt_AddSkill(SID_MovBonus, CHARACTER_EPHRAIM) +#if defined(SID_HpBonus) && (COMMON_SKILL_VALID(SID_HpBonus)) + Evt_AddSkill(SID_HpBonus, CHARACTER_EPHRAIM) #endif #if defined(SID_Pass) && (COMMON_SKILL_VALID(SID_Pass)) @@ -484,6 +484,9 @@ static const EventScr EventScr_Beginning[] = { SVAL(EVT_SLOT_1, 40) SET_HP(CHARACTER_VIGARDE) + SVAL(EVT_SLOT_1, 23) + SET_HP(CHARACTER_EPHRAIM) + NoFade ENDA }; diff --git a/Wizardry/Core/BattleSys/BattleHitExpasion/RepointBattleHit.event b/Wizardry/Core/BattleSys/BattleHitExpasion/RepointBattleHit.event index 72e204bf3..797d9afc8 100644 --- a/Wizardry/Core/BattleSys/BattleHitExpasion/RepointBattleHit.event +++ b/Wizardry/Core/BattleSys/BattleHitExpasion/RepointBattleHit.event @@ -1,78 +1,105 @@ PUSH + ORG $2AEC4 + #include "Source/pr_BattleHitArrayRe.lyn.event" + // PROTECT 0x0002AE90 0x0002AED0 // ClearBattleHits + ORG $2C44C #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0002C40C 0x0002C450 // GetUnitExpMultiplier // Already covered in function: GetBattleUnitStaffExp ORG $2C660 - // #include "Source/pr_BattleHitArrayRe.lyn.event" + #include "Source/pr_BattleHitArrayRe.lyn.event" + // PROTECT 0x0002C638 0x0002C6A0 // GetBattleUnitStaffExp ORG $2CB0C #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0002CAFC 0x0002CB24 // BattlePrintDebugHitInfo ORG $2CE98 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0002CE88 0x0002CE9C // BattleIsTriangleAttack ORG $2CFA8 #include "Source/pr_BattleHitArrayRe.lyn.event" - PROTECT $2CF4C $2D0BC // Port from DebuffRework/Source/MiscHooks.event + PROTECT 0x0002CF4C 0x0002D0BC // BattleUnwindScripted ORG $2F658 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0002F598 0x0002F664 // sub_802F598 ORG $2F730 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0002F664 0x0002F73C // ExecUnitPromotion ORG $2F7FC #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0002F760 0x0002F808 // sub_802F760 ORG $58244 - prBattleHitArray: #include "Source/pr_BattleHitArrayRe.lyn.event" + // PROTECT 0x000581EC 0x00058848 // ParseBattleHitToBanimCmd ORG $58930 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x00058918 0x0005893C // CheckBattleHasHit ORG $72564 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x00072548 0x00072570 // EfxCheckRetaliation ORG $7B4CC #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B464 0x0007B4D0 // SetupBattleMOVEUNITs ORG $7B574 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B4D0 0x0007B5DC // sub_807B4D0 ORG $7B628 + prBattleHitArray: #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B5DC 0x0007B634 // BeginMapAnimForPoisonDmg ORG $7B680 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B634 0x0007B68C // BeginMapAnimForEggDmg ORG $7B6D8 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B68C 0x0007B6E4 // BeginMapAnimForCritAtk ORG $7B738 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B6E4 0x0007B740 // BeginMapAnimForSteal ORG $7B790 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B740 0x0007B798 // BeginMapAnimForSummon ORG $7B7E8 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B798 0x0007B7F0 // BeginMapAnimForSummonDK ORG $7B84C #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B7F0 0x0007B854 // BeginMapAnimForDance ORG $7B8B8 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B854 0x0007B8D4 // BeginBattleMapAnims ORG $7B9B0 - #include "Source/pr_BattleHitArrayRe.lyn.event" + // #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007B900 0x0007B9B8 // SetupMapBattleAnim ORG $7C920 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x0007C8FC 0x0007CAA8 // SetupMADebugBattle ORG $A6D18 #include "Source/pr_BattleHitArrayRe.lyn.event" + PROTECT 0x000A6C8C 0x000A6D1C // ReadExtraMapInfo ORG 0x2AEB2 BattleHitArrayWidth: diff --git a/Wizardry/Core/MapTask/Source/map-task.c b/Wizardry/Core/MapTask/Source/map-task.c index b269bde6e..a09ad5817 100644 --- a/Wizardry/Core/MapTask/Source/map-task.c +++ b/Wizardry/Core/MapTask/Source/map-task.c @@ -43,9 +43,15 @@ void PutUnitSpriteIconsOam(void) * 1. HpBar */ if (unit->curHP != unit->maxHP) { + int _cur = unit->curHP; + int _max = unit->maxHP; + + if (_cur > _max) + _cur = _max; + MapTaskPutOamHi( MTSKCONF_HPBAR, - OAM2_PAL(0) + OAM2_LAYER(2) + OAM2_CHR(gpHpBarChr[Div(unit->curHP * 10, unit->maxHP)])); + OAM2_PAL(0) + OAM2_LAYER(2) + OAM2_CHR(gpHpBarChr[k_udiv(_cur * 10, _max)])); } /** diff --git a/Wizardry/Core/UnitStatusGetter/UnitStatusGetter.event b/Wizardry/Core/UnitStatusGetter/UnitStatusGetter.event index e9f8754c3..e93351589 100644 --- a/Wizardry/Core/UnitStatusGetter/UnitStatusGetter.event +++ b/Wizardry/Core/UnitStatusGetter/UnitStatusGetter.event @@ -20,7 +20,7 @@ ALIGN 4 #include "source/InjectHPGetters.event" #include "source/InjectMovGetters.event" - +#include "source/MiscHooks.lyn.event" #include "source/StatusGetterExample.lyn.event" #include "UnitMaxStatus/UnitMaxStatus.lyn.event" diff --git a/Wizardry/Core/UnitStatusGetter/source/InjectHPGetters.event b/Wizardry/Core/UnitStatusGetter/source/InjectHPGetters.event index 10169986a..01de3b03d 100644 --- a/Wizardry/Core/UnitStatusGetter/source/InjectHPGetters.event +++ b/Wizardry/Core/UnitStatusGetter/source/InjectHPGetters.event @@ -3,15 +3,6 @@ PUSH -ORG $193A4 //UnitTryHeal - SHORT $B570 $1C04 $1C0D - BYTE $FF $F7 $D1 $FE - SHORT $1C06 $1C20 - BYTE $FF $F7 $ED $FE - SHORT $1C03 $1C30 $1940 $4298 $DD00 $1C18 $74E0 $BC70 $BC01 $4700 - - PROTECT $193A4 $193E4 - ORG $17CE0 //LoadUnit SHORT $F001 $FA56 $E005 ORG $17CF2 @@ -30,15 +21,6 @@ ORG $17D18 PROTECT $17AC4 $17D3A -ORG $1936E //SetUnitHp - SHORT $1C0C $F7FF $FF0E $E006 -ORG $19384 - SHORT $4284 $DD0A $1C20 $E007 -ORG $1939C - SHORT $74E8 - - PROTECT $19368 $193A2 - POP #endif /* HP_GETTER_MESSED_HOOKS_INSTALLED */ diff --git a/Wizardry/Core/UnitStatusGetter/source/LynJump.event b/Wizardry/Core/UnitStatusGetter/source/LynJump.event index 3d6fd4334..d61451bf4 100644 --- a/Wizardry/Core/UnitStatusGetter/source/LynJump.event +++ b/Wizardry/Core/UnitStatusGetter/source/LynJump.event @@ -10,3 +10,27 @@ ALIGN 4 WORD $46C04778 $E59FC000 $E12FFF1C POIN GetUnitCurrentHp POP +PUSH +ORG $18740 +ALIGN 4 +WORD $46C04778 $E59FC000 $E12FFF1C +POIN MoveActiveUnit +POP +PUSH +ORG $19368 +ALIGN 4 +WORD $46C04778 $E59FC000 $E12FFF1C +POIN SetUnitHp +POP +PUSH +ORG $193a4 +ALIGN 4 +WORD $46C04778 $E59FC000 $E12FFF1C +POIN AddUnitHp +POP +PUSH +ORG $7b900 +ALIGN 4 +WORD $46C04778 $E59FC000 $E12FFF1C +POIN SetupMapBattleAnim +POP diff --git a/Wizardry/Core/UnitStatusGetter/source/MiscHooks.c b/Wizardry/Core/UnitStatusGetter/source/MiscHooks.c new file mode 100644 index 000000000..4829f76a1 --- /dev/null +++ b/Wizardry/Core/UnitStatusGetter/source/MiscHooks.c @@ -0,0 +1,78 @@ +#include "common-chax.h" +#include "hooks.h" + +LYN_REPLACE_CHECK(MoveActiveUnit); +void MoveActiveUnit(int x, int y) +{ + gActiveUnit->xPos = x; + gActiveUnit->yPos = y; + + gActiveUnit->state |= US_UNSELECTABLE; + + PidStatsAddSquaresMoved(gActiveUnit->pCharacterData->number, gActionData.moveCount); + + if (GetUnitCurrentHp(gActiveUnit) != 0) + gActiveUnit->state = gActiveUnit->state &~ US_HIDDEN; + + UnitFinalizeMovement(gActiveUnit); +} + +LYN_REPLACE_CHECK(AddUnitHp); +void AddUnitHp(struct Unit *unit, int amount) +{ + int hp = unit->curHP; + + hp += amount; + + if (hp > GetUnitMaxHp(unit)) + hp = GetUnitMaxHp(unit); + + if (hp < 0) + hp = 0; + + unit->curHP = hp; +} + +LYN_REPLACE_CHECK(SetUnitHp); +void SetUnitHp(struct Unit *unit, int value) +{ + unit->curHP = value; + + if (unit->curHP > GetUnitMaxHp(unit)) + unit->curHP = GetUnitMaxHp(unit); +} + +LYN_REPLACE_CHECK(SetupMapBattleAnim); +void SetupMapBattleAnim(struct BattleUnit *actor, struct BattleUnit *target, struct BattleHit *hit) +{ + int i; + + MakeBattleMOVEUNIT(0, actor, &actor->unit); + + if (gManimSt.actorCount_maybe > 1) { + HideUnitSprite(&gBattleTarget.unit); // NOTE: uses gBattleTarget instead of target argument + MakeBattleMOVEUNIT(1, target, &target->unit); + } + + if (prBattleHitArray[0].attributes & BATTLE_HIT_ATTR_TATTACK) { + MakeBattleMOVEUNIT(2, actor, gBattleStats.taUnitA); + MakeBattleMOVEUNIT(3, actor, gBattleStats.taUnitB); + + HideUnitSprite(gBattleStats.taUnitA); + HideUnitSprite(gBattleStats.taUnitB); + } + + SetupBattleMOVEUNITs(); + + for (i = 0; i < gManimSt.actorCount_maybe; ++i) { + gManimSt.actor[i].hp_cur = gManimSt.actor[i].bu->hpInitial; + +#if CHAX + gManimSt.actor[i].hp_max = gManimSt.actor[i].bu->unit.maxHP; +#else + gManimSt.actor[i].hp_max = GetUnitMaxHp(gManimSt.actor[i].unit); +#endif + } + + SetDefaultColorEffects(); +} diff --git a/include/hooks.h b/include/hooks.h index 225673819..bb350b6b2 100644 --- a/include/hooks.h +++ b/include/hooks.h @@ -3,3 +3,4 @@ #include "common-chax.h" extern struct CharacterData const *const gpCharacterData; +extern struct BattleHit *const prBattleHitArray;