behavior3行为树
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

21 řádky
834 B

  1. %%%-------------------------------------------------------------------
  2. %%% @author DY
  3. %%% @copyright (C) 2020, <COMPANY>
  4. %%% @doc
  5. %%% 恢复体力
  6. %%% 根据Max - Min之间随机恢复几点体力
  7. %%% 返回:SUCCESS
  8. %%% @end
  9. %%% Created : 07. 10月 2020 15:13
  10. %%%-------------------------------------------------------------------
  11. -module(action_recover_power).
  12. -include("eBhv3.hrl").
  13. -include("example.hrl").
  14. %% API
  15. -export([tick/2]).
  16. tick(#{properties := #{max_power := MaxPower, min_power := MinPower}} = _BTree, #{cur_power := CurPower} = State) ->
  17. RecoverPower = ?RAND(MinPower, MaxPower),
  18. State1 = State#{cur_power := min(CurPower + RecoverPower, ?MAX_POWER)},
  19. ?INFO("~ts:体力值增加了~w点 当前体力:~w", [maps:get(uid, State1), RecoverPower, maps:get(cur_power, State1)]),
  20. {?BT_SUCCESS, State1}.