Register forum user name Search FAQ

Gammon Forum

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 ➜ Compiling the server ➜ Source Code

Source Code

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


Pages: 1  2 3  4  5  

Posted by Kris   USA  (198 posts)  Bio
Date Reply #15 on Tue 29 May 2001 11:43 PM (UTC)
Message
I've created a new invis command (krisinvis), which emulates invis, but automatically sets my invis level to 20000, and is available only to myself. Basically, I intend to use it so as to keep tabs on my other immortals. Lack of production alarms me, so I intend to 'spy' on them to see what they're doing with all their time when I'm not there (i.e. goofing off). Surprisingly, I was totally successful on my own, except for one thing. In act_wiz.c, in the function do_users, how can I get it so that someone doesn't show up on 'users' when affected by krisinvis? Instead of ch->pcdata->wizinvis, it's ch->pcdata->krisinvis, and instead of PLR_WIZINVIS, it's PLR_KRISINVIS. Using either of those variables, how do I perform a successful ifcheck in the do_users function which will prevent someone under krisinvis from showing up? Thanks for your help :)
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #16 on Wed 30 May 2001 11:59 PM (UTC)
Message
In do_users, add these lines after the loop through each character:



for ( d = first_descriptor; d; d = d->next )
  {

  // skip krisinvis characters
  if (d->character->pcdata->krisinvis)
    continue;


 ... rest of stuff here ....
  
  }  // end of loop


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #17 on Fri 01 Jun 2001 12:43 AM (UTC)
Message
It worked like a charm; thanks :)
I was also wondering: How do I get it to where it doesn't log my actions while krisinvissed? I.e.
"Build: Kris: Reset Area" would probably tip someone off that I'm online. Or "Log: Kris: force mob report" etc. I'm sure the same ifcheck would work, but where exactly do I put it?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #18 on Fri 01 Jun 2001 01:26 AM (UTC)
Message
I think you'll have to look for instances of the words "log_string_plus" which seems to be used to log lots of things.

Also, commands have a log level (log) in the command table. I would find out where that gets used.

You'll need to use grep to find such things.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #19 on Sat 02 Jun 2001 12:27 AM (UTC)
Message
I went to every instance of log_string_plus and put in an ifcheck at the appropriate instances, basically checking to see if the person is krisinvissed or not. However, despite all the changes I made, there are still many more commands and such that log anyways. The 'order' command and such don't log, but reset area does, log does, etc. Is there any one piece of coding I can change to accomodate everything that logs as a log, build, comm, or whatever?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #20 on Sun 03 Jun 2001 10:27 PM (UTC)
Message
I couldn't see it. The problem is that a lot of commands do logging *but* they don't pass down to the log routine the pointer to the character.

In other words, the logging routine doesn't know *who* is logging, and thus a simple test in one place doesn't seem possible.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #21 on Thu 14 Jun 2001 11:19 PM (UTC)
Message
I'm trying to create a quest race. Well, I've already created the race and everything, including its language and all that, but now I'm trying to make a mpcommand that will transform the player into the race (in this case, a cat). After all, that seems the best route to having an automated quest. I successfully created a new mpcommand (mptransformcat), using mpadvance as a template. It worked fine, and I made sure it was calling up the function and all that, which it was. But then I tried to get it to actually transform the player's race.... I took some code from the nanny function of comm.c. My hope was to change not only the person's race, but everything from skill\stat bonuses, to native language, to height and weight. However, when I tested it, the mud did its little buzzing of the hard drive thing, and disconnected everyone. (I hate how it doesn't even return an error message when that happens) Here is the function that I created:


/* allow a mobile to transform a player into a different race (cat); use only for special quests */
void do_mptransformcat ( CHAR_DATA *ch, char *argument )
{
char arg[MAX_STRING_LENGTH];
CHAR_DATA *victim;
int level;
int iLevel;
int iLang;

if ( !IS_NPC( ch ) || IS_AFFECTED( ch, AFF_CHARM ))
{
send_to_char( "Huh?\n\r", ch );
return;
}


argument = one_argument( argument, arg );

if ( arg[0] == '\0' )
{
progbug( "Mptransform - Bad syntax", ch );
return;
}

if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
progbug( "Mptransform - Victim not there", ch );
return;
}

if ( IS_NPC(victim) )
{
progbug( "Mptransform - Victim is NPC", ch );
return;
}

/* Now that we're done with some standard ifchecks, let's get to the transformation coding */

