Initial commit

This commit is contained in:
2025-04-15 22:27:20 -04:00
parent 5b7b68f81f
commit 771d8fe8e8
597 changed files with 149544 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
#define GAME_DESCRIPTION "Tower Defense"
#define PLAYER_LIMIT 6
#define METALPACK_LIMIT 50
#define TEAM_DEFENDER 3
#define TEAM_ATTACKER 2
/*========================================
= Server Data Keys =
========================================*/
#define SERVER_CONNECTIONS "SERVER_CONNECTIONS"
#define SERVER_ROUNDS_PLAYED "SERVER_ROUNDS_PLAYED"
#define SERVER_ROUNDS_WON "SERVER_ROUNDS_WON"
#define SERVER_PLAYTIME "SERVER_PLAYTIME"
/*----- End of Server Data Keys ------*/
/*========================================
= Player Data Keys =
========================================*/
#define PLAYER_COMMUNITY_ID "PLAYER_COMMUNITY_ID"
#define PLAYER_DATABASE_ID "PLAYER_DATABASE_ID"
#define PLAYER_IMMUNITY "PLAYER_IMMUNITY"
#define PLAYER_IP_ADDRESS "PLAYER_IP_ADDRESS"
#define PLAYER_STEAM_ID "PLAYER_STEAM_ID"
#define PLAYER_KILLS "PLAYER_KILLS"
#define PLAYER_ASSISTS "PLAYER_ASSISTS"
#define PLAYER_DEATHS "PLAYER_DEATHS"
#define PLAYER_DAMAGE "PLAYER_DAMAGE"
#define PLAYER_OBJECTS_BUILT "PLAYER_OBJECTSBUILT"
#define PLAYER_TOWERS_BOUGHT "PLAYER_TOWERS_BOUGHT"
#define PLAYER_METAL_PICK "PLAYER_METAL_PICK"
#define PLAYER_METAL_DROP "PLAYER_METAL_DROP"
#define PLAYER_WAVES_PLAYED "PLAYER_WAVES_PLAYED"
#define PLAYER_WAVE_REACHED "PLAYER_WAVE_REACHED"
#define PLAYER_ROUNDS_PLAYED "PLAYER_ROUNDS_PLAYED"
#define PLAYER_ROUNDS_WON "PLAYER_ROUNDS_WON"
#define PLAYER_PLAYTIME "PLAYER_PLAYTIME"
/*----- End of Player Data Keys ------*/

View File

@@ -0,0 +1,72 @@
#pragma semicolon 1
#include <sourcemod>
#if defined INFO_INCLUDES
#include "../info/constants.sp"
#include "../info/enums.sp"
#include "../info/variables.sp"
#endif
stock void CreateConVars() {
CreateConVar("td_version", PLUGIN_VERSION, "Tower Defense Version", FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY | FCVAR_DONTRECORD);
g_hEnabled = CreateConVar("td_enabled", "1", "Enables/disables Tower Defense", FCVAR_DONTRECORD, true, 0.0, true, 1.0);
g_hMaxBotsOnField = CreateConVar("td_max_bots_on_field", "8", "Max bots simultaneously on field. Might be actually lower than set due to maxplayer limit");
}
stock void LoadConVars() {
g_hEnabled.AddChangeHook(OnConVarChanged);
g_hTfBotQuota = FindConVar("tf_bot_quota");
g_hTfBotQuota.AddChangeHook(OnConVarChanged);
}
stock void SetConVars() {
g_hTfBotQuota.IntValue = 0;
}
stock void SetPregameConVars() {
FindConVar("sv_cheats").SetInt(1, true, false);
}
/**
* Called when a console variable's value is changed.
*
* @param hConVar Handle to the convar that was changed.
* @param sOldValue String containing the value of the convar before it was changed.
* @param sNewValue String containing the new value of the convar.
* @noreturn
*/
public void OnConVarChanged(ConVar hConVar, const char[] sOldValue, const char[] sNewValue) {
if (hConVar == g_hEnabled) {
if (!g_bMapRunning) {
return;
}
if (g_hEnabled.BoolValue) {
if (!g_bEnabled) {
bool bEnabled = IsTowerDefenseMap();
if (bEnabled) {
// Basically do the same as in OnConfigsExecuted().
g_bEnabled = true;
UpdateGameDescription();
}
}
} else {
if (g_bEnabled) {
// Basically do the same as in OnMapEnd().
g_bEnabled = false;
UpdateGameDescription();
}
}
} else if (hConVar == g_hTfBotQuota) {
if (StringToInt(sNewValue) > 0) {
LogType(TDLogLevel_Error, TDLogType_FileAndConsole, "ConVar 'tf_bot_quota' can't be above 0 - Current Value: %d - New Value: %d", StringToInt(sOldValue), StringToInt(sNewValue));
LogType(TDLogLevel_Error, TDLogType_FileAndConsole, "Setting ConVar 'tf_bot_quota' to default");
ResetConVar(g_hTfBotQuota, true, false);
}
}
}

