shithub: pokecrystal

Download patch

ref: 91fa3dd9b94845b512fae799ecbc0d187c948289
parent: 61faca1f917043e2ec9c9a2ba1d6e88adcca0552
author: Idain <luiscarlosholguinperez@outlook.com>
date: Mon Mar 14 18:53:38 EDT 2022

Replace flawed Metal Powder bugfix (#890)


--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -182,23 +182,33 @@
 
 ([Video](https://www.youtube.com/watch?v=rGqu3d3pdok&t=450))
 
-**Fix:** Edit `DittoMetalPowder` in [engine/battle/effect_commands.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/effect_commands.asm):
+**Fix:** Edit [engine/battle/effect_commands.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/effect_commands.asm):
 
 ```diff
- 	ld a, c
- 	srl a
- 	add c
- 	ld c, a
- 	ret nc
+ DittoMetalPowder:
+ 	...
 
- 	srl b
- 	ld a, b
- 	and a
- 	jr nz, .done
- 	inc b
- .done
- 	scf
- 	rr c
+-	ld a, c
+-	srl a
+-	add c
+-	ld c, a
+-	ret nc
+-
+-	srl b
+-	ld a, b
+-	and a
+-	jr nz, .done
+-	inc b
+-.done
+-	scf
+-	rr c
++	ld h, b
++	ld l, c
++	srl b
++	rr c
++	add hl, bc
++	ld b, h
++	ld c, l
 +
 +	ld a, HIGH(MAX_STAT_VALUE)
 +	cp b
@@ -210,6 +220,46 @@
 +
 +.cap
 +	ld bc, MAX_STAT_VALUE
+ 	ret
+```
+
+```diff
+ PlayerAttackDamage:
+ 	...
+
+ .done
++	push hl
++	call DittoMetalPowder
++	pop hl
+
+ 	call TruncateHL_BC
+
+ 	ld a, [wBattleMonLevel]
+ 	ld e, a
+-	call DittoMetalPowder
+
+ 	ld a, 1
+ 	and a
+ 	ret
+```
+
+```diff
+ EnemyAttackDamage:
+ 	...
+
+ .done
++	push hl
++	call DittoMetalPowder
++	pop hl
+
+ 	call TruncateHL_BC
+
+ 	ld a, [wBattleMonLevel]
+ 	ld e, a
+-	call DittoMetalPowder
+
+ 	ld a, 1
+ 	and a
  	ret
 ```