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,450
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-05-2008, 12:20 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Good point. I supposed that if scribespells worked the ideal way, you could just do quest::scribespells($ulevel); to achieve the same effect that it currently does, but you would still have the option to set any other level you wanted it to be.

And, if you don't want a class to have a certain spell, it is probably best to scribe them all and then unscribe the 1 spell with quest::unscribespell();. Though, you might need to use a timer to delay and make sure the scribing finishes before the unscribe happens.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #8  
Old 09-05-2008, 08:49 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

Another interesting idea. Thank you so much. Sorry for having derailed the thread a bit, but I don't think you're in any danger. Your idea's quite a nice proposal, I think it's a no-brainer, even =P
Reply With Quote
  #9  
Old 09-06-2008, 06:30 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I moved this post to Server Code Submissions. I tested out the code in my first post and had to change "t" to "initiator" (which I already edited into the post), and it works perfectly as intended. I think this is ready for the official source.

This is for the discipline version of the quest::scribespells() command. It works almost exactly the same way.

If someone wanted to make new versions for both scribespells and traindiscs that has an argument option, then please do. The idea for an argument that allows you to define how high to scribe/train to in level has already been mentioned, but that is a little above my coding level still lol. I don't actually code anything, I just steal code from elsewhere and use it from example.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #10  
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
  #11  
Old 09-07-2008, 10:54 PM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

quick question

do you have to turn in your discipline book to GM to get ability?

cuase on live since 2006 they made it so you can now scribe your melee discpline tome just like a caster scroll - no gm turn in needed.

would be nice if we could do it the same way. less messing with gms
Reply With Quote
  #12  
Old 09-08-2008, 04:39 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I don't see any reason why you wouldn't be able to make tomes scribe-able. You would just need to make it like a normal spell scroll accept use the disc spell ID instead of a spell. The only reason that the scribespells command doesn't train disciplines is because there is code to block disciplines from being scribed when you use it. But there is nothing as far as I know to keep spell scrolls from doing it.

So far the last code I submitted above for the new scribespells and traindiscs commands with arguments compiled. Now to see if they actually work after a server reboot
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 09-08-2008 at 01:37 PM..
Reply With Quote
  #13  
Old 09-08-2008, 08:00 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Woot! Just confirmed that my last code post here for the new scribespells and traindiscs works perfectly as intended. I tried setting them both to level 10 and it only trained up to level 10. Then I tried using $ulevel and they both worked the way they used to by scribing/training up to my level!

Not a huge or complex code change, but I think it is something that has been needed for a while. And I think I am finally starting to learn a little by using examples in the source

If this makes it into the official code, then it would probably be a good idea to note that scribespells() won't work anymore unless it has the level argument. But a simple change to scribespells($ulevel) works perfectly as a replacement. So, any server using this command will need to make the appropriate changes for it to work again after the update.

Of course, the command name could be changed to add in 1 more command, but IMO this is the way that scribespells should work in the first place. And it really only requires a very minor script change for any server. I don't think it is more than asking them to add required SQL.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #14  
Old 09-08-2008, 09:13 AM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

Quote:
Originally Posted by trevius View Post
I don't see any reason why you wouldn't be able to make tomes scribe-able. You would just need to make it like a normal spell scroll accept use the disc spell ID instead of a spell. The only reason that the scribespells command doesn't train disciplines is because there is code to block disciplines from being scribed when you use it. But there is nothing as far as I know to keep spell scrolls from doing it.

So far the last code I submitted above for the new scribespells and traindiscs commands with arguments compiled. Now to see if they actually work after a server reboot
I think you missunderstood me.
I don't meant scribeable like using scribe quest comand
I mean using old fashion- open spell book and scribing (puting) spell scroll into it.

On LIVE they made it that melees simply right click the Discipline Tome- like reading a book - and they now know the discipline.

kind of like spell scribing (memorizing) works in eq2

it just pure melees do not have spell book nor spell bar otherwise I would have made all disciplines to be spells (just payable with endurance)
Reply With Quote
  #15  
Old 09-08-2008, 05:25 PM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Quote:
Originally Posted by trevius View Post
I don't see any reason why you wouldn't be able to make tomes scribe-able. You would just need to make it like a normal spell scroll accept use the disc spell ID instead of a spell. The only reason that the scribespells command doesn't train disciplines is because there is code to block disciplines from being scribed when you use it. But there is nothing as far as I know to keep spell scrolls from doing it.

So far the last code I submitted above for the new scribespells and traindiscs commands with arguments compiled. Now to see if they actually work after a server reboot
Quote:
Originally Posted by ChaosSlayer View Post
I think you missunderstood me.
I don't meant scribeable like using scribe quest comand
I mean using old fashion- open spell book and scribing (puting) spell scroll into it.
You both are actually talking about the same thing. Trev was only saying the reason the #scribespells command doesn't train disciplines because the code for that command basically filters those out. Basically, if spell->IsDiscipline, keep it moving.

However, I think there may be a problem. Comparing a Discipline Tome & Spell Scroll, they have the same scrolltype (7, which I believe is for all spell scrolls) & have a corresponding spell ID. I think there might have been a change in the client to allow it to be done, since spells have to still be clicked into the spell book to scribe them (can't right-click them).

I'm sure it could be done by piggybacking the spell casting system, but it would be more of a hack than anything. In addition, it would require changing all of the tomes in the database to be right-click castable (like a regular, instant cast clickie).

Now, if we ever make it to the Anniversary client, I'm sure it's a possibility, but that's still a ways off. *Looks at Derision with his OpCode hunting & packet structure deriving skeelz*
__________________
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
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:38 PM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3