View File

@@ -0,0 +1,90 @@
enum TDDataType
{
TDDataType_Integer = 0,
TDDataType_Boolean,
TDDataType_Float,
TDDataType_String
};
enum TDBloodColor
{
TDBlood_None = -1,
TDBlood_Color_Red = 0,
TDBlood_Color_Yellow,
TDBlood_Color_Green,
TDBlood_Color_Mech
};
enum TDMetalPackSpawnType
{
TDMetalPack_Small = 0,
TDMetalPack_Medium,
TDMetalPack_Large
};
enum TDMetalPackReturn
{
TDMetalPack_InvalidMetal = 0,
TDMetalPack_LimitReached,
TDMetalPack_InvalidType,
TDMetalPack_SpawnedPack
};
enum TDBuildingType
{
TDBuilding_Dispenser = 0,
TDBuilding_TeleporterEntry,
TDBuilding_Sentry,
TDBuilding_TeleporterExit
};
enum TDTowerId
{
TDTower_Invalid = -1,
TDTower_Engineer = 0,
TDTower_Sniper = 1,
TDTower_Medic = 2,
TDTower_Grenade = 3,
TDTower_Pyro = 4,
TDTower_Jarate = 5,
TDTower_AnitAir_Rocket = 6,
TDTower_AntiAir_Flare = 7,
TDTower_Crossbow = 8,
TDTower_Flare = 9,
TDTower_Heavy = 10,
TDTower_Shotgun = 11,
TDTower_Knockback = 12,
TDTower_Rocket = 13,
TDTower_Rapidflare = 14,
TDTower_Backburner_Pyro = 15,
TDTower_Lochnload_Demoman = 16,
TDTower_Machina_Sniper = 17,
TDTower_Liberty_Soldier = 18,
TDTower_Juggle_Soldier = 19,
TDTower_Bushwacka_Sniper = 20,
TDTower_Natascha_Heavy = 21,
TDTower_Guillotine_Scout = 22,
TDTower_Homewrecker_Pyro = 23,
TDTower_Airblast_Pyro = 24,
TDTower_AoE_Engineer = 25,
TDTower_Kritz_Medic = 26,
TDTower_Slow_Spy = 27,
TDTower_Quantity
};
enum
{
TDWaveType_Boss = (1 << 0), // 1
TDWaveType_Rapid = (1 << 1), // 2
TDWaveType_Regen = (1 << 2), // 4
TDWaveType_KnockbackImmune = (1 << 3), // 8
TDWaveType_Air = (1 << 4), // 16
TDWaveType_JarateImmune = (1 << 5) // 32
};
enum TDMetalPackType
{
TDMetalPack_Invalid = -1,
TDMetalPack_Start = 0,
TDMetalPack_Boss
};

