int sp_bot_number;
-/*QUAKED spawnfunc_tdm_team (0 .5 .8) (-16 -16 -24) (16 16 32)
-Team declaration for TDM gameplay, this allows you to decide what team names and control point models are used in your map.
-Note: If you use spawnfunc_tdm_team entities you must define at least 2! However, unlike domination, you don't need to make a blank one too.
-Keys:
-"netname" Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)...
-"cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
+// Team entity for single player mode
spawnfunc(sp_team)
{
if(!g_singleplayer || !this.cnt) { delete(this); return; }
this.team = this.cnt + 1;
}
-// code from here on is just to support maps that don't have team entities
+// Spawns the given team
void sp_spawn_team_entity(string teamname, int teamcolor)
{
entity this = new_pure(sp_team);
this.spawnfunc_checked = true;
}
-// spawnfuncs
+// Spawn point for the player
spawnfunc(info_player_singleplayer)
{
if (!g_singleplayer) { delete(this); return; }
spawnfunc_info_player_deathmatch(this);
}
+/*
+ * Creates a new bot and assigns it to the given spawn point
+ */
void sp_spawn_bot(entity spawn_point)
{
sp_bot_number++;
}
}
+/*
+ * Think function for enemy spawn points,
+ * creates a bot and stops all processing
+ */
void sp_enemy_spawn_think(entity this)
{
sp_spawn_bot(this);
setthink(this, func_null);
}
-
+/*
+ * Use function for enemy spawn points,
+ * creates bot
+ */
void sp_enemy_spawn_use(entity this, entity actor, entity trigger)
{
sp_spawn_bot(this);
}
+// Enemy spawn point entity
spawnfunc(info_player_singleplayer_enemy)
{
if (!g_singleplayer) { delete(this); return; }
setthink(this, sp_enemy_spawn_think);
}
+// Game mode initialization function
void sp_delayed_init(entity this)
{
// if no teams are found, spawn defaults
sp_bot_number = 0;
}
+// Ensures the given bot will be removed
void sp_remove_bot(entity bot)
{
sp_bot_number--;
bot_clear(bot);
}
+/*
+ * Force teams:
+ * bots are team 2,
+ * players (including observers) are in team 1
+ */
MUTATOR_HOOKFUNCTION(sp, CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
{
M_ARGV(1, string) = "sp_team";
return true;
}
+// Avoid the frags left messages
MUTATOR_HOOKFUNCTION(sp, Scores_CountFragsRemaining)
{
return false;
}
+/*
+ * Sets up players, more specifically assigns items, health and name to bots
+ * based on their spawn point
+ */
MUTATOR_HOOKFUNCTION(sp, PlayerSpawn)
{
entity player = M_ARGV(0, entity);
}
}
+// Prevent bots from dropping weapons by default
MUTATOR_HOOKFUNCTION(sp, ForbidDropCurrentWeapon)
{
entity player = M_ARGV(0, entity);
return !player.can_drop_weapon;
}
+// Winning rules (TODO)
MUTATOR_HOOKFUNCTION(sp, CheckRules_World)
{
M_ARGV(0, float) = WINNING_NO;
return true;
}
+/*
+ * Only allow players to spawn from specific points
+ * For real clients forces the team spawn points even for observers
+ * For bots that need to be spawned, forces them to spawn from their specifi point
+ * for bots that need to be removes, allows all team spawn points to avoid crashes
+ */
MUTATOR_HOOKFUNCTION(sp, Spawn_Score)
{
entity player = M_ARGV(0, entity);
M_ARGV(2, vector) = spawn_score;
}
+// Avoid unbalanced teams notice as there will be far more enemies than players
MUTATOR_HOOKFUNCTION(sp, HideTeamNagger)
{
return true;
}
+/*
+ * Forces the bot count to be determined based on the spawn points,
+ * regardless of any other setting
+ */
MUTATOR_HOOKFUNCTION(sp, Bot_FixCount)
{
M_ARGV(2, int) = sp_bot_number;
return true;
}
+// Remove bots that cannot respawn when they die
MUTATOR_HOOKFUNCTION(sp, PlayerDies)
{
entity target = M_ARGV(2, entity);
}
}
+// Ensures the bots that get removed are the ones that cannot respawn
MUTATOR_HOOKFUNCTION(sp, Bot_SelectRemove)
{
FOREACH_CLIENT(it.isbot,
});
}
+// Actually removes the bot entity when needed
MUTATOR_HOOKFUNCTION(sp, PlayerPreThink)
{
entity player = M_ARGV(0, entity);
bot_remove(player);
}
+// Prevents bots from being able to pick up items
MUTATOR_HOOKFUNCTION(sp, ItemTouch)
{
entity toucher = M_ARGV(1, entity);
return MUT_ITEMTOUCH_CONTINUE;
}
+// revents bots from being willing to pick up items
MUTATOR_HOOKFUNCTION(sp, Item_Spawn)
{
entity item = M_ARGV(0, entity);