Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; =============== S U B R O U T I N E =======================================
- ; ASM FILE code\gameflow\battle\battleactions\battleactionsengine_4.asm
- ; 0xAAB6..0xAAFB
- ;There is 121 free bytes between 0x8000..0x10000 so the attack_new script could technically be placed here
- WriteBattlesceneScript_Attack:
- jsr WriteBattlesceneScript_Attack_New
- rts
- ; End of function WriteBattlesceneScript_Attack
- ; =============== S U B R O U T I N E =======================================
- ;NOTE: If using the standard patch: EXPANDED_ITEMS_AND_SPELLS
- ;Change $FFF6B0 to $FFF730
- WriteBattlesceneScript_Attack_New:
- move.b (a5),d0 ;pointer to target
- jsr GetCurrentHP
- move.w d1,$FFF6B0 ;store CurrentHP in RAM for later
- jsr WriteBattlesceneScript_DetermineDodge
- tst.b dodge(a2)
- bne.s @DoubleAndCounter
- jsr WriteBattlesceneScript_CalculateDamage
- jsr WriteBattlesceneScript_DetermineCriticalHit
- jsr WriteBattlesceneScript_InflictDamage
- tst.b targetDies(a2)
- beq.s @Continue
- jsr WriteBattlesceneScript_DeathMessage
- bra.s @CheckDodge
- @Continue:
- jsr WriteBattlesceneScript_InflictAilment
- tst.b targetDies(a2)
- beq.s @DoubleAndCounter
- exg a4,a5
- jsr WriteBattlesceneScript_DeathMessage
- exg a4,a5
- bra.s @CheckDodge
- @DoubleAndCounter:
- jsr WriteBattlesceneScript_DetermineDoubleAndCounter
- @CheckDodge:
- tst.b dodge(a2)
- bne.s @Return
- bsr.s Lifesteal_Effect
- ; jsr WriteBattlesceneScript_InflictCurseDamage ;re-write, remove or set chance to 0% because bugs
- @Return:
- clr.w $FFF6B0
- rts
- ; End of function WriteBattlesceneScript_Attack_New
- ; =============== S U B R O U T I N E =======================================
- Lifesteal_Effect:
- exg a4,a5
- lsr.w #1,d6 ;leeches 1/2 of damage output.
- move.b (a5), d0
- jsr GetEquippedWeapon
- cmpi.w #ITEM_EVIL_KNUCKLES,d1
- beq.s @TargetCurrentHPCap
- cmpi.w #ITEM_EVIL_AXE,d1
- beq.s @TargetCurrentHPCap
- cmpi.w #ITEM_EVIL_SHOT,d1
- beq.s @TargetCurrentHPCap
- cmpi.w #ITEM_EVIL_LANCE,d1
- beq.s @TargetCurrentHPCap
- cmpi.w #ITEM_DARK_SWORD,d1
- beq.s @TargetCurrentHPCap
- cmpi.w #ITEM_DEMON_ROD,d1
- beq.s @TargetCurrentHPCap
- bra.w @Return
- @TargetCurrentHPCap:
- move.b (a4),d0 ;pointer to target
- jsr GetCurrentHP
- tst.w d1 ;checks if target dies
- bne.s @MissingHPCap
- move.w $FFF6B0,d6
- lsr.w #1,d6 ;leeches 1/2 of targets CurrentHP
- @MissingHPCap:
- move.b (a5),d0 ;pointer to attacker
- jsr GetMaxHP
- move.w d1,d2
- jsr GetCurrentHP
- sub.w d1,d2
- cmp.w d6,d2
- bcc.s @AttackerAllyOrEnemy
- move.w d2,d6 ;cap recovery amount if missing HP is lower than leeched hp
- @AttackerAllyOrEnemy:
- tst.w d6 ;check if leech amount equals 0
- beq.s @Return ;rts if 0
- jsr GetStatusEffects
- btst #COMBATANT_BIT_ENEMY,d0
- bne.s @EnemyAttacker
- executeAllyReaction d6,#0,d1,#2
- bra.s @CheckDoubleAttack
- @EnemyAttacker:
- executeEnemyReaction d6,#0,d1,#2
- bscHideTextBox
- @CheckDoubleAttack:
- tst.b doubleattack(a2)
- beq.s @DisplayMessage
- move.w d6,d1
- jsr IncreaseCurrentHP ;second attack compensates the HP leeched on first hit (for missing hp recovery cap calculation)
- @DisplayMessage:
- displayMessage #MESSAGE_BATTLE_RECOVERED_HIT_POINTS,d0,#0,d6
- exg a4,a5
- @Return:
- rts
- ; End of function Lifesteal_Effect
Advertisement
Add Comment
Please, Sign In to add comment