Alright I’m making Pokémon in Godot and I’m on to type advantages and disadvantages and I’m a bit stuck on how I would add that I have here a Types.gd file
extends Control
class_name types
var Normal : Dictionary = {
"a_rock": "neff",
"a_steel": "neff",
"a_ghost": "no",
"d_ghost": "no",
"d_fighting": "seff",
}
var Fire : Dictionary = {
"a_grass": "seff",
"a_ice": "seff",
"a_bug": "seff",
"a_steel": "seff",
"a_fire": "neff",
"a_water": "neff",
"a_rock": "neff",
"a_dragon": "neff",
"d_fire": "neff",
"d_grass": "neff",
"d_ice": "neff",
"d_bug": "neff",
"d_steel": "neff",
"d_fairy": "neff",
"d_water": "seff",
"d_ground": "seff",
"d_rock": "seff",
}
var Water : Dictionary = {
"a_fire": "seff",
"a_ground": "seff",
"a_rock": "seff",
"a_water": "neff",
"a_grass": "neff",
"a_dragon": "neff",
"d_fire": "neff",
"d_water": "neff",
"d_ice": "neff",
"d_steel": "neff",
"d_electric": "seff",
"d_grass": "seff",
}
a_ type meaning attacking so for example type fire would be
"a_grass": "seff"
because fire is super effective against grass now that’s all good but now I added the class to my main battle scene with
var Type = types.new()
also works fine but now this is where I’m stuck super effective moves doing 2x the damage and not very effective moves doing .5x damage how would i add checking the types of two different Pokémon and doing damage multiplication
data.Player = {
"level" : randi_range(5,7),
"hp" : randi_range(1,5),
"spd" : randi_range(1,5),
"atk" : randi_range(1,5),
"def" : randi_range(1,5),
"type": request_type(data.starter),
"exp": 0,
"max_exp": null
}
code for the player with the type being let’s say the string "Fire"
data.Enemy = {
"level" : randi_range(5,7),
"hp" : randi_range(1,5),
"spd" : randi_range(1,5),
"atk" : randi_range(1,5),
"def" : randi_range(1,5),
"move1": randmov(),
"move2": randmov(),
"move3": randmov(),
"move4": randmov(),
"current": null,
"sprite" : get_random_mon(1),
"type": set_enemy_type(),
}
code for the enemy with the type being the string "Water"
now this is the attack code / damage function
func _on_moves_damage(entity, damage, text, effectivity, type):
await get_tree().create_timer(.5).timeout
if entity == "Enemy":
match data.Enemy.type:
"Normal":
pass
data.Player.hp -= damage
disable_btns(false)
if effectivity == "weak":
$"SFX/weak attack".play()
elif effectivity == "reg":
$SFX/attack.play()
var tween = get_tree().create_tween()
tween.tween_property($Cast/Player/hpbar,"value",data.Player.hp,1).set_trans(Tween.TRANS_LINEAR)
elif entity == "Player":
data.Enemy.hp -= damage
if effectivity == "weak":
$"SFX/weak attack".play()
elif effectivity == "reg":
$SFX/attack.play()
var tween = get_tree().create_tween()
tween.tween_property($Cast/Enemy/hpbar,"value",data.Enemy.hp,1).set_trans(Tween.TRANS_LINEAR)
if data.Enemy.hp <= 0:
textedit(text)
await get_tree().create_timer(1).timeout
kill_enemy()
return
$"Timers/after_attack cooldown".start()
textedit(text)
how would i add the multipliers without 1000 match statements?