otherworldly_simulation/scene/behavour_tree/condition_accuse.gd
2024-10-25 15:41:39 +08:00

23 lines
574 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.unit_id,i.unit_id)
var res=get_res(favour,unit.get_hungry())
if res:
black_board.set_value("target_unit_id",i.unit_id)
return SUCCESS
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