quests: Convert the Spaceport to configuration files.

This commit is contained in:
Loïc Hoguin 2010-11-08 19:24:08 +01:00
parent 681d61e73c
commit 1e83a98d22
5 changed files with 69 additions and 12 deletions

View File

@ -204,7 +204,7 @@
{1102000, [{type, lobby}, {file, nofile}]}, {1102000, [{type, lobby}, {file, nofile}]},
{1103000, [{type, lobby}, {file, nofile}]}, {1103000, [{type, lobby}, {file, nofile}]},
{1104000, [{type, spaceport}, {file, "data/lobby/spaceport.quest.nbl"}]}, {1104000, [{type, spaceport}, {file, nofile}]},
% Tutorial % Tutorial

View File

@ -0,0 +1,48 @@
%% This file is part of EGS.
%%
%% EGS is free software: you can redistribute it and/or modify
%% it under the terms of the GNU Affero General Public License as
%% published by the Free Software Foundation, either version 3 of the
%% License, or (at your option) any later version.
%%
%% EGS is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%% GNU Affero General Public License for more details.
%%
%% You should have received a copy of the GNU Affero General Public License
%% along with EGS. If not, see <http://www.gnu.org/licenses/>.
%% Spaceport.
{questid, 1104000}.
%% @doc The spaceport doesn't need unit_title* files.
{notitles, true}.
%% @todo Default to {1, 6} if missing?
{party_size, {1, 6}}.
%% @todo Those should probably default to those values if unspecified (lobbies).
{cursor, {0, 0}}.
{icon, 65535}.
%% @todo Default enemy_level to 1 if unspecified (lobbies).
{zones, [
[{zoneid, 0}, {areaid, 2}, {enemy_level, 1}, {sets, []}, {maps, [900]}]
]}.
{temp_flags, []}.
{value_flags, ["SV_WK_LC_RETURN"]}.
{bool_flags, []}.
{items, []}.
%% @todo if is questid then defaults to ffffffff.
%% @todo Default to full ffff if missing.
{enter_warp, {1104000, 0, 900, 0}}.
{exit_warp, {1104000, 65535, 65535, 65535}}.
{fail_warp, {1104000, 65535, 65535, 65535}}.
%% @doc Current -> next. Values are the area and the exit/entrance entryid.
{warps, []}.

View File

@ -4,3 +4,4 @@ List of quests:
1101000 Parum lobbies 1101000 Parum lobbies
1102000 Neudaiz lobbies 1102000 Neudaiz lobbies
1103000 Moatoob lobbies 1103000 Moatoob lobbies
1104000 PPT Spaceport

View File

@ -187,6 +187,8 @@ load_quest_xnr_warps(QuestID, [Warp|Tail], Acc) ->
Bin2 = load_quest_xnr_warp(QuestID, NextWarp), Bin2 = load_quest_xnr_warp(QuestID, NextWarp),
load_quest_xnr_warps(QuestID, Tail, [<< Bin1/binary, Bin2/binary >>|Acc]). load_quest_xnr_warps(QuestID, Tail, [<< Bin1/binary, Bin2/binary >>|Acc]).
%% @todo Counter(16#7fffffff) has ffff before EnemyLevel, why?
%% @todo Spaceport(1104000) and counter(16#7fffffff) has 04010000 be 00010000, why?
load_quest_xnr_zones(ZonesList, BasePos) -> load_quest_xnr_zones(ZonesList, BasePos) ->
load_quest_xnr_zones(ZonesList, BasePos, [], [], []). load_quest_xnr_zones(ZonesList, BasePos, [], [], []).
load_quest_xnr_zones([], _BasePos, SetsAcc, SetsPtrsAcc, ZonesAcc) -> load_quest_xnr_zones([], _BasePos, SetsAcc, SetsPtrsAcc, ZonesAcc) ->

View File

@ -85,15 +85,17 @@ get_quest(QuestID, Cache) ->
ConfFilename = Dir ++ "quest.conf", ConfFilename = Dir ++ "quest.conf",
{QuestXnrData, QuestXnrPtrs} = egs_files:load_quest_xnr(ConfFilename), {QuestXnrData, QuestXnrPtrs} = egs_files:load_quest_xnr(ConfFilename),
UnitTitleBinFiles = load_unit_title_bin_files(Dir, ConfFilename), UnitTitleBinFiles = load_unit_title_bin_files(Dir, ConfFilename),
TablePos = egs_files:nbl_padded_size(byte_size(QuestXnrData)), Files = [{data, "quest.xnr", QuestXnrData, QuestXnrPtrs}],
TextSize = lists:sum([egs_files:nbl_padded_size(byte_size(D)) || {data, _F, D, _P} <- UnitTitleBinFiles]), Files2 = Files ++ case UnitTitleBinFiles of
TablePos2 = TablePos + TextSize, ignore -> [];
{UnitTitleTableRelData, UnitTitleTableRelPtrs} = egs_files:load_unit_title_table_rel(ConfFilename, TablePos2), _Any ->
QuestNbl = egs_files:nbl_pack([{files, TablePos = egs_files:nbl_padded_size(byte_size(QuestXnrData)),
[{data, "quest.xnr", QuestXnrData, QuestXnrPtrs}] TextSize = lists:sum([egs_files:nbl_padded_size(byte_size(D)) || {data, _F, D, _P} <- UnitTitleBinFiles]),
++ UnitTitleBinFiles TablePos2 = TablePos + TextSize,
++ [{data, "unit_title_table.rel", UnitTitleTableRelData, UnitTitleTableRelPtrs}] {UnitTitleTableRelData, UnitTitleTableRelPtrs} = egs_files:load_unit_title_table_rel(ConfFilename, TablePos2),
}]), UnitTitleBinFiles ++ [{data, "unit_title_table.rel", UnitTitleTableRelData, UnitTitleTableRelPtrs}]
end,
QuestNbl = egs_files:nbl_pack([{files, Files2}]),
Quest = [{quest, QuestNbl}], Quest = [{quest, QuestNbl}],
Cache2 = [{QuestID, Quest}|Cache], Cache2 = [{QuestID, Quest}|Cache],
{Quest, Cache2}; {Quest, Cache2};
@ -103,8 +105,12 @@ get_quest(QuestID, Cache) ->
load_unit_title_bin_files(Dir, ConfFilename) -> load_unit_title_bin_files(Dir, ConfFilename) ->
{ok, Settings} = file:consult(ConfFilename), {ok, Settings} = file:consult(ConfFilename),
Zones = proplists:get_value(zones, Settings), case proplists:get_value(notitles, Settings) of
[load_unit_title_bin(Dir, Zone) || Zone <- Zones]. true -> ignore;
_Any ->
Zones = proplists:get_value(zones, Settings),
[load_unit_title_bin(Dir, Zone) || Zone <- Zones]
end.
load_unit_title_bin(Dir, Zone) -> load_unit_title_bin(Dir, Zone) ->
ZoneID = proplists:get_value(zoneid, Zone), ZoneID = proplists:get_value(zoneid, Zone),