Login
User Name:

Password:



Register
Forgot your password?
LOP 1.39r1
Author: Remcon
Submitted by: Remcon
Yaeger areas
Author: Yaeger
Submitted by: Cyberthrope
The City of Anon
Author: Yaeger
Submitted by: Cyberthrope
The Walls of Anon - Smaug
Author: Yaeger
Submitted by: Cyberthrope
LOP 1.39
Author: Remcon
Submitted by: Remcon
CommonCrawl, Yandex, Bing, Yahoo!

Members: 0
Guests: 2
Stats
Files
Topics
Posts
Members
Newest Member
375
3,323
16,512
561
Aurin
Affiliates
Smaug Building Institute Arthmoor
» SmaugMuds.org » General » Coding » Multiclassing do_cast(ing) wo...
Forum Rules | Mark all | Recent Posts

Multiclassing do_cast(ing) woes.
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Jul 14, 2009, 11:09 pm
Go to the bottom of the page Go to the top of the page
Syriac
Fledgling
GroupMembers
Posts12
JoinedJul 14, 2009

Hello everyone,

I've been getting frustrated over this code so I thought I'd pick some other people's brains. Essentially my mud has a dual class system that allows the players to add a second class later on in the game, and then switching back and forth between the two (essentially swaping out the class information with a command) - this systems works great for levelling up 2 seperate classes but the problem comes in when someone is say - a warrior / mage. When the warrior class is the primary class they cannot cast spells and vice versa. I've written a piece of code that is also a piece of ---- apparently because its not working. This is under the do_cast section in magic.c

            if (xIS_SET(ch->act, PLR_MULTICLASS)) {
                int class = ch->mclass;
            if ( ( sn = find_spell( ch, arg1, TRUE) ) < 0
            || ( ch->level < skill_table[sn]->skill_level[ch->class] ||
                ch->mclasslvl < skill_table[sn]->skill_level[class]) ) {
                send_to_char( "You have yet to master this spell..\n\r", ch );
                return;  } }



Help would be amazing right about now
       
Post is unread #2 Jul 15, 2009, 9:09 am
Go to the bottom of the page Go to the top of the page


David Haley
Sorcerer
GroupMembers
Posts902
JoinedJan 29, 2007
WWW

What exactly is printed out when warrior-mages try to cast spells?

What does the find_spell function do? .........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org
       
Post is unread #3 Jul 15, 2009, 12:32 pm   Last edited Jul 15, 2009, 12:35 pm by Syriac
Go to the bottom of the page Go to the top of the page
Syriac
Fledgling
GroupMembers
Posts12
JoinedJul 14, 2009

gives them the "You have yet to master this spell.."

Find_spell

int find_spell( CHAR_DATA *ch, const char *name, bool know )
{
    if ( IS_NPC(ch) || !know )
        return bsearch_skill( name, gsn_first_spell, gsn_first_skill-1 );
    else
        return ch_bsearch_skill( ch, name, gsn_first_spell, gsn_first_skill-1 );
}
        


which points to ch_bsearch_skill


ch_bsearch_skill_prefix which I added this:
      if(xIS_SET(ch->act, PLR_MULTICLASS)) {
    for (;;)
    {
     	sn = (first + top) >> 1;
//      int class = ch->mclass;
        
        /* if ( LOWER(name[0]) == LOWER(skill_table[sn]->name[0])
        &&  !str_prefix(name, skill_table[sn]->name)
        &&   ch->pcdata->learned[sn] > 0
        && (  ch->level >= skill_table[sn]->skill_level[ch->class]
        ||   ch->mclasslvl >= skill_table[sn]->skill_level[class] ) )
                return sn; */
                
    if( LOWER(name[0] == LOWER(skill_table[sn]->name[0])
        && !str_prefix(name, skill_table[sn]->name)
        && ch->pcdata->learned[sn] > 0
        && ( ch->mclasslvl >= skill_table[sn]->skill_level[ch->mclass]
        && skill_table[sn]->skill_level[ch->mclass] )) )
                return sn;
            

	if (first >= top)
            return -1;

        if (strcmp( name, skill_table[sn]->name) < 1)
            top = sn - 1;
        else
            first = sn + 1;
    } }

  
       
