Raised This Month: $51 Target: $400
 12% 

TF2: Capper Regeneration


Post New Thread Reply   
 
Thread Tools Display Modes
Author
deltron
Junior Member
Join Date: Feb 2008
Plugin ID:
353
Plugin Version:
1.1
Plugin Category:
Gameplay
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Regenerates a player when they capture the intelligence (like Q3F/ETF)
    Unapprover:
    Reason for Unapproving:
    Hardcodes (incorrect) TF2 weapon/ammo/health data rather than using TF2_RegeneratePlayer, abandoned(?)
    Old 04-14-2008 , 17:23   TF2: Capper Regeneration
    Reply With Quote #1

    This is a very simple plugin (~100 loc) that implements a feature of Q3F/ETF that I missed in TF2.

    When this plugin is enabled, a player capturing the flag will be regenerated to full health and ammo, as in previous TF mods.

    This will currently only work on Linux servers as I do not have the function signature for Windows. If someone feels inclined to find it (CTFPlayer::Regenerate()), let me know and I'll add it to the plugin.

    Many thanks to bl4nk for providing example code to remove the dependency on sdktools. The plugin should now work on all platforms supported by TF2/SourceMod.

    Convar to enable/disable is `sm_tf2_capregen_enable'. The default is enabled.

    A gitweb interface to the plugin is available here.

    This plugin requires the TF2 extension, so you must use one of the Sourcemod 1.0 or 1.1 snapshots!
    Attached Files
    File Type: sp Get Plugin or Get Source (tf2-cap-regen.sp - 1991 views - 3.9 KB)
    File Type: smx tf2-cap-regen.smx (3.5 KB, 580 views)

    Last edited by deltron; 07-02-2008 at 07:12. Reason: Version bump to 1.1
    deltron is offline
    Fredd
    Veteran Member
    Join Date: Jul 2007
    Old 04-14-2008 , 17:35   Re: TF2: Capper Regeneration
    Reply With Quote #2

    your plugin is not that huge, no need to zip it up..please attach the .sp and the gamedata file and the forum will generate the .smx for download.
    __________________
    Need a private coder? AMXX, SourceMOD, MMS? PM me!
    Fredd is offline
    bl4nk
    SourceMod Developer
    Join Date: Jul 2007
    Old 04-14-2008 , 18:38   Re: TF2: Capper Regeneration
    Reply With Quote #3

    I imagine the zip file is to make it easier to get the files in the right place, rather than because of file sizes.

    As for the whole using signatures thing, why don't you just change the player's m_iHealth offset instead?
    bl4nk is offline
    teddyruxpin
    Overseer of lost packets
    Join Date: Feb 2008
    Old 04-14-2008 , 18:38   Re: TF2: Capper Regeneration
    Reply With Quote #4

    This will currently only work on Linux servers as I do not have the function signature for Windows. If someone feels inclined to find it (CTFPlayer::Regenerate()), let me know and I'll add it to the plugin.

    I have windows hosts. Where would I find this info and I will pass it onto you.

    Thanks,

    -Teddy
    teddyruxpin is offline
    Fredd
    Veteran Member
    Join Date: Jul 2007
    Old 04-14-2008 , 19:15   Re: TF2: Capper Regeneration
    Reply With Quote #5

    did you not just see what bl4nk posted?
    __________________
    Need a private coder? AMXX, SourceMOD, MMS? PM me!
    Fredd is offline
    bl4nk
    SourceMod Developer
    Join Date: Jul 2007
    Old 04-14-2008 , 20:28   Re: TF2: Capper Regeneration
    Reply With Quote #6

    Calm down, Fredd. I posted it literally seconds before his post. He never even saw my post before his was submitted.
    bl4nk is offline
    deltron
    Junior Member
    Join Date: Feb 2008
    Old 04-14-2008 , 20:28   Re: TF2: Capper Regeneration
    Reply With Quote #7

    Quote:
    Originally Posted by bl4nk View Post
    As for the whole using signatures thing, why don't you just change the player's m_iHealth offset instead?
    The Regenerate() function gives full health, full ammo and a full clip to the client (presumably it's the same function that's run when a resupply is touched). So it's not as simple as just using SetEntityHealth().

    I'd have to jump through hoops to achieve the same effects using offsets and SetEntData() etc.
    deltron is offline
    bl4nk
    SourceMod Developer
    Join Date: Jul 2007
    Old 04-14-2008 , 20:28   Re: TF2: Capper Regeneration
    Reply With Quote #8

    Using offsets is a whole lot easier than finding a Windows signature.
    bl4nk is offline
    SaintK
    Veteran Member
    Join Date: Mar 2004
    Old 04-16-2008 , 16:15   Re: TF2: Capper Regeneration
    Reply With Quote #9

    Sounds like an intresting idea!
    SaintK is offline
    bl4nk
    SourceMod Developer
    Join Date: Jul 2007
    Old 04-17-2008 , 18:02   Re: TF2: Capper Regeneration
    Reply With Quote #10

    PHP Code:
    stock bool:RegeneratePlayer(client)
    {
        if (!
    IsClientConnected(client) || !IsClientInGame(client) || !IsPlayerAlive(client))
            return 
    false;

        new 
    TFClassType:class = TF2_GetPlayerClass(client);
        switch (class)
        {
            case 
    0:
            {
                return 
    false;
            }
            case 
    1:
            {
                
    SetEntProp(clientProp_Send"m_iHealth"125);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 432);
                
    SetEntData(GetPlayerWeaponSlot(client0), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 6);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 836);
                
    SetEntData(GetPlayerWeaponSlot(client1), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 12);
            }
            case 
    2:
            {
                
    SetEntProp(clientProp_Send"m_iHealth"125);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 425);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 875);
                
    SetEntData(GetPlayerWeaponSlot(client0), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 25);
            }
            case 
    3:
            {
                
    SetEntProp(clientProp_Send"m_iHealth"200);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 416);
                
    SetEntData(GetPlayerWeaponSlot(client0), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 4);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 832);
                
    SetEntData(GetPlayerWeaponSlot(client1), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 6);
            }
            case 
    4:
            {
                
    SetEntProp(clientProp_Send"m_iHealth"175);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 416);
                
    SetEntData(GetPlayerWeaponSlot(client0), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 4);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 824);
                
    SetEntData(GetPlayerWeaponSlot(client1), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 8);
            }
            case 
    5:
            {
                
    SetEntProp(clientProp_Send"m_iHealth"150);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 4150);
                
    SetEntData(GetPlayerWeaponSlot(client0), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 30);
            }
            case 
    6:
            {
                
    SetEntProp(clientProp_Send"m_iHealth"300);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 4200);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 832);
                
    SetEntData(GetPlayerWeaponSlot(client1), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 6);
            }
            case 
    7:
            {
                
    SetEntProp(clientProp_Send"m_iHealth"175);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 4200);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 832);
                
    SetEntData(GetPlayerWeaponSlot(client1), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 6);
            }
            case 
    8:
            {
                
    SetEntProp(clientProp_Send"m_iHealth"125);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 424);
                
    SetEntData(GetPlayerWeaponSlot(client0), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 6);
            }
            case 
    9:
            {
                
    SetEntProp(clientProp_Send"m_iHealth"125);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 432);
                
    SetEntData(GetPlayerWeaponSlot(client1), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 6);
                
    SetEntData(clientFindSendPropInfo("CTFPlayer""m_iAmmo") + 8200);
                
    SetEntData(GetPlayerWeaponSlot(client1), FindSendPropInfo("CTFWeaponBase""m_iClip1"), 12);
            }
        }

        return 
    true;

    I tried it out, and it seems to work fine for me. I didn't notice any bugs with it. It returns true if successful, false if the client isn't connected/in-game/alive or if they do not currently have a class (not sure where this would apply, but it's just a safety precaution).

    It uses functions from the snapshots, so you'll need to use those instead of the 1.0 base.
    bl4nk 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 18:33.


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