Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 09-03-2008, 07:05 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default quest::traindiscs()

***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
Code:
	void traindiscs();

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.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 09-22-2008 at 04:02 AM..
Reply With Quote
  #2  
Old 09-04-2008, 12:12 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Just a thought so far, but wouldn't it be better to allow an argument, say level, so that you could have some flexibility instead of just using the current level? For example, a mob that will only train you up to level 10 (for noobs), and you have to get the rest of your spells normally.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
  #3  
Old 09-04-2008, 03:04 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Well, I was going by the example of scribespells. Currently I just allow the use of #traindisc command on my server, but I would love to remove the need for that. Though, I do think it would be nice if there was an option to train up to a certain level. But, I think it should be set so that if you don't set anything it will go by current level as the max.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 09-04-2008, 08:49 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

As AndMetal pointed out, I think that that's one of the failings of quest::scribespell, and it'd be nice to not repeat the same mistake here =P

I know I'd intended for every class to be able to have their spells scribed up to level 51 on my server, but I had to change it for mages; I didn't want them getting a free epic. Having more flexibility with the scribespell function (and the proposed traindisc) can only help.
Reply With Quote
  #5  
Old 09-04-2008, 11:29 AM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,449
Default

Quote:
Originally Posted by So_1337 View Post
I know I'd intended for every class to be able to have their spells scribed up to level 51 on my server, but I had to change it for mages; I didn't want them getting a free epic. Having more flexibility with the scribespell function (and the proposed traindisc) can only help.
Just a quick FYI, if you don't want people getting spells on scribespells, change the spell file SERVERSIDED ONLY to class level 255 on that spell that you don't want. This will disable the spell.

Provided you do not have spell scrolls, of course, then it's another issue altogether.
Reply With Quote
  #6  
Old 09-04-2008, 11:35 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

I want them to have the spell available to them, just not via a spell-scribing NPC. If they complete the magician epic, they sure deserve to use it =P

That's a good tip for some other spells that might be included in what are scribed, though, such as if I wanted to limit spells from the scriber by different eras. Then update the file once a new era is unlocked. (We're currently doing progression.)

Thanks for the tip, didn't consider that =)
Reply With Quote
  #7  
Old 09-07-2008, 09:07 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Discussion: http://eqemulator.net/forums/showthread.php?t=26083

I think I have a simple change to the scribespells and new traindiscs quest commands that should get them working as I think most people would want them to be. These changes add an argument to the commands so that a level can be defined in the command in case the admin wants to restrict the spell/disc levels that are automatically scribed.

I think this should work for both of them, but I haven't tried it yet. I will give it a try and report back with if it works or not.

questmgr.cpp
Code:
void QuestManager::scribespells(int spell_level) {
 	//Cofruben:-Scribe spells for user up to his 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] <= spell_level &&
		  spells[curspell].skill != 52
	   )
	   {
		  initiator->ScribeSpell(curspell, book_slot++);
	   }
	}
}

void QuestManager::traindiscs(int disc_level) {
 	//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] <= disc_level &&
		  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
Code:
	void scribespells(int spell_level);

	void traindiscs(int disc_level);
perlparser.cpp
Code:
XS(XS__scribespells);
XS(XS__scribespells)
{
	dXSARGS;
	if (items != 1)
		Perl_croak(aTHX_ "Usage: scribespells(spell_level)");

	int	spell_level = (int)SvIV(ST(0));

	quest_manager.scribespells(spell_level);

	XSRETURN_EMPTY;
}

XS(XS__traindiscs);
XS(XS__traindiscs)
{
	dXSARGS;
	if (items != 1)
		Perl_croak(aTHX_ "Usage: traindiscs(disc_level)");

	int	disc_level = (int)SvIV(ST(0));

	quest_manager.traindiscs(disc_level);

	XSRETURN_EMPTY;
}


		newXS(strcpy(buf, "scribespells"), XS__scribespells, file);

		newXS(strcpy(buf, "traindiscs"), XS__traindiscs, file);
parser.cpp
Code:
	else if (!strcmp(command,"scribespells")) {
		quest_manager.scribespells(atoi(arglist[0]));
	}
	else if (!strcmp(command,"traindiscs")) {
		quest_manager.traindiscs(atoi(arglist[0]));
	}

These changes would require that any server using them has to change their spell scriber quests a little. This is only a minor change and should be easy for almost every server, since most only have 1 or a few spell scribers. For anyone who wants this to work as it currently does, they can simply use this in the place of the current command:

Code:
quest::scribespells($ulevel);

#OR

quest::traindiscs($ulevel);
But the nice thing about this feature is that spell scribing can be limited with it. So, maybe you want your players to be able to scribe all of their spells up to level 50 to make leveling easier, but you want them to actually collect and manually scribe all spells over level 50. You can do that easily with this. I am already coming up with some neat ideas to make using a spell sciber more interesting with this new feature. Maybe adding a spell scriber at the end of a dungeon so players have to clear to it to get their higher level spells. Or, maybe scribing higher level spells after a quest is completed. It really opens up some cool options and brings some of the fun back into getting new spells without necessarily bringing the horrid job of having to research on the web about each spell and find them or buy them all.

I will test this out and report back if it works as intended. But, as far as I can tell, this looks like good code to me.

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.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 04:36 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3