I threw something together and it happened to work. It's fairly non-intrusive, only using a small block of code in zone/exp.cpp and a global quest flag.
Edit zone/exp.cpp and add the following to the top of the AddEXP function:
Code:
std::string query = StringFormat("SELECT value FROM quest_globals WHERE charid='%i' AND name='Halt_Exp_Gains_Toggle'", this->CharacterID());
auto results = database.QueryDatabase(query);
if(results.Success()) {
auto row = results.begin();
char* ExpOff = row[0];
int8 ExpFlag = atoi(ExpOff);
if (ExpFlag == 1)
return;
}
I added the following quest code. Add it to whatever NPC you want to toggle the experience flag:
Code:
if($text=~/experience/i) {
quest::say("Greetings, $name. This is a test script. Do you want to [check your experience flag] or [toggle your experience flag]? and things");
}
if($text=~/check my exp/i) {
if(defined $qglobals{Halt_Exp_Gains_Toggle}) {
if($qglobals{Halt_Exp_Gains_Toggle} == 1) {
$expflag = "disabled";
} else {
$expflag = "enabled";
}
} else {
$expflag = "enabled";
}
quest::say("Well, $name, your ability to gain experience appears to be $expflag");
}
if($text=~/toggle my exp/i) {
quest::say("Are you sure you [want to toggle] your experience flag?");
}
if($text=~/want to toggle/i) {
if(defined $qglobals{Halt_Exp_Gains_Toggle}) {
if($qglobals{Halt_Exp_Gains_Toggle} == 1) {
quest::setglobal("Halt_Exp_Gains_Toggle", 0, 5, "F");
$expflag = "enabled";
} else {
quest::setglobal("Halt_Exp_Gains_Toggle", 1, 5, "F");
$expflag = "disabled";
}
} else {
quest::setglobal("Halt_Exp_Gains_Toggle", 1, 5, "F");
$expflag = "disabled";
}
quest::say("Your ability to gain experience is now $expflag. If you wish to alter this status, please talk to me again.");
}
Obviously, all of the quest text can be modified and the confirmation can be removed if wanted.
The code in exp.cpp should only need to go in AddEXP. There are also SetEXP and CalcEXP functions, but I believe SetEXP is only used by the #setxp and #setaaxp commands, while I have no idea where CalcEXP is used.