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

[:3] TF2_CTFWeaponInfo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 08-30-2010 , 14:36   [:3] TF2_CTFWeaponInfo
Reply With Quote #1

Rawr moar stuff. This allows you to change weapon information that you would find in the ctx files.
PHP Code:
class CTFWeaponInfo :                                //  2884
    
public FileWeaponInfo_t                            // +0
{
public :
    
int m_nDamage;                                    // +1704
    
int m_nBulletsPerShot;                            // +1708
    
float m_fRange;                                    // +1712
    
float m_fSpread;                                // +1716
    
float m_fPunchAngle;                            // +1720
    
float m_fTimeFireDelay;                            // +1724
    
float m_fTimeIdle;                                // +1728
    
float m_fTimeIdleEmpty;                            // +1732
    
float m_fTimeReloadStart;                        // +1736
    
float m_fTimeReload;                            // +1740
    
bool m_bDrawCrosshair;                            // +1744
    
int m_nProjectileType;                            // +1748
    
int m_nAmmoPerShot;                                // +1752
    
float m_fProjectileSpeed;                        // +1756
    
float m_fSmackDelay;                            // +1760
    
bool m_bUseRapidFireCrits;                        // +1764
    
int m_nSecondary_Damage;                        // +1768
    
int m_nSecondary_BulletsPerShot;                // +1772
    
float m_fSecondary_Range;                        // +1776
    
float m_fSecondary_Spread;                        // +1780
    
float m_fSecondary_PunchAngle;                    // +1784
    
float m_fSecondary_TimeFireDelay;                // +1788
    
float m_fSecondary_TimeIdle;                    // +1792
    
float m_fSecondary_TimeIdleEmpty;                // +1796
    
float m_fSecondary_TimeReloadStart;                // +1800
    
float m_fSecondary_TimeReload;                    // +1804
    
bool m_bSecondary_DrawCrosshair;                // +1808
    
int m_nSecondary_ProjectileTyp;                    // +1812
    
int m_nSecondary_AmmoPerShot;                    // +1816
    
int m_nUnknown1;                                // +1820
    
float m_fSecondary_SmackDelay;                    // +1824
    
bool m_bSecondary_UseRapidFireCrits;            // +1828
    
int m_nWeaponType;                                // +1832
    
bool m_bGrenade;                                // +1836
    
float m_fDamageRadius;                            // +1840
    
float m_fPrimerTimer;                            // +1844
    
bool m_bLowerMainWeapon;                        // +1848
    
bool m_bPlayGrenTimer;                            // +1849
    
bool m_bHasTeamSkins;                            // +1850
    
bool m_bHasTeamSkins_Worldmodel;                // +1851
    
char m_achMuzzleFlashModel[128];                // +1852
    
float m_fMuzzleFlashModelDuration;                // +1980
    
char m_achMuzzleFlashParticleEffect[128];        // +1984
    
char m_achTracerEffect[128];                    // +2112
    
bool m_bDoInstantEjectBrass;                    // +2240
    
char m_achBrassModel[128];                        // +2241
    
char m_achExplosionSound[128];                    // +2369
    
char m_achExplosionEffect[128];                    // +2497
    
char m_achExplosionPlayerEffect[128];            // +2625
    
char m_achExplosionWaterEffect[128];            // +2753
    
bool m_bDontDrop;                                // +2881
};

typedef CUtlDictCTFWeaponInfo *, unsigned short WeaponDatabase;

WeaponDatabase *g_pWeaponInfoDatabase;

CON_COMMAND(wazz_weapon"Wazz Environment :: Weapon info hacks")
{
    if (
args.ArgC() == 1)
    {
        
META_CONPRINTF("Wazz Environment :: Weapon info hacks\n");
        return;
    }

    static 
bool bInit false;

    if (!
bInit)
    {
#ifdef _WIN32
        
void *addr;
        
int offset;
/*
            "ReadWeaponDataFromFileForSlot_SubCall_01"
            {
                "library"        "server"
                "windows"        "\x83\xEC\x08\x85\xF6\x74\x2A\x8D\x04\x24\x50\xB9"
            }
*/
        
if (!g_pGameConf->GetMemSig("ReadWeaponDataFromFileForSlot_SubCall_01", &addr) || !addr)
        {
            
META_CONPRINTF("NULL 1\n");
            return;
        }
/*
            "WeaponDatabase_Offset"
            {
                "windows"        "12"
            }
*/
        
if (!g_pGameConf->GetOffset("WeaponDatabase_Offset", &offset))
        {
            
META_CONPRINTF("NULL 2\n");
            return;
        }
        
        
g_pWeaponInfoDatabase = *(WeaponDatabase **)((uint32)addr offset);
#else
/*
            "m_WeaponInfoDatabase"
            {
                "library"        "server"
                "linux"            "@m_WeaponInfoDatabase"                
            }
*/
        
void *addr;
        if (!
g_pGameConf->GetMemSig("m_WeaponInfoDatabase", &addr) || !addr)
        {
            
META_CONPRINTF("NULL 1\n");
            return;
        }
        
        
g_pWeaponInfoDatabase = (WeaponDatabase *)addr;
#endif
        
        
META_CONPRINTF("Address: %p\n"g_pWeaponInfoDatabase);
        
META_CONPRINTF("Count: %i\n"g_pWeaponInfoDatabase->Count());

        
bInit true;
    }
    
    if (
args.ArgC() != 3)
    {
        
META_CONPRINTF("Wrong number of args u slag\n");

        return;
    }

    const 
char *pszName args.Arg(1);

    
int iIndex g_pWeaponInfoDatabase->Find(pszName);

    if (!
g_pWeaponInfoDatabase->IsValidIndex(iIndex))
    {
        
META_CONPRINTF("Invalid Name: %s\n"pszName);

        return;
    }

    
CTFWeaponInfo *pInfo g_pWeaponInfoDatabase->Element(iIndex);
    
    
pInfo->m_nProjectileType atoi(args.Arg(2));

    
META_CONPRINTF("Done\n");

    return;

The CONCOMMAND is just an example, if you were to use it and do wazz_weapons tf_weapon_minigun 2 you would have a minigun that shoots rockets. Changes are instant but this method effects all weapons of that type. To have a per-weapon setup you should detour `CTFWeaponBase::GetTFWpnData(void)const` and return your own instance of CTFWeaponInfo... I guess.

Edit: Include weapon_parse.h from the HL SDK for the FileWeaponInfo_t class.

Last edited by Wazz; 09-01-2010 at 12:14. Reason: zombie ghosts compelled me to
Wazz is offline
Swixel
Senior Member
Join Date: Jul 2010
Location: Sydney, Australia
Old 09-03-2010 , 07:37   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #2

Also, <3 and :3

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

0 - projectile_none (lowers ammo, does no damage)
1 - projectile_bullet (bullets)
2 - tf_projectile_rocket (rocket launcher)
3 - tf_projectile_pipe (grenade)
4 - tf_projectile_pipe_remote (sticky)
5 - tf_projectile_syringe (needlegun -- doesn't always work)
6 - tf_projectile_flare (flaregun)
7 - tf_projectile_jar (doesn't work)
8 - tf_projectile_arrow (huntsman)


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

DO NOT CHANGE THE PIPEBOMBLAUNCHER'S PRIMARY FIRE. If anyone right-clicks the server crashes...
(You could use TF2Items to kill alt-fire on the stickylauncher, but why nerf it? =\)

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

There are two groups of projectiles (as far as I'm concerned). Those which require force (2, 3, and 8), and those which don't. Those which require force (not sure how this works, haven't really looked) will drop straight down (so arrows -- 8 -- will shoot straight into the ground). The rest fire from any gun. Obviously, the guns from which these weapons originally spawn -- pipebomb launcher (stickies), grenade launcher (pipes), and huntsman (arrows) -- will shoot these weapons (and the others) fine. The arc appears to belong to the weapon, so with any luck it's a ctx attribute.

From what I've gathered (based on how these projectiles spawn) the reason for this is likely to be tied to "CBaseEntity::ApplyLocalAngularVelocityImpuls e". What this does isn't something I've looked into... but it's used by pipes and jars (which both arc). There's likely to be something similar for arrows and stickies, but I haven't looked yet.

Last edited by Swixel; 09-04-2010 at 10:30. Reason: attacked by the case of zomgwtfbbq pyros
Swixel is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 09-06-2010 , 16:59   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #3

CCSWeaponInfo:

PHP Code:
class CCSWeaponInfo :                                // +0

    
public FileWeaponInfo_t                            // +0

{

public:

    
float m_fMaxPlayerSpeed;                        // +1784

    
int m_nWeaponType;                                // +1788

    
int m_nTeam;                                    // +1792

    
float m_fUnknown;                                // +1796

    
float m_fWeaponArmorRatio;                        // +1800

    
int m_nCrosshairMinDistance;                    // +1804

    
int m_nCrosshariDeltaDistance;                    // +1808

    
bool m_bCanEquipWithShield;                        // +1812

    
char m_aWrongTeamMsg[32];                        // +1813

    
char m_aPlayerAnimationExtension[16];            // +1845

    
char m_aShieldViewModel[64];                    // +1861

    
char m_aAddonModel[80];                            // +1925

    
char m_aDroppedModel[80];                        // +2005

    
char m_aSilencerModel[80];                        // +2085

    
char PADDING[3];                                // +2165

    
int m_nMuzzleFlashStyle;                        // +2168

    
float m_fMuzzleFlashScale;                        // +2172

    
int m_nPenetration;                                // +2176

    
int m_nDamage;                                    // +2180

    
float m_fRange;                                    // +2184

    
float m_fRangeModifier;                            // +2188

    
int m_nBullets;                                    // +2192

    
float m_fCycleTime;                                // +2196

    
int m_nAccuracyQuadratic;                        // +2200

    
float m_fAccuracyDivisor;                        // +2204

    
float m_fAccuracyOffset;                        // +2208

    
float m_fMaxInaccuracy;                            // +2212

    
float m_fTimeToIdle;                            // +2216

    
float m_fIdleInterval;                            // +2220

    
int m_nBlackMarketPrice;                        // +2224

    
int m_nBlackMarketPrice2;                        // +2228

    
int m_nBlackMarketPreviousPrice;                // +2232

}; 

Last edited by Seta00; 06-20-2011 at 19:37.
Seta00 is offline
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 09-15-2010 , 05:00   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #4

in TF2 it doesnt seem to work ... here my console output:
Code:
wazz_weapons tf_weapon_minigun
Address: 10AFC8C0
Count: 44
Wrong number of args u slag
wazz_weapons tf_weapon_minigun 2
Done
no rocket-miniguns ... what could be wrong ?
__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 09-15-2010 , 08:45   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #5

Changes still seem to work for me however I just tested it using a slightly different function.

PHP Code:
CON_COMMAND(wazz_replaceweapon"Wazz Environment :: Weapon info replacing. Format <weapon1> <weapon2>")
{
    if (
args.ArgC() == 1)
    {
        
META_CONPRINTF("Wazz Environment :: Weapon info replacing. Format <weapon1> <weapon2>\n");
        return;
    }

    if (!
g_pWeaponInfoDatabase)
    {
#ifdef _WIN32
        
void *addr;
        
int offset;

        if (!
g_pGameConf->GetMemSig("ReadWeaponDataFromFileForSlot_SubCall_01", &addr) || !addr)
        {
            
META_CONPRINTF("NULL 1\n");
            return;
        }

        if (!
g_pGameConf->GetOffset("WeaponDatabase_Offset", &offset))
        {
            
META_CONPRINTF("NULL 2\n");
            return;
        }
        
        
g_pWeaponInfoDatabase = *(WeaponDatabase **)((uint32)addr offset);
#else
        
void *addr;
        if (!
g_pGameConf->GetMemSig("m_WeaponInfoDatabase", &addr) || !addr)
        {
            
META_CONPRINTF("NULL 1\n");
            return;
        }
        
        
g_pWeaponInfoDatabase = (WeaponDatabase *)addr;
#endif
        
        
META_CONPRINTF("Address: %p\n"g_pWeaponInfoDatabase);
        
META_CONPRINTF("Count: %i\n"g_pWeaponInfoDatabase->Count());
    }

    if (
args.ArgC() != 3)
    {
        
META_CONPRINTF("Not enough args. Format <weapon1> <weapon2>\n");

        return;
    }

    const 
char *pszWpn args.Arg(1);
    const 
char *pszSwap args.Arg(2);

    
int iIndex1 g_pWeaponInfoDatabase->Find(pszWpn);

    if (!
g_pWeaponInfoDatabase->IsValidIndex(iIndex1))
    {
        
META_CONPRINTF("Invalid Name: %s\n"pszWpn);

        return;
    }

    
int iIndex2 g_pWeaponInfoDatabase->Find(pszSwap);

    if (!
g_pWeaponInfoDatabase->IsValidIndex(iIndex2))
    {
        
META_CONPRINTF("Invalid Name: %s\n"pszSwap);

        return;
    }

    
char *pszClassname = new char[80];
    
strncpy(pszClassnameg_pWeaponInfoDatabase->Element(iIndex1)->m_achClassname80);

    
memcpy(g_pWeaponInfoDatabase->Element(iIndex1), g_pWeaponInfoDatabase->Element(iIndex2), sizeof(CTFWeaponInfo));

    
// Player cannot switch to weapon if classname isn't preserved
    
strncpy(g_pWeaponInfoDatabase->Element(iIndex1)->m_achClassnamepszClassname80);
    
delete pszClassname;

    
META_CONPRINTF("Done\n");

    return;


Last edited by Matthias Vance; 09-15-2010 at 08:55. Reason: Fixed code.
Wazz is offline
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 09-15-2010 , 08:56   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #6

with your your i get the following now:
PHP Code:
\extension.cpp(290): error C2039'm_achClassname' is not a member of 'CTFWeaponInfo' 
maybe it does not work cos the weapon info struct is not correct?
__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 09-15-2010 , 09:00   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #7

Ah, I rebuilt FileWeaponInfo_t because I didn't like its naming convention. http://wazz.ampaste.net/d76b20ba4
Wazz is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 09-15-2010 , 09:02   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #8

Are changes to FileWeaponInfo_t replicated on TF2? Can somebody change iSlot/m_nBucket for me and see if it works?
Seta00 is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 09-15-2010 , 09:13   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #9

Doesn't look like it
Wazz is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 09-15-2010 , 09:17   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #10

D:
Seta00 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 20:12.


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