send_to_char( "You start to feel a strange sensation in your body....", victim );
WAIT_STATE( victim, 2 * PULSE_VIOLENCE );
send_to_char( "What the bloody hell?!", victim );
/* Blahblahblah some fancy-schmancy stuff, then the actual transformation */


ch->race = RACE_CAT;
ch->perm_str += race_table[ch->race]->str_plus;
ch->perm_int += race_table[ch->race]->int_plus;
ch->perm_wis += race_table[ch->race]->wis_plus;
ch->perm_dex += race_table[ch->race]->dex_plus;
ch->perm_con += race_table[ch->race]->con_plus;
ch->perm_cha += race_table[ch->race]->cha_plus;
ch->affected_by = race_table[ch->race]->affected;
ch->perm_lck += race_table[ch->race]->lck_plus;

ch->armor += race_table[ch->race]->ac_plus;
ch->alignment += race_table[ch->race]->alignment;
ch->attacks = race_table[ch->race]->attacks;
ch->defenses = race_table[ch->race]->defenses;
ch->saving_poison_death = race_table[ch->race]->saving_poison_death;
ch->saving_wand = race_table[ch->race]->saving_wand;
ch->saving_para_petri = race_table[ch->race]->saving_para_petri;
ch->saving_breath = race_table[ch->race]->saving_breath;
ch->saving_spell_staff = race_table[ch->race]->saving_spell_staff;

ch->height = number_range(race_table[ch->race]->height *.9, race_table[ch->race]->height *1.1);
ch->weight = number_range(race_table[ch->race]->weight *.9, race_table[ch->race]->weight *1.1);

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;
}

ch->level += 1;
ch->exp += 5000;
ch->max_hit += race_table[ch->race]->hit;
ch->max_mana += race_table[ch->race]->mana;

send_to_char( "You have been transformed into a CAT!!", victim );
return;
}

If you could tell me what I did wrong and need to fix, I would be very greatful. Thank you =)

(p.s. Sorry bout all the source code junk I'm posting today)
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #22 on Fri 15 Jun 2001 01:10 AM (UTC)
Message
One thing that strikes me is that you are changing "ch" which I think is the mobile doing the mptransformcat, and not the victim, who is the player you want to affect. In other words, instead of:


ch->race = RACE_CAT;
ch->perm_str += race_table[ch->race]->str_plus;


you want:


victim->race = RACE_CAT;
victim->perm_str += race_table[victim->race]->str_plus;


... and so on.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #23 on Fri 15 Jun 2001 01:41 AM (UTC)
Message
uhhmmmm.... oops....

btw It works now; that's what I get for copying and pasting code without paying attention.... *smacks his forehead*
Thanks =)
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #24 on Fri 15 Jun 2001 02:57 AM (UTC)
Message
Okay, this is just more of an aesthetic thing, but I'm trying to have some text (a small storyline) appear to the character, but I don't want the bloody thing to spam it up all at once. I tried using WAIT_STATE from do_delay function, but it's having no effect. I tried every variation of the delay time, please note, and 80 is just my latest futile attempt. Here's the relevant code:

/* Now that we're done with some standard ifchecks, let's get to the transformation coding */

send_to_char( "You start to feel a strange sensation in your body....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nWhat the bloody hell?!\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\n\n\nA vast, open field flashes before your eyes....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nYou are standing in this field....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nYour ears perk-up, your eyes focus, and you crouch down low in the grass....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nPatience is a virtue.... You wait calmly....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\n\nYou *LEAP* out of your hiding place, and land upon your unsuspecting victim!!\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nYour prey tries to escape, but to no avail!\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nThe helpless mouse struggles as you bat it around playfully....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\n\nThe rodent bolts!\n", victim );
send_to_char( "\nYour spring-loaded legs ZIP into action! The chase is on....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nYour superior dexterity is no match for the mouse, and you swiftly overtake it!\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nWith a quick bite to the neck, you kill your prey.\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nYou take your catch deep into the woods, where hundreds of cats are waiting for your arrival....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\n\nAn orange-yellow tabby steps forth from the group.\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nYou open your mouth and let the mouse fall upon the ground for the tabby to see....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nThe tabby nods approvingly.\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nThe tabby says: You came to know our ways and our tongue. You have found much more than that. You have the heart of a tiger within you.... You are one of us.... We shall always be with you, my friend.... My brother....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nThe tabby purrs. Soon, the rest of the group starts purring as well.... The sound resonates your ears, and your heart....\n", victim );
WAIT_STATE( victim, 80 );
send_to_char( "\nThe tabby lovingly rubs his cheek against yours, and disappears, along with the rest of the vision....\n", victim );
victim->race = RACE_CAT;
/* Then back to the same code as before */

