behavior3行为树
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 rivejä
800 B

4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
  1. %%%-------------------------------------------------------------------
  2. %%% @author DY
  3. %%% @copyright (C) 2020, <COMPANY>
  4. %%% @doc
  5. %%% 扣除体力
  6. %%% 获取Misc结构中的atk_dmg字段的值
  7. %%% 返回:SUCCESS
  8. %%% @end
  9. %%% Created : 07. 10月 2020 15:13
  10. %%%-------------------------------------------------------------------
  11. -module(action_cost_power).
  12. -include("eBhv3.hrl").
  13. -include("example.hrl").
  14. %% API
  15. -export([tick/2]).
  16. tick(_BTree, State) ->
  17. #{cur_power := CurPower, misc := #{atk_dmg := {AtkType, Dmg}} = Misc} = State,
  18. State1 = State#{cur_power := max(CurPower - Dmg, 0), misc := maps:remove(atk_dmg, Misc)},
  19. ?INFO("~ts:受到~ts攻击,体力值减少~w点 剩余体力~w", [maps:get(uid, State1), AtkType, Dmg, maps:get(cur_power, State1)]),
  20. {?BT_SUCCESS, State1}.