Post is unread #4 Jul 15, 2009, 2:40 pm
Go to the bottom of the page Go to the top of the page


David Haley
Sorcerer
GroupMembers
Posts902
JoinedJan 29, 2007
WWW

        && ( ch->mclasslvl >= skill_table[sn]->skill_level[ch->mclass]
        && skill_table[sn]->skill_level[ch->mclass] )

This is probably what's getting you. Is mclass set to what you expect? .........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org
       
Post is unread #5 Jul 15, 2009, 3:02 pm
Go to the bottom of the page Go to the top of the page
Syriac
Fledgling
GroupMembers
Posts12
JoinedJul 14, 2009

Yes, for instance mage is 0 - so either of these should be acceptable

ch->class = 0
ch->mclass = 0

(either one results in being a mage)
       
Post is unread #6 Jul 15, 2009, 3:20 pm
Go to the bottom of the page Go to the top of the page


David Haley
Sorcerer
GroupMembers
Posts902
JoinedJan 29, 2007
WWW

Why are they both the same, and are you sure that that is what is happening as you run the code? (E.g., have you tried printing out the variables, or running it through a debugger.)

And the code there only shows mclass -- not class. Where is 'class' coming from? .........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org
       
Post is unread #7 Jul 15, 2009, 7:01 pm
Go to the bottom of the page Go to the top of the page
Syriac
Fledgling
GroupMembers
Posts12
JoinedJul 14, 2009

The stock code is there first, then it runs through the second part I put if the multiclass bit has been set. I've ran through the debugger but had no luck... I can try I could print the variables but I'm about 99% sure what they will say... I think for some reason it just won't except ch->mclass in the place of ch->class. That is the part that is giving me a very hard time trying to trace the problem.
       
Post is unread #8 Jul 15, 2009, 9:53 pm
Go to the bottom of the page Go to the top of the page


David Haley
Sorcerer
GroupMembers
Posts902
JoinedJan 29, 2007
WWW

When debugging problems you don't understand, make as few assumptions as possible -- if your assumptions were all correct, you wouldn't be having the problem in the first place...!

So go back to basics and verify that all variables involved contain what they're supposed to contain. .........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org
       
Post is unread #9 Jul 15, 2009, 11:55 pm
Go to the bottom of the page Go to the top of the page
Syriac
Fledgling
GroupMembers
Posts12
JoinedJul 14, 2009

            if (!xIS_SET(ch->act, PLR_MULTICLASS)) {
            if ( ( sn = find_spell( ch, arg1, TRUE ) ) < 0
            || ( !IS_NPC(ch) && ch->level < skill_table[sn]->skill_level[ch->class] ) )
            {
                send_to_char( "You aren't ready to do this.\n\r", ch );
                return;
            } }
    
            if (xIS_SET(ch->act, PLR_MULTICLASS)) {
            if ( ( sn = find_spell( ch, arg1, TRUE ) ) < 0
             || (( !IS_NPC(ch) && ch->level < skill_table[sn]->skill_level[ch->class]
             &&  !IS_NPC(ch) && ch->mclasslvl < skill_table[sn]->skill_level[ch->mclass] )) )
            {
                        send_to_char( "You aren't ready to do this.\n\r", ch );
    
                //if (xIS_SET(ch->act, PLR_MULTICLASS))
                //        pager_printf(ch, "debug: not working...\n\r";);
    
                return;
            } }



I got it! Damn stupid syntax will kill you every time! I should have been using an && instead of an ||
       
Post is unread #10 Jul 16, 2009, 8:12 am
Go to the bottom of the page Go to the top of the page


David Haley
Sorcerer
GroupMembers
Posts902
JoinedJan 29, 2007
WWW

That is not code you had pasted before... having the actual code you're looking at usually makes debugging easier for us. :wink: .........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org
       
Pages:<< prev 1 next >>

 
Contact Us