Put some basic AI in for every difficulty
This commit is contained in:
parent
5079a77296
commit
9f7cb83789
File diff suppressed because one or more lines are too long
@ -66,19 +66,35 @@ func cast() -> void:
|
||||
get_node("/root").add_child(anim)
|
||||
attemptCast()
|
||||
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:
|
||||
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:
|
||||
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():
|
||||
match data.difficulty:
|
||||
Data.Difficulty.EASY:
|
||||
print("Awaiting")
|
||||
await get_tree().create_timer(randf_range(0.5, 1.5)).timeout
|
||||
print("Awaited")
|
||||
if randi_range(1, 100) < 85:
|
||||
if randi_range(0, 99) < 90:
|
||||
spell.castProgress += 1
|
||||
anim.setProgress(spell.castProgress)
|
||||
|
||||
@ -99,23 +115,63 @@ func attemptCast():
|
||||
spellbook.cooldowns[spellIndex] = spell.cooldown * (float(spell.castProgress) / float(spell.castCombo.size()))
|
||||
_finishedCasting()
|
||||
Data.Difficulty.NORMAL:
|
||||
await get_tree().create_timer(randf_range(0.5, 1.5)).timeout
|
||||
if randi_range(1, 100) < 50:
|
||||
pass #Success
|
||||
await get_tree().create_timer(randf_range(0.4, 1)).timeout
|
||||
if randi_range(0, 99) < 95:
|
||||
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:
|
||||
attemptCast()
|
||||
else:
|
||||
pass #fail
|
||||
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:
|
||||
await get_tree().create_timer(randf_range(0.5, 1.5)).timeout
|
||||
if randi_range(1, 100) < 50:
|
||||
pass #Success
|
||||
await get_tree().create_timer(randf_range(0.2, 0.6)).timeout
|
||||
if randi_range(0, 99) < 98:
|
||||
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:
|
||||
attemptCast()
|
||||
else:
|
||||
pass #fail
|
||||
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:
|
||||
await get_tree().create_timer(randf_range(0.5, 1.5)).timeout
|
||||
if randi_range(1, 100) < 50:
|
||||
pass #Success
|
||||
await get_tree().create_timer(.1).timeout
|
||||
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:
|
||||
pass #fail
|
||||
attemptCast()
|
||||
|
||||
func alterHealth(change: float, stun: bool) -> void:
|
||||
health += change
|
||||
|
Loading…
x
Reference in New Issue
Block a user