Put some basic AI in for every difficulty

This commit is contained in:
nc543 2024-05-12 09:56:52 -04:00
parent 5079a77296
commit 9f7cb83789
2 changed files with 486 additions and 427 deletions

File diff suppressed because one or more lines are too long

View File

@ -66,19 +66,35 @@ func cast() -> void:
get_node("/root").add_child(anim) get_node("/root").add_child(anim)
attemptCast() attemptCast()
Data.Difficulty.NORMAL: Data.Difficulty.NORMAL:
pass spellIndex = randi_range(0, spellbook.spells.size() - 1)
spell = spellbook.spells[spellIndex]
anim = data.animations[spell.animation].instantiate()
anim.setProgress(0, spell.castCombo.size())
anim.inverted = true
get_node("/root").add_child(anim)
attemptCast()
Data.Difficulty.HARD: Data.Difficulty.HARD:
pass spellIndex = randi_range(0, spellbook.spells.size() - 1)
spell = spellbook.spells[spellIndex]
anim = data.animations[spell.animation].instantiate()
anim.setProgress(0, spell.castCombo.size())
anim.inverted = true
get_node("/root").add_child(anim)
attemptCast()
Data.Difficulty.GAMER: Data.Difficulty.GAMER:
pass spellIndex = randi_range(0, spellbook.spells.size() - 1)
spell = spellbook.spells[spellIndex]
anim = data.animations[spell.animation].instantiate()
anim.setProgress(0, spell.castCombo.size())
anim.inverted = true
get_node("/root").add_child(anim)
attemptCast()
func attemptCast(): func attemptCast():
match data.difficulty: match data.difficulty:
Data.Difficulty.EASY: Data.Difficulty.EASY:
print("Awaiting")
await get_tree().create_timer(randf_range(0.5, 1.5)).timeout await get_tree().create_timer(randf_range(0.5, 1.5)).timeout
print("Awaited") if randi_range(0, 99) < 90:
if randi_range(1, 100) < 85:
spell.castProgress += 1 spell.castProgress += 1
anim.setProgress(spell.castProgress) anim.setProgress(spell.castProgress)
@ -99,23 +115,63 @@ func attemptCast():
spellbook.cooldowns[spellIndex] = spell.cooldown * (float(spell.castProgress) / float(spell.castCombo.size())) spellbook.cooldowns[spellIndex] = spell.cooldown * (float(spell.castProgress) / float(spell.castCombo.size()))
_finishedCasting() _finishedCasting()
Data.Difficulty.NORMAL: Data.Difficulty.NORMAL:
await get_tree().create_timer(randf_range(0.5, 1.5)).timeout await get_tree().create_timer(randf_range(0.4, 1)).timeout
if randi_range(1, 100) < 50: if randi_range(0, 99) < 95:
pass #Success spell.castProgress += 1
anim.setProgress(spell.castProgress)
if spell.castProgress == spell.castCombo.size():
casting = false
spell.castProgress = 0
renderer.play("attack1")
spellbook.cooldowns[spellIndex] = spell.cooldown
data.player.alterHealth(-spell.damage, false)
_finishedCasting()
else: else:
pass #fail attemptCast()
else:
alterHealth(-spell.backfireStrength, true)
casting = false
anim.castFailed()
spell.castProgress = 0
spellbook.cooldowns[spellIndex] = spell.cooldown * (float(spell.castProgress) / float(spell.castCombo.size()))
_finishedCasting()
Data.Difficulty.HARD: Data.Difficulty.HARD:
await get_tree().create_timer(randf_range(0.5, 1.5)).timeout await get_tree().create_timer(randf_range(0.2, 0.6)).timeout
if randi_range(1, 100) < 50: if randi_range(0, 99) < 98:
pass #Success spell.castProgress += 1
anim.setProgress(spell.castProgress)
if spell.castProgress == spell.castCombo.size():
casting = false
spell.castProgress = 0
renderer.play("attack1")
spellbook.cooldowns[spellIndex] = spell.cooldown
data.player.alterHealth(-spell.damage, false)
_finishedCasting()
else: else:
pass #fail attemptCast()
else:
alterHealth(-spell.backfireStrength, true)
casting = false
anim.castFailed()
spell.castProgress = 0
spellbook.cooldowns[spellIndex] = spell.cooldown * (float(spell.castProgress) / float(spell.castCombo.size()))
_finishedCasting()
Data.Difficulty.GAMER: Data.Difficulty.GAMER:
await get_tree().create_timer(randf_range(0.5, 1.5)).timeout await get_tree().create_timer(.1).timeout
if randi_range(1, 100) < 50: spell.castProgress += 1
pass #Success anim.setProgress(spell.castProgress)
if spell.castProgress == spell.castCombo.size():
casting = false
spell.castProgress = 0
renderer.play("attack1")
spellbook.cooldowns[spellIndex] = spell.cooldown
data.player.alterHealth(-spell.damage, false)
_finishedCasting()
else: else:
pass #fail attemptCast()
func alterHealth(change: float, stun: bool) -> void: func alterHealth(change: float, stun: bool) -> void:
health += change health += change