***EDIT: Look at my post about 9 down from this one for the actual code to add in that is tested and working and includes changes to scribespells() as well as the new working traindiscs() quest command ***
This is a new quest command similar to the quest::scribespells command. The idea is the same, accept instead of scribing all spells up to the user's level, this will scribe all Disciplines up to their level. I have not tested this code yet, which is why I am posting it in the development section. But once I get it tested and confirm that it works, I will move this post to the Server Code Submissions section.
Here is the new code:
questmgr.cpp
Code:
void QuestManager::traindiscs() {
//Trevius: Train Disc for user up to their actual level.
int16 book_slot;
int16 curspell;
for(curspell = 0, book_slot = 0; curspell < SPDAT_RECORDS && book_slot < MAX_PP_SPELLBOOK; curspell++)
{
if
(
spells[curspell].classes[WARRIOR] != 0 &&
spells[curspell].classes[initiator->GetPP().class_-1] <= initiator->GetLevel() &&
spells[curspell].skill != 52
)
{
if(IsDiscipline(curspell)){
for(int r = 0; r < MAX_PP_DISCIPLINES; r++) {
if(initiator->GetPP().disciplines.values[r] == curspell) {
initiator->Message(13, "You already know this discipline.");
r = MAX_PP_DISCIPLINES;
} else if(initiator->GetPP().disciplines.values[r] == 0) {
initiator->GetPP().disciplines.values[r] = curspell;
initiator->SendDisciplineUpdate();
initiator->Message(0, "You have learned a new discipline!");
r = MAX_PP_DISCIPLINES;
}
}
}
}
}
}
questmgr.h
perlparser.cpp
Code:
XS(XS__traindiscs);
XS(XS__traindiscs)
{
dXSARGS;
if (items != 0)
Perl_croak(aTHX_ "Usage: traindiscs()");
quest_manager.traindiscs();
XSRETURN_EMPTY;
}
Code:
newXS(strcpy(buf, "traindiscs"), XS__traindiscs, file);
If anyone has any corrections or suggestions, please let me know here
And an optional change that I figured might as well get put in that isn't related to this new quest command is this (Changes are marked in
RED):
command.cpp
Code:
void command_traindisc(Client *c, const Seperator *sep)
{
int level;
int16 book_slot;
int16 curspell;
Client *t=c;
if(c->GetTarget() && c->GetTarget()->IsClient() && c->GetGM())
t=c->GetTarget()->CastToClient();
if(!sep->arg[1][0])
{
c->Message(0, "FORMAT: #traindisc <level>");
return;
}
level = atoi(sep->arg[1]);
if(level < 1) //used to be: if(level < 1 || level > 70)
{
c->Message(0, "ERROR: Enter a level greater than 1."); //used to be: "ERROR: Enter a level between 1 and 70 inclusive."
return;
}
This extra change is mainly so that it matches the scribespell command. I see no reason to limit the argument to level 70 as it was previously. Not a big deal either way, but it wouldn't hurt.