2021-03-08 03:08:54 -08:00
|
|
|
/*
|
2022-03-13 16:56:32 -07:00
|
|
|
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
2021-03-08 03:08:54 -08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2022-07-09 17:36:23 -07:00
|
|
|
bool
|
2022-07-16 15:08:28 -07:00
|
|
|
TFCGameRules::IsTeamplay(void)
|
2022-07-09 17:36:23 -07:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-07-10 13:07:35 -07:00
|
|
|
void
|
|
|
|
TFCGameRules::DropGoalItem(NSClientPlayer pp)
|
|
|
|
{
|
|
|
|
/* skip normal players */
|
|
|
|
if (!(pp.g_items & ITEM_GOALITEM))
|
|
|
|
return;
|
|
|
|
|
|
|
|
item_tfgoal target;
|
|
|
|
|
|
|
|
for (entity e = world; (e = find(e, ::classname, "item_tfgoal"));) {
|
|
|
|
target = (item_tfgoal)e;
|
|
|
|
|
|
|
|
/* item is still pick-upable */
|
|
|
|
if (target.solid != SOLID_NOT) {
|
|
|
|
print("the item is not picked up. \n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* that's us, yup */
|
|
|
|
if (target.m_eActivator == pp) {
|
|
|
|
target.DropReturnable(pp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print("^1WARNING: ^7Player marked as having impossible goal-item\n");
|
|
|
|
}
|
|
|
|
|
2021-03-08 03:08:54 -08:00
|
|
|
/* we check what fields have changed over the course of the frame and network
|
|
|
|
* only the ones that have actually changed */
|
|
|
|
void
|
2022-05-11 12:50:59 -07:00
|
|
|
TFCGameRules::PlayerPostFrame(NSClientPlayer pp)
|
2021-03-08 03:08:54 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TFCGameRules::LevelNewParms(void)
|
|
|
|
{
|
|
|
|
parm1 = parm2 = parm3 = parm4 = parm5 = parm6 = parm7 =
|
|
|
|
parm8 = parm9 = parm10 = parm11 = parm12 = parm13 = parm14 =
|
|
|
|
parm15 = parm16 = parm17 = parm18 = parm19 = parm20 = parm21 =
|
|
|
|
parm22 = parm23 = parm24 = parm25 = parm26 = parm27 = parm28 =
|
|
|
|
parm29 = parm30 = 0;
|
|
|
|
parm64 = FL_CLIENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-05-11 12:50:59 -07:00
|
|
|
TFCGameRules::PlayerConnect(NSClientPlayer pl)
|
2021-03-08 03:08:54 -08:00
|
|
|
{
|
|
|
|
if (Plugin_PlayerConnect(pl) == FALSE)
|
|
|
|
bprint(PRINT_HIGH, sprintf("%s connected\n", pl.netname));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-05-11 12:50:59 -07:00
|
|
|
TFCGameRules::PlayerDisconnect(NSClientPlayer pl)
|
2021-03-08 03:08:54 -08:00
|
|
|
{
|
|
|
|
bprint(PRINT_HIGH, sprintf("%s disconnected\n", pl.netname));
|
|
|
|
|
|
|
|
/* Make this unusable */
|
|
|
|
pl.solid = SOLID_NOT;
|
|
|
|
pl.movetype = MOVETYPE_NONE;
|
|
|
|
pl.modelindex = 0;
|
|
|
|
pl.health = 0;
|
|
|
|
pl.takedamage = 0;
|
|
|
|
pl.SendFlags = PLAYER_MODELINDEX;
|
|
|
|
}
|
|
|
|
|
2022-07-10 13:21:16 -07:00
|
|
|
void
|
|
|
|
TFCGameRules_PlayerRespawn(void)
|
|
|
|
{
|
|
|
|
TFCGameRules rule = (TFCGameRules)g_grMode;
|
|
|
|
rule.PlayerRespawn((NSClientPlayer)self);
|
|
|
|
}
|
|
|
|
|
2022-07-09 16:45:52 -07:00
|
|
|
void
|
|
|
|
TFCGameRules::PlayerDeath(NSClientPlayer pp)
|
|
|
|
{
|
|
|
|
player pl = (player)pp;
|
2022-07-09 16:46:55 -07:00
|
|
|
|
2022-07-10 13:07:35 -07:00
|
|
|
DropGoalItem(pp);
|
2022-07-09 16:46:55 -07:00
|
|
|
pl.SetSolid(SOLID_NOT);
|
|
|
|
pl.SetMovetype(MOVETYPE_NONE);
|
2022-07-10 13:21:16 -07:00
|
|
|
|
|
|
|
pl.think = TFCGameRules_PlayerRespawn;
|
2022-07-09 16:46:55 -07:00
|
|
|
pl.nextthink = time + 4.0f;
|
2022-07-09 16:53:51 -07:00
|
|
|
|
|
|
|
/* play the iconic death sound */
|
|
|
|
Sound_Play(pl, CHAN_VOICE, "player_tfc.death");
|
2022-07-09 16:45:52 -07:00
|
|
|
}
|
|
|
|
|
2021-03-08 03:08:54 -08:00
|
|
|
void
|
2022-05-11 12:50:59 -07:00
|
|
|
TFCGameRules::PlayerKill(NSClientPlayer pp)
|
2021-03-08 03:08:54 -08:00
|
|
|
{
|
|
|
|
player pl = (player)pp;
|
|
|
|
Damage_Apply(pl, pl, pl.health, WEAPON_NONE, DMG_SKIP_ARMOR);
|
|
|
|
}
|
|
|
|
|
2022-07-09 16:45:52 -07:00
|
|
|
void
|
|
|
|
TFCGameRules::PlayerRespawn(NSClientPlayer pp)
|
|
|
|
{
|
|
|
|
player pl = (player)pp;
|
|
|
|
pl.MakeClass(pl.classtype);
|
|
|
|
pl.SpawnIntoGame();
|
|
|
|
}
|
|
|
|
|
2021-03-08 03:08:54 -08:00
|
|
|
void
|
2022-05-11 12:50:59 -07:00
|
|
|
TFCGameRules::PlayerSpawn(NSClientPlayer pp)
|
2021-03-08 03:08:54 -08:00
|
|
|
{
|
|
|
|
player pl = (player)pp;
|
2022-07-09 16:45:52 -07:00
|
|
|
pl.MakeTempSpectator(); /* replace this with a non-spectator ghost */
|
2021-03-08 03:08:54 -08:00
|
|
|
Spawn_ObserverCam(pl);
|
|
|
|
}
|
2021-05-24 23:32:11 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
TFCGameRules::TFCGameRules(void)
|
|
|
|
{
|
2022-07-09 16:45:52 -07:00
|
|
|
/* TODO: Make this depend on the actual spawn types */
|
2021-05-24 23:32:11 -07:00
|
|
|
forceinfokey(world, "teams", "2");
|
|
|
|
forceinfokey(world, "team_1", "Blue");
|
|
|
|
forceinfokey(world, "teamscore_1", "0");
|
|
|
|
forceinfokey(world, "team_2", "Red");
|
|
|
|
forceinfokey(world, "teamscore_2", "0");
|
|
|
|
}
|