EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development: Custom Code (https://www.eqemulator.org/forums/forumdisplay.php?f=665)
-   -   Disable Exp Gains (https://www.eqemulator.org/forums/showthread.php?t=40105)

Cilraaz 10-14-2015 11:12 PM

Disable Exp Gains
 
For one reason or another, you may wish to disable exp gains on a character by character basis. If so, feel free to use this code to do so. Changes should be added to the beginning of the Client::AddEXP function in zone/exp.cpp:

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;
        }

This makes use of a quest global flag named "Halt_Exp_Gains_Toggle", which would need to be set via a quest (or as simply as talking to an NPC). For example, I tested this via adding the below to Seer Mal Nae-Shi's perl script in PoK:

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]?");
                }

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.");
}

Of course the quest portion could be modified in any way you'd like. Have fun with it!


All times are GMT -4. The time now is 10:13 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.