ok, here goes, basic class and interitance in c++:
Lets say we have two classes in c++ GenericEntity and AwesomeEntity.
- Code: Select all
class GenericEntity
{
Spawn();
TakeDamage();
Die();
FancyStuff();
}
class AwesomeEntity
{
Spawn();
TakeDamage();
Die();
FancyStuff();
}
GenericEntity can be damaged and killed, as can AwesomeEntity. The only difference is that AwesomeEntity blows up when its damaged.
Ok, so instead of writing all the damaging and killing code twice, we can make AwesomeEntity derive (or inherit) from GenericEntity. This basically means: AwesomeEntity has all code from GenericEntity. E.g.
- Code: Select all
class GenericEntity
{
Spawn();
TakeDamage();
Die();
FancyStuff();
}
class AwesomeEntity : public GenericEntity
{
}
Is the same as the example above. You can Spawn(), TakeDamage(), Die() and FancyStuff() AwesomeEntity like before, even though the code for all of that is described in another class.
We didnt want the same entity tho, it required a slight different code. Remember, AwesomeEntity had to explode?
Now comes the fun part of c++: we can mark a piece of code in such a way that it can be overridden.
- Code: Select all
class GenericEntity
{
Spawn();
TakeDamage();
virtual Die();
FancyStuff();
}
class AwesomeEntity : public GenericEntity
{
virtual Die();
Explode();
}
The keyword here is 'virtual'. Now, when some piece of code kills AwesomeEntity, it will trigger AwesomeEntity's Die() code, instead of GenericEntity's DIe() code. AwesomeEntity's Die code is the following:
- Code: Select all
Die()
{
Explode();
GenericEntity::Die();
}
This code triggers the Explosion() code, and finally GenericEntity's Die() code (we still want to remove the entity from the game, after all).
Note that valve usually uses BaseClass::Die(), where BaseClass is a reference to the class we derived from (it's actually a typedef).
Ok, now things become more difficult. The above example had two classes, but in c++ you can derive from derived classes (ad infinitam)
So you can have for instance
- Code: Select all
class GenericEntity
{
Spawn();
TakeDamage();
virtual Die();
FancyStuff();
}
class AwesomeEntity : public GenericEntity
{
virtual Die();
Explode();
}
class SuperAwesomeEntity : public AwesomeEntity
{
virtual Die() { GenericEntity::Die(); };
}
class ExtremelySuperAwesomeEntity: public SuperAwesomeEntity
{
}
etc
Note SuperAwesomeEntity's Die() code. It overrides the die code, and triggers GenericEntity's Die() code. It doesn't explode, because it doesn't trigger AwesomeEntity's Die() code.
Ok, your situation:
It seems you are fiddling with a piece of code like this Die() code. If the class ingame is actually ExtremelySuperAwesomeEntity or AwesomeEntity, the Die() code of AwesomeEntity will be triggered, and any changes you make there will show. However, if the class ingame is SuperAwesomeEntity, a class that derives from the class you are editing, changes will do diddly squat.
I hope you get where the problem lies now, so we can move on to the solution:
1) google. Esp the valve dev wiki.
2) rightclick on your function, find all references, usually yields possible other places you needed to edit instead. You can even use Visual studio's builtin search box.
3) if you run the game from visual studio (see debuggin in valve dev wiki) you can set breakpoints and see what variables look like when playing the game. It should help you bigtime.
In your specific case, there is no single player class specifying all players code. Theres HL2_Player which derives from CBasePlayer which derives from CBaseCombatCharacter which derives from CBaseFlex which derives from CBaseAnimatingOverlay which derives from CBaseAnimating which derives from CBaseEntity which derives from IServerEntity or IClientEntity depending on context which derives from IUnknown which derives from IHandleEntity. Any of these classes (well, to be exact, those 'below' CBaseEntity) can have the code you need to alter. Get it? You need to find the 'lowest' class that has the code triggered you need to alter.