AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   SwarmTools - Alien Swarm Function Lib for Plugin Devs (https://forums.alliedmods.net/showthread.php?t=144324)

psychonic 12-02-2010 08:48

SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
3 Attachment(s)
SwarmTools

SwarmTools adds natives and stocks that are useful for Alien Swarm plugin developers.

Users:
The attached swarmtools.inc may be required to compile some plugins, and the SwarmTools plugin itself may be required on the server for some Alien Swarm plugins to run.

Plugin Developers
In Alien Swarm, the player/client entity is separate from the marine entity. There is then a third entity type, a marine resource, that links these two together.

This plugin provides a few natives to make converting between client and marine seemless. There are also many useful stocks provided to simplify plugin development.

A taste:
Code:
/**  * Returns whether or not the game is active. If not, all the below calls will error.  *  * @return              True if game is active, false otherwise  */ native bool:Swarm_IsGameActive(); /**  * Gets the marine entity controlled by the given player  *  * @param client        Client index  * @return              Marine entity index or -1 for none or not found  * @error               Invalid client index  */ native Swarm_GetMarine(client); /**  * Gets the count of marines controlled by a given player  *  * @param client        Client index  * @return              Count of marines found under given player's control  *  * @error               Invalid client index  */ native Swarm_GetClientMarineCount(client); /**  * Gets the client index controlling given marine  *  * @param marine        Marine entity index  * @return              Client index of controller or -1 for none or not found  * @error               Invalid marine index  */ stock Swarm_GetClientOfMarine(marine); /**  * Gets the marine resource entity index of given client  *  * @param client        Client index  * @return              Marine resource entity index of client or -1 for none or not found  * @error               Invalid client index  */ native Swarm_GetMarineResFromCommander(client); /**  * Gets the marine resource entity index of given marine  *  * @param marine        Marine entity index  * @return              Marine resource entity index of entity or -1 for none or not found  * @error               Invalid marine index  */ native Swarm_GetMarineResOfMarine(marine); /**  * Returns the weapon in a marine's slot.  *  * @param marine        Marine entity index  * @param slot          Slot index (0-based)  * @return              Entity index on success, -1 if no weapon existed.  * @error               Invalid entity or unable to find marine's weapons  */ stock Swarm_GetMarineWeaponSlot(marine, slot); /**  * Returns the marine's current weapon.  *  * @param marine        Marine entity index  * @return              Entity index on success, -1 if no weapon existed.  * @error               Invalid entity  */ stock Swarm_GetMarineActiveWeapon(marine); /**  * Returns the marine's health.  *  * @param marine        Marine entity index  * @return              Health value  * @error               Invalid entity  */ stock Swarm_GetMarineHealth(marine); /**  * Set the marine's health. (same as SetEntityHealth)  *  * @param marine        Marine entity index  * @param amount        Health amount  * @error               Invalid entity  */ stock Swarm_SetMarineHealth(marine, health); /**  * Returns the marine's max health.  *  * @param marine        Marine entity index  * @return              Max Health value  * @error               Invalid entity  */ stock Swarm_GetMarineMaxHealth(marine); /**  * Returns the marine's ammo amount of the specified type.  *  * @param marine        Marine entity index  * @return              Amount  * @error               Invalid entity or unable to find marine ammo offset  */ stock Swarm_GetMarineAmmo(marine, SwarmAmmoType:ammotype); /**  * Set the marine's ammo amount of the specified type.  *  * @param marine        Marine entity index  * @param amount        Amount  * @error               Invalid entity or unable to find marine ammo offset  */ stock Swarm_SetMarineAmmo(marine, SwarmAmmoType:ammotype, amount); /**  * Returns if a marine is infested  *  * @param marine        Marine entity index  * @return              True if marine is infested, false otherwise  * @error               Invalid entity  */ stock bool:Swarm_IsMarineInfested(marine); /**  * Causes a marine to become infested.  *  * @param marine        Marine entity index  * @param duration      Length of infestion  * @noreturn  * @error               Function not found or invalid marine  */ native Swarm_StartMarineInfestation(marine, Float:duration=20.0); /**  * Cures a marine's infestation.  *  * @param marine        Marine entity index  * @noreturn  * @error               Invalid entity  */ stock Swarm_CureMarineInfestation(marine); /**  * Returns if a marine is on fire  *  * @param marine        Marine entity index  * @return              True if marine is on fire, false otherwise  * @error               Invalid entity  */ stock bool:Swarm_IsMarineOnFire(marine); /**  * Adds a weapon to the marine's inventory and equips it.  *  * @param marine        Marine entity index  * @param weapon        Weapon entity index  * @noreturn  * @error               Function not found or invalid marine  */ native Swarm_EquipMarineWeapon(marine, weapon); /**  * Forces a marine to drop the specified weapon.  *  * @param marine        Marine entity index  * @param weapon        Weapon entity index  * @noreturn  * @error               Function not found or invalid marine  */ native Swarm_DropMarineWeapon(marine, weapon);    /**  * Forces a marine to commit suicide.  *  * @param marine        Marine entity index  * @noreturn  * @error               Function not found or invalid marine  */ native Swarm_ForceMarineSuicide(marine);   /**  * Slaps a marine in a random direction.  *  * @param marine        Marine entity index  * @param amount        Health to subtract  * @param bsound        False to disable sound effects  * @noreturn  * @error               Function not found or invalid marine  */ native Swarm_SlapMarine(marine, amount=5, bool:bSound=true); /**  * Returns the marines's eye angles.  *  * @param marine        Marine entity index  * @param ang           Destination vector to store the marine's eye angles  * @noreturn  * @error               Function not found or invalid marine  */ native Swarm_GetMarineEyeAngles(marine, Float:ang[3]); enum SwarmAmmoType {     SwarmAmmo_AR2,     SwarmAmmo_Rifle,     SwarmAmmo_RifleGrenades,     SwarmAmmo_Autogun,     SwarmAmmo_Shotgun,     SwarmAmmo_AssaultShotgun,     SwarmAmmo_Flamer,     SwarmAmmo_Pistol,     SwarmAmmo_MiningLaser,     SwarmAmmo_TeslaGun,     SwarmAmmo_Railun,     SwarmAmmo_ChainSaw,     SwarmAmmo_Flares,     SwarmAmmo_Medkit,     SwarmAmmo_MedSatchel,     SwarmAmmo_MedSatchelSelf,     SwarmAmmo_Stim,     SwarmAmmo_Welder,     SwarmAmmo_FireExtinguisher,     SwarmAmmo_VGrenades,     SwarmAmmo_PDW,     SwarmAmmo_HandGrenades,     SwarmAmmo_GrenadeLauncher,     SwarmAmmo_SniperRifle, }

To use any of the natives or stocks in a plugin, just add the following:
Code:
#include <swarmtools>

If you are not using any of the natives or any of the stocks that require the natives and do not wish to require the plugin, you can add it as such:
Code:
#undef REQUIRE_PLUGINS #include <swarmtools> #define REQUIRE_PLUGINS

If you post a plugin requiring it, put the SwarmTools plugin id into the dependency field so that users can easily find it.

-------------

Thank you to comp_noob for doing all of the testing.

McFlurry 12-02-2010 13:40

Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
Good work, hopefully this kick starts some Alien Swarm plugins. :wink:

sejin513 12-03-2010 11:44

Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
awesome ;)

Bacardi 04-23-2011 11:06

Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
Miss Float ??


...addons\sourcemod\scripting\include\swarmto ols.inc(220) : error 092: number of arguments does not match definition

PHP Code:

/**
 * Cures a marine's infestation.
 *
 * @param marine        Marine entity index
 * @noreturn
 * @error               Invalid entity
 */
stock Swarm_CureMarineInfestation(marine)
{
    
SetEntPropFloat(marineProp_Send"m_fInfestedTime");


SetEntPropFloat
Code:

Syntax:
native SetEntPropFloat(entity, PropType:type, const String:prop[], Float:value);

*edit
Or is it
GetEntPropFloat

psychonic 04-23-2011 14:14

Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
Quote:

Originally Posted by Bacardi (Post 1456081)
Miss Float ??


...addons\sourcemod\scripting\include\swarmto ols.inc(220) : error 092: number of arguments does not match definition

PHP Code:

/**
 * Cures a marine's infestation.
 *
 * @param marine        Marine entity index
 * @noreturn
 * @error               Invalid entity
 */
stock Swarm_CureMarineInfestation(marine)
{
    
SetEntPropFloat(marineProp_Send"m_fInfestedTime");


SetEntPropFloat
Code:

Syntax:
native SetEntPropFloat(entity, PropType:type, const String:prop[], Float:value);

*edit
Or is it
GetEntPropFloat

DarthNinja pointed out to me that and I think one other issue a couple months ago. It didn't seem to matter as obviously not one but him had used it since posting. I'll update the post in a little bit.

DarthNinja 05-30-2011 08:15

Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
SetEntPropFloat in Swarm_CureMarineInfestation is missing a value as you know. (I just ran into it again).
PHP Code:

SetEntPropFloat(marineProp_Send"m_fInfestedTime"); 

Needs to be:
PHP Code:

SetEntPropFloat(marineProp_Send"m_fInfestedTime"0.001); 


psychonic 08-10-2011 20:13

Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
Happened to be looking at this today so I posted a fixed version of the inc that takes care of a couple of long-standing issues.

- Fixed Swarm_CureMarineInfestation stock compile error
- Fixed natives always being marked as optional even if REQUIRE_PLUGINS was defined.

Despirator 08-19-2011 11:14

Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
also
PHP Code:

return SetEntData(marineammoOffset + (ammotype 4), amount); 

should be
PHP Code:

SetEntData(marineammoOffset + (_:ammotype 4), amount); 


psychonic 08-19-2011 11:20

Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
Quote:

Originally Posted by Despirator (Post 1536295)
also
PHP Code:

return SetEntData(marineammoOffset + (ammotype 4), amount); 

should be
PHP Code:

SetEntData(marineammoOffset + (_:ammotype 4), amount); 


Thank you. Posted new inc with fixed tag mismatch warnings in Get and Set MarineAmmo fixed.

Edison1318 05-04-2019 04:12

Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
 
Wish this works on Reactive Drop.


All times are GMT -4. The time now is 00:02.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.