behavior3行为树
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

25 行
917 B

  1. %%%-------------------------------------------------------------------
  2. %%% @author DY
  3. %%% @copyright (C) 2020, <COMPANY>
  4. %%% @doc
  5. %%% 寻找巡逻兵
  6. %%% 找到:SUCCESS
  7. %%% 未找到:FAILURE
  8. %%% @end
  9. %%% Created : 07. 10月 2020 15:13
  10. %%%-------------------------------------------------------------------
  11. -module(action_collect_patrol).
  12. -include("eBhv3.hrl").
  13. -include("example.hrl").
  14. %% API
  15. -export([tick/2]).
  16. tick(_BTree, #{cur_grid := CurGrid, rival_list := RivalList} = State) ->
  17. Fun = fun(UID) -> maps:get(type, game_dict:get_role_state(UID)) == ?HUMAN end,
  18. case lists:filter(Fun, game_dict:get_map_data(CurGrid)) of
  19. UIDList when UIDList /= [] ->
  20. ?INFO("~ts:嗅到了人类的味道,将要对[~ts]发起攻击", [maps:get(uid, State), lists:join(",", UIDList)]),
  21. {?BT_SUCCESS, State#{rival_list := UIDList ++ RivalList}};
  22. [] ->
  23. {?BT_FAILURE, State}
  24. end.