From bc5e8aaae1fb6a0fe79c313b540bb359978eeb02 Mon Sep 17 00:00:00 2001
From: Marco Cawthorne <marco@vera-visions.com>
Date: Mon, 9 Sep 2024 22:02:59 -0700
Subject: [PATCH] class edef changes

---
 src/server/info_tfgoal.qc           |   2 +-
 src/server/spawn.qc                 |   5 -
 src/shared/defs.h                   |  23 ----
 src/shared/include.src              |   2 +-
 src/shared/player.qc                | 175 +++-------------------------
 zpak001.pk3dir/decls/def/player.def | 154 ++++++++++++++++++++++++
 zpak001.pk3dir/default.cfg          |  54 +--------
 7 files changed, 176 insertions(+), 239 deletions(-)
 mode change 100755 => 100644 zpak001.pk3dir/default.cfg

diff --git a/src/server/info_tfgoal.qc b/src/server/info_tfgoal.qc
index ad3be72..b6fc82a 100644
--- a/src/server/info_tfgoal.qc
+++ b/src/server/info_tfgoal.qc
@@ -207,7 +207,7 @@ info_tfgoal::Touch(entity eToucher)
 	pl.GiveAmmo(detpackType, m_iDetpack);
 
 	/* clamp */
-	pl.health = bound(0, pl.health, pl.m_iMaxHealth);
+	pl.health = bound(0, pl.health, pl.max_health);
 	pl.armor = bound(0, pl.armor, pl.m_iMaxArmor);
 
 	pl.frags += frags;
diff --git a/src/server/spawn.qc b/src/server/spawn.qc
index 2cfdda3..1b76b25 100644
--- a/src/server/spawn.qc
+++ b/src/server/spawn.qc
@@ -136,10 +136,6 @@ CSEv_ClassJoin_f(float f)
 		return;
 	}
 
-	if (self.classname != "player") {
-		spawnfunc_TFPlayer();
-	}
-
 	/* invalid */
 	if (pl.classtype == f)
 		return;
@@ -157,6 +153,5 @@ CSEv_ClassJoin_f(float f)
 
 		/* turn the player into the class of his choice */
 		pl.MakeClass(f);
-		pl.SpawnIntoGame();
 	}
 } 
diff --git a/src/shared/defs.h b/src/shared/defs.h
index b76ab48..0164cef 100644
--- a/src/shared/defs.h
+++ b/src/shared/defs.h
@@ -52,26 +52,3 @@ string g_teammodels_hd[] = {
 	"models/player/spy/spy2.mdl",
 	"models/player/engineer/engineer2.mdl"
 };
-
-/* are we using a later build of TF? */
-bool
-TFC_IsLaterBuild(void)
-{
-	if (whichpack(g_teammodels_hd[1]))
-		return true;
-
-	return false;
-}
-
-/* stuff */
-string
-TFC_GetModelForClasstype(classtype_e type)
-{
-	if (TFC_IsLaterBuild() == true)
-		if (autocvar(tfc_newmodels, 0) == 1)
-			return g_teammodels[type];	/* on later versions, the old names are the HD ones */
-		else
-			return g_teammodels_hd[type];
-
-	return g_teammodels[type];
-}
\ No newline at end of file
diff --git a/src/shared/include.src b/src/shared/include.src
index 35df0ef..4ba3338 100644
--- a/src/shared/include.src
+++ b/src/shared/include.src
@@ -5,12 +5,12 @@ weapons.h
 
 flags.h
 events.h
+../../../valve/src/shared/skeleton.h
 ../../../valve/src/shared/player.qc
 player.qc
 ../../../valve/src/shared/animations.h
 animations_tfc.h
 ../../../valve/src/shared/animations.qc
-../../../valve/src/shared/pmove.qc
 pmove.qc
 
 ../../../valve/src/shared/fx_blood.qc
diff --git a/src/shared/player.qc b/src/shared/player.qc
index 6f54f7f..66c033e 100644
--- a/src/shared/player.qc
+++ b/src/shared/player.qc
@@ -85,7 +85,6 @@ class TFPlayer:HLPlayer
 void
 TFPlayer::TFPlayer(void)
 {
-	classname = "player";
 }
 
 void
