-
Member
Can the 'Level Up' action be canceled?
I am using Azerothcore 3.3.5a.
I am trying to find a way to disable a player from being 'automatically' leveled up once the xp for the level has been met.
I want the level up to happen from a gobject instead.
I have performed many sniffs to weed out the exact action associated with the level up but I only come up with the following:
After 1193 ms
Strigid Owl (1995) (GUID 15) dies [343]
Strigid Owl (1995) (GUID 15) exits combat [343]
Player 7 exits combat [343]
Updated Player 7 [343]
UNIT_FIELD_LEVEL = 2 (old: 1)
Is there a more advanced sniff to show more of whats happening here: UNIT_FIELD_LEVEL = 2 (old: 1)?
Or this a function that cannot be changed?
-
This is entirely controlled server side. Look at the Player.cpp class and the methods around LevelUp / GiveXp.
-
Post Thanks / Like - 1 Thanks
phantazmo7 (1 members gave Thanks to stoneharry for this useful post)
-
Member
Stoneharry dead on as always.
So this is where the magic happens in Player.cpp
while (newXP >= nextLvlXP && level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
{
newXP -= nextLvlXP;
if (level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
GiveLevel(level + 1);
level = GetLevel();
nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
}
SetUInt32Value(PLAYER_XP, newXP);
I've just begun to learning c++ but if I were to make this statement into its own function that I could call during say....a quest reward....that shouldn't cause any issues elsewhere would it?
I guess what I am asking is, what's the best way to go about making that statement into it's own function? Just make the function in Player.cpp? Custom Script?
-
Originally Posted by
phantazmo7
Stoneharry dead on as always.
So this is where the magic happens in Player.cpp
while (newXP >= nextLvlXP && level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
{
newXP -= nextLvlXP;
if (level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
GiveLevel(level + 1);
level = GetLevel();
nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
}
SetUInt32Value(PLAYER_XP, newXP);
I've just begun to learning c++ but if I were to make this statement into its own function that I could call during say....a quest reward....that shouldn't cause any issues elsewhere would it?
I guess what I am asking is, what's the best way to go about making that statement into it's own function? Just make the function in Player.cpp? Custom Script?
The easiest way to stop the existing level up functionality is to disable this function. You can add to the first line: "if (true) return;" so that it always immediately returns (exits the function) without executing anything.
Then yes, add a new version of the function that can be called from your script and/or other logic when you want. In C++ you need to define the method signature in the header file and the implementation in the class file.
The reason I suggest doing it this way is then you don't need to go and update all the references to leveling up logic, instead you just disable the level up function and use your own method when required.
-
Post Thanks / Like - 1 Thanks
phantazmo7 (1 members gave Thanks to stoneharry for this useful post)