diff --git a/src/psu/psu_game.erl b/src/psu/psu_game.erl index c312a52..181f69c 100644 --- a/src/psu/psu_game.erl +++ b/src/psu/psu_game.erl @@ -519,6 +519,11 @@ broadcast(Command, Orig) lists:foreach(fun(User) -> User#egs_user_model.pid ! {psu_broadcast, Packet} end, SpawnList) end. +%% @doc Trigger many events. +events(Events) -> + [event(Event) || Event <- Events], + ok. + %% @todo When changing lobby to the room, 0230 must also be sent. Same when going from room to lobby. %% @todo Probably move area_load inside the event and make other events call this one when needed. event({area_change, QuestID, ZoneID, MapID, EntryID}) -> @@ -635,7 +640,7 @@ event({hit, FromTargetID, ToTargetID, A, B}) -> case Type of box -> %% @todo also has a hit sent, we should send it too - handle_events(Events); + events(Events); _ -> PlayerHP = (NewUser#egs_user_model.character)#characters.currenthp, case lists:member(death, TargetSE) of @@ -826,6 +831,10 @@ event({object_boss_gate_enter, ObjectID}) -> event({object_boss_gate_leave, _ObjectID}) -> ignore; +%% @doc Server-side event. +event({object_box_destroy, ObjectID}) -> + send_1213(ObjectID, 3); + %% @todo Second send_1211 argument should be User#egs_user_model.lid. Fix when it's correctly handled. event({object_chair_sit, ObjectTargetID}) -> %~ {ok, User} = egs_user_model:read(get(gid)), @@ -839,6 +848,10 @@ event({object_chair_stand, ObjectTargetID}) -> event({object_crystal_activate, ObjectID}) -> send_1213(ObjectID, 1); +%% @doc Server-side event. +event({object_event_trigger, BlockID, EventID}) -> + send_1205(EventID, BlockID, 0); + event({object_key_console_enable, ObjectID}) -> {ok, User} = egs_user_model:read(get(gid)), {BlockID, [EventID|_]} = psu_instance:std_event(User#egs_user_model.instancepid, (User#egs_user_model.area)#psu_area.zoneid, ObjectID), @@ -1064,16 +1077,6 @@ handle(16#170b, _) -> handle(Command, _) -> log("dismissed packet ~4.16.0b", [Command]). -%% @doc Handle a list of events. -handle_events([]) -> - ok; -handle_events([{explode, ObjectID}|Tail]) -> - send_1213(ObjectID, 3), - handle_events(Tail); -handle_events([{event, [BlockID, EventID]}|Tail]) -> - send_1205(EventID, BlockID, 0), - handle_events(Tail). - %% @doc Build the packet header. header(Command) -> GID = get(gid), diff --git a/src/psu/psu_instance.erl b/src/psu/psu_instance.erl index 99da72a..0db3f2b 100644 --- a/src/psu/psu_instance.erl +++ b/src/psu/psu_instance.erl @@ -215,8 +215,8 @@ object_select(ID) -> box_hit(#psu_object{args={BlockID, ObjectID, TrigEventID}}) -> Events = - if TrigEventID =:= false -> [{explode, ObjectID}]; - true -> [{explode, ObjectID}, {event, [BlockID, TrigEventID]}] + if TrigEventID =:= false -> [{object_box_destroy, ObjectID}]; + true -> [{object_box_destroy, ObjectID}, {object_event_trigger, BlockID, TrigEventID}] end, #hit_response{type=box, events=Events}.