Raised This Month: $ Target: $400
 0% 

[L4D2] Ghost HP restore


Post New Thread Reply   
 
Thread Tools Display Modes
Author
SGG
Member
Join Date: Feb 2012
Plugin ID:
2849
Plugin Version:
0.2
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Sets SI HP back to it's current Cvar value when they enter ghost mode.
    Old 03-26-2012 , 07:43   [L4D2] Ghost HP restore
    Reply With Quote #1

    After having a look for something to do this, I couldn't find one exactly like it, so found out how to build it myself.

    Feature list:
    On entering ghost mode, it sets SI health back to it's maximum value determined by the appropriate z_xxx_health cvar.

    CVAR/Command list:
    l4d2_ghost_hp_restore_smoker (Default of 1, determines if smoker hp restore is enabled, 1 for yes, 0 for no)

    l4d2_ghost_hp_restore_boomer (Default of 1)

    l4d2_ghost_hp_restore_hunter (Default of 1)

    l4d2_ghost_hp_restore_spitter (Default of 1)

    l4d2_ghost_hp_restore_jockey (Default of 1)

    l4d2_ghost_hp_restore_charger (Default of 1)

    Changelog:
    2012-03-28 (0.2)
    • Fixes/changes as suggested by Dont Fear The Reaper
    • Changed Cvars so you can enable/disable individual SI ghost health restore
    2012-03-26 (0.1)
    • Initial release

    Installation instructions:
    Will auto generate a cfg file if needed, no special install instructions

    Dependencies:
    Requires Left4Downtown2

    Plans:
    None, unless someone has a good idea.
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d2_ghost_hp_restore.sp - 566 views - 3.9 KB)
    File Type: smx l4d2_ghost_hp_restore.smx (3.3 KB, 689 views)

    Last edited by SGG; 03-28-2012 at 02:37.
    SGG is offline
    Dont Fear The Reaper
    Member
    Join Date: Nov 2011
    Old 03-27-2012 , 13:22   Re: [L4D2] Ghost HP restore
    Reply With Quote #2

    Nice idea and plugin

    Just some minor things i noticed:


    - For consistency:

    The topics name "[L4D2] Ghost HP restore", the plugins filename "L4D2_Ghost_HP_Regen" and the cvars "l4d2_ghost_HP_regen_enabled" and "l4d2_Ghost_HP_regen_version" have different usage of capitals and restore/regen.
    My suggestion is for topic and plugin name (the name in the plugin info, you don't need underscores there) use "[L4D2] Ghost HP Regen" and for filename, config name and cvars just lowercase like "l4d2_ghost_hp_regen...".


    - You might have forgot to check the cvar descriptions again

    Could be something like "Disable/Enable the '[L4D2] Ghost HP Regen' plugin" and "Version of the '[L4D2] Ghost HP Regen' plugin".


    - You can get the handle to the cvar directly from "CreateConVar()", so you don't need the "FindConVar()" there:
    Code:
    H_GhostHPRegenEnabled = CreateConVar("l4d2_ghost_HP_regen_enabled"...);
    - Not sure if you do, but if you want the config file to have the same name as the plugin, just use:
    Code:
    AutoExecConfig(true, "l4d2_ghost_hp_regen");
    - If you want the plugin to only work in L4D2, you could add a game check at the start of "OnPluginStart()" like:
    Code:
    public OnPluginStart()
    {
            decl String:sGame[16];
            GetGameFolderName(sGame, sizeof(sGame));
            if (!StrEqual(sGame, "left4dead2", false))
            {
                SetFailState("Plugin supports 'Left 4 Dead 2' only.");
            }
    
            CreateConVar...
    But as i said it's just minor things, nothing affecting the functionality of the plugin. Good job, thanks for sharing

    Last edited by Dont Fear The Reaper; 03-27-2012 at 13:23.
    Dont Fear The Reaper is offline
    SGG
    Member
    Join Date: Feb 2012
    Old 03-28-2012 , 02:30   Re: [L4D2] Ghost HP restore
    Reply With Quote #3

    Yeah, I guess most of those come from what was (for me), a rush job of 20 mins.

    All of your suggestions have been implemented (fixing the names, CaPitaLIzaTIOn, etc), and added in the l4d2 check code. I also changed it from being an all or nothing, to individual yes/no for each SI health restore.
    SGG is offline
    Dont Fear The Reaper
    Member
    Join Date: Nov 2011
    Old 03-28-2012 , 16:24   Re: [L4D2] Ghost HP restore
    Reply With Quote #4

    That "all or nothing" just made me think of making the cvars not work as on/off, but as percentages to restore the lost hp. 0 would add nothing and 1 would add all the lost hp back, like in the following equation:
    Code:
    (hp to set) = (current hp) + ( (max hp) - (current hp) ) * (cvar value)
    
        200     =      150     + (    250   -     150      ) *     0.5    (as example for 50% restore)
    But i'm not sure if it's worth the effort since it's fine as it is now and that might not get used much anyway. As i said it just came to my mind, so don't see it as a request
    Dont Fear The Reaper is offline
    disawar1
    AlliedModders Donor
    Join Date: Aug 2011
    Location: Russian
    Old 04-08-2012 , 17:19   Re: [L4D2] Ghost HP restore
    Reply With Quote #5

    you can use a basic API function.

    PHP Code:
    stock SetEntityHealth(entityamount)

    /**
     * Sets an entity's health
     *
     * @param entity    Entity index.
     * @param amount    Health amount.
     * @noreturn
     * @error            Invalid entity index, or lack of mod compliance.
     * 
    __________________
    disawar1 is offline
    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:01.


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