diff --git a/src/psu/psu_game.erl b/src/psu/psu_game.erl index ad27638..6602d0b 100644 --- a/src/psu/psu_game.erl +++ b/src/psu/psu_game.erl @@ -634,6 +634,25 @@ event({item_unequip, ItemID, TargetGID, TargetLID, A, B}) -> event(lobby_transport_request) -> send_0c08(true); +%% @todo Probably replenish the player HP when entering a non-mission area rather than when aborting the mission? +event(mission_abort) -> + send_1006(11), + {ok, User} = egs_user_model:read(get(gid)), + %% delete the mission + psu_instance:stop(User#egs_user_model.instancepid), + %% full hp + Character = User#egs_user_model.character, + MaxHP = Character#characters.maxhp, + NewCharacter = Character#characters{currenthp=MaxHP}, + NewUser = User#egs_user_model{character=NewCharacter, setid=0}, + egs_user_model:write(NewUser), + %% map change + if User#egs_user_model.areatype =:= mission -> + Area = User#egs_user_model.prev_area, + area_load(Area#psu_area.questid, Area#psu_area.zoneid, Area#psu_area.mapid, User#egs_user_model.prev_entryid); + true -> ignore + end; + %% @todo Forward the mission start to other players of the same party, whatever their location is. event({mission_start, QuestID}) -> log("mission start ~b", [QuestID]), @@ -803,26 +822,6 @@ handle(16#0a09, Data) -> handle(16#0a10, << ItemID:32/unsigned-integer >>) -> send_0a11(ItemID, "dammy"); -%% @doc Abort mission handler. -%% Replenish the player HP. -handle(16#0c0e, _) -> - send_1006(11), - {ok, User} = egs_user_model:read(get(gid)), - %% delete the mission - psu_instance:stop(User#egs_user_model.instancepid), - %% full hp - Character = User#egs_user_model.character, - MaxHP = Character#characters.maxhp, - NewCharacter = Character#characters{currenthp=MaxHP}, - NewUser = User#egs_user_model{character=NewCharacter, setid=0}, - egs_user_model:write(NewUser), - %% map change (temporary) - if User#egs_user_model.areatype =:= mission -> - Area = User#egs_user_model.prev_area, - area_load(Area#psu_area.questid, Area#psu_area.zoneid, Area#psu_area.mapid, User#egs_user_model.prev_entryid); - true -> ignore - end; - %% @doc Counter available mission list request handler. handle(16#0c0f, _) -> {ok, User} = egs_user_model:read(get(gid)), diff --git a/src/psu/psu_proto.erl b/src/psu/psu_proto.erl index 94f1ecc..4b88196 100644 --- a/src/psu/psu_proto.erl +++ b/src/psu/psu_proto.erl @@ -272,6 +272,21 @@ parse(Size, 16#0c07, Channel, Data) -> ?ASSERT_EQ(VarI, 0), lobby_transport_request; +parse(Size, 16#0c0e, Channel, Data) -> + << _LID:16/little, VarA:16/little, VarB:32/little, VarC:32/little, VarD:32/little, VarE:32/little, VarF:32/little, VarG:32/little, VarH:32/little, VarI:32/little >> = Data, + ?ASSERT_EQ(Size, 44), + ?ASSERT_EQ(Channel, 2), + ?ASSERT_EQ(VarA, 0), + ?ASSERT_EQ(VarB, 0), + ?ASSERT_EQ(VarC, 0), + ?ASSERT_EQ(VarD, 0), + ?ASSERT_EQ(VarE, 0), + ?ASSERT_EQ(VarF, 0), + ?ASSERT_EQ(VarG, 0), + ?ASSERT_EQ(VarH, 0), + ?ASSERT_EQ(VarI, 0), + mission_abort; + parse(_Size, Command, Channel, Data) -> %% @todo log unknown command? %~ ignore.