@@ -448,200 +447,58 @@ TFPlayer::SpawnIntoGame(void)
 }
 
 void
-TFPlayer::MakeClass(classtype_e class)
+TFPlayer::MakeClass(classtype_e classType)
 {
 	int atShells = ammoNumForName("ammo_shells");
 	int atNails = ammoNumForName("ammo_nails");
 	int atCells = ammoNumForName("ammo_cells");
 	int atRockets = ammoNumForName("ammo_rockets");
-	MakePlayer();
+	int oldTeam = team;
 
-	/* select our class model */
-	model = TFC_GetModelForClasstype(classtype);
-	setmodel(this, model);
-	setsize(this, VEC_HULL_MIN, VEC_HULL_MAX);
-	velocity = [0,0,0];
-	gravity = __NULL__;
-
-	armor = activeweapon = g_items = 0;
-	iBleeds = TRUE;
-	forceinfokey(this, "*spec", "0");
-	forceinfokey(this, "*team", ftos(team));
-
-	switch (classtype) {
+	switch (classType) {
 	case CLASS_SCOUT:
-		GiveItem("tf_weapon_axe");
-		GiveItem("tf_weapon_shotgun");
-		GiveItem("tf_weapon_ng");
-		GiveAmmo(atShells, 17i);
-		GiveAmmo(atNails, 100i);
-
-		m_iMaxHealth = 75;
-		m_iMaxArmor = 50;
-		health = m_iMaxHealth;
-		armor = 25;
-
-		m_iMaxShells = 50;
-		m_iMaxNails = 200;
-		m_iMaxCells = 100;
-		m_iMaxRockets = 25;
+		EntityDef_SpawnClassname("player_scout");
 		env_message_single(this, "HELP_SCOUT");
 		break;
 	case CLASS_SNIPER:
-		GiveItem("tf_weapon_axe");
-		GiveItem("tf_weapon_sniperrifle");
-		GiveItem("tf_weapon_autorifle");
-		GiveItem("tf_weapon_ng");
-		GiveAmmo(atShells, 60i); /* sniper rifles use shells */
-		GiveAmmo(atNails, 50i);
-
-		m_iMaxHealth = 90;
-		m_iMaxArmor = 50;
-		health = m_iMaxHealth;
-		armor = 0;
-
-		m_iMaxShells = 75;
-		m_iMaxNails = 100;
-		m_iMaxCells = 50;
-		m_iMaxRockets = 25;
+		EntityDef_SpawnClassname("player_sniper");
 		env_message_single(this, "HELP_SNIPER");
 		break;
 	case CLASS_SOLDIER:
-		GiveItem("tf_weapon_axe");
-		GiveItem("tf_weapon_supershotgun");
-		GiveItem("tf_weapon_shotgun");
-		GiveItem("tf_weapon_rpg");
-		GiveAmmo(atShells, 26i);
-		GiveAmmo(atRockets, 6i);
-
-		m_iMaxHealth = 100;
-		m_iMaxArmor = 200;
-		health = m_iMaxHealth;
-		armor = 100;
-
-		m_iMaxShells = 100;
-		m_iMaxNails = 100;
-		m_iMaxCells = 50;
-		m_iMaxRockets = 50;
+		EntityDef_SpawnClassname("player_soldier");
 		env_message_single(this, "HELP_SOLDIER");
 		break;
 	case CLASS_DEMO:
-		GiveItem("tf_weapon_axe");
-		GiveItem("tf_weapon_shotgun");
-		GiveItem("tf_weapon_gl");
-		GiveItem("tf_weapon_pl");
-		GiveAmmo(atShells, 22i);
-		GiveAmmo(atRockets, 14i);
-
-		m_iMaxHealth = 90;
-		m_iMaxArmor = 100;
-		health = m_iMaxHealth;
-		armor = 50;
-
-		m_iMaxShells = 75;
-		m_iMaxNails = 50;
-		m_iMaxCells = 50;
-		m_iMaxRockets = 50;
+		EntityDef_SpawnClassname("player_demo");
 		env_message_single(this, "HELP_DEMOMAN");
 		break;
 	case CLASS_MEDIC:
-		GiveItem("tf_weapon_medikit");
-		GiveItem("tf_weapon_supershotgun");
-		GiveItem("tf_weapon_shotgun");
-		GiveItem("tf_weapon_superng");
-		GiveAmmo(atShells, 26i);
-		GiveAmmo(atNails, 50i);
-
-		m_iMaxHealth = 90;
-		m_iMaxArmor = 100;
-		health = m_iMaxHealth;
-		armor = 50;
-
-		m_iMaxShells = 75;
-		m_iMaxNails = 150;
-		m_iMaxCells = 50;
-		m_iMaxRockets = 25;
+		EntityDef_SpawnClassname("player_medic");
 		env_message_single(this, "HELP_MEDIC");
 		break;
 	case CLASS_HVYWEAPON:
-		GiveItem("tf_weapon_axe");
-		GiveItem("tf_weapon_supershotgun");
-		GiveItem("tf_weapon_shotgun");
-		GiveItem("tf_weapon_ac");
-		GiveAmmo(atShells, 176i); /* all of the heavy's weapons use shells */
-
-		m_iMaxHealth = 100;
-		m_iMaxArmor = 300;
-		health = m_iMaxHealth;
-		armor = 150;
-
-		m_iMaxShells = 200;
-		m_iMaxNails = 200;
-		m_iMaxCells = 50;
-		m_iMaxRockets = 25;
+		EntityDef_SpawnClassname("player_heavy");
 		env_message_single(this, "HELP_HWGUY");
 		break;
 	case CLASS_PYRO:
-		GiveItem("tf_weapon_axe");
-		GiveItem("tf_weapon_shotgun");
-		GiveItem("tf_weapon_flamethrower");
-		GiveItem("tf_weapon_ic");
-		GiveAmmo(atShells, 12i);
-		GiveAmmo(atCells, 120i);
-		GiveAmmo(atRockets, 5i);
-
-		m_iMaxHealth = 100;
-		m_iMaxArmor = 150;
-		health = m_iMaxHealth;
-		armor = 50;
-
-		m_iMaxShells = 40;
-		m_iMaxNails = 50;
-		m_iMaxCells = 200;
-		m_iMaxRockets = 60;
+		EntityDef_SpawnClassname("player_pyro");
 		env_message_single(this, "HELP_PYRO");
 		break;
 	case CLASS_SPY:
-		GiveItem("tf_weapon_knife");
-		GiveItem("tf_weapon_tranq");
-		GiveItem("tf_weapon_supershotgun");
-		GiveItem("tf_weapon_ng");
-		GiveAmmo(atShells, 24i); /* tranquil and dbs use shells */
-		GiveAmmo(atNails, 50i);
-
-		m_iMaxHealth = 90;
-		m_iMaxArmor = 100;
-		health = m_iMaxHealth;
-		armor = 25;
-
-		m_iMaxShells = 40;
-		m_iMaxNails = 50;
-		m_iMaxCells = 30;
-		m_iMaxRockets = 15;
+		EntityDef_SpawnClassname("player_spy");
 		env_message_single(this, "HELP_SPY");
 		break;
 	case CLASS_ENGINEER:
-		GiveItem("tf_weapon_spanner");
-		GiveItem("tf_weapon_railgun");
-		GiveItem("tf_weapon_supershotgun");
-		GiveAmmo(atCells, 100i);
-		GiveAmmo(atNails, 25i);
-		GiveAmmo(atShells, 4i);
-
-		m_iMaxHealth = 80;
-		m_iMaxArmor = 50;
-		health = m_iMaxHealth;
-		armor = 25;
-
-		m_iMaxShells = 50;
-		m_iMaxNails = 50;
-		m_iMaxCells = 200;
-		m_iMaxRockets = 30;
+		EntityDef_SpawnClassname("player_engineer");
 		env_message_single(this, "HELP_ENGINEER");
 		break;
 	}
 
+	MakePlayer();
+	team = oldTeam;
+	forceinfokey(this, "*team", ftos(team));
 	GiveItem("item_suit");
+	SpawnIntoGame();
 }
 
 /*
diff --git a/zpak001.pk3dir/decls/def/player.def b/zpak001.pk3dir/decls/def/player.def
index 365c063..a879d5e 100644
--- a/zpak001.pk3dir/decls/def/player.def
+++ b/zpak001.pk3dir/decls/def/player.def
@@ -2,3 +2,157 @@ entityDef player
 {
 	"spawnclass" "TFPlayer"
 }
+
+entityDef player_scout
+{
+	"inherit"			"player"
+	"model"				"models/player/scout/scout.mdl"
+	"health"			"75"
+	"armor"				"25"
+	"maxarmor"			"50"
+	"ammo_shells"		"17"
+	"ammo_nails"		"100"
+	"max_ammo_shells"	"50"
+	"max_ammo_nails"	"200"
+	"max_ammo_cells"	"100"
+	"max_ammo_rockets"	"25"
+	"weapon"			"tf_weapon_axe,tf_weapon_shotgun,tf_weapon_ng"
+	"current_weapon"	"1"
+}
+
+entityDef player_sniper
+{
+	"inherit"			"player"
+	"model"				"models/player/sniper/sniper.mdl"
+	"health"			"90"
+	"armor"				"0"
+	"maxarmor"			"50"
+	"ammo_shells"		"60"
+	"ammo_nails"		"50"
+	"max_ammo_shells"	"75"
+	"max_ammo_nails"	"100"
+	"max_ammo_cells"	"50"
+	"max_ammo_rockets"	"25"
+	"weapon"			"tf_weapon_axe,tf_weapon_sniperrifle,tf_weapon_autorifle,tf_weapon_ng"
+	"current_weapon"	"1"
+}
+
+entityDef player_soldier
+{
+	"inherit"			"player"
+	"model"				"models/player/soldier/soldier.mdl"
+	"health"			"100"
+	"armor"				"100"
+	"maxarmor"			"200"
+	"ammo_shells"		"26"
+	"ammo_rockets"		"6"
+	"max_ammo_shells"	"100"
+	"max_ammo_nails"	"100"
+	"max_ammo_cells"	"50"
+	"max_ammo_rockets"	"50"
+	"weapon"			"tf_weapon_axe,tf_weapon_supershotgun,tf_weapon_shotgun,tf_weapon_rpg"
+	"current_weapon"	"1"
+}
+
+entityDef player_demo
+{
+	"inherit"			"player"
+	"model"				"models/player/demo/demo.mdl"
+	"health"			"90"
+	"armor"				"50"
+	"maxarmor"			"100"
+	"ammo_shells"		"22"
+	"ammo_rockets"		"14"
+	"max_ammo_shells"	"75"
+	"max_ammo_nails"	"50"
+	"max_ammo_cells"	"50"
+	"max_ammo_rockets"	"50"
+	"weapon"			"tf_weapon_axe,tf_weapon_shotgun,tf_weapon_gl,tf_weapon_pl"
+	"current_weapon"	"1"
+}
+
+entityDef player_medic
+{
+	"inherit"			"player"
+	"model"				"models/player/medic/medic.mdl"
+	"health"			"90"
+	"armor"				"50"
+	"maxarmor"			"100"
+	"ammo_shells"		"26"
+	"ammo_nails"		"50"
+	"max_ammo_shells"	"75"
+	"max_ammo_nails"	"150"
+	"max_ammo_cells"	"50"
+	"max_ammo_rockets"	"25"
+	"weapon"			"tf_weapon_medikit,tf_weapon_supershotgun,tf_weapon_shotgun,tf_weapon_superng"
+	"current_weapon"	"1"
+}
+
+entityDef player_heavy
+{
+	"inherit"			"player"
+	"model"				"models/player/hvyweapon/hvyweapon.mdl"
+	"health"			"100"
+	"armor"				"150"
+	"maxarmor"			"300"
+	"ammo_shells"		"176"
+	"max_ammo_shells"	"200"
+	"max_ammo_nails"	"200"
+	"max_ammo_cells"	"50"
+	"max_ammo_rockets"	"25"
+	"weapon"			"tf_weapon_axe,tf_weapon_supershotgun,tf_weapon_shotgun,tf_weapon_ac"
+	"current_weapon"	"1"
+}
+
+entityDef player_pyro
+{
+	"inherit"			"player"
+	"model"				"models/player/pyro/pyro.mdl"
+	"health"			"100"
+	"armor"				"50"
+	"maxarmor"			"150"
+	"ammo_shells"		"12"
+	"ammo_cells"		"120"
+	"ammo_rockets"		"5"
+	"max_ammo_shells"	"40"
+	"max_ammo_nails"	"50"
+	"max_ammo_cells"	"200"
+	"max_ammo_rockets"	"60"
+	"weapon"			"tf_weapon_axe,tf_weapon_shotgun,tf_weapon_flamethrower,tf_weapon_ic"
+	"current_weapon"	"1"
+}
+
+entityDef player_spy
+{
+	"inherit"			"player"
+	"model"				"models/player/spy/spy.mdl"
+	"health"			"90"
+	"armor"				"25"
+	"maxarmor"			"100"
+	"ammo_shells"		"24"
+	"ammo_nails"		"50"
+	"max_ammo_shells"	"40"
+	"max_ammo_nails"	"50"
+	"max_ammo_cells"	"30"
+	"max_ammo_rockets"	"15"
+	"weapon"			"tf_weapon_knife,tf_weapon_tranq,tf_weapon_supershotgun,tf_weapon_ng"
+	"current_weapon"	"1"
+}
+
+entityDef player_engineer
+{
+	"inherit"			"player"
+	"model"				"models/player/engineer/engineer.mdl"
+	"health"			"80"
+	"armor"				"25"
+	"maxarmor"			"50"
+	"ammo_shells"		"4"
+	"ammo_nails"		"25"
+	"ammo_cells"		"100"
+	"max_ammo_shells"	"50"
+	"max_ammo_nails"	"50"
+	"max_ammo_cells"	"200"
+	"max_ammo_rockets"	"30"
+	"weapon"			"tf_weapon_spanner,tf_weapon_railgun,tf_weapon_supershotgun"
+	"current_weapon"	"1"
+}
diff --git a/zpak001.pk3dir/default.cfg b/zpak001.pk3dir/default.cfg
old mode 100755
new mode 100644
index ab61ada..2e4168a
--- a/zpak001.pk3dir/default.cfg
+++ b/zpak001.pk3dir/default.cfg
@@ -1,52 +1,6 @@
-// Generic Binds
-bind "ESC" "togglemenu"
-bind "w" "+forward"
-bind "s" "+back"
-bind "a" "+moveleft"
-bind "d" "+moveright"
-bind "SPACE" "+jump"
-bind "CTRL" "+duck"
-bind "SHIFT" "+speed"
-bind "0" "slot10"
-bind "1" "slot1"
-bind "2" "slot2"
-bind "3" "slot3"
-bind "4" "slot4"
-bind "5" "slot5"
-bind "6" "slot6"
-bind "7" "slot7"
-bind "8" "slot8"
-bind "9" "slot9"
-bind "UPARROW" "+forward"
-bind "DOWNARROW" "+back"
-bind "LEFTARROW" "+left"
-bind "RIGHTARROW" "+right"
-bind "MOUSE1" "+attack"
-bind "MOUSE2" "+attack2"
-bind "MWHEELDOWN" "invnext"
-bind "MWHEELUP" "invprev"
-bind "r" "+reload"
-bind "e" "+use"
-bind "TAB" "+showscores"
-bind "y" "messagemode"
-bind "u" "messagemode2"
-bind "t" "impulse 201"
-bind "f" "impulse 100"
-bind "f1" "vote yes"
-bind "f2" "vote no"
-
-// Game Variables
+exec default_controls.cfg
+exec cvar_defaults.cfg
+
 seta "hostname" "FreeTFC Server"
 seta "maxplayers" "8"
-
-// disable some nuclide niceties
-seta v_muzzledlight 0
-
-// config compat
-alias mp_timelimit timelimit
-alias mp_fraglimit fraglimit
-
-// video settings
-seta gl_overbright 0
-seta gl_ldr 1
-seta r_lightmap_format rgb8
+
\ No newline at end of file