Stadium Server
Stadium Server
25 for PES 2020 - assign the stadium for either home team or
competition
-- Custom content is used, not LiveCPK/game: content\stadium-server is the root
-- author: zlac, 2018-2020
-- extra credits: juce
-- originally posted on evo-web
-- local new_stadium_path
local version = "1.25"
local stadiumroot = ".\\content\\stadium-server\\"
local stadium_switched = false
local stadium_name_switched = false
local last_choice
local settings
--[[
local replay_stad_id = nil
local replay_source_stadium_map = nil
local replay_source_stadium_key = nil
]]--
local team_assignment_map = {}
local competition_assignment_map = {}
local all_stadiums_map = {}
local _stadium_info = {}
local current_stadium_preview_path
local stadium_config = {}
-- dump_table(konami_stadiums_map)
-- log(dump_table(all_stadiums_map))
total_stadiums = tableLength(all_stadiums_map)
if total_stadiums > 0 then
manual_stad_idx = 1
end
log(string.format("%s unique stadiums available for random selection in
exhibition modes.", total_stadiums))
table.sort(all_stadiums_map, compare_stadium_names)
end
table.insert(competition_assignment_map[tonumber(fields[1])], {fields[2],
fields[3], fields[4], fields[5], fields[6], fields[7]})
else
competition_assignment_map[tonumber(fields[1])] =
{ {fields[2], fields[3], fields[4], fields[5], fields[6], fields[7]} }
end
_log(string.format(" ==> %s stadium assignment:: competition:
%s -> stadium_id: %s, stadium: %s (%s) (finals: %s %s (%s))", filename, fields[1],
fields[2], fields[4], fields[3], fields[5], fields[7], fields[6]))
end
end
end
end
end
--now for competiton modes ... whenever game selects new home_team, pick a
random index of a stadium to be used on competition level (e.g. if multiple
stadiums are assigned to one competition_ID)
random_num_comp = nil
if tid < 65535 and competition_assignment_map[tid] ~= nil then
if #competition_assignment_map[tid] == 1 then
-- if there's only one stadium assigned to competition, set "random"
number to 1
random_num_comp = 1
else
-- if there are more stadiums, select one index rendomly
-- math.randomseed(os.time())
random_num_comp = get_random_stad(#competition_assignment_map[tid]) --
math.random(1, #competition_assignment_map[tid])
_log("Selecting random stadium for competition ID " .. tostring(tid) ..
": Stadium no. " .. tostring(random_num_comp) .. " (from " ..
tostring(#competition_assignment_map[tid]) .. " stadium(s) available)")
end
end
end
-- reset ctx.stadium_server
ctx.stadium_server = nil
-- if in-game stadium settings for exhibition modes are set to 'Random', then
decide where to choose the stadium from - stadium server or .cpk
--[[
math.randomseed(os.time())
rnd_server_or_cpk = math.random(1, 100)
if rnd_server_or_cpk % 2 == 0 then
rnd_server_or_cpk = 1 -- if even number, use stadium from stadium server
else
rnd_server_or_cpk = 2 -- otherwise if odd, use stadium from .cpk
end
]]--
-- newer approach, sider 5.1.4 - easier for getting Konami stadium previews,
all Konami stadiums must be assigned in map_competitions.txt to ID 0
rnd_server_or_cpk = 1 -- always use stadium server as a source, Konami's
stadiums are listed too
_log("If 'Random' in-game setting will be used in exhibition modes:: Source of
random stadiums - either stadium server (1) or from .cpk (2): " ..
tostring(rnd_server_or_cpk) )
end
if
string.match(filename, "asset\\model\\bg\\common") or -- sweeping match of
every gfx-related common asset for stadiums (too generic, perhaps??)
string.match(filename, "asset\\model\\bg\\st%d%d%d") or -- every stadium-
specific asset (stXXX)
string.match(filename, "common\\bg\\model\\bg\\draw_parameter") or
string.match(filename, "common\\bg\\model\\bg\\tv") or
string.match(filename, "common\\demo\\fixdemo") or
string.match(filename, "common\\demo\\fixdemoobj") or
string.match(filename, "common\\demo\\light") or
string.match(filename, "common\\demo\\mob") or
string.match(filename, "common\\demo\\prop") or
string.match(filename, "common\\render\\model\\bg\\hit\\stadium")
then
return true
else
return false
end
end
if ctx.stadserv_addons_list then
-- weather-specific files for a specific stadium have priority ...
if override_found == false and weatherPrefix and weatherTypePrefix then
-- fine/rainy/snowy specifics first
for idx_key, mod_name in pairs(ctx.stadserv_addons_list) do
if file_exists(stadiumroot .. stadium_path .. "\\AddOn\\" ..
mod_name .. "\\" .. st_id .. "\\" .. weatherPrefix .. "\\" .. weatherTypePrefix ..
"\\".. filename) then
_log("Weather-type-specific, fixed-stadium AddOn file
found: " .. stadium_path .. "\\AddOn\\" .. mod_name .. "\\".. st_id .. "\\" ..
weatherPrefix .. "\\" .. weatherTypePrefix .. "\\" .. filename )
stadium_path = stadium_path .. "\\AddOn\\" .. mod_name ..
"\\".. st_id .. "\\" .. weatherPrefix .. "\\" .. weatherTypePrefix
-- _log("stadium_path (weather-type-specific): " ..
stadium_path)
override_found = true
break
end
end
-- if not fine/rain/snowy, then fallback to weather-specific that
considers only season and time of day
if override_found == false then
for idx_key, mod_name in pairs(ctx.stadserv_addons_list) do
if file_exists(stadiumroot .. stadium_path ..
"\\AddOn\\" .. mod_name .. "\\" .. st_id .. "\\" .. weatherPrefix .. "\\" ..
filename) then
_log("Weather-specific, fixed-stadium AddOn file found:
" .. stadium_path .. "\\AddOn\\" .. mod_name .. "\\".. st_id .. "\\" ..
weatherPrefix .. "\\" .. filename )
stadium_path = stadium_path .. "\\AddOn\\" ..
mod_name .. "\\".. st_id .. "\\" .. weatherPrefix
-- _log("stadium_path (weather-specific): " ..
stadium_path)
override_found = true
break
end
end
-- if not weather-specific, then perhaps there is a non
weather-specific version of a file for a specific stadium id?
if override_found == false then
-- fine/rainy/snowy specifics first
for idx_key, mod_name in pairs(ctx.stadserv_addons_list) do
if file_exists(stadiumroot .. stadium_path ..
"\\AddOn\\" .. mod_name .. "\\".. st_id .. "\\Any_Weather\\" ..
weatherTypePrefix .. "\\".. filename) then
_log("Any-weather (type-specific), fixed-stadium
AddOn file found: " .. stadium_path .. "\\AddOn\\" .. mod_name .. "\\".. st_id ..
"\\Any_Weather\\" .. weatherTypePrefix .. "\\".. filename )
stadium_path = stadium_path .. "\\AddOn\\" ..
mod_name .. "\\".. st_id.. "\\Any_Weather\\" .. weatherTypePrefix
-- _log("stadium_path (any-weather, type-specific):
" .. stadium_path)
override_found = true
break
end
end
-- if not fine/rain/snowy, then fallback to any-weather
if override_found == false then
for idx_key, mod_name in
pairs(ctx.stadserv_addons_list) do
if file_exists(stadiumroot .. stadium_path ..
"\\AddOn\\" .. mod_name .. "\\".. st_id .. "\\Any_Weather\\" .. filename) then
_log("Any-weather, fixed-stadium AddOn file
found: " .. stadium_path .. "\\AddOn\\" .. mod_name .. "\\".. st_id ..
"\\Any_Weather\\" .. filename )
stadium_path = stadium_path .. "\\AddOn\\" ..
mod_name .. "\\".. st_id.. "\\Any_Weather"
-- _log("stadium_path (any-weather): " ..
stadium_path)
override_found = true
break
end
end
-- competitionID-based overrides
(e.g. UCL stadium boards, etc.)
if override_found == false then
for idx_key, mod_name in
pairs(ctx.stadserv_addons_list) do
if
file_exists(stadiumroot .. stadium_path .. "\\AddOn\\" .. mod_name .. "\\Comp\\" ..
comp_id .. "\\" .. filename) then
_log("Competition-
based AddOn file found: " .. stadium_path .. "\\AddOn\\" .. mod_name ..
"\\Comp\\" .. comp_id .. "\\" .. filename )
stadium_path =
stadium_path .. "\\AddOn\\" .. mod_name .. "\\Comp\\" .. comp_id
--
_log("stadium_path (competition-based): " .. stadium_path)
override_found =
true
break
end
end
-- if not stadium/pack-global
file too, then perhaps there is a uber-generic version of a file for an entire
stadium server?
if override_found == false
then
if
file_exists(stadiumroot .. "\\Super-Global\\" .. filename) then
end
-- if override_found == true then
-- _log("AddOn:: Overriden file path to be used: " .. stadium_path)
-- end
end
-- this event allows only stadium_id to be changed in options!! other params are
read-only (time of day/weather/weather effects/season)
local function set_stadium(ctx, options)
random_num_exhib = nil
random_num_comp = nil
end
end
end
local new_stadium_path
local custom_st_id
local new_stadium_name
if changed then
return options
end
end
end
ctx.register("set_stadium", set_stadium)
ctx.register("set_conditions", set_weather_conditions)
ctx.register("get_stadium_name", change_stadium_name)
ctx.register("livecpk_make_key", make_key)
ctx.register("livecpk_get_filepath", get_filepath)
ctx.register("set_teams", teams_selected)
ctx.register("overlay_on", overlay_on)
ctx.register("key_down", key_down)
ctx.register("after_set_conditions", change_gfx_preview_fallback)
end