[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Need help with new project

Need help with new project

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Toy   (206 posts)  [Biography] bio
Date Thu 04 Mar 2004 05:08 PM (UTC)
Message
I've been looking over the class files, and I've noticed that the languages you can practice are based on your class. I'm looking to change that, so certain races will be able to speak different langauges right from the start. I peeked in comm.c and noticed that nanny handles giving the common language to all characters in this bit:

	    if ( (iLang = skill_lookup( "common" )) < 0 )
	    	bug( "Nanny: cannot find common language." );
	    else
	    	ch->pcdata->learned[iLang] = 100;
	    	
	    for ( iLang = 0; lang_array[iLang] != LANG_UNKNOWN; iLang++ )
	    	if ( lang_array[iLang] == race_table[ch->race]->language )
	    		break;
	    if ( lang_array[iLang] == LANG_UNKNOWN )
	    	bug( "Nanny: invalid racial language." );
	    else
	    {
	    	if ( (iLang = skill_lookup( lang_names[iLang] )) < 0 )
	    		bug( "Nanny: cannot find racial language." );
	    	else
	    		ch->pcdata->learned[iLang] = 100;
	    }


Can anyone give me some help on how to go about this?
-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Fri 05 Mar 2004 02:05 AM (UTC)
Message
This is only because languages are "skills" - if I recall correctly the race determines starting languages.

In fact; the code you posted serves precisely the purpose of giving the race its racial language and the common language.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Toy   (206 posts)  [Biography] bio
Date Reply #2 on Fri 05 Mar 2004 05:42 PM (UTC)
Message
Hmm, I see what you're saying about that bit of code giving all players their natural language plus the common language. What I'm looking to do is this:

The race wood-elf has the natural language Sylvan plus common to start. The bit number for the language is 128. Say I want to have wood-elf's also know the Pixie langauge, bit number 8, right from the start, but instead of having it at 100% like common starts at, I'd like it to be 20%, making the player have to practice using it to get it right through normal talking.

Also, I have a Lizardman race who's intelligence is too low to understand anything but their own. So I need to set up an IF check to make sure that the Lizardmen don't learn common right off the bat. What confuses me if this line though:

	    if ( (iLang = skill_lookup( "common" )) < 0 )
	    	bug( "Nanny: cannot find common language." );
	    else
	    	ch->pcdata->learned[iLang] = 100;


Does this mean if I take the tongue skills out of the class files no one will learn common when they first log in?

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] top

Posted by Toy   (206 posts)  [Biography] bio
Date Reply #3 on Fri 05 Mar 2004 05:49 PM (UTC)
Message
Ok, after a quick test of removing all the tongue skills from each class, I now know that this bit of code:

if ( (iLang = skill_lookup( "common" )) < 0 )
	    	bug( "Nanny: cannot find common language." );
	    else
	    	ch->pcdata->learned[iLang] = 100;


No matter what, all characters start with common. At least this gives me a starting ground now.

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #4 on Fri 05 Mar 2004 07:03 PM (UTC)
Message
For one, just put an ifcheck that doesn't set it to 100% if the player race is lizardman.

I also don't think that languages naturally get better with time as you use them (unlike skills), but that could be something we changed on my MUD a long time ago and I forgot about.

What those lines are doing is as simple as looking up the skill number associated with "common" language, if that is smaller than zero report an error, else, set the player's language level to 100.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Toy   (206 posts)  [Biography] bio
Date Reply #5 on Fri 05 Mar 2004 07:41 PM (UTC)
Message
I added IF checks for the Lizardmen's languages, attempting to make them not learn common. Here's the code:

	    if ( (iLang = skill_lookup( "common" )) < 0 )
	    	bug( "Nanny: cannot find common language." );
	    else
/* Added so Lizardmen could not use common - Toy*/
          if ( ch->race == RACE_LIZARDMAN )
		ch->pcdata->learned[iLang] = 0;
	    else
  	      ch->pcdata->learned[iLang] = 100;
	    	    	
	    for ( iLang = 0; lang_array[iLang] != LANG_UNKNOWN; iLang++ )
	    	if ( lang_array[iLang] == race_table[ch->race]->language )
	    break;

	    if ( lang_array[iLang] == LANG_UNKNOWN )
	    	bug( "Nanny: invalid racial language." );
	    else
	    {
	    	if ( (iLang = skill_lookup( lang_names[iLang] )) < 0 )
	    		bug( "Nanny: cannot find racial language." );
	    	else
/* Added so Lizardmen could not use common - Toy */
          if ( ch->race == RACE_LIZARDMAN )
			ch->pcdata->learned[iLang] = 0;
	    else
	    		ch->pcdata->learned[iLang] = 100;
	    }


Lizardmen characters still gain common when they log in. Anyone see what I'm doing wrong?

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #6 on Fri 05 Mar 2004 10:03 PM (UTC)

Amended on Fri 05 Mar 2004 10:04 PM (UTC) by David Haley

Message
a) If I'm not mistaken that code is run upon character creation, not character login, so you can't test it by just logging in

b) By adding in the second ifcheck to the racial section, you just made sure that Lizardmen don't get ANY language - and especially, not their racial one.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Toy   (206 posts)  [Biography] bio
Date Reply #7 on Sat 06 Mar 2004 06:34 AM (UTC)
Message
Doh.. I seriously need to keep an eye on how I word things. I was creating the character and getting common still, not just loggin in. ;p

And I removed the second ifcheck, as per your advice. Still, however, the lizardman race still gets both the common and reptile language. This is how the code looks now for nanny:

	    if ( (iLang = skill_lookup( "common" )) < 0 )
	    	bug( "Nanny: cannot find common language." );
	    else
/* Added so Lizardmen could not use common - Toy*/
          if ( ch->race == RACE_LIZARDMAN )
		ch->pcdata->learned[iLang] = 0;
	    else
  	      ch->pcdata->learned[iLang] = 100;
	    	    	
	    for ( iLang = 0; lang_array[iLang] != LANG_UNKNOWN; iLang++ )
	    	if ( lang_array[iLang] == race_table[ch->race]->language )
	    break;

	    if ( lang_array[iLang] == LANG_UNKNOWN )
	    	bug( "Nanny: invalid racial language." );
	    else
	    {
	    	if ( (iLang = skill_lookup( lang_names[iLang] )) < 0 )
	    		bug( "Nanny: cannot find racial language." );
	    	else
	    		ch->pcdata->learned[iLang] = 100;


Any other reasons anyone can think of on why it's still giving the common language?

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] top

Posted by Nick Gammon   Australia  (22,985 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Sun 07 Mar 2004 01:50 AM (UTC)
Message
Try using 'grep common *.c' - this is what I found ...


/*
 * Language support functions. -- Altrag
 * 07/01/96
 *
 * Modified to return how well the language is known 04/04/98 - Thoric
 * Currently returns 100% for known languages... but should really return
 * a number based on player's wisdom (maybe 50+((25-wisdom)*2) ?)
 */
int knows_language( CHAR_DATA *ch, int language, CHAR_DATA *cch )
{
        sh_int sn;

        if ( !IS_NPC(ch) && IS_IMMORTAL(ch) )
                return 100;
        if ( IS_NPC(ch) && !ch->speaks ) /* No langs = knows all for npcs */
                return 100;
        if ( IS_NPC(ch) && IS_SET(ch->speaks, (language & ~LANG_CLAN)) )
                return 100;
        /* everyone KNOWS common tongue */
        if ( IS_SET(language, LANG_COMMON) )
                return 100;


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Toy   (206 posts)  [Biography] bio
Date Reply #9 on Mon 08 Mar 2004 01:23 AM (UTC)
Message
Thanks Nick, you were right. I totally overlooked act_comm.c. I was able to get it so Lizardmen can only use the reptile language with this:

	if ( !IS_NPC(ch) && IS_IMMORTAL(ch) )
		return 100;
	if ( IS_NPC(ch) && !ch->speaks ) /* No langs = knows all for npcs */
		return 100;
	if ( IS_NPC(ch) && IS_SET(ch->speaks, (language & ~LANG_CLAN)) )
		return 100;
	/* Make so Lizardman cannot learn common */
	if ( ch->race == RACE_LIZARDMAN && IS_SET(language, LANG_COMMON) )
		return 0;
	/* everyone but Lizardman KNOWS common tongue */
	if ( IS_SET(language, LANG_COMMON) )
		return 100;


Thanks.

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #10 on Mon 08 Mar 2004 08:42 AM (UTC)
Message
Actually, with that setup I think you still get lizardmen learning common because the common language is set to 100 *after* being set to 0 for lizards.

Try

if ( ch->race != RACE_LIZARDMAN && IS_SET(language, LANG_COMMON) )

for that last check and destroy the existing lizardman check where the language is set to 0.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #11 on Mon 08 Mar 2004 02:59 PM (UTC)
Message
Actually, because you have the return in the lizardman check, if they are a lizardman and it is common, it will return 0, and just stop there, not dropping down to set everyone else to common.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Toy   (206 posts)  [Biography] bio
Date Reply #12 on Mon 08 Mar 2004 04:23 PM (UTC)
Message
Well, I tried changing this:

	if ( ch->race == RACE_LIZARDMAN && IS_SET(language, LANG_COMMON) )
		return 0;


into this like suggested:
	if ( ch->race != RACE_LIZARDMAN && IS_SET(language, LANG_COMMON) )
		return 0;


All it did was give lizardmen the common language again, so the ch->race == RACE_LIZARDMAN is the needed check to remove the common language right off the bat. Attempting now to see how to set practicing languages based on race, not on having the tongue in a class file. Thanks anyways guys. :)

-Toy the Grateful

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] 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.


25,098 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]