View File

@@ -0,0 +1,168 @@
/*======================================
= Data Variables =
======================================*/
Handle g_hMapTowers;
Handle g_hMapWeapons;
Handle g_hMapWaves;
Handle g_hMapMetalpacks;
Handle g_hMultiplierType;
Handle g_hMultiplier;
Handle g_hServerData;
int g_iTime;
/*=========================================
= Generic Variables =
=========================================*/
/*========== Boolean ==========*/
bool g_bConfigsExecuted;
bool g_bEnabled;
bool g_bLockable;
bool g_bMapRunning;
bool g_bServerInitialized;
bool g_bSteamWorks;
bool g_bTF2Attributes;
bool g_bTowerDefenseMap;
bool g_bCanGetUnlocks;
/*========== ConVar ==========*/
ConVar g_hEnabled;
ConVar g_hTfBotQuota;
ConVar g_hMaxBotsOnField;
/*========== Handle ==========*/
Handle hHintTimer;
/*========== Float ==========*/
float fMultiplier[50];
/*========== Integer ==========*/
int g_iBuildingLimit[TDBuildingType];
int g_iHaloMaterial;
int g_iLaserMaterial;
int g_iMetalPackCount;
int iMaxWaves;
int iMaxMultiplierTypes;
int g_iBotsToSpawn;
int g_iTotalBotsLeft;
int g_iMaxClients;
/*========== String ==========*/
char g_sPassword[8];
/*==========================================
= Database Variables =
==========================================*/
/*========== Boolean ==========*/
/*========== Handle ==========*/
Database g_hDatabase;
/*========== Float ==========*/
/*========== Integer ==========*/
int g_iServerId;
int g_iServerMap;
int g_iServerPort;
/*========== String ==========*/
char g_sServerIp[16];
/*========================================
= Client Variables =
========================================*/
/*========== Boolean ==========*/
bool g_bCarryingObject[MAXPLAYERS + 1];
bool g_bInsideNobuild[MAXPLAYERS + 1];
bool g_bPickupSentry[MAXPLAYERS + 1];
bool g_bReplaceWeapon[MAXPLAYERS + 1][3];
/*========== Handle ==========*/
Handle g_hPlayerData;
/*========== Float ==========*/
/*========== Integer ==========*/
int g_iAttachedTower[MAXPLAYERS + 1];
int g_iLastButtons[MAXPLAYERS + 1];
int g_iHealBeamIndex[MAXPLAYERS + 1][2];
/*========== String ==========*/
/*=======================================
= Tower Variables =
=======================================*/
/*========== Boolean ==========*/
int g_bTowerBought[TDTowerId];
bool g_bTowersLocked;
bool g_bAoEEngineerAttack;
bool g_bKritzMedicCharged;
/*========== Handle ==========*/
Handle hAoETimer;
/*========== Float ==========*/
/*========== Integer ==========*/
int g_iLastMover[MAXPLAYERS + 1];
int g_iUpgradeLevel[MAXPLAYERS + 1];
int g_iUpgradeMetal[MAXPLAYERS + 1];
int iAoEEngineerTimer;
int iAoEKritzMedicTimer;
/*========== String ==========*/
/*======================================
= Wave Variables =
======================================*/
/*========== Boolean ==========*/
bool g_bBoostWave;
bool g_bStartWaveEarly;
bool g_iSlowAttacker[MAXPLAYERS + 1];
/*========== Handle ==========*/
/*========== Float ==========*/
float g_fAirWaveSpawn[3];
float g_fWaveStartButtonLocation[3];
float g_fBeamPoints[MAXPLAYERS + 1][8][3];
/*========== Integer ==========*/
int g_iCurrentWave;
int g_iHealthBar;
int g_iNextWaveType;
int g_iRespawnWaveTime;
int g_iWaveStartButton;
/*========== String ==========*/
char g_sAirWaveSpawn[64];