Skip to content

Commit

Permalink
Implemented several weather-related abilities
Browse files Browse the repository at this point in the history
These ones:
* Dry Skin
* Solar Power
* Hydration
* Rain Dish
* Ice Body

Also changed how weather are shown at the end of the turn, and fixed
some bugs with inverted checks (nc instead of c or similar)
  • Loading branch information
FredrIQ committed Oct 7, 2016
1 parent 49ec756 commit 1f55fb0
Show file tree
Hide file tree
Showing 7 changed files with 668 additions and 592 deletions.
10 changes: 5 additions & 5 deletions abilities.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ OK MAGMA_ARMOR
OK WATER_VEIL
! MAGNET_PULL (Routines done, not fully used yet)
OK SOUNDPROOF
- RAIN_DISH
OK RAIN_DISH
OK SAND_STREAM
. PRESSURE
OK THICK_FAT
Expand Down Expand Up @@ -83,14 +83,14 @@ OK STEADFAST
- SNOW_CLOAK
OK ANGER_POINT
- UNBURDEN
! DRY_SKIN (Water-type moves healing done)
OK DRY_SKIN
OK DOWNLOAD
- IRON_FIST
OK POISON_HEAL
OK ADAPTABILITY
OK SKILL_LINK
- HYDRATION
- SOLAR_POWER
OK HYDRATION
OK SOLAR_POWER
! QUICK_FEET (paralysis' speed penalty bypass implemented)
OK SNIPER
- MAGIC_GUARD
Expand All @@ -106,7 +106,7 @@ OK SUPER_LUCK
OK TINTED_LENS
OK FILTER
OK SCRAPPY
- ICE_BODY
OK ICE_BODY
OK SOLID_ROCK
OK FRISK
OK RECKLESS
Expand Down
202 changes: 89 additions & 113 deletions battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1804,127 +1804,22 @@ HandleWeather: ; 3cb9e

ld hl, .WeatherMessages
call .PrintWeatherMessage

ld a, [Weather]
cp WEATHER_HAIL
jp z, .HandleHail
cp WEATHER_SANDSTORM
ret nz

ld a, [hLinkPlayerNumber]
cp 1
jr z, .enemy_first_sandstorm

.player_first_sandstorm
call SetPlayerTurn
call .SandstormDamage
call SetEnemyTurn
jr .SandstormDamage
call .ShowWeatherAnimation

.enemy_first_sandstorm
call SetEnemyTurn
call .SandstormDamage
call SetPlayerTurn

.SandstormDamage:
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVar
bit SUBSTATUS_UNDERGROUND, a
ret nz
ld a, BATTLE_VARS_ABILITY
call GetBattleVar
cp OVERCOAT
ret nz
cp MAGIC_GUARD
ret nz

ld hl, BattleMonType1
ld a, [hBattleTurn]
and a
jr z, .ok_sandstorm
ld hl, EnemyMonType1
.ok_sandstorm
ld a, [hli]
cp ROCK
ret z
cp GROUND
ret z
cp STEEL
ret z

ld a, [hl]
cp ROCK
ret z
cp GROUND
ret z
cp STEEL
ret z

call SwitchTurnCore
xor a
ld [wNumHits], a
ld de, ANIM_IN_SANDSTORM
call Call_PlayBattleAnim
call SwitchTurnCore
call GetSixteenthMaxHP
call SubtractHPFromUser

ld hl, SandstormHitsText
jp StdBattleTextBox

.HandleHail
ld a, [hLinkPlayerNumber]
cp 1
jr z, .enemy_first_hail

.player_first_hail
jr z, .enemy_first
call SetPlayerTurn
call .HailDamage
call HandleWeatherEffects
call SetEnemyTurn
jr .HailDamage
jp HandleWeatherEffects

.enemy_first_hail
.enemy_first
call SetEnemyTurn
call .HailDamage
call HandleWeatherEffects
call SetPlayerTurn

.HailDamage:
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVar
bit SUBSTATUS_UNDERGROUND, a
ret nz
ld a, BATTLE_VARS_ABILITY
call GetBattleVar
cp OVERCOAT
ret nz
cp MAGIC_GUARD
ret nz

ld hl, BattleMonType1
ld a, [hBattleTurn]
and a
jr z, .ok_hail
ld hl, EnemyMonType1
.ok_hail
ld a, [hli]
cp ICE
ret z

ld a, [hl]
cp ICE
ret z

call SwitchTurnCore
xor a
ld [wNumHits], a
ld de, ANIM_IN_HAIL
call Call_PlayBattleAnim
call SwitchTurnCore
call GetSixteenthMaxHP
call SubtractHPFromUser

ld hl, HailHitsText
jp StdBattleTextBox
jp HandleWeatherEffects

.ended
ld hl, .WeatherEndedMessages
Expand All @@ -1944,7 +1839,17 @@ HandleWeather: ; 3cb9e
ld h, [hl]
ld l, a
jp StdBattleTextBox
; 3cc2d

.ShowWeatherAnimation:
ld hl, .WeatherAnimations
ld a, [Weather]
dec a
ld b, 0
ld c, a
add hl, bc
ld d, 0
ld e, [hl]
jp Call_PlayBattleAnim

.WeatherMessages:
dw BattleText_RainContinuesToFall
Expand All @@ -1956,8 +1861,79 @@ HandleWeather: ; 3cb9e
dw BattleText_TheSunlightFaded
dw BattleText_TheSandstormSubsided
dw BattleText_TheHailStopped
.WeatherAnimations:
db RAIN_DANCE
db SUNNY_DAY
db SANDSTORM
db HAIL
; 3cc39

HandleWeatherEffects:
; sandstorm/hail damage, abilities like rain dish, etc.
ld a, [Weather]
cp WEATHER_HAIL
call z, .HandleHail
ld a, [Weather] ; HandleHail messes with a
cp WEATHER_SANDSTORM
call z, .HandleSandstorm
farcall RunWeatherAbilities
ret

.HandleSandstorm
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVar
bit SUBSTATUS_UNDERGROUND, a
ret nz
ld a, BATTLE_VARS_ABILITY
call GetBattleVar
cp MAGIC_GUARD
ret z
cp OVERCOAT
ret z
cp SAND_FORCE
ret z
cp SAND_RUSH
ret z
cp SAND_VEIL
ret z

call CheckIfUserIsGroundType
ret z
call CheckIfUserIsRockType
ret z
call CheckIfUserIsSteelType
ret z

ld hl, SandstormHitsText
call StdBattleTextBox

call GetSixteenthMaxHP
jp SubtractHPFromUser

.HandleHail
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVar
bit SUBSTATUS_UNDERGROUND, a
ret nz
ld a, BATTLE_VARS_ABILITY
call GetBattleVar
cp MAGIC_GUARD
ret z
cp OVERCOAT
ret z
cp SNOW_CLOAK
ret z
cp ICE_BODY
ret z

call CheckIfUserIsIceType
ret z
ld hl, HailHitsText
jp StdBattleTextBox

call GetSixteenthMaxHP
jp SubtractHPFromUser

SubtractHPFromTarget: ; 3cc39
call SubtractHP
jp UpdateHPBar
Expand Down
24 changes: 22 additions & 2 deletions battle/effect_commands.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,7 @@ BattleCommand_DamageCalc: ; 35612
ld a, BATTLE_VARS_ABILITY
call GetBattleVar
cp HUGE_POWER
jr z, .ability_double
jp z, .ability_double
cp HUSTLE
jr z, .ability_semidouble
cp SHEER_FORCE
Expand All @@ -3430,6 +3430,8 @@ BattleCommand_DamageCalc: ; 35612
jr z, .analytic
cp TINTED_LENS
jr z, .tinted_lens
cp SOLAR_POWER
jr z, .solar_power
cp RECKLESS
jr z, .reckless
cp GUTS
Expand All @@ -3455,6 +3457,11 @@ BattleCommand_DamageCalc: ; 35612
cp 10 ; x1
jr nc, .ability_penalties
jr .ability_double
.solar_power
ld a, [Weather]
cp WEATHER_SUN
jr nz, .ability_penalties
jr .ability_semidouble
.reckless
; skip Struggle
ld a, BATTLE_VARS_MOVE
Expand Down Expand Up @@ -3545,7 +3552,7 @@ BattleCommand_DamageCalc: ; 35612
jr .abilities_done
.skip_solid_rock
cp THICK_FAT
jr nz, .abilities_done
jr nz, .skip_thick_fat
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVar
cp FIRE
Expand All @@ -3556,6 +3563,19 @@ BattleCommand_DamageCalc: ; 35612
ld [hl], 2
ld b, $4
call Divide
jr .abilities_done
.skip_thick_fat
cp DRY_SKIN
jr nz, .abilities_done
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVar
cp FIRE
jr nz, .abilities_done
ld [hl], 5
call Multiply
ld [hl], 4
ld b, $4
call Divide
.abilities_done
; Flash Fire
ld a, BATTLE_VARS_SUBSTATUS3
Expand Down
Loading

0 comments on commit 1f55fb0

Please sign in to comment.