Degreezy

SF2 Siel's Lifesteal hack

Nov 1st, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. ; =============== S U B R O U T I N E =======================================
  2. ; ASM FILE code\gameflow\battle\battleactions\battleactionsengine_4.asm
  3. ; 0xAAB6..0xAAFB
  4. ;There is 121 free bytes between 0x8000..0x10000 so the attack_new script could technically be placed here
  5.  
  6.  
  7. WriteBattlesceneScript_Attack:
  8.  
  9. jsr WriteBattlesceneScript_Attack_New
  10. rts
  11.  
  12. ; End of function WriteBattlesceneScript_Attack
  13.  
  14.  
  15. ; =============== S U B R O U T I N E =======================================
  16. ;NOTE: If using the standard patch: EXPANDED_ITEMS_AND_SPELLS
  17. ;Change $FFF6B0 to $FFF730
  18.  
  19. WriteBattlesceneScript_Attack_New:
  20.  
  21. move.b (a5),d0 ;pointer to target
  22. jsr GetCurrentHP
  23. move.w d1,$FFF6B0 ;store CurrentHP in RAM for later
  24. jsr WriteBattlesceneScript_DetermineDodge
  25. tst.b dodge(a2)
  26. bne.s @DoubleAndCounter
  27. jsr WriteBattlesceneScript_CalculateDamage
  28. jsr WriteBattlesceneScript_DetermineCriticalHit
  29. jsr WriteBattlesceneScript_InflictDamage
  30. tst.b targetDies(a2)
  31. beq.s @Continue
  32. jsr WriteBattlesceneScript_DeathMessage
  33. bra.s @CheckDodge
  34.  
  35. @Continue:
  36. jsr WriteBattlesceneScript_InflictAilment
  37. tst.b targetDies(a2)
  38. beq.s @DoubleAndCounter
  39. exg a4,a5
  40. jsr WriteBattlesceneScript_DeathMessage
  41. exg a4,a5
  42. bra.s @CheckDodge
  43.  
  44. @DoubleAndCounter:
  45.  
  46. jsr WriteBattlesceneScript_DetermineDoubleAndCounter
  47.  
  48. @CheckDodge:
  49. tst.b dodge(a2)
  50. bne.s @Return
  51. bsr.s Lifesteal_Effect
  52. ; jsr WriteBattlesceneScript_InflictCurseDamage ;re-write, remove or set chance to 0% because bugs
  53.  
  54. @Return:
  55. clr.w $FFF6B0
  56. rts
  57.  
  58. ; End of function WriteBattlesceneScript_Attack_New
  59.  
  60. ; =============== S U B R O U T I N E =======================================
  61.  
  62. Lifesteal_Effect:
  63.  
  64. exg a4,a5
  65. lsr.w #1,d6 ;leeches 1/2 of damage output.
  66. move.b (a5), d0
  67. jsr GetEquippedWeapon
  68. cmpi.w #ITEM_EVIL_KNUCKLES,d1
  69. beq.s @TargetCurrentHPCap
  70. cmpi.w #ITEM_EVIL_AXE,d1
  71. beq.s @TargetCurrentHPCap
  72. cmpi.w #ITEM_EVIL_SHOT,d1
  73. beq.s @TargetCurrentHPCap
  74. cmpi.w #ITEM_EVIL_LANCE,d1
  75. beq.s @TargetCurrentHPCap
  76. cmpi.w #ITEM_DARK_SWORD,d1
  77. beq.s @TargetCurrentHPCap
  78. cmpi.w #ITEM_DEMON_ROD,d1
  79. beq.s @TargetCurrentHPCap
  80. bra.w @Return
  81.  
  82. @TargetCurrentHPCap:
  83.  
  84. move.b (a4),d0 ;pointer to target
  85. jsr GetCurrentHP
  86. tst.w d1 ;checks if target dies
  87. bne.s @MissingHPCap
  88. move.w $FFF6B0,d6
  89. lsr.w #1,d6 ;leeches 1/2 of targets CurrentHP
  90.  
  91. @MissingHPCap:
  92.  
  93. move.b (a5),d0 ;pointer to attacker
  94. jsr GetMaxHP
  95. move.w d1,d2
  96. jsr GetCurrentHP
  97. sub.w d1,d2
  98. cmp.w d6,d2
  99. bcc.s @AttackerAllyOrEnemy
  100. move.w d2,d6 ;cap recovery amount if missing HP is lower than leeched hp
  101.  
  102.  
  103. @AttackerAllyOrEnemy:
  104. tst.w d6 ;check if leech amount equals 0
  105. beq.s @Return ;rts if 0
  106. jsr GetStatusEffects
  107. btst #COMBATANT_BIT_ENEMY,d0
  108. bne.s @EnemyAttacker
  109. executeAllyReaction d6,#0,d1,#2
  110. bra.s @CheckDoubleAttack
  111.  
  112. @EnemyAttacker:
  113. executeEnemyReaction d6,#0,d1,#2
  114. bscHideTextBox
  115.  
  116. @CheckDoubleAttack:
  117. tst.b doubleattack(a2)
  118. beq.s @DisplayMessage
  119. move.w d6,d1
  120. jsr IncreaseCurrentHP ;second attack compensates the HP leeched on first hit (for missing hp recovery cap calculation)
  121.  
  122. @DisplayMessage:
  123. displayMessage #MESSAGE_BATTLE_RECOVERED_HIT_POINTS,d0,#0,d6
  124. exg a4,a5
  125.  
  126. @Return:
  127. rts
  128.  
  129. ; End of function Lifesteal_Effect
Advertisement
Add Comment
Please, Sign In to add comment