Fix credits victory screen

This commit is contained in:
fed 2023-04-07 03:24:45 +02:00
parent d30f94529b
commit 3fe7d970d1
7 changed files with 306 additions and 32 deletions

View File

@ -1,6 +1,11 @@
#include maps\_endmission;
main()
{
replacefunc(maps\_credit_h2_autogen::_id_B775, ::initiwcredits);
// fix credits victory screen
replacefunc(maps\_endmission::_nextmission, ::nextmission);
}
initcredits_h2mod()
@ -27,3 +32,150 @@ initiwcredits()
maps\_credit_h2_autogen::initiwcredits_nerve();
maps\_credit_h2_autogen::initiwcredits_irongalaxy();
}
nextmission(var_0)
{
level notify("achievements_level_complete");
if (level.script == "ending" && level._id_AC38 != "credits_1")
{
changelevel("");
}
else
{
if (!isdefined(var_0))
var_0 = 0;
level notify("nextmission");
level.player notify("levelComplete");
level.nextmission = 1;
level.player enableinvulnerability();
if (maps\_utility::arcademode())
{
level._id_AC81 = 1;
thread _id_D36F::_id_AF95();
common_scripts\utility::flag_wait("arcademode_ending_complete");
}
var_1 = undefined;
setsaveddvar("ui_nextMission", "1");
setdvar("ui_showPopup", "0");
setdvar("ui_popupString", "");
if (level.script == "ending")
{
level.script = "af_chase";
nextmission(1);
level.script = "ending";
}
game["previous_map"] = level.script;
var_1 = level.missionsettings getlevelindex(level.script);
if (!(level.script == "af_chase" && var_0) && !maps\_utility::achievement_conditions("IMMORTAL"))
{
_func_1FC(level.script, var_1);
updategamerprofileall();
maps\_endmission::check_immortal_achievement();
}
maps\_gameskill::auto_adust_zone_complete("aa_main_" + level.script);
if (!isdefined(var_1))
{
missionsuccess(level.script);
return;
}
if (level.script != "ending" && !(level.script == "af_chase" && var_0))
{
level.player thread maps\_hud_util::fade_out(1, undefined);
soundscripts\_snd::snd_message("end_mission_fade_to_black");
wait 2;
maps\_utility::level_end_save();
}
if (level.script != "af_chase" || var_0)
{
level.missionsettings setlevelcompleted(var_1);
var_3 = maps\_endmission::updatesppercent();
updategamerprofile();
if (level.missionsettings hasachievement(var_1))
maps\_utility::giveachievement_wrapper(level.missionsettings getachievement(var_1));
if (level.missionsettings haslevelveteranaward(var_1) && getlevelcompleted(var_1) == 4 && level.missionsettings check_other_haslevelveteranachievement(var_1))
maps\_utility::giveachievement_wrapper(level.missionsettings getlevelveteranaward(var_1));
if (level.missionsettings hasmissionhardenedaward() && level.missionsettings getlowestskill() > 2)
maps\_utility::giveachievement_wrapper(level.missionsettings gethardenedaward());
level.missionsettings maps\_endmission::_id_D1B9();
var_4 = level.missionsettings.levels.size;
}
if (level.script == "af_chase" && var_0)
return;
if (level.script == "ending" && level._id_AC38 == "credits_1")
common_scripts\utility::flag_wait("af_chase_nextmission");
if (level.script == "airplane" || level.script == "ending")
{
if (level.credits_active)
{
level notify("credits_ended");
credits_end();
}
setsaveddvar("ui_nextMission", "0");
return;
}
else
{
var_4 = var_1 + 1;
}
if (getdvarint("limited_mode"))
{
setsaveddvar("ui_nextMission", "0");
changelevel("");
return;
}
if (maps\_utility::arcademode())
{
if (!getdvarint("arcademode_full"))
{
setsaveddvar("ui_nextMission", "0");
changelevel("");
return;
}
if (level.script == "cargoship")
{
changelevel("blackout", level.missionsettings getkeepweapons(var_1));
return;
}
else if (level.script == "airlift")
{
changelevel("village_assault", level.missionsettings getkeepweapons(var_1));
return;
}
else if (level.script == "jeepride")
{
changelevel("airplane", level.missionsettings getkeepweapons(var_1));
return;
}
}
if (level.missionsettings skipssuccess(var_1))
{
changelevel(level.missionsettings getlevelname(var_4), level.missionsettings getkeepweapons(var_1));
return;
}
missionsuccess(level.missionsettings getlevelname(var_4), level.missionsettings getkeepweapons(var_1));
}
}

View File

@ -1 +1,2 @@
require("credits")
require("victoryscreen")

View File

