I implement API to correct spawn infected bosses with more options (owner,ghost, startorigin, etc)
If you found bugs in API(or misprints in the English text) please inform me.
Sample plugin included.
Truncated Header File:
PHP Code:
/* (c) Infected Spawn API by V10 aka maldersoft (http://sourcemod.V10.name).
* This API written for l4d2 plugin writers to correct spawn infected bosses with more options (owner,ghost, startorigin, etc).
* Also plugin implement easy utils functions (stocks).
* Put InfectedAPI.txt to addons\sourcemod\gamedata folder!
*/
/* ChangeLog:
* 1.6.1
* - Fixed spawn command from z_spawn to z_spawn_old.
* 1.6
* - Added array g_iMaxInfectedCounts[]
* - Removed GetMaxInfectedCounts()
* - Added InitInfectedSpawnAPI() you must call this in Plugin_Start()
* - Removed all checks for alive and other checks. Now plugin must use it.
* - Some optimizations for speed up
* 1.5
* - Added function StringToClass
* - Improved small optimizations
* - Added check player claws entity id to prevent errors
* 1.4
* - updated InfectedAPI.txt: added offset RefEHandleOffset
* - simple changes in GenerateZombieId
* - fixed all MAXPLAYERS to MaxClients
* - disable use function InfectedForceGhostFinale
* - Added second try to spawn if first fail
* - updated InfectedAPI.txt: changed sign OnEnterGhostState (thanks to AtomicStryker)
* 1.3
* - Allow ghost mode for class TANK also (check removed)
* - Added config file gamedata\InfectedAPI.txt
* - Added bGhostFinale parameter to function SpawnInfectedBoss
* - Temporary removed InfectedAPI_mm (no needed now)
* - Added function InfectedForceGhost to correct spawn ghost and ghost in finale without any exstensions (l4dtoolz, etc)
* - Removed InitializeAsGhost (is not a reliable function)
* - Added function to correct generate random infected class
* - Added function to correct change infected class (based on SDK)
* - Added new consts for classes,also fixed bug with TANK (ZC_WITCH=7, ZC_TANK=8, ZC_NOT_INFECTED=9)
* - Changed g_sBossNames
* - Changed array in GetInfectedCounts() to Array[ZC_NOT_INFECTED], also now return TANK count
* - Added function GetInfectedClass
* - Added debug log to file.
* 1.2
* - Added metamod plugin for spawn ghost in finale (cvar z_ghost_finale).
* - Added detect l4dtoolz for spawning ghost in finale.
* - Removed fGhostFinale (not needed).
* - Removed function InitializeInfectedAPI (not needed).
* - Added param Velocity to function SpawnInfectedBoss.
* - Added counter to prevent infinite loop on try spawn ghost.
* - Fixed some bugs.
* 1.1
* - Added function GetInfectedCounts.
* - Added function GetMaxInfectedCounts.
* 1.0
* - Initial release.
*
*/
#define InfectedApiVersion1_5 1
#define InfectedApiVersion1_6 1
#define TEAM_SURVIVOR 2
#define TEAM_INFECTED 3
#define STATE_GHOST 8
#define ZC_SMOKER 1
#define ZC_BOOMER 2
#define ZC_HUNTER 3
#define ZC_SPITTER 4
#define ZC_JOCKEY 5
#define ZC_CHARGER 6
#define ZC_WITCH 7
#define ZC_TANK 8
#define ZC_NOT_INFECTED 9 //survivor
new String:g_sBossNames[ZC_NOT_INFECTED+1][10]={"","smoker","boomer","hunter","spitter","jockey","charger","witch","tank","survivor"};
new g_iMaxInfectedCounts[ZC_TANK];
new bool:g_ISAPIInited=false;
new g_ISAPI_propinfo_isAlive = -1;
new g_ISAPI_propinfoghost = -1;
new g_ISAPI_propinfo_zombieClass = -1;
new g_ISAPI_propinfo_customAbility = -1;
new g_ISAPI_propinfo_lifeState = -1;
new g_ISAPI_propinfo_isCulling = -1;
new g_ISAPI_propinfo_vecVelocity0 = -1;
InitInfectedSpawnAPI();
/**
* Spawn the specified zombie boss
*
* @param client Client index.
* @param Class Class of boss (see constants ZC_ in top of this file)
* @param bGhost True = spawned as ghost, False= spawned as alived..
* @param bGhostFinale True = spawned as ghost in finale, False= spawned as alived.in finale
* @param bAuto Use director auto position? True = use, False = spawn in eye direction (if param Origin not set)
* @param Origin Set position new zombie
* @param Angles Set angles new zombie
* @param Velocity Set velocitys new zombie
* @return True if successfully spawn, false otherwise.
* @error Invalid handle, or bounds error.
* Invalid infected class
* Client is alive
* Client is not in game
* Client is not infected team
* Can't get open config file (gamedata\InfectedAPI.txt) (FAILSTATE FOR PLUGIN)
* Can't get offsets (FAILSTATE FOR PLUGIN)
*/
stock SpawnInfectedBoss(client, Class, bool:bGhost=false, bool:bAuto=true, bool:bGhostFinale=false ,const Float:Origin[3]=NULL_VECTOR,const Float:Angles[3]=NULL_VECTOR,const Float:Velocity[3]=NULL_VECTOR);
/**
* Force infected to full ghost state
*
* @param client Client index.
* @param SavePos True = save position, False = spawn in director pos
* @param inFinaleAlso True = ghost in finale, False = return false in finale
* @return True if successfully , false otherwise.
* @error Invalid handle, or bounds error.
* Client is alive
* Client is already ghost
* Client is not in game
* Client is not infected team
* Can't get open config file (gamedata\InfectedAPI.txt) (FAILSTATE FOR PLUGIN)
* Can't get offsets (FAILSTATE FOR PLUGIN)
*
* Notice: Function detect l4dtoolz and if sv_force_normal_respawn==1 to spawn ghost in finales, ignore inFinaleAlso
*/
stock bool:InfectedForceGhost(client, SavePos=false, inFinaleAlso=false);
/**
* Change infected zombie class
*
* @param client Client index.
* @param newclass New class for zombie
* @return True if successfully , false otherwise.
* @error Invalid handle, or bounds error.
* Client is alive
* Client is already ghost
* Client is not in game
* Client is not infected team
* Can't get open config file (gamedata\InfectedAPI.txt) (FAILSTATE FOR PLUGIN)
* Can't get offsets (FAILSTATE FOR PLUGIN)
*/
stock InfectedChangeClass(client,newclass);
/**
* Correctly generate new zombie class id for spawn, change, etc
*
* @param client Client index.
* @param lastClass Last used class (for exlude same class)
* @return Corectry randomed new class id
*/
stock GenerateZombieId(lastClass, bool:checkmax=true);
/**
* Get all infected boss counts
*
* @return Array longs from ZC_SMOKER to ZC_TANK (Array[ZC_NOT_INFECTED])
* Notice: This function not return wiches count
*/
stock GetInfectedCounts();
/**
* Get Player class
*
* @param client Client index.
* @return player class
*
*/
stock GetInfectedClass(client);
stock SetPlayerIsAlive(client, bool:alive);
stock StringToClass(const String:zclass[]);
stock bool:IsPlayerGhost(client);
stock SetPlayerGhostStatus(client, bool:ghost);
stock SetPlayerLifeState(client, bool:ready);
stock CheatCommand(client, const String:command[], const String:arguments[]="");
stock bool:isWin32();
Downloads:
v1.6 ~ 400
v1.5 ~ 500
v1.3 ~ 230
v1.2 ~ 100
Sry for my english.
I good speak on russian =)