I'm calling it up the same exact way it's called in other functions, at least as far as I can tell. *sigh* What am I doing wrong with this one? =)
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #25 on Thu 21 Jun 2001 06:47 PM (UTC)
Message
Does anybody know? It's been almost a week and I still can't figure this one out :\
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #26 on Thu 21 Jun 2001 09:05 PM (UTC)
Message
It's not particularly easy to do that. If you look in mud.h you can see what WAIT_STATE does.


/* Addition to make people with nuisance flag have more wait */

#define WAIT_STATE(ch, npulse) ((ch)->wait=(!IS_NPC(ch)&&ch->pcdata->nuisance&&\
(ch->pcdata->nuisance->flags>4))?UMAX((ch)->wait,\
(npulse+((ch)->pcdata->nuisance->flags-4)+ \
ch->pcdata->nuisance->power)): \
UMAX((ch)->wait, (npulse)))


For one thing it only seems to apply to characters with the "nuisance" flag set. Also what it does is make that character wait in the main loop, what you have done is only set up, many times, a single 80-second wait.

The thing is, you can't afford to have all those 80-second pauses for that one character, between each message, like that. Imagine what will happen to everyone else on the server. As the program makes its way slowly through the list, they all have to wait 80 seconds per message as well.

The only way you can do something like that is:

1. Send the first message
2. Mark the character as having to wait (say) 10 seconds, doing something similar to what WAIT_STATE does (basically sets the "wait" variable).
3. Remember where you are in the list of messages
4. When the time is up send the next message.
5. Go back to (2).

It's not easy, but it could be done.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #27 on Mon 25 Jun 2001 10:30 PM (UTC)
Message
It would help a bit if I understood more about where the "main loop" is, and such. If I were to create a new function, perhaps set another variable to remember the place in the mud_comm function, where would I put the function calls? I can't just hold-up in a delay function without delaying the mud, so I have to let it do the main loop and have it call the delay function back or something like that..... I'm not sure. I understand what you're saying, but is there any more details you could give me, like some run-down on what the main loop function(s) is? My question is vague I know, but I really don't know how exactly to ask it. I hope you can understand what I'm asking, even though I don't totally understand myself =)

Thank you for your help and patience =)
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #28 on Tue 26 Jun 2001 12:32 AM (UTC)

Amended on Tue 26 Jun 2001 12:33 AM (UTC) by Nick Gammon

Message
In file comm.c is a function called "game_loop".

A few lines into that function is a comment:


/* Main loop */


So there it is, even labelled "main loop".

This loop:


  • Checks for timeouts
  • Checks for comms errors
  • Accepts player input (read_from_buffer) and handles the login sequence (nanny), interprets their commands (interpret) or handles editing (edit_buffer)
  • Does autonomous motion, eg. mobs moving around (update_handler)
  • Sends any new output to players


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #29 on Wed 27 Jun 2001 01:21 AM (UTC)
Message
I think I got the right premise, but I'm having a few small technical problems. For the purposes of the delay, I duplicated WAIT_STATE in mud.h as TEMPWAIT_STATE, using the variable tempwait instead of wait. As follows:

#define TEMPWAIT_STATE(ch, npulse) ((ch)->tempwait=(!IS_NPC(ch)&&ch->pcdata->nuisance&&\
(ch->pcdata->nuisance->flags>4))?UMAX((ch)->tempwait,\
(npulse+((ch)->pcdata->nuisance->flags-4)+ \
ch->pcdata->nuisance->power)): \
UMAX((ch)->tempwait, (npulse)))

No problems there as I can see. At approximately 2277 in mud.h, I added the following:

sh_int tempwait;
sh_int tempwaitb;
sh_int tempwaitc;

Tempwaitb is used to remember where in the message sequence it is, and tempwaitc is used to rembember what function to call once the tempwait variable reaches zero. As follows:
*in comm.c*

if ( d->character && d->character->tempwait > 0 )
{
--d->character->tempwait;

if (d->character->tempwait == 0)
{
if (tempwaitc == 1)
do_mptransformcat(ch, d->character); /* Problem 1: I can't figure out how to call this function, having it remember ch and victim */
}

continue;
}


The rest is in the next post; too many characters in this.
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.


196,394 views.

This is page 2, subject is 5 pages long:  [Previous page]  1  2 3  4  5  [Next page]

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

Go to topic:           Search the forum


[Go to top] top

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