Add wait after giving mission rewards

This commit is contained in:
fed 2023-04-09 19:33:41 +02:00
parent ae55d8af08
commit 41dd5ab7d0
3 changed files with 188 additions and 150 deletions

View File

@ -3,9 +3,6 @@
main() main()
{ {
replacefunc(maps\_credit_h2_autogen::_id_B775, ::initiwcredits); replacefunc(maps\_credit_h2_autogen::_id_B775, ::initiwcredits);
// fix credits victory screen
replacefunc(maps\_endmission::_nextmission, ::nextmission);
} }
initcredits_h2mod() initcredits_h2mod()
@ -32,150 +29,3 @@ initiwcredits()
maps\_credit_h2_autogen::initiwcredits_nerve(); maps\_credit_h2_autogen::initiwcredits_nerve();
maps\_credit_h2_autogen::initiwcredits_irongalaxy(); 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

@ -0,0 +1,171 @@
#include maps\_endmission;
main()
{
// fix credits victory screen & add wait after giving mission achievements
replacefunc(maps\_endmission::_nextmission, ::nextmission);
}
give_mission_achievement(name)
{
was_unlocked = achievementunlocked(name);
maps\_utility::giveachievement_wrapper(name);
if (!was_unlocked)
{
wait 4;
}
}
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))
{
give_mission_achievement(level.missionsettings getachievement(var_1));
}
if (level.missionsettings haslevelveteranaward(var_1) && getlevelcompleted(var_1) == 4 && level.missionsettings check_other_haslevelveteranachievement(var_1))
{
give_mission_achievement(level.missionsettings getlevelveteranaward(var_1));
}
if (level.missionsettings hasmissionhardenedaward() && level.missionsettings getlowestskill() > 2)
{
give_mission_achievement(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

@ -8,6 +8,8 @@
#include "scheduler.hpp" #include "scheduler.hpp"
#include "command.hpp" #include "command.hpp"
#include "gsc/script_extension.hpp"
#include "game/ui_scripting/execution.hpp" #include "game/ui_scripting/execution.hpp"
#include <utils/hook.hpp> #include <utils/hook.hpp>
@ -268,6 +270,21 @@ namespace achievements
get_achievements(&file); get_achievements(&file);
give_achievement_id_internal(&file, id); give_achievement_id_internal(&file, id);
}); });
gsc::add_function("achievementunlocked", []()
{
const auto name = game::Scr_GetString(0);
const auto id = get_achievement_id(name);
if (!id.has_value())
{
game::Scr_AddInt(0);
return;
}
achievement_file_t file{};
get_achievements(&file);
game::Scr_AddInt(has_achievement(&file, id.value()));
});
} }
}; };
} }