Skip to content

Un-Hardcode Gamemodes #37

@Heapons

Description

@Heapons

Examples

CTeamFortress2Mod::mapInit()

void CTeamFortress2Mod :: mapInit ()
{
	(...)
	if (std::strncmp(szmapname, "ctf_", 4) == 0 || std::strncmp(szmapname, "quake_turbine", 13) == 0 ||
		std::strncmp(szmapname, "pass_", 5) == 0 || std::strncmp(szmapname, "pd_", 3) == 0 ||
		std::strncmp(szmapname, "od_", 3) == 0 ||
		(std::strncmp(szmapname, "slendytubbies", 13) == 0 &&
			!(std::strncmp(szmapname, "ctf_chouhen", 11) == 0 || std::strncmp(szmapname, "ctf_haarp", 9) == 0)))
		// Quake Turbine is CTF. - RussiaTails
		m_MapType = TF_MAP_CTF; // capture the flag
	else if (std::strncmp(szmapname, "cp_", 3) == 0 || std::strncmp(szmapname, "cqt_", 4) == 0 ||
		std::strncmp(szmapname, "conquest_", 9) == 0 || std::strncmp(szmapname, "dom_", 4) == 0 ||
		std::strncmp(szmapname, "2koth_", 6) == 0 || std::strncmp(szmapname, "ctf_chouhen", 11) == 0 ||
		std::strncmp(szmapname, "ctf_haarp", 9) == 0 || std::strncmp(szmapname, "falling_cp", 10) == 0 ||
		std::strncmp(szmapname, "stt_", 4) == 0 || std::strncmp(szmapname, "koth_lifesnatcher", 17) == 0 ||
		(std::strncmp(szmapname, "vip_", 4) == 0 &&
			std::strncmp(szmapname, "cp_helmsdeep_v2", 15) != 0))
		// Conquest, 2koth and DOM works fine as CP_. Moved stt to cp to make bots attack a tank - RussiaTails
		m_MapType = TF_MAP_CP; // control point
	else if (std::strncmp(szmapname, "tc_", 3) == 0)
		m_MapType = TF_MAP_TC; // territory control
	else if (std::strncmp(szmapname, "pl_", 3) == 0 ||
		(std::strncmp(szmapname, "kotc_", 5) == 0 &&
			(!(std::strncmp(szmapname, "pl_fountain", 11) == 0 ||
				std::strncmp(szmapname, "pl_divulgence", 13) == 0))))
		// Tug of War works fine as Payload - RussiaTails
		m_MapType = TF_MAP_CART; // pipeline
	else if (std::strncmp(szmapname, "plr_", 4) == 0 || std::strncmp(szmapname, "tow_", 4) == 0 ||
		std::strncmp(szmapname, "arena_tinyrock", 14) == 0 || std::strncmp(szmapname, "tow_impasse", 11) == 0 ||
		std::strncmp(szmapname, "arena_hailstone", 15) == 0) // to make bots push payloads on these maps. - RussiaTails
		m_MapType = TF_MAP_CARTRACE; // pipeline racing
	else if (std::strncmp(szmapname, "arena_", 6) == 0 || std::strncmp(szmapname, "ft_", 3) == 0)  // pongo1321
		m_MapType = TF_MAP_ARENA; // arena mode
	else if (std::strncmp(szmapname, "vsh_", 4) == 0)
		m_MapType = TF_MAP_SAXTON; // arena mode
	else if (std::strncmp(szmapname, "pipeball_", 9) == 0)
		m_MapType = TF_MAP_PIPEBALL; // arena mode
	else if (std::strncmp(szmapname, "koth_", 5) == 0 || std::strncmp(szmapname, "ctk_", 4) == 0)
		// Control the Keep works almost the same as KOTH. - RussiaTails
		m_MapType = TF_MAP_KOTH; // king of the hill
	else if (std::strncmp(szmapname, "sd_", 3) == 0 || std::strncmp(szmapname, "sdr_", 4) == 0)
		// Object Destruction and Special Delivery Race (I dunno why it's named like this when it works as a usual sd_) works the same as SD_. - RussiaTails
		m_MapType = TF_MAP_SD; // special delivery
	else if (std::strncmp(szmapname, "tr_", 3) == 0)
		m_MapType = TF_MAP_TR; // training mode
	else if (std::strncmp(szmapname, "cppl_", 5) == 0 || std::strncmp(szmapname, "pl_fountain", 11) == 0 ||
		std::strncmp(szmapname, "pl_divulgence", 13) == 0 || std::strncmp(szmapname, "cp_helmsdeep_v2", 15) == 0 ||
		std::strncmp(szmapname, "cw_", 3) == 0) // Hybrid - RussiaTails
		m_MapType = TF_MAP_CPPL; // CP+PL maps
	else if (std::strncmp(szmapname, "gg_", 3) == 0 || std::strncmp(szmapname, "dm_hydro_v20", 12) == 0 ||
		std::strncmp(szmapname, "dm_powerdown_v20", 16) == 0 || std::strncmp(szmapname, "dm_forgecall_v20", 16) == 0 ||
		std::strncmp(szmapname, "dm_poolparty_v20", 16) == 0 || std::strncmp(szmapname, "dm_badworks_v20", 15) == 0 ||
		std::strncmp(szmapname, "dm_razorpoint_v20", 17) == 0 || std::strncmp(szmapname, "dm_deadlock_v20", 15) == 0)
		// GunGame (and non-team deathmatch) - RussiaTails
		m_MapType = TF_MAP_GG; // GunGame maps
	else if (std::strncmp(szmapname, "mvm_", 4) == 0 || std::strncmp(szmapname, "gd_", 3) == 0)
		// gd is MvM Guardian, for now there are only two maps exist with this prefix. - RussiaTails
		m_MapType = TF_MAP_MVM; // mann vs machine
	else if (std::strncmp(szmapname, "rd_", 3) == 0)
		m_MapType = TF_MAP_RD; // robot destruction
	else if (std::strncmp(szmapname, "zi_", 3) == 0)
		m_MapType = TF_MAP_ZI; // Zombie Infection //TODO: add support for those gamemodes [APG]RoboCop[CL]
	else
		m_MapType = TF_MAP_DM; // deathmatch //TODO: to prevent bots from idling in their spawns by giving them basic tasks [APG]RoboCop[CL]
	(...)
}

CBotFortress::startGame()

bool CBotFortress::startGame()
{
	(...)
	else if (m_iClass == TF_CLASS_MAX)
	// Removed "(m_iDesiredClass > 0 && (m_iClass != m_iDesiredClass))" to avoid bots trying to change class when it was forced by something like in VSH and VIP maps
	{
		// can't change class in MVM during round!
		if (CTeamFortress2Mod::isMapType(TF_MAP_MVM) && CTeamFortress2Mod::hasRoundStarted())
		{
			return true;
		}
		if (CTeamFortress2Mod::isMapType(TF_MAP_SAXTON) || CTeamFortress2Mod::isMapType(TF_MAP_GG) ||
			std::strncmp(szmapname, "vip_", 4) == 0 || std::strncmp(szmapname, "cw_", 3) == 0 ||
			std::strncmp(szmapname, "ctf_2fort_sniperwars", 20) == 0 || std::strncmp(szmapname, "dm_", 3) == 0)
		{
			return true;
		}
		selectClass();
	}
	(...)
}

The Problem

Whenever it comes to gamemode detection, the plugin checks for map names/prefixes; but what if a gamemode was running despite using an unconventional prefix or map name?


Let's take these maps for example:

  • dm_powerdown_v20
  • dm_forgecall_v20
  • dm_poolparty_v20
  • dm_badworks_v20
  • dm_razorpoint_v20
  • dm_deadlock_v20

What if Lizard Of Oz's DeathMatch maps receive an update? What if even more maps of that gamemode are being made?

Do we wait for another RCBot2 update?

No, we shouldn't have to wait until more maps get hardcoded.

Solution Proposal

addons/rcbot2/config/<modname>/bot_gamemodes.cfg

Example with Team Fortress 2:

"Gamemodes" // Priority: File > Entity > Map
{
    "Files"
    {
        // VScripts
        "scripts/vscripts/ffa/ffa.nut"                   "TF_MAP_GG"
        "scripts/vscripts/vssaxtonhale/vsh.nut"          "TF_MAP_SAXTON"
        "scripts/vscripts/infection/infection.nut"       "TF_MAP_ZI"
        "scripts/vscripts/vip/vip.nut"                   "TF_MAP_CP"
        "scripts/vscripts/vip.nut"                       "TF_MAP_CP"
        "scripts/vscripts/stopthattank/RobotMain.nut"    "TF_MAP_CP

        // HUD
        "resource/ui/hudobjectiveobjectdestruction.res"  "TF_MAP_CTF"

        // Models
        "models/props_poth/bomb_cart_neutral.mdl"        "TF_MAP_CART"
    }
    "Entities"
    {
        "tf_logic_arena"                "TF_MAP_ARENA"
        "tf_logic_hybrid_ctf_cp"        "TF_MAP_CTF"
        "tf_logic_multiple_escort"      "TF_MAP_CARTRACE"
        "tf_logic_player_destruction"   "TF_MAP_CTF"
        "tf_logic_robot_destruction"    "TF_MAP_RD"
        "tf_logic_mann_vs_machine"      "TF_MAP_MVM"
        "tf_logic_training_mode"        "TF_MAP_TR"
        "team_train_watcher"            "TF_MAP_CART"
        "item_teamflag"                 "TF_MAP_CTF"
        "func_flagdetectionzone"        "TF_MAP_CTF"
        "func_capturezone"              "TF_MAP_CP"
        "passtime_logic"                "TF_MAP_CTF"
    }
    "Maps" // Sub-strings allowed
    {
        "quake_turbine"     "TF_MAP_CTF"
        "slendytubbies"     "TF_MAP_CTF"
        "ctf_chouhen"       "TF_MAP_CP"
        "ctf_haarp"         "TF_MAP_CP"
        "falling_cp"        "TF_MAP_CP"
        "stt_"              "TF_MAP_CP"
        "koth_lifesnatcher" "TF_MAP_CP"
        "vip_"              "TF_MAP_CP"
        "vipr_"             "TF_MAP_CP"
        "kotc_"             "TF_MAP_CART"
        "tow_"              "TF_MAP_CARTRACE"
        "arena_tinyrock"    "TF_MAP_CARTRACE"
        "tow_impasse"       "TF_MAP_CARTRACE"
        "arena_hailstone"   "TF_MAP_CARTRACE"
        "ft_"               "TF_MAP_ARENA"
        "vsh_"              "TF_MAP_SAXTON"
        "ff2_"              "TF_MAP_SAXTON"
        "pipeball_"         "TF_MAP_PIPEBALL"
        "ctk_"              "TF_MAP_KOTH"
        "sd_"               "TF_MAP_SD"
        "sdr_"              "TF_MAP_SD"
        "tr_"               "TF_MAP_TR"
        "cppl_"             "TF_MAP_CPPL"
        "cw_"               "TF_MAP_CPPL"
        "gg_"               "TF_MAP_GG"
        "gd_"               "TF_MAP_MVM"
    }
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions