Raised This Month: $32 Target: $400
 8% 

SwarmTools - Alien Swarm Function Lib for Plugin Devs


Post New Thread Reply   
 
Thread Tools Display Modes
Author
psychonic

BAFFLED
Join Date: May 2008
Plugin ID:
2110
Plugin Version:
1.2.4
Plugin Category:
Technical/Development
Plugin Game:
Alien Swarm
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Exposes extra functionality to Alien Swarm plugin developers
    Old 12-02-2010 , 08:48   SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #1

    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.
    Attached Files
    File Type: txt swarmtools.games.txt (670 Bytes, 949 views)
    File Type: sp Get Plugin or Get Source (swarmtools.sp - 2046 views - 9.3 KB)
    File Type: inc swarmtools.inc (7.9 KB, 709 views)

    Last edited by psychonic; 11-03-2011 at 22:41. Reason: changed game to Alien Swarm
    psychonic is offline
    McFlurry
    Veteran Member
    Join Date: Mar 2010
    Location: RemoveEdict(0);
    Old 12-02-2010 , 13:40   Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #2

    Good work, hopefully this kick starts some Alien Swarm plugins.
    __________________
    McFlurry is offline
    Send a message via Skype™ to McFlurry
    sejin513
    AlliedModders Donor
    Join Date: Dec 2008
    Location: ._.
    Old 12-03-2010 , 11:44   Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #3

    awesome ;)
    sejin513 is offline
    Bacardi
    Veteran Member
    Join Date: Jan 2010
    Location: mom's basement
    Old 04-23-2011 , 11:06   Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #4

    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

    Last edited by Bacardi; 04-23-2011 at 11:09.
    Bacardi is offline
    psychonic

    BAFFLED
    Join Date: May 2008
    Old 04-23-2011 , 14:14   Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #5

    Quote:
    Originally Posted by Bacardi View Post
    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.
    psychonic is offline
    DarthNinja
    SourceMod Plugin Approver
    Join Date: Mar 2009
    Location: PreThinkHook()
    Old 05-30-2011 , 08:15   Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #6

    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); 
    __________________

    Last edited by DarthNinja; 05-30-2011 at 08:37.
    DarthNinja is offline
    psychonic

    BAFFLED
    Join Date: May 2008
    Old 08-10-2011 , 20:13   Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #7

    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.
    psychonic is offline
    Despirator
    Senior Member
    Join Date: Jun 2011
    Location: Kazakhstan ->Shymkent
    Old 08-19-2011 , 11:14   Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #8

    also
    PHP Code:
    return SetEntData(marineammoOffset + (ammotype 4), amount); 
    should be
    PHP Code:
    SetEntData(marineammoOffset + (_:ammotype 4), amount); 
    Despirator is offline
    psychonic

    BAFFLED
    Join Date: May 2008
    Old 08-19-2011 , 11:20   Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #9

    Quote:
    Originally Posted by Despirator View Post
    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.
    psychonic is offline
    Edison1318
    Senior Member
    Join Date: Nov 2015
    Location: Peaceful place of the in
    Old 05-04-2019 , 04:12   Re: SwarmTools - Alien Swarm Function Lib for Plugin Devs
    Reply With Quote #10

    Wish this works on Reactive Drop.
    __________________
    EdisonGar
    Edison1318 is offline
    Send a message via Skype™ to Edison1318
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 21:52.


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