otherworldly_simulation/scene/behavour_tree/condition_accuse.gd
2024-10-28 19:24:10 +08:00

24 lines
635 B
GDScript

extends ConditionLeaf
func tick(actor:Node,black_board:Blackboard):
var unit:UnitOther=actor
var all_bodys=unit.sense_area.get_overlapping_bodies()
for i in all_bodys:
if i is Unit:
var favour=Global.get_unit_favour(unit.get_unit_id(),i.get_unit_id())
var res=get_res(favour,unit.get_hungry())
if res:
black_board.set_value("target_unit_id",i.get_unit_id())
return SUCCESS
black_board.erase_value("target_unit_id")
return FAILURE
pass
#返回true口角判定成功
func get_res(favour:float,hungry:float=0)->bool:
if favour>0 or favour<-50:
return false
else:
return randf()<=(-favour/100)-hungry/300