Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Wanted to know how to do this with remort
Wanted to know how to do this with remort
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Mefestos
(5 posts) Bio
|
Date
| Sat 29 May 2004 08:54 PM (UTC) |
Message
| I installed Xerves's remort code and do not like the way morts can remort to ALL remort classes, and want to restrict that to two or three specific classes per base class. However, having little experience with C, I have worked with the code for the remort for hours to no avail. If someone could help me with this, it would be greatly appreciated. | Top |
|
Posted by
| Meerclar
USA (733 posts) Bio
|
Date
| Reply #1 on Sun 30 May 2004 03:39 AM (UTC) |
Message
|
Quote:
However, having little experience with C,...
This poses a serious challenge for an experienced coder with having to find a way to track which classes a char has "lived" and incorporating the necessary checks into the remort system. For a beginning coder, I would say this is night impossible. As many strange and seriously difficult projects as I've attempted in my time as a coder, this is a project I would still be wary of attempting due to the extreme complexity of the tracking needed. Were this in C++ I might consider adding a STL class object to the char data structure to track their "lives" but even that would be more difficult than I could justify the time and effort for I suspect.
Even if you did find a way to track the classes "lived" by a given character, would you allow remorts from any class lived or just from the most recent? Would you allow remorts into other base classes? Would you allow multiple remorts at all? Single remorts wouldn't be too bad an implementation I suppose if it was kept very simple.
Something like
Switch (ch->class)
case 'warrior':
knight
brigand
heretic
case 'rogue':
brigand
illusionist
assassin
case 'cleric':
sage
sorcerer
knight
case 'mage':
sorcerer
heretic
primalist
Granted, that's a very simplified pseudocode but the basic check structure is there for a single remort system. |
Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org | Top |
|
Posted by
| Mefestos
(5 posts) Bio
|
Date
| Reply #2 on Sun 30 May 2004 05:26 PM (UTC) Amended on Sun 30 May 2004 05:29 PM (UTC) by Mefestos
|
Message
| actually, there are checks already implemented to check, as you say, how many "lives" a char has had, called tiers. Its an entry in the pfile itself, and there is a set tier for each class as well. thats not my problem.
I have the classes set up to where, right now, the remort class for each base is 10 higher than the base class, ie. the remort (for now) of mage, which is class 0, is class 10. What i am having trouble with is adding a check to see if the character of a certain class is choosing the class that is 10 above their current class.
here is the code:
if (ch->level == LEVEL_HERO)
ch->pcdata->tier++;
for ( iClass = 9; iClass <= MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name[0] != '\0' && class_table[iClass]->remort_class <= ch->pcdata->tier-1)
{
if (!str_cmp(arg, class_table[iClass]->who_name))
break;
}
}
if (iClass == MAX_PC_CLASS)
{
if (ch->level == LEVEL_HERO)
ch->pcdata->tier--;
send_to_char("That is not a valid class.\n\r", ch);
return;
My first intuition was to add, right after (&& class_table[iClass]->remort_class <= ch->pcdata->tier-1) (&& class_table[iClass] == ch->class+10), but that crashes the damn mud. I just need to know what to add to make that check. | Top |
|
Posted by
| Typhon
USA (112 posts) Bio
|
Date
| Reply #3 on Tue 01 Jun 2004 11:45 PM (UTC) |
Message
| you could check that by adding say 10 to the class but you would ahve to make 10 base classes then 10 teir 1 classes then 10 teir 2 classes etc.. then you can limit it to only pick the current class and the next class or something. wouldnt be super hard but making that many classes would suck :p
| Top |
|
Posted by
| Mefestos
(5 posts) Bio
|
Date
| Reply #4 on Wed 02 Jun 2004 03:49 AM (UTC) |
Message
| Kinda like this?
if ( class_table[iClass]->who_name[0] != '\0' && class_table[iClass]->remort_class <= ch->pcdata->tier-1 && class_table[iClass] == ch->class+10)
Ive tried that already, and it not only causes a compile warning, saying something to the tune of 'comparing pointer and integer" or something, but also causes the mud to crash when i try to remort.
I just need to know how to do this check CORRECTLY. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #5 on Wed 02 Jun 2004 04:56 AM (UTC) Amended on Wed 02 Jun 2004 05:00 AM (UTC) by Nick Cash
|
Message
| Hmm, I think you have called it wrong. The class_table is bascially a table of pointers to the classes. Thus, your warning. Try something like this:
[EDIT] I forgot to say why you were calling it wrong. If you look in mud.h under char_data, class is defined as sh_int (short integer), and is consequently a number. If you look at the class table which is defined in mud.h as:
extern struct class_type * class_table [MAX_CLASS];
You can see that the return type for the class_table is struct class_type, which is a pointer to an allocated class structure. So your statement is comparing a pointer of allocated space to a number, which does not work. Hopefully you understand the cocept now. :)
[/EDIT]
if ( class_table[iClass]->who_name[0] != '\0' && class_table[iClass]->remort_class <= ch->pcdata->tier-1 && class_table[iClass] == class_table[ch->class+10])
I'm not sure what you are trying to accomplish, but that will take away that compile warning and that crash bug hopefully.
Best of luck! |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Mefestos
(5 posts) Bio
|
Date
| Reply #6 on Wed 02 Jun 2004 10:01 PM (UTC) |
Message
| it does fix the compile warning, but it still crashes. I changed the code to look like this:
if (ch->level == LEVEL_HERO)
ch->pcdata->tier++;
for ( iClass = 9; iClass <= MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass] != class_table[ch->class+10])
{
ch->pcdata->tier--;
send_to_char("That is not a valid class.\n\r", ch);
return;
}
if ( class_table[iClass]->who_name[0] != '\0' && class_table[iClass]->remort_class <= ch->pcdata->tier-1)
{
if (!str_cmp(arg, class_table[iClass]->who_name))
break;
}
}
if (iClass == MAX_PC_CLASS)
{
if (ch->level == LEVEL_HERO)
ch->pcdata->tier--;
send_to_char("That is not a valid class.\n\r", ch);
return;
}
}
The only problem is now i can't remort to any class at all. I know its the second if that its not getting by, but i dont know what to do about it. any help, as always, is appreciated. | Top |
|
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Reply #7 on Thu 03 Jun 2004 03:54 AM (UTC) |
Message
| What is your core dumpl telling you in gdb? Try running it inside gdb, and do a back trace when it crashes to see which line the problem is. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | Top |
|
Posted by
| Mefestos
(5 posts) Bio
|
Date
| Reply #8 on Fri 04 Jun 2004 01:29 AM (UTC) |
Message
| Thanks for all the help, but i ended up having to rewrite most of the code i posted. Its long, but it works, and thats what I am concerned about. Thanks for all the help that everyone submitted.
| Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
26,684 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top