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

18 lines
398 B
GDScript

extends ConditionLeaf
func tick(actor:Node,black_board:Blackboard):
var unit:UnitOther=actor
if unit.get_hungry()<=50:
return FAILURE
if randf()>float(unit.get_hungry()-50)/50:
return FAILURE
unit.show_action("饥饿")
var all_bodys=unit.sense_area.get_overlapping_areas()
for i in all_bodys:
if i is Food:
black_board.set_value("target",i)
return SUCCESS
return FAILURE
pass