psu_proto: Move player_death, player_death_return_to_lobby and player_type_capabilities_request to events.

This commit is contained in:
Loïc Hoguin 2010-08-21 00:23:17 +02:00
parent 5672d40ca9
commit fb07769e44
2 changed files with 49 additions and 31 deletions

View File

@ -610,6 +610,26 @@ event({item_unequip, ItemID, TargetGID, TargetLID, A, B}) ->
send(<< 16#01050300:32, 0:64, GID:32/little-unsigned-integer, 0:64, 16#00011300:32, GID:32/little-unsigned-integer,
0:64, TargetGID:32/little-unsigned-integer, TargetLID:32/little-unsigned-integer, ItemID, 2, Category, A, B:32/little-unsigned-integer >>);
%% @todo If the player has a scape, use it! Otherwise red screen.
%% @todo Right now we force revive and don't update the player's HP.
event(player_death) ->
% @todo send_0115(get(gid), 16#ffffffff, LV=1, EXP=idk, Money=1000), % apparently sent everytime you die...
%% use scape:
NewHP = 10,
send_0117(NewHP),
send_1022(NewHP);
%% red screen with return to lobby choice:
%~ send_0111(3, 1);
%% @todo Refill the player's HP to maximum, remove SEs etc.
event(player_death_return_to_lobby) ->
{ok, User} = egs_user_model:read(get(gid)),
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);
event(player_type_capabilities_request) ->
send_0113();
%% @doc Uni cube handler.
event(unicube_request) ->
send_021e();
@ -658,35 +678,6 @@ handle(16#010a, Data) ->
send(<< 16#010a0300:32, 0:64, GID:32/little-unsigned-integer, 0:64, 16#00011300:32,
GID:32/little-unsigned-integer, 0:64, GID:32/little-unsigned-integer, 0:32, File/binary >>);
%% @doc Character death, and more, handler. Warp to 4th floor for now.
%% @todo Recover from death correctly.
%% @todo A is probably PartyPos or LID.
handle(16#0110, Data) ->
<< _:32, A:32/little-unsigned-integer, B:32/little-unsigned-integer, C:32/little-unsigned-integer >> = Data,
case B of
2 -> % triggered when looking at the type menu
send_0113();
3 -> % type change
log("changed type to ~b", [C]);
4 -> % related to npc death, ignore for now
ignore;
7 -> % player death: if the player has a scape, use it! otherwise red screen @todo Right now we force revive and don't reset the HP.
% @todo send_0115(get(gid), 16#ffffffff, LV=1, EXP=idk, Money=1000), % apparently sent everytime you die...
% use scape
NewHP = 10,
send_0117(NewHP),
send_1022(NewHP);
% red screen with return to lobby choice:
%~ send_0111(3, 1);
8 -> % return to lobby after death
log("return to lobby after death"),
area_load(1100000, 0, 4, 6); %% @todo temporary handler
10 -> % online status change
log("changed status to ~b", [C]);
_ ->
log("unknown 0110 (~b, ~b, ~b)", [A, B, C])
end;
%% @doc Shortcut changes handler. Do nothing.
%% @todo Save it.
handle(16#0302, _) ->

View File

@ -69,9 +69,9 @@ parse(Size, 16#0105, Channel, Data) ->
3 -> ignore; %% @todo item_link_pa;
4 -> ignore; %% @todo item_unlink_pa;
5 -> item_drop;
7 -> ?ASSERT(), ignore;
7 -> ?ASSERT(), ignore; %% @todo
8 -> ignore; %% @todo item_use;
9 -> ?ASSERT(), ignore;
9 -> ?ASSERT(), ignore; %% @todo
18 -> ignore; %% @todo item_unlearn_pa;
_ -> log("unknown 0105 EventID ~p", [EventID])
end,
@ -89,6 +89,33 @@ parse(Size, 16#0105, Channel, Data) ->
{Event, ItemID, TargetGID, TargetLID, VarH, VarI}
end;
parse(Size, 16#0110, Channel, Data) ->
<< _LID:16/little, VarA:16/little, VarB:32/little, HeaderGID:32/little, VarC:32/little, VarD:32/little, VarE:32/little,
VarF:32/little, VarG:32/little, VarH:32/little, BodyGID:32/little, _PartyPosOrLID:32/little, EventID:32/little, Param:32/little >> = Data,
?ASSERT_EQ(Size, 60),
?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(HeaderGID, BodyGID),
case EventID of
1 -> ?ASSERT_EQ(Param, 0), ?ASSERT(), ignore;
2 -> ?ASSERT_EQ(Param, 0), player_type_capabilities_request;
3 -> ignore; %% @todo {player_type_change, Param};
4 -> ?ASSERT_EQ(Param, 0), ignore; %% @todo (related to npc death)
6 -> ?ASSERT_EQ(Param, 0), ignore; %% @todo
7 -> ?ASSERT_EQ(Param, 0), player_death;
8 -> ?ASSERT_EQ(Param, 0), player_death_return_to_lobby;
9 -> ?ASSERT_EQ(Param, 10), ignore; %% @todo
10 -> ignore; %% @todo {player_online_status_change, Param};
_ -> log("unknown 0110 EventID ~p", [EventID])
end;
parse(Size, 16#021d, Channel, Data) ->
<< _LID:16/little, VarB:16/little, VarC:32/little, VarD:32/little, VarE:32/little, VarF:32/little,
VarG:32/little, VarH:32/little, VarI:32/little, VarJ:32/little, _EntryID:32/little >> = Data,