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

20 行
726 B

  1. %%%-------------------------------------------------------------------
  2. %%% @author DY
  3. %%% @copyright (C) 2020, <COMPANY>
  4. %%% @doc
  5. %%% 扣除怒气
  6. %%% 根据cost_rage扣除相应怒气,结果大于等于0
  7. %%% 返回:SUCCESS
  8. %%% @end
  9. %%% Created : 07. 10月 2020 15:13
  10. %%%-------------------------------------------------------------------
  11. -module(action_cost_rage).
  12. -include("eBhv3.hrl").
  13. -include("example.hrl").
  14. %% API
  15. -export([tick/2]).
  16. tick(#{properties := #{cost_rage := CostRage}} = _BTree, #{cur_rage := CurRage} = State) ->
  17. State1 = State#{cur_rage := max(CurRage - CostRage, 0)},
  18. ?INFO("~ts:怒气值减少~w", [maps:get(uid, State1), CurRage - maps:get(cur_rage, State1)]),
  19. {?BT_SUCCESS, State1}.