[TF2] Extending the Player class

All other Source.Python topics and issues.
User avatar
Zeus
Member
Posts: 47
Joined: Sat Mar 24, 2018 5:25 pm
Location: Chicago
Contact:

[TF2] Extending the Player class

Postby Zeus » Sat Jun 27, 2020 4:55 am

Hello! There are some convenience methods that would be very helpful for me to have on the player class from TF2.

I'm currently monkey patching the Player module to add them, but wondering what I could do to make this part of SP directly.
It would add methods to this class here: http://wiki.sourcepython.com/developing ... gebox.html

Unless that is shared with other games, at which point maybe having a subclass specifically for TF2 would be needed?

Here is the code:

Code: Select all

class TFTEAMS(Enum):
    UNASSIGNED = 0
    SPECTATORS = 1
    RED = 2
    BLUE = 3

class TFCLASS(Enum):
    SCOUT = 1
    SNIPER = 2
    SOLDIER = 3
    DEMOMAN = 4
    MEDIC = 5
    HEAVY = 6
    PYRO = 7
    SPY = 8
    ENGINEER = 9
   
def set_class(self, class_id):
    self.set_property_uchar('m_Shared.m_iDesiredPlayerClass', class_id)

def set_class_name(self, class_name):
    class_id = TFCLASS.__members__[class_name.upper()].value
    self.set_class(class_id)

def get_class(self):
    return self.get_property_uchar('m_PlayerClass.m_iClass')

def get_class_name(self):
    class_id = self.get_class()
    return TFCLASS(class_id).name

def get_team_name(self):
    return TFTEAMS(self.team).name

Player.get_class = get_class
Player.get_class_name = get_class_name
Player.set_class = set_class
Player.set_class_name = set_class_name
Player.get_team_name = get_team_name


There's prob some more things I would find valuable to add such as:
    Which TF2 weapon they're holding
    A medic players uber charge percentage
    If the player is currently has a certain condition applied (like uber charge, kritz, disguised, etc)
Sam
Senior Member
Posts: 100
Joined: Tue Jul 03, 2018 3:00 pm
Location: *DELETED*
Contact:

Re: [TF2] Extending the Player class

Postby Sam » Sat Jun 27, 2020 9:26 am

This is a very good offer! It will be useful to everyone. Good job.
Last edited by Sam on Sat Jun 27, 2020 9:26 am, edited 1 time in total.
Reason: Original post version
User avatar
VinciT
Senior Member
Posts: 246
Joined: Thu Dec 18, 2014 2:41 am

Re: [TF2] Extending the Player class

Postby VinciT » Sat Jun 27, 2020 8:30 pm

Similar to the Player classes for CSGO and CSS, you can create one for Team Fortress 2 (source-python/packages/source-python/players/orangebox/tf.py). As for enums, there's already data for teams, you can use that as a template for creating one for classes.

The class properties you're using are also in the data - to which you can add more TF2 related properties (m_flChargeLevel, m_nDisguiseClass, m_nPlayerCond). Just make a pull request with whatever additions/changes you feel are needed for TF2. I'm sure a lot of plugin makers will appreciate it! :smile:
ImageImageImageImageImage
User avatar
Zeus
Member
Posts: 47
Joined: Sat Mar 24, 2018 5:25 pm
Location: Chicago
Contact:

Re: [TF2] Extending the Player class

Postby Zeus » Sat Jun 27, 2020 10:55 pm

VinciT wrote:Similar to the Player classes for CSGO and CSS, you can create one for Team Fortress 2 (source-python/packages/source-python/players/orangebox/tf.py). As for enums, there's already data for teams, you can use that as a template for creating one for classes.

The class properties you're using are also in the data - to which you can add more TF2 related properties (m_flChargeLevel, m_nDisguiseClass, m_nPlayerCond). Just make a pull request with whatever additions/changes you feel are needed for TF2. I'm sure a lot of plugin makers will appreciate it! :smile:


Awesome, ill look into this.

How will I be able ot get this to work with PlayerIter? I would want it to return the TF2 player class instead of the generic orangebox one

Also how can I use those data files to provide some convience methods? Like if I wanted to have a "team_name" property; i assume that data is already loaded in the program and i can import it into my class?
User avatar
VinciT
Senior Member
Posts: 246
Joined: Thu Dec 18, 2014 2:41 am

Re: [TF2] Extending the Player class

Postby VinciT » Sun Jun 28, 2020 3:51 am

Zeus wrote:How will I be able to get this to work with PlayerIter? I would want it to return the TF2 player class instead of the generic orangebox one
That should happen automatically as soon as you create the TF2 Player class. As you can see here, SP will look for a game-specific Player class and load it if there is one - which will then be used by the rest of modules.
Zeus wrote:Also how can I use those data files to provide some convience methods? Like if I wanted to have a "team_name" property; i assume that data is already loaded in the program and i can import it into my class?
Check out how it's done with teams - I'd give you an example, but my bed is calling me. :tongue:
ImageImageImageImageImage
User avatar
Zeus
Member
Posts: 47
Joined: Sat Mar 24, 2018 5:25 pm
Location: Chicago
Contact:

Re: [TF2] Extending the Player class

Postby Zeus » Sun Jun 28, 2020 11:40 pm

So I'm not seeing any data with a class name to id mapping; i assume i should add it?

Since it's very specfic to TF2, im not sure where to put it.

Bascially would want this:

Code: Select all

        [classes]
        scout = 1
        sniper = 2
        soldier = 3
        demoman = 4
        medic = 5
        heavy = 6
        pyro = 7
        spy = 8
        engineer = 9
User avatar
L'In20Cible
Project Leader
Posts: 1366
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [TF2] Extending the Player class

Postby L'In20Cible » Mon Jun 29, 2020 12:01 am

Zeus wrote:So I'm not seeing any data with a class name to id mapping; i assume i should add it?

Since it's very specfic to TF2, im not sure where to put it.

Bascially would want this:

Code: Select all

        [classes]
        scout = 1
        sniper = 2
        soldier = 3
        demoman = 4
        medic = 5
        heavy = 6
        pyro = 7
        spy = 8
        engineer = 9


I'd say this would fit perfectly into the players.teams module (into ../data/teams/* files) with the proper mapping into ../players/teams.py. Other games, such as CS games, also have classes.
User avatar
Zeus
Member
Posts: 47
Joined: Sat Mar 24, 2018 5:25 pm
Location: Chicago
Contact:

Re: [TF2] Extending the Player class

Postby Zeus » Mon Jun 29, 2020 1:02 am

So im looking to get uber gun percentage as well

So I would need to be able to get the active weapon class that the player has. I see this being under this:

Code: Select all

CTFPlayer    (type    DT_TFPlayer)
    Table:    baseclass    (offset    0)    (type    DT_BasePlayer)
        Table:    baseclass    (offset    0)    (type    DT_BaseCombatCharacter)
            Table:    baseclass    (offset    0)    (type    DT_BaseFlex)
            ...
            Member:    m_hActiveWeapon    (offset    2052)    (type    integer)    (bits    21)    (Unsigned)


According to netprops I need to get the medigun class (CWeaponMedigun). I can get the percent from this i believe:

Code: Select all

CWeaponMedigun.LocalTFWeaponMedigunData.m_flChargeLevel
(not sure what the diff between local and nonlocal is tho)

Source:

Code: Select all

CWeaponMedigun (type DT_WeaponMedigun)
 Table: baseclass (offset 0) (type DT_TFWeaponBaseGun)
  Table: baseclass (offset 0) (type DT_TFWeaponBase)
   Table: baseclass (offset 0) (type DT_BaseCombatWeapon)
    Table: baseclass (offset 0) (type DT_EconEntity)
     Table: baseclass (offset 0) (type DT_BaseAnimating)
      Table: baseclass (offset 0) (type DT_BaseEntity)
       Table: AnimTimeMustBeFirst (offset 0) (type DT_AnimTimeMustBeFirst)
        Member: m_flAnimTime (offset 140) (type integer) (bits 8) (Unsigned|ChangesOften)
       Member: m_flSimulationTime (offset 144) (type integer) (bits 8) (Unsigned|ChangesOften)
       Member: m_vecOrigin (offset 792) (type vector) (bits 0) (ChangesOften|CoordMP)
       Member: m_ubInterpolationFrame (offset 148) (type integer) (bits 2) (Unsigned)
       Member: m_nModelIndex (offset 114) (type integer) (bits 13) ()
       Table: m_Collision (offset 348) (type DT_CollisionProperty)
        Member: m_vecMinsPreScaled (offset 8) (type vector) (bits 0) (NoScale)
        Member: m_vecMaxsPreScaled (offset 20) (type vector) (bits 0) (NoScale)
        Member: m_vecMins (offset 32) (type vector) (bits 0) (NoScale)
        Member: m_vecMaxs (offset 44) (type vector) (bits 0) (NoScale)
        Member: m_nSolidType (offset 65) (type integer) (bits 3) (Unsigned)
        Member: m_usSolidFlags (offset 60) (type integer) (bits 10) (Unsigned)
        Member: m_nSurroundType (offset 64) (type integer) (bits 3) (Unsigned)
        Member: m_triggerBloat (offset 66) (type integer) (bits 8) (Unsigned)
        Member: m_bUniformTriggerBloat (offset 67) (type integer) (bits 1) (Unsigned)
        Member: m_vecSpecifiedSurroundingMinsPreScaled (offset 68) (type vector) (bits 0) (NoScale)
        Member: m_vecSpecifiedSurroundingMaxsPreScaled (offset 80) (type vector) (bits 0) (NoScale)
        Member: m_vecSpecifiedSurroundingMins (offset 92) (type vector) (bits 0) (NoScale)
        Member: m_vecSpecifiedSurroundingMaxs (offset 104) (type vector) (bits 0) (NoScale)
       Member: m_nRenderFX (offset 112) (type integer) (bits 8) (Unsigned)
       Member: m_nRenderMode (offset 113) (type integer) (bits 8) (Unsigned)
       Member: m_fEffects (offset 212) (type integer) (bits 10) (Unsigned)
       Member: m_clrRender (offset 132) (type integer) (bits 32) (Unsigned)
       Member: m_iTeamNum (offset 516) (type integer) (bits 6) ()
       Member: m_CollisionGroup (offset 496) (type integer) (bits 5) (Unsigned)
       Member: m_flElasticity (offset 636) (type float) (bits 0) (NoScale|CoordMP)
       Member: m_flShadowCastDistance (offset 504) (type float) (bits 12) (Unsigned)
       Member: m_hOwnerEntity (offset 488) (type integer) (bits 21) (Unsigned)
       Member: m_hEffectEntity (offset 492) (type integer) (bits 21) (Unsigned)
       Member: moveparent (offset 336) (type integer) (bits 21) (Unsigned)
       Member: m_iParentAttachment (offset 333) (type integer) (bits 6) (Unsigned)
       Member: movetype (offset 334) (type integer) (bits 4) (Unsigned)
       Member: movecollide (offset 335) (type integer) (bits 3) (Unsigned)
       Member: m_angRotation (offset 804) (type vector) (bits 13) (ChangesOften)
       Member: m_iTextureFrameIndex (offset 680) (type integer) (bits 8) (Unsigned)
       Table: predictable_id (offset 0) (type DT_PredictableId)
        Member: m_PredictableID (offset 156) (type integer) (bits 31) (Unsigned)
        Member: m_bIsPlayerSimulated (offset 835) (type integer) (bits 1) (Unsigned)
       Member: m_bSimulatedEveryTick (offset 681) (type integer) (bits 1) (Unsigned)
       Member: m_bAnimatedEveryTick (offset 682) (type integer) (bits 1) (Unsigned)
       Member: m_bAlternateSorting (offset 683) (type integer) (bits 1) (Unsigned)
       Table: m_nModelIndexOverrides (offset 116) (type m_nModelIndexOverrides)
        Member: 000 (offset 0) (type integer) (bits 13) ()
        Member: 001 (offset 4) (type integer) (bits 13) ()
        Member: 002 (offset 8) (type integer) (bits 13) ()
        Member: 003 (offset 12) (type integer) (bits 13) ()
      Member: m_nForceBone (offset 864) (type integer) (bits 8) ()
      Member: m_vecForce (offset 868) (type vector) (bits 0) (NoScale)
      Member: m_nSkin (offset 880) (type integer) (bits 10) ()
      Member: m_nBody (offset 884) (type integer) (bits 32) ()
      Member: m_nHitboxSet (offset 888) (type integer) (bits 2) (Unsigned)
      Member: m_flModelScale (offset 892) (type float) (bits 0) (NoScale)
      Table: m_flPoseParameter (offset 944) (type m_flPoseParameter)
       Member: 000 (offset 0) (type float) (bits 8) ()
       Member: 001 (offset 4) (type float) (bits 8) ()
       Member: 002 (offset 8) (type float) (bits 8) ()
       Member: 003 (offset 12) (type float) (bits 8) ()
       Member: 004 (offset 16) (type float) (bits 8) ()
       Member: 005 (offset 20) (type float) (bits 8) ()
       Member: 006 (offset 24) (type float) (bits 8) ()
       Member: 007 (offset 28) (type float) (bits 8) ()
       Member: 008 (offset 32) (type float) (bits 8) ()
       Member: 009 (offset 36) (type float) (bits 8) ()
       Member: 010 (offset 40) (type float) (bits 8) ()
       Member: 011 (offset 44) (type float) (bits 8) ()
       Member: 012 (offset 48) (type float) (bits 8) ()
       Member: 013 (offset 52) (type float) (bits 8) ()
       Member: 014 (offset 56) (type float) (bits 8) ()
       Member: 015 (offset 60) (type float) (bits 8) ()
       Member: 016 (offset 64) (type float) (bits 8) ()
       Member: 017 (offset 68) (type float) (bits 8) ()
       Member: 018 (offset 72) (type float) (bits 8) ()
       Member: 019 (offset 76) (type float) (bits 8) ()
       Member: 020 (offset 80) (type float) (bits 8) ()
       Member: 021 (offset 84) (type float) (bits 8) ()
       Member: 022 (offset 88) (type float) (bits 8) ()
       Member: 023 (offset 92) (type float) (bits 8) ()
      Member: m_nSequence (offset 940) (type integer) (bits 12) (Unsigned)
      Member: m_flPlaybackRate (offset 896) (type float) (bits 8) (RoundUp)
      Table: m_flEncodedController (offset 1040) (type m_flEncodedController)
       Member: 000 (offset 0) (type float) (bits 11) (RoundDown)
       Member: 001 (offset 4) (type float) (bits 11) (RoundDown)
       Member: 002 (offset 8) (type float) (bits 11) (RoundDown)
       Member: 003 (offset 12) (type float) (bits 11) (RoundDown)
      Member: m_bClientSideAnimation (offset 1056) (type integer) (bits 1) (Unsigned)
      Member: m_bClientSideFrameReset (offset 1057) (type integer) (bits 1) (Unsigned)
      Member: m_nNewSequenceParity (offset 1060) (type integer) (bits 3) (Unsigned)
      Member: m_nResetEventsParity (offset 1064) (type integer) (bits 3) (Unsigned)
      Member: m_nMuzzleFlashParity (offset 1068) (type integer) (bits 2) (Unsigned)
      Member: m_hLightingOrigin (offset 1072) (type integer) (bits 21) (Unsigned)
      Member: m_hLightingOriginRelative (offset 1076) (type integer) (bits 21) (Unsigned)
      Table: serveranimdata (offset 0) (type DT_ServerAnimationData)
       Member: m_flCycle (offset 936) (type float) (bits 10) (RoundDown|ChangesOften)
      Member: m_fadeMinDist (offset 1096) (type float) (bits 0) (NoScale)
      Member: m_fadeMaxDist (offset 1100) (type float) (bits 0) (NoScale)
      Member: m_flFadeScale (offset 1104) (type float) (bits 0) (NoScale)
     Table: m_AttributeManager (offset 1160) (type DT_AttributeContainer)
      Member: m_hOuter (offset 56) (type integer) (bits 21) (Unsigned)
      Member: m_ProviderType (offset 64) (type integer) (bits 4) (Unsigned)
      Member: m_iReapplyProvisionParity (offset 52) (type integer) (bits 6) (Unsigned)
      Table: m_Item (offset 96) (type DT_ScriptCreatedItem)
       Member: m_iItemDefinitionIndex (offset 4) (type integer) (bits 20) (Unsigned)
       Member: m_iEntityLevel (offset 12) (type integer) (bits 8) ()
       Member: m_iItemIDHigh (offset 24) (type integer) (bits 32) (Unsigned)
       Member: m_iItemIDLow (offset 28) (type integer) (bits 32) (Unsigned)
       Member: m_iAccountID (offset 32) (type integer) (bits 32) (Unsigned)
       Member: m_iEntityQuality (offset 8) (type integer) (bits 5) ()
       Member: m_bInitialized (offset 84) (type integer) (bits 1) (Unsigned)
       Member: m_bOnlyIterateItemViewAttributes (offset 144) (type integer) (bits 1) (Unsigned)
       Table: m_AttributeList (offset 88) (type DT_AttributeList)
        Table: m_Attributes (offset 0) (type _ST_m_Attributes_20)
         Table: lengthproxy (offset 0) (type _LPT_m_Attributes_20)
          Member: lengthprop20 (offset 0) (type integer) (bits 5) (Unsigned)
         Table: 000 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 001 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 002 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 003 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 004 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 005 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 006 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 007 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 008 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 009 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 010 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 011 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 012 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 013 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 014 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 015 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 016 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 017 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 018 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 019 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
       Member: m_iTeamNumber (offset 80) (type integer) (bits 32) ()
       Table: m_NetworkedDynamicAttributesForDemos (offset 116) (type DT_AttributeList)
        Table: m_Attributes (offset 0) (type _ST_m_Attributes_20)
         Table: lengthproxy (offset 0) (type _LPT_m_Attributes_20)
          Member: lengthprop20 (offset 0) (type integer) (bits 5) (Unsigned)
         Table: 000 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 001 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 002 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 003 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 004 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 005 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 006 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 007 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 008 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 009 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 010 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 011 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 012 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 013 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 014 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 015 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 016 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 017 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 018 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 019 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
     Member: m_bValidatedAttachedEntity (offset 1408) (type integer) (bits 1) (Unsigned)
    Table: LocalWeaponData (offset 0) (type DT_LocalWeaponData)
     Member: m_iClip1 (offset 1512) (type integer) (bits 8) (Unsigned)
     Member: m_iClip2 (offset 1516) (type integer) (bits 8) (Unsigned)
     Member: m_iPrimaryAmmoType (offset 1504) (type integer) (bits 8) ()
     Member: m_iSecondaryAmmoType (offset 1508) (type integer) (bits 8) ()
     Member: m_nViewModelIndex (offset 1440) (type integer) (bits 1) (Unsigned)
     Member: m_bFlipViewModel (offset 1560) (type integer) (bits 8) ()
     Member: m_flAnimTime (offset 0) (type integer) (bits 0) (Exclude)
    Table: LocalActiveWeaponData (offset 0) (type DT_LocalActiveWeaponData)
     Member: m_flNextPrimaryAttack (offset 1444) (type float) (bits 0) (NoScale)
     Member: m_flNextSecondaryAttack (offset 1448) (type float) (bits 0) (NoScale)
     Member: m_nNextThinkTick (offset 208) (type integer) (bits 32) ()
     Member: m_flTimeWeaponIdle (offset 1452) (type float) (bits 0) (NoScale)
     Member: m_flAnimTime (offset 0) (type integer) (bits 0) (Exclude)
    Member: m_iViewModelIndex (offset 1460) (type integer) (bits 13) ()
    Member: m_iWorldModelIndex (offset 1464) (type integer) (bits 13) ()
    Member: m_iState (offset 1496) (type integer) (bits 8) (Unsigned)
    Member: m_hOwner (offset 1424) (type integer) (bits 21) (Unsigned)
   Member: m_bLowered (offset 1732) (type integer) (bits 1) (Unsigned)
   Member: m_bResetParity (offset 1896) (type integer) (bits 1) (Unsigned)
   Member: m_iReloadMode (offset 1704) (type integer) (bits 4) (Unsigned)
   Member: m_bReloadedThroughAnimEvent (offset 1908) (type integer) (bits 1) (Unsigned)
   Member: m_bDisguiseWeapon (offset 1964) (type integer) (bits 1) (Unsigned)
   Table: LocalActiveTFWeaponData (offset 0) (type DT_LocalTFWeaponData)
    Member: m_flLastCritCheckTime (offset 1748) (type float) (bits 0) (NoScale)
    Member: m_flReloadPriorNextFire (offset 1708) (type float) (bits 0) (NoScale)
    Member: m_flLastFireTime (offset 1968) (type float) (bits 0) (NoScale)
    Member: m_flEffectBarRegenTime (offset 1696) (type float) (bits 0) (NoScale)
    Member: m_flObservedCritChance (offset 1980) (type float) (bits 0) (NoScale)
   Table: NonLocalTFWeaponData (offset 0) (type DT_TFWeaponDataNonLocal)
   Member: m_flEnergy (offset 1912) (type float) (bits 0) (NoScale)
   Member: m_hExtraWearable (offset 1972) (type integer) (bits 21) (Unsigned)
   Member: m_hExtraWearableViewModel (offset 1976) (type integer) (bits 21) (Unsigned)
   Member: m_bBeingRepurposedForTaunt (offset 1984) (type integer) (bits 1) (Unsigned)
   Member: m_nKillComboClass (offset 1988) (type integer) (bits 4) (Unsigned)
   Member: m_nKillComboCount (offset 1992) (type integer) (bits 2) (Unsigned)
   Member: m_flInspectAnimEndTime (offset 1996) (type float) (bits 0) (NoScale)
   Member: m_nInspectStage (offset 2000) (type integer) (bits 32) (VarInt)
   Member: m_iConsecutiveShots (offset 1960) (type integer) (bits 32) (VarInt)
 Member: m_hHealingTarget (offset 2008) (type integer) (bits 21) (Unsigned)
 Member: m_bHealing (offset 2017) (type integer) (bits 1) (Unsigned)
 Member: m_bAttacking (offset 2018) (type integer) (bits 1) (Unsigned)
 Member: m_bChargeRelease (offset 2041) (type integer) (bits 1) (Unsigned)
 Member: m_bHolstered (offset 2040) (type integer) (bits 1) (Unsigned)
 Member: m_nChargeResistType (offset 2048) (type integer) (bits 32) ()
 Member: m_hLastHealingTarget (offset 2012) (type integer) (bits 21) (Unsigned)
 Table: LocalTFWeaponMedigunData (offset 0) (type DT_LocalTFWeaponMedigunData)
  Member: m_flChargeLevel (offset 2044) (type float) (bits 0) (NoScale|ChangesOften)
 Table: NonLocalTFWeaponMedigunData (offset 0) (type DT_TFWeaponMedigunDataNonLocal)
  Member: m_flChargeLevel (offset 2044) (type float) (bits 0) (NoScale|ChangesOften)



How can I add this to the CTFPlayer.ini file? This stuff confuses me, and not sure how SP handles these ini files.
I assume I can add the active weapon id to the data file; and have some code in my tf2 player class that can lookup the uber percent?
User avatar
L'In20Cible
Project Leader
Posts: 1366
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [TF2] Extending the Player class

Postby L'In20Cible » Mon Jun 29, 2020 1:43 am

Zeus wrote:So im looking to get uber gun percentage as well

So I would need to be able to get the active weapon class that the player has. I see this being under this:

Code: Select all

CTFPlayer    (type    DT_TFPlayer)
    Table:    baseclass    (offset    0)    (type    DT_BasePlayer)
        Table:    baseclass    (offset    0)    (type    DT_BaseCombatCharacter)
            Table:    baseclass    (offset    0)    (type    DT_BaseFlex)
            ...
            Member:    m_hActiveWeapon    (offset    2052)    (type    integer)    (bits    21)    (Unsigned)


According to netprops I need to get the medigun class (CWeaponMedigun). I can get the percent from this i believe:

Code: Select all

CWeaponMedigun.LocalTFWeaponMedigunData.m_flChargeLevel
(not sure what the diff between local and nonlocal is tho)

Source:

Code: Select all

CWeaponMedigun (type DT_WeaponMedigun)
 Table: baseclass (offset 0) (type DT_TFWeaponBaseGun)
  Table: baseclass (offset 0) (type DT_TFWeaponBase)
   Table: baseclass (offset 0) (type DT_BaseCombatWeapon)
    Table: baseclass (offset 0) (type DT_EconEntity)
     Table: baseclass (offset 0) (type DT_BaseAnimating)
      Table: baseclass (offset 0) (type DT_BaseEntity)
       Table: AnimTimeMustBeFirst (offset 0) (type DT_AnimTimeMustBeFirst)
        Member: m_flAnimTime (offset 140) (type integer) (bits 8) (Unsigned|ChangesOften)
       Member: m_flSimulationTime (offset 144) (type integer) (bits 8) (Unsigned|ChangesOften)
       Member: m_vecOrigin (offset 792) (type vector) (bits 0) (ChangesOften|CoordMP)
       Member: m_ubInterpolationFrame (offset 148) (type integer) (bits 2) (Unsigned)
       Member: m_nModelIndex (offset 114) (type integer) (bits 13) ()
       Table: m_Collision (offset 348) (type DT_CollisionProperty)
        Member: m_vecMinsPreScaled (offset 8) (type vector) (bits 0) (NoScale)
        Member: m_vecMaxsPreScaled (offset 20) (type vector) (bits 0) (NoScale)
        Member: m_vecMins (offset 32) (type vector) (bits 0) (NoScale)
        Member: m_vecMaxs (offset 44) (type vector) (bits 0) (NoScale)
        Member: m_nSolidType (offset 65) (type integer) (bits 3) (Unsigned)
        Member: m_usSolidFlags (offset 60) (type integer) (bits 10) (Unsigned)
        Member: m_nSurroundType (offset 64) (type integer) (bits 3) (Unsigned)
        Member: m_triggerBloat (offset 66) (type integer) (bits 8) (Unsigned)
        Member: m_bUniformTriggerBloat (offset 67) (type integer) (bits 1) (Unsigned)
        Member: m_vecSpecifiedSurroundingMinsPreScaled (offset 68) (type vector) (bits 0) (NoScale)
        Member: m_vecSpecifiedSurroundingMaxsPreScaled (offset 80) (type vector) (bits 0) (NoScale)
        Member: m_vecSpecifiedSurroundingMins (offset 92) (type vector) (bits 0) (NoScale)
        Member: m_vecSpecifiedSurroundingMaxs (offset 104) (type vector) (bits 0) (NoScale)
       Member: m_nRenderFX (offset 112) (type integer) (bits 8) (Unsigned)
       Member: m_nRenderMode (offset 113) (type integer) (bits 8) (Unsigned)
       Member: m_fEffects (offset 212) (type integer) (bits 10) (Unsigned)
       Member: m_clrRender (offset 132) (type integer) (bits 32) (Unsigned)
       Member: m_iTeamNum (offset 516) (type integer) (bits 6) ()
       Member: m_CollisionGroup (offset 496) (type integer) (bits 5) (Unsigned)
       Member: m_flElasticity (offset 636) (type float) (bits 0) (NoScale|CoordMP)
       Member: m_flShadowCastDistance (offset 504) (type float) (bits 12) (Unsigned)
       Member: m_hOwnerEntity (offset 488) (type integer) (bits 21) (Unsigned)
       Member: m_hEffectEntity (offset 492) (type integer) (bits 21) (Unsigned)
       Member: moveparent (offset 336) (type integer) (bits 21) (Unsigned)
       Member: m_iParentAttachment (offset 333) (type integer) (bits 6) (Unsigned)
       Member: movetype (offset 334) (type integer) (bits 4) (Unsigned)
       Member: movecollide (offset 335) (type integer) (bits 3) (Unsigned)
       Member: m_angRotation (offset 804) (type vector) (bits 13) (ChangesOften)
       Member: m_iTextureFrameIndex (offset 680) (type integer) (bits 8) (Unsigned)
       Table: predictable_id (offset 0) (type DT_PredictableId)
        Member: m_PredictableID (offset 156) (type integer) (bits 31) (Unsigned)
        Member: m_bIsPlayerSimulated (offset 835) (type integer) (bits 1) (Unsigned)
       Member: m_bSimulatedEveryTick (offset 681) (type integer) (bits 1) (Unsigned)
       Member: m_bAnimatedEveryTick (offset 682) (type integer) (bits 1) (Unsigned)
       Member: m_bAlternateSorting (offset 683) (type integer) (bits 1) (Unsigned)
       Table: m_nModelIndexOverrides (offset 116) (type m_nModelIndexOverrides)
        Member: 000 (offset 0) (type integer) (bits 13) ()
        Member: 001 (offset 4) (type integer) (bits 13) ()
        Member: 002 (offset 8) (type integer) (bits 13) ()
        Member: 003 (offset 12) (type integer) (bits 13) ()
      Member: m_nForceBone (offset 864) (type integer) (bits 8) ()
      Member: m_vecForce (offset 868) (type vector) (bits 0) (NoScale)
      Member: m_nSkin (offset 880) (type integer) (bits 10) ()
      Member: m_nBody (offset 884) (type integer) (bits 32) ()
      Member: m_nHitboxSet (offset 888) (type integer) (bits 2) (Unsigned)
      Member: m_flModelScale (offset 892) (type float) (bits 0) (NoScale)
      Table: m_flPoseParameter (offset 944) (type m_flPoseParameter)
       Member: 000 (offset 0) (type float) (bits 8) ()
       Member: 001 (offset 4) (type float) (bits 8) ()
       Member: 002 (offset 8) (type float) (bits 8) ()
       Member: 003 (offset 12) (type float) (bits 8) ()
       Member: 004 (offset 16) (type float) (bits 8) ()
       Member: 005 (offset 20) (type float) (bits 8) ()
       Member: 006 (offset 24) (type float) (bits 8) ()
       Member: 007 (offset 28) (type float) (bits 8) ()
       Member: 008 (offset 32) (type float) (bits 8) ()
       Member: 009 (offset 36) (type float) (bits 8) ()
       Member: 010 (offset 40) (type float) (bits 8) ()
       Member: 011 (offset 44) (type float) (bits 8) ()
       Member: 012 (offset 48) (type float) (bits 8) ()
       Member: 013 (offset 52) (type float) (bits 8) ()
       Member: 014 (offset 56) (type float) (bits 8) ()
       Member: 015 (offset 60) (type float) (bits 8) ()
       Member: 016 (offset 64) (type float) (bits 8) ()
       Member: 017 (offset 68) (type float) (bits 8) ()
       Member: 018 (offset 72) (type float) (bits 8) ()
       Member: 019 (offset 76) (type float) (bits 8) ()
       Member: 020 (offset 80) (type float) (bits 8) ()
       Member: 021 (offset 84) (type float) (bits 8) ()
       Member: 022 (offset 88) (type float) (bits 8) ()
       Member: 023 (offset 92) (type float) (bits 8) ()
      Member: m_nSequence (offset 940) (type integer) (bits 12) (Unsigned)
      Member: m_flPlaybackRate (offset 896) (type float) (bits 8) (RoundUp)
      Table: m_flEncodedController (offset 1040) (type m_flEncodedController)
       Member: 000 (offset 0) (type float) (bits 11) (RoundDown)
       Member: 001 (offset 4) (type float) (bits 11) (RoundDown)
       Member: 002 (offset 8) (type float) (bits 11) (RoundDown)
       Member: 003 (offset 12) (type float) (bits 11) (RoundDown)
      Member: m_bClientSideAnimation (offset 1056) (type integer) (bits 1) (Unsigned)
      Member: m_bClientSideFrameReset (offset 1057) (type integer) (bits 1) (Unsigned)
      Member: m_nNewSequenceParity (offset 1060) (type integer) (bits 3) (Unsigned)
      Member: m_nResetEventsParity (offset 1064) (type integer) (bits 3) (Unsigned)
      Member: m_nMuzzleFlashParity (offset 1068) (type integer) (bits 2) (Unsigned)
      Member: m_hLightingOrigin (offset 1072) (type integer) (bits 21) (Unsigned)
      Member: m_hLightingOriginRelative (offset 1076) (type integer) (bits 21) (Unsigned)
      Table: serveranimdata (offset 0) (type DT_ServerAnimationData)
       Member: m_flCycle (offset 936) (type float) (bits 10) (RoundDown|ChangesOften)
      Member: m_fadeMinDist (offset 1096) (type float) (bits 0) (NoScale)
      Member: m_fadeMaxDist (offset 1100) (type float) (bits 0) (NoScale)
      Member: m_flFadeScale (offset 1104) (type float) (bits 0) (NoScale)
     Table: m_AttributeManager (offset 1160) (type DT_AttributeContainer)
      Member: m_hOuter (offset 56) (type integer) (bits 21) (Unsigned)
      Member: m_ProviderType (offset 64) (type integer) (bits 4) (Unsigned)
      Member: m_iReapplyProvisionParity (offset 52) (type integer) (bits 6) (Unsigned)
      Table: m_Item (offset 96) (type DT_ScriptCreatedItem)
       Member: m_iItemDefinitionIndex (offset 4) (type integer) (bits 20) (Unsigned)
       Member: m_iEntityLevel (offset 12) (type integer) (bits 8) ()
       Member: m_iItemIDHigh (offset 24) (type integer) (bits 32) (Unsigned)
       Member: m_iItemIDLow (offset 28) (type integer) (bits 32) (Unsigned)
       Member: m_iAccountID (offset 32) (type integer) (bits 32) (Unsigned)
       Member: m_iEntityQuality (offset 8) (type integer) (bits 5) ()
       Member: m_bInitialized (offset 84) (type integer) (bits 1) (Unsigned)
       Member: m_bOnlyIterateItemViewAttributes (offset 144) (type integer) (bits 1) (Unsigned)
       Table: m_AttributeList (offset 88) (type DT_AttributeList)
        Table: m_Attributes (offset 0) (type _ST_m_Attributes_20)
         Table: lengthproxy (offset 0) (type _LPT_m_Attributes_20)
          Member: lengthprop20 (offset 0) (type integer) (bits 5) (Unsigned)
         Table: 000 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 001 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 002 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 003 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 004 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 005 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 006 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 007 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 008 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 009 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 010 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 011 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 012 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 013 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 014 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 015 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 016 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 017 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 018 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 019 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
       Member: m_iTeamNumber (offset 80) (type integer) (bits 32) ()
       Table: m_NetworkedDynamicAttributesForDemos (offset 116) (type DT_AttributeList)
        Table: m_Attributes (offset 0) (type _ST_m_Attributes_20)
         Table: lengthproxy (offset 0) (type _LPT_m_Attributes_20)
          Member: lengthprop20 (offset 0) (type integer) (bits 5) (Unsigned)
         Table: 000 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 001 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 002 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 003 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 004 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 005 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 006 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 007 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 008 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 009 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 010 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 011 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 012 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 013 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 014 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 015 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 016 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 017 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 018 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
         Table: 019 (offset 0) (type DT_ScriptCreatedAttribute)
          Member: m_iAttributeDefinitionIndex (offset 4) (type integer) (bits 16) (Unsigned)
          Member: m_iRawValue32 (offset 8) (type integer) (bits 32) (Unsigned)
          Member: m_nRefundableCurrency (offset 12) (type integer) (bits 32) (Unsigned)
     Member: m_bValidatedAttachedEntity (offset 1408) (type integer) (bits 1) (Unsigned)
    Table: LocalWeaponData (offset 0) (type DT_LocalWeaponData)
     Member: m_iClip1 (offset 1512) (type integer) (bits 8) (Unsigned)
     Member: m_iClip2 (offset 1516) (type integer) (bits 8) (Unsigned)
     Member: m_iPrimaryAmmoType (offset 1504) (type integer) (bits 8) ()
     Member: m_iSecondaryAmmoType (offset 1508) (type integer) (bits 8) ()
     Member: m_nViewModelIndex (offset 1440) (type integer) (bits 1) (Unsigned)
     Member: m_bFlipViewModel (offset 1560) (type integer) (bits 8) ()
     Member: m_flAnimTime (offset 0) (type integer) (bits 0) (Exclude)
    Table: LocalActiveWeaponData (offset 0) (type DT_LocalActiveWeaponData)
     Member: m_flNextPrimaryAttack (offset 1444) (type float) (bits 0) (NoScale)
     Member: m_flNextSecondaryAttack (offset 1448) (type float) (bits 0) (NoScale)
     Member: m_nNextThinkTick (offset 208) (type integer) (bits 32) ()
     Member: m_flTimeWeaponIdle (offset 1452) (type float) (bits 0) (NoScale)
     Member: m_flAnimTime (offset 0) (type integer) (bits 0) (Exclude)
    Member: m_iViewModelIndex (offset 1460) (type integer) (bits 13) ()
    Member: m_iWorldModelIndex (offset 1464) (type integer) (bits 13) ()
    Member: m_iState (offset 1496) (type integer) (bits 8) (Unsigned)
    Member: m_hOwner (offset 1424) (type integer) (bits 21) (Unsigned)
   Member: m_bLowered (offset 1732) (type integer) (bits 1) (Unsigned)
   Member: m_bResetParity (offset 1896) (type integer) (bits 1) (Unsigned)
   Member: m_iReloadMode (offset 1704) (type integer) (bits 4) (Unsigned)
   Member: m_bReloadedThroughAnimEvent (offset 1908) (type integer) (bits 1) (Unsigned)
   Member: m_bDisguiseWeapon (offset 1964) (type integer) (bits 1) (Unsigned)
   Table: LocalActiveTFWeaponData (offset 0) (type DT_LocalTFWeaponData)
    Member: m_flLastCritCheckTime (offset 1748) (type float) (bits 0) (NoScale)
    Member: m_flReloadPriorNextFire (offset 1708) (type float) (bits 0) (NoScale)
    Member: m_flLastFireTime (offset 1968) (type float) (bits 0) (NoScale)
    Member: m_flEffectBarRegenTime (offset 1696) (type float) (bits 0) (NoScale)
    Member: m_flObservedCritChance (offset 1980) (type float) (bits 0) (NoScale)
   Table: NonLocalTFWeaponData (offset 0) (type DT_TFWeaponDataNonLocal)
   Member: m_flEnergy (offset 1912) (type float) (bits 0) (NoScale)
   Member: m_hExtraWearable (offset 1972) (type integer) (bits 21) (Unsigned)
   Member: m_hExtraWearableViewModel (offset 1976) (type integer) (bits 21) (Unsigned)
   Member: m_bBeingRepurposedForTaunt (offset 1984) (type integer) (bits 1) (Unsigned)
   Member: m_nKillComboClass (offset 1988) (type integer) (bits 4) (Unsigned)
   Member: m_nKillComboCount (offset 1992) (type integer) (bits 2) (Unsigned)
   Member: m_flInspectAnimEndTime (offset 1996) (type float) (bits 0) (NoScale)
   Member: m_nInspectStage (offset 2000) (type integer) (bits 32) (VarInt)
   Member: m_iConsecutiveShots (offset 1960) (type integer) (bits 32) (VarInt)
 Member: m_hHealingTarget (offset 2008) (type integer) (bits 21) (Unsigned)
 Member: m_bHealing (offset 2017) (type integer) (bits 1) (Unsigned)
 Member: m_bAttacking (offset 2018) (type integer) (bits 1) (Unsigned)
 Member: m_bChargeRelease (offset 2041) (type integer) (bits 1) (Unsigned)
 Member: m_bHolstered (offset 2040) (type integer) (bits 1) (Unsigned)
 Member: m_nChargeResistType (offset 2048) (type integer) (bits 32) ()
 Member: m_hLastHealingTarget (offset 2012) (type integer) (bits 21) (Unsigned)
 Table: LocalTFWeaponMedigunData (offset 0) (type DT_LocalTFWeaponMedigunData)
  Member: m_flChargeLevel (offset 2044) (type float) (bits 0) (NoScale|ChangesOften)
 Table: NonLocalTFWeaponMedigunData (offset 0) (type DT_TFWeaponMedigunDataNonLocal)
  Member: m_flChargeLevel (offset 2044) (type float) (bits 0) (NoScale|ChangesOften)



How can I add this to the CTFPlayer.ini file? This stuff confuses me, and not sure how SP handles these ini files.
I assume I can add the active weapon id to the data file; and have some code in my tf2 player class that can lookup the uber percent?


The entity data files are really just dynamic alliases for an Entity (or any subclass, such as Player or Weapon). For that one, you would need to add it to the CWeaponMedigun.ini file and would be accessible for CWeaponMedigun instances as Entity.<your allias>.
User avatar
Zeus
Member
Posts: 47
Joined: Sat Mar 24, 2018 5:25 pm
Location: Chicago
Contact:

Re: [TF2] Extending the Player class

Postby Zeus » Mon Jun 29, 2020 2:29 am

So this is what my ctf player is looking like:

CTFPlayer.ini

Code: Select all

[virtual_function]

    # _ZN9CTFPlayer10BumpWeaponEP17CBaseCombatWeapon
    [[bump_weapon]]
        offset_linux = 401
        offset_windows = 400
        arguments = POINTER
        return_type = BOOL


[property]

    ragdoll = m_hRagdoll
    player_class = m_PlayerClass.m_iClass
    desired_player_class = m_Shared.m_iDesiredPlayerClass

    condition = m_Shared.m_nPlayerCond
   
    active_weapon = DT_BaseFlex.m_hActiveWeapon
   
    [[eye_angle]]
        name = tfnonlocaldata.m_angEyeAngles[0]
        type = QAngle



Then I would need to make ini files for weapons?
User avatar
L'In20Cible
Project Leader
Posts: 1366
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [TF2] Extending the Player class

Postby L'In20Cible » Mon Jun 29, 2020 2:57 am

You don't have to add m_hActiveWeapon to CTFPlayer, as it is already inherited by CBaseCombatCharacter as active_weapon_handle: https://github.com/Source-Python-Dev-Te ... er.ini#L16 (Although, technically from PlayerMixin but that is irrelevant here.)

Meaning you can access it with:

Syntax: Select all

Player(index).active_weapon_handle
User avatar
L'In20Cible
Project Leader
Posts: 1366
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [TF2] Extending the Player class

Postby L'In20Cible » Mon Jun 29, 2020 3:02 am

May have some outdated information, but that guide should be helpful: viewtopic.php?f=8&t=972

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests