Skip to content

[ZM] Script Function Call Order

JezuzLizard edited this page Apr 26, 2022 · 4 revisions

This page will describe the call order of functions for ZM. In ZM there are four entry points for starting up the game logic. Only notable functions are included. In map functions we'll use the Nuketown zombies map since it is the most barebones map in T6ZM. In gametype functions we'll use zclassic since it is the most basic gametype.

Key: code means its an engine function. The arrows and numbers indicate the depth of the call relative to the original caller.

Gametype::main()

code::Scr_LoadGameType()
-1> maps\mp\gametypes_zm\zclassic::main();
--2> maps\mp\gametypes_zm\_zm_gametype::main();
---3> maps\mp\gametypes_zm\_globallogic::init();
----4> maps\mp\gametypes_zm\_tweakables::init();
---3> maps\mp\gametypes_zm\_callbacksetup::setupcallbacks();
----4> maps\mp\gametypes_zm\_callbacksetup::setdefaultcallbacks();
---3> maps\mp\gametypes_zm\_zm_gametype::globallogic_setupdefault_zombiecallbacks();
---3> maps\mp\gametypes_zm\_zm_gametype::menu_init();
--2> maps\mp\gametypes_zm\_zm_gametype::post_gametype_main( "zclassic" );

The first eight functions are called in every gametype script in order to setup the ZM gametype. As you can see most of the gametype logic is setup in _zm_gametype and not in the zclassic script. This is because ZM was ported over to the MP engine which uses gametype scripts as the primary entry point for the game logic. Much of the MP scripts are unused in ZM indicating that ZM was probably rushed not allowing time to properly optimize the scripts to not waste so many variables. Most of the zombies specific features are initialized by the map script not the gametype script.

Mapname::main()

code::Scr_LoadLevel()
-1> maps\mp\zm_nuked::main();
--2> maps\mp\zm_nuked_fx::main();
--2> maps\mp\zombies\_zm::init_fx();
--2> maps\mp\zombies\_load::main();
---3> common_scripts\utility::struct_class_init();
--2> maps\mp\zombies\_zm::init();
---3> maps\mp\zombies\_zm_zonemgr::init();
---3> maps\mp\zombies\_zm_unitrigger::init();
---3> maps\mp\zombies\_zm_audio::init();
---3> maps\mp\zombies\_zm_blockers::init();
---3> maps\mp\zombies\_zm_bot::init();
---3> maps\mp\zombies\_zm_clone::init();
---3> maps\mp\zombies\_zm_buildables::init();
---3> maps\mp\zombies\_zm_equipment::init();
---3> maps\mp\zombies\_zm_laststand::init();
---3> maps\mp\zombies\_zm_magicbox::init();
---3> maps\mp\zombies\_zm_perks::init();
---3> maps\mp\zombies\_zm_playerhealth::init();
---3> maps\mp\zombies\_zm_power::init();
---3> maps\mp\zombies\_zm_powerups::init();
---3> maps\mp\zombies\_zm_score::init();
---3> maps\mp\zombies\_zm_spawner::init();
---3> maps\mp\zombies\_zm_gump::init();
---3> maps\mp\zombies\_zm_timer::init();
---3> maps\mp\zombies\_zm_traps::init();
---3> maps\mp\zombies\_zm_weapons::init();
---3> maps\mp\zombies\_zm::init_function_overrides();

As you can see the mapname::main() sets up most of the zombie logic.

Mapname::gamemode_callback_setup

code::Scr_LoadGameType()
-1> maps\mp\zm_nuked_gamemodes::init();
--2> add_map_gamemode( "zstandard", maps\mp\zm_nuked::zstandard_preinit, undefined, undefined );
--2> add_map_location_gamemode( "zstandard", "nuked", maps\mp\zm_nuked_standard::precache, maps\mp\zm_nuked_standard::main );

Primarily used to define sub locations for a map. Used in all maps but only Tranzit, Mob of the Dead, and Buried have more than the default location defined.

_callbacksetup::CodeCallback_StartGameType

code::Scr_StartupGameType()
-1> maps\mp\gametypes_zm\_callbacksetup::codecallback_startgametype()
--2> maps\mp\gametypes_zm\_globallogic::callback_startgametype();
---3> maps\mp\gametypes_zm\zclassic::onprecachegametype();
----4> maps\mp\gametypes_zm\_zm_gametype::rungametypeprecache( "zclassic" );;
---3> thread maps\mp\gametypes_zm\_hud::init();
---3> thread maps\mp\gametypes_zm\_serversettings::init();
---3> thread maps\mp\gametypes_zm\_clientids::init();
---3> thread maps\mp\gametypes_zm\_weaponobjects::init();
---3> thread maps\mp\gametypes_zm\_scoreboard::init();
---3> thread maps\mp\gametypes_zm\_shellshock::init();
---3> thread maps\mp\gametypes_zm\_spectating::init();
---3> thread maps\mp\gametypes_zm\_gameobjects::init();
---3> thread maps\mp\gametypes_zm\_spawnlogic::init();
---3> thread maps\mp\gametypes_zm\_globallogic_audio::init();
---3> maps\mp\gametypes_zm\zclassic::onstartgametype();
----4> maps\mp\gametypes_zm\_zm_gametype::rungametypemain( "zclassic", maps\mp\gametypes_zm\_zm_gametype::zclassic_main );
-----5> level thread maps\mp\gametypes_zm\_zm_gametype::setup_classic_gametype();
-----5> level thread maps\mp\zombies\_zm::round_start();

Clone this wiki locally