%%%-----------------------------------
%%% @Module  : pp_npc
%%% @Author  : xyao
%%% @Email   : jiexiaowen@gmail.com
%%% @Created : 2011.12.29
%%% @Description: npc
%%%-----------------------------------
-module(pp_npc).
-export([handle/3]).
-include("common.hrl").
-include("server.hrl").
-include("scene.hrl").

%% 动态npc信息
handle(12100, Ps, [Scene]) ->
    Data = lib_npc:get_scene_npc(Scene, Ps#player_status.npc_info),
    {ok, BinData} = pt_121:write(12100, [Data]),
    lib_server_send:send_to_sid(Ps#player_status.sid, BinData);

%% 获取npc默认对话和关联任务
handle(12101, Ps, [NpcId]) ->
    NewNpcId = lib_role_task:exchange_npc(NpcId),
    TaskList = lib_role_task:get_npc_task_list(NewNpcId, lib_task_api:ps2task_args(Ps)),
    {ok, BinData} = pt_121:write(12101, [NewNpcId, TaskList]),
    lib_server_send:send_to_sid(Ps#player_status.sid, BinData);

%% 任务对话
handle(12102, Ps, [NpcId, TaskId])->
    {_Type, TalkId} = lib_role_task:get_npc_task_talk_id(TaskId, NpcId, lib_task_api:ps2task_args(Ps)),
    {ok, BinData} = pt_121:write(12102, [NpcId, TaskId, TalkId]),
    lib_server_send:send_to_sid(Ps#player_status.sid, BinData);

handle(_Cmd, _PlayerStatus, _Data) ->
    {error, bad_request}.
