dmc/src/server/gamerules_singleplayer.qc

147 lines
4.1 KiB
Plaintext

/*
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
*
* 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.
*/
bool FreeDMC_CanThreeWave(void);
bool FreeDMC_CanExtra(void);
bool
HLSingleplayerRules::IsMultiplayer(void)
{
return false;
}
void
HLSingleplayerRules::PlayerDeath(NSClientPlayer pl)
{
pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.gflags &= ~GF_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = pl.weapon = 0;
pl.health = 0;
Sound_Play(pl, CHAN_AUTO, "Player.Death");
if (cvar("coop") == 1) {
pl.think = PutClientInServer;
pl.nextthink = time + 4.0f;
}
if (pl.health < -50) {
vector gibDir = vectoangles(pl.origin - g_dmg_eAttacker.origin);
float gibStrength = g_dmg_iDamage * 2.0f;
BreakModel_Entity(pl, gibDir, gibStrength);
}
/* Let's handle corpses on the clientside */
entity corpse = spawn();
setorigin(corpse, pl.origin + [0,0,32]);
setmodel(corpse, pl.model);
setsize(corpse, VEC_HULL_MIN, VEC_HULL_MAX);
corpse.movetype = MOVETYPE_TOSS;
corpse.solid = SOLID_TRIGGER;
corpse.modelindex = pl.modelindex;
corpse.frame = ANIM_DIESIMPLE;
corpse.angles = pl.angles;
corpse.velocity = pl.velocity;
}
void
HLSingleplayerRules::PlayerSpawn(NSClientPlayer pl)
{
string playerModel = "models/player.mdl";
pl.classname = "player";
pl.SetHealth(100);
pl.SetMaxHealth(100);
pl.SetTakedamage(DAMAGE_YES);
pl.SetSolid(SOLID_SLIDEBOX);
pl.SetMovetype(MOVETYPE_WALK);
pl.AddFlags(FL_CLIENT);
pl.viewzoom = 1.0;
/* if in cooperative mode, we want to respect the player model */
if (cvar("coop") == 1) {
string testModel = infokey(pl, "model");
if (testModel) {
testModel = sprintf("models/player/%s/%s.mdl", testModel, testModel);
if (whichpack(testModel)) {
playerModel = testModel;
}
}
}
pl.SetModel(playerModel);
pl.SetSize(VEC_HULL_MIN, VEC_HULL_MAX);
pl.ClearVelocity();
pl.SetInfoKey("*spec", "0");
pl.SetInfoKey("*deaths", ftos(pl.deaths));
pl.SetPropData("actor_human");
pl.SetCanBleed(true);
if (startspot != "") {
LevelDecodeParms(pl);
pl.SetOrigin(Landmark_GetSpot());
} else {
entity spawnPoint;
LevelNewParms();
spawnPoint = find(world, ::classname, "info_player_start");
pl.Transport(spawnPoint.origin, spawnPoint.angles);
}
Weapons_RefreshAmmo(pl);
Client_FixAngle(pl, pl.angles);
}
bool
HLSingleplayerRules::ImpulseCommand(NSClient bp, float num)
{
switch (num) {
case 101:
player pl = (player)bp;
pl.health = 100;
pl.armor = 100;
pl.g_items |= ITEM_SUIT;
Weapons_AddItem(pl, WEAPON_CROWBAR, -1);
Weapons_AddItem(pl, WEAPON_SHOTGUN, -1);
Weapons_AddItem(pl, WEAPON_SUPERSHOTGUN, -1);
Weapons_AddItem(pl, WEAPON_NAILGUN, -1);
Weapons_AddItem(pl, WEAPON_SUPERNAILGUN, -1);
Weapons_AddItem(pl, WEAPON_GRENADELAUNCHER, -1);
Weapons_AddItem(pl, WEAPON_ROCKETLAUNCHER, -1);
Weapons_AddItem(pl, WEAPON_LIGHTNING, -1);
if (FreeDMC_CanExtra()) {
Weapons_AddItem(pl, WEAPON_HAMMER, -1);
Weapons_AddItem(pl, WEAPON_GRAPPLE, -1);
Weapons_AddItem(pl, WEAPON_ICESHOTGUN, -1);
Weapons_AddItem(pl, WEAPON_ICESUPERSHOTGUN, -1);
Weapons_AddItem(pl, WEAPON_MULTIGREN, -1);
Weapons_AddItem(pl, WEAPON_MULTIROCKET, -1);
Weapons_AddItem(pl, WEAPON_LAVANAILGUN, -1);
Weapons_AddItem(pl, WEAPON_LAVASUPERNAILGUN, -1);
Weapons_AddItem(pl, WEAPON_PLASMACANNON, -1);
Weapons_AddItem(pl, WEAPON_PLASMARIFLE, -1);
Weapons_AddItem(pl, WEAPON_PROXMINE, -1);
}
break;
default:
return super::ImpulseCommand(bp, num);
}
return true;
}