psu_proto: Move mission_abort to events.
This commit is contained in:
parent
efa743a465
commit
98b2e2ba3a
@ -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)),
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user