HiddenPowerDamage:
; Override Hidden Power's type and power based on the user's DVs.

	ld hl, BattleMonDVs
	ld a, [hBattleTurn]
	and a
	jr z, .got_dvs
	ld hl, EnemyMonDVs
.got_dvs

; Type:

	; Def & 3
	ld a, [hl]
	and 3
	ld b, a

	; + (Atk & 3) << 2
	ld a, [hl]
	and 3 << 4
	rrca
	rrca
	or b

	add a, .types & $ff
	ld l, a
	ld h, .types >> 8
	jr nc, .done
	inc h
.done
	
	ld a, [hl]
; Overwrite the current move type.
	push af
	ld a, BATTLE_VARS_MOVE_TYPE
	call GetBattleVarAddr
	pop af
	or SPECIAL << 6
	ld [hl], a

; Get the rest of the damage formula variables
; based on the new type, but keep base power.
	push af
	callba BattleCommand_DamageStats ; damagestats
	pop af
	ld hl, wCurDamageMovePowerNumerator
	xor a
	ld [hli], a
	ld a, 70 ;constant power 70, no longer calculated
	ld [hli], a
	; hl = wCurDamageMovePowerDenominator
	ld [hl], 1
	jp SetDamageDirtyFlag

.types
	db FIGHTING
	db FLYING
	db POISON
	db GROUND
	db ROCK
	db BUG
	db GHOST
	db STEEL
	db FIRE
	db WATER
	db GRASS
	db ELECTRIC
	db PSYCHIC
	db ICE
	db DRAGON
	db DARK