@ -0,0 +1,85 @@
local specopsmod = "mods/specops"
function CampaignCompleteMenu()
Engine.ExecNow("profile_menuDvarsSetup")
Engine.SetDvarBool("profileMenuOption_resumeIsGameCompleted", true)
Engine.ExecNow("profile_menuDvarsFinish")
Engine.Exec("updategamerprofile")
local victory = LUI.UIImage.new({
material = RegisterMaterial("victory"),
top = -300,
width = 1126,
height = 563,
alpha = 0
})
victory:registerAnimationState("show", {
alpha = 1
})
victory:animateInSequence({
{
"default",
0
},
{
"show",
1000
}
})
local topoffset = 590
local text = LUI.UIText.new({
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = false,
top = topoffset,
bottom = topoffset + CoD.TextSettings.BodyFont18.Height,
font = CoD.TextSettings.BodyFont18.Font,
alignment = LUI.Alignment.Center,
alpha = 0
})
text:registerAnimationState("show", {
alpha = 1
})
text:setText(Engine.Localize("@MENU_SP_CONTINUE_TO_SPECIAL_OPS_CAPS"))
victory:addElement(text)
victory.text = text
victory.skipLocked = true
victory:addElement(LUI.UITimer.new(3000, "enable_quit", nil, true))
victory:registerEventHandler("enable_quit", function (element, event)
element.text:animateToState("show", 300)
element.skipLocked = false
end)
local buttonhandler = function (element, event)
if (element.skipLocked) then
return
else
if (mods.getinfo(specopsmod).isvalid) then
mods.load(specopsmod)
else
game:openlink("specops")
Engine.PlaySound(CoD.SFX.MenuAccept)
Engine.PopupClosed(event.controller, "accept_normal")
LUI.FlowManager.RequestCloseAllMenus(element)
end
end
end
local bindbutton = LUI.UIBindButton.new()
bindbutton:registerEventHandler("button_start", buttonhandler)
bindbutton:registerEventHandler("button_action", buttonhandler)
bindbutton:registerEventHandler("button_secondary", buttonhandler)
bindbutton.handlePrimary = true
victory:addElement(bindbutton)
return victory
end
LUI.MenuBuilder.m_types_build["MENU_CAMPAIGN_COMPLETED"] = CampaignCompleteMenu

View File

@ -332,6 +332,11 @@ namespace mods
return mod_list;
}
bool mod_exists(const std::string& folder)
{
return utils::io::directory_exists(utils::string::va("%s\\%s", MOD_FOLDER, folder.data()));
}
std::optional<nlohmann::json> get_mod_info(const std::string& name)
{
const auto info_file = name + "/info.json";
@ -353,6 +358,46 @@ namespace mods
return {};
}
void load(const std::string& path)
{
if (!utils::io::directory_exists(path))
{
console::error("Mod %s not found!\n", path.data());
return;
}
console::info("Loading mod %s\n", path.data());
set_mod(path);
if ((mod_info.path.has_value() && mod_requires_restart(mod_info.path.value())) ||
mod_requires_restart(path))
{
// vid_restart is still broken :(
console::info("Restarting...\n");
full_restart("-mod "s + path);
}
else
{
restart();
}
}
void unload()
{
console::info("Unloading mod %s\n", mod_info.path.value().data());
if (mod_requires_restart(mod_info.path.value()))
{
console::info("Restarting...\n");
full_restart("");
}
else
{
clear_mod();
restart();
}
}
class component final : public component_interface
{
public:
@ -386,26 +431,7 @@ namespace mods
}
const auto path = params.get(1);
if (!utils::io::directory_exists(path))
{
console::error("Mod %s not found!\n", path);
return;
}
console::info("Loading mod %s\n", path);
set_mod(path);
if ((mod_info.path.has_value() && mod_requires_restart(mod_info.path.value())) ||
mod_requires_restart(path))
{
// vid_restart is still broken :(
console::info("Restarting...\n");
full_restart("-mod "s + path);
}
else
{
restart();
}
load(path);
});
command::add("unloadmod", [](const command::params& params)
@ -423,18 +449,7 @@ namespace mods
return;
}
console::info("Unloading mod %s\n", mod_info.path.value().data());
if (mod_requires_restart(mod_info.path.value()))
{
console::info("Restarting...\n");
full_restart("");
}
else
{
clear_mod();
restart();
}
unload();
});
command::add("com_restart", []()

View File

@ -28,8 +28,12 @@ namespace mods
std::optional<std::string> get_mod();
std::vector<mod_zone> get_mod_zones();
void load(const std::string& path);
void unload();
std::vector<std::string> get_mod_list();
std::optional<nlohmann::json> get_mod_info(const std::string& mod);
bool mod_exists(const std::string& folder);
nlohmann::json& get_current_stats();
void write_mod_stats();

View File

@ -180,6 +180,7 @@ namespace motd
{
{"github", "https://github.com/fedddddd/h2-mod"},
{"donate", "https://www.paypal.com/donate/?hosted_button_id=LM5BA9UABEV4Q"},
{"specops", "https://github.com/fedddddd/h2-specops-mod"},
{"credits_1", "https://github.com/momo5502"},
{"credits_2", "https://github.com/VladWinner"},
{"credits_3", "https://github.com/diamante0018"},

View File

@ -482,6 +482,22 @@ namespace ui_scripting
return info_table;
};
mods_table["load"] = [](const std::string& mod)
{
scheduler::once([=]()
{
mods::load(mod);
}, scheduler::main);
};
mods_table["unload"] = []
{
scheduler::once([]()
{
mods::unload();
}, scheduler::main);
};
auto mods_stats_table = table();
mods_table["stats"] = mods_stats_table;