如何解决为什么这个函数没有被调用,但在轮到他之后又被调用了
我正在制作一个回合制游戏,目前我正在尝试添加一个重击系统,它显示它正在造成重击伤害但没有发挥重击功能,对我来说也没有意义的是,它得到再次轮到他时调用,所以在第一轮中的某些东西使该函数不被调用而是在第二次被调用,似乎谁先攻击并没有调用对话功能,但在第一次之后玩得很好转。
func check_if_player(attacker,target):
if attacker == player_node:
print(attacker.move_slot[move_index].name)
dialogue_text.text = (attacker.name + " is attacking")
dialogue_ani.play("TextScroll")
target.take_damage(attacker.move_slot[move_index],attacker)
yield(get_tree().create_timer(2),"timeout")
_update_view()
if attacker.crit:
attacker.crit = false # Where I turn it off
print(attacker.crit)
yield(critical_hit(attacker),"completed")
else:
yield(attack(attacker,target),"completed")
func attack(attacker,target):
var random_move = randi() % 3 + 1
print(attacker.move_slot[move_index].name)
dialogue_text.text = (attacker.name + " is attacking")
dialogue_ani.play("TextScroll")
target.take_damage(attacker.move_slot[random_move],attacker) # Calls the function to take damage
yield(get_tree().create_timer(2),"timeout") #Wait for 2 seconds
_update_view()
if attacker.crit:
attacker.crit = false # Where I turn it off
print(attacker.crit)
yield(critical_hit(attacker),"completed")
这两个函数是我如何检查玩家是否在攻击我需要这样做,因为我希望玩家使用选定的动作,如果不是玩家则播放敌人的攻击
这是我的怪物脚本,我在其中检测是否发生了重击,我应该说这个怪物脚本是一种资源并且与其他脚本分开,其中玩家、敌人和重击功能都在一个脚本中.
func take_damage(move,attacker):
randomize()
var critical = 1
#var critical_chance = randi() % 100 + 1
var critical_chance = 5
if critical_chance <= 99.25:
crit = true
critical = 2
var type : float = Get_effectiveness(move.type,type_1) * Get_effectiveness(move.type,type_2)
var modifier : float = rand_range(0.85,1.0) * type * critical
var a : float = (2.0 * attacker.level / 5.0 + 2.0)
var b : float = (a * attacker.attack * move.power / defence) / 50.0
var c : float = (b + 2.0) * modifier
var damage = int(c)
current_health -= damage
print(str(attacker.name) + " = " + str(damage))
#print(a)
#print(b)
目前我认为每次玩家或敌人攻击时它几乎都是正确的,所以它应该调用/显示暴击功能,我在前几个功能中将暴击布尔值设置为假,所以它应该只发生一次
这是在屏幕上添加文本的功能,它也打印它告诉我它的工作原理,但它不打印它,如果它是第一个攻击怪物,我在这里犯了一个noobie错误吗?
func critical_hit(attacker):
dialogue_text.text = (attacker.name + " has landed a critical hit!")
dialogue_ani.play("TextScroll")
print(attacker.name + " has landed a critical hit!")
yield(get_tree().create_timer(3),"timeout")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。