Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!

Members: 0
Guests: 13
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » fly a kitty
Forum Rules | Mark all | Recent Posts

fly a kitty
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2 next >>
Post is unread #21 Apr 24, 2013, 8:29 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

Sorry if I'm hard to understand, I'm not an english native speaker as I suppose you may have noticed.

I want it to go through the process and treat it like a spell is being cast if and only if I say 1 word.
If the spell needs two words to be cast, the second word must come from "pointing" and only from pointing.

If arg1 exists, we don't want to go through the process.
       
Post is unread #22 Apr 24, 2013, 8:35 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

ah ok try this for do_spell
CMDF( do_say )
{
   char buf[MSL];
   CHAR_DATA *vch;
   EXT_BV actflags;
   int sn;   
   char arg[MIL];
   char arg1[MIL];
   
#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg1 );

   if( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 )
   {
      char buf1[MSL];

      /* We are pointing at someone/something, and didn't specify anyone else */
      if( ch->pcdata->pointing && ( arg1 == NULL || arg1[0] == '\0' ) )
         snprintf( arg1, sizeof( arg1 ), "%s", ch->pcdata->pointing );


      /* Do this on yourself */
      if( arg1 == NULL || arg1[0] == '\0' )
      {
         do_cast( ch, arg );
         return;
      }

      /* Do it on someone/something else, if they are pointing */
      if( ch->pcdata->pointing )
      {
         STRFREE( ch->pcdata->pointing );
         ch->pcdata->pointing = STRALLOC( arg1 );

         snprintf( buf1, sizeof( buf1 ), "%s %s", arg, arg1 );
         do_cast( ch, buf1 );
         return;
      }
   }

   if( xIS_SET( ch->in_room->room_flags, ROOM_SILENCE ) )
   {
      send_to_char( "You can't do that here.\r\n", ch );
      return;
   }

   actflags = ch->act;
   if( IS_NPC( ch ) )
      xREMOVE_BIT( ch->act, ACT_SECRETIVE );
   for( vch = ch->in_room->first_person; vch; vch = vch->next_in_room )
   {
      const char *sbuf = argument;

      if( vch == ch )
         continue;

      /*
       * Check to see if character is ignoring speaker 
       */
      if( is_ignoring( vch, ch ) )
      {
         /*
          * continue unless speaker is an immortal 
          */
         if( !IS_IMMORTAL( ch ) || get_trust( vch ) > get_trust( ch ) )
            continue;
         else
         {
            set_char_color( AT_IGNORE, vch );
            ch_printf( vch, "You attempt to ignore %s, but" " are unable to do so.\r\n", ch->name );
         }
      }

#ifndef SCRAMBLE
      if( speaking != -1 && ( !IS_NPC( ch ) || ch->speaking ) )
      {
         int speakswell = UMIN( knows_language( vch, ch->speaking, ch ),
                                knows_language( ch, ch->speaking, vch ) );

         if( speakswell < 75 )
            sbuf = translate( speakswell, argument, lang_names[speaking] );
      }
#else
      if( !knows_language( vch, ch->speaking, ch ) && ( !IS_NPC( ch ) || ch->speaking != 0 ) )
         sbuf = scramble( argument, ch->speaking );
#endif
      sbuf = drunk_speech( sbuf, ch );

      MOBtrigger = FALSE;                                     //notice this part where I try to send
	  if (arg1[0] == '\0')                         //the text if we aren't casting a spell.
         {                                                                
         ch_printf( vch, "&c%s say '", ch->name );
	     ch_printf( vch, "&w%s&c'", arg );
	  }
	  if ((arg1[0] != '\0') && (buf == '\0'))
	  {
         ch_printf( vch, "&c%s say '", ch->name );
	     ch_printf( vch, "&w%s", arg );
	     ch_printf( vch, " %s&c'", arg1 );
	  }
	  if ((arg1[0] != '\0') && (buf != '\0'))
	  {
         ch_printf( vch, "&c%s say '", ch->name );
	     ch_printf( vch, "&w%s", arg );
	     ch_printf( vch, " %s ", arg1 );
         act( AT_SAY, "$t&D'", ch, sbuf, vch, TO_VICT );
	  }	  
   }
/*    MOBtrigger = FALSE;
    act( AT_SAY, "$n says '$T'", ch, NULL, argument, TO_ROOM );*/
   ch->act = actflags;
   MOBtrigger = FALSE;
   
   if (arg1[0] == '\0')
   {
      ch_printf( ch, "&cYou say '&w%s&c'", arg );
   }
   if ((arg1[0] != '\0') && (buf == '\0'))
   {
      ch_printf( ch, "&cYou say '&w%s", arg );
      ch_printf( ch, " &w%s&c'", arg1 );
   }
   if ((arg1[0] != '\0') && (buf != '\0'))
   {
      ch_printf( ch, "&cYou say '&w%s", arg );
      ch_printf( ch, " &w%s ", arg1 );
      act( AT_SAY, "&w$T&c'&D", ch, NULL, drunk_speech( argument, ch ), TO_CHAR );
   }
   
   if( xIS_SET( ch->in_room->room_flags, ROOM_LOGSPEECH ) )
   {
      snprintf( buf, MSL, "%s: %s", IS_NPC( ch ) ? ch->short_descr : ch->name, argument );
      append_to_file( LOG_FILE, buf );
   }
   mprog_speech_trigger( argument, ch );
   if( char_died( ch ) )
      return;
   oprog_speech_trigger( argument, ch );
   if( char_died( ch ) )
      return;
   rprog_speech_trigger( argument, ch );
   return;
}

       
Post is unread #23 Apr 24, 2013, 8:38 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

also you might want to add in so point stop stops pointing or something and clears the ch->pcdata->pointing so that they aren't always pointing at someone or clear it right before do_cast is used in do_say (both places) just kind of depends on how you want it to work
       
Post is unread #24 Apr 24, 2013, 8:53 pm   Last edited Apr 24, 2013, 8:55 pm by Leia
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

      /* Do it on someone/something else, if they are pointing */
      if( ch->pcdata->pointing )
      {
         STRFREE( ch->pcdata->pointing );
         ch->pcdata->pointing = STRALLOC( arg1 );

         snprintf( buf1, sizeof( buf1 ), "%s %s", arg, arg1 );
         do_cast( ch, buf1 );
         return;
      }


The only diference are this two { } ? I can't see any other change and It doesn't work :S

And you are right with the stop pointing issue.. I want people to stop pointing if they type point nothing, or if they stop holding their wands or if they move to another room.. but I think I can handle that part
       
Post is unread #25 Apr 24, 2013, 8:55 pm
Go to the top of the page
Go to the bottom of the page

Quixadhal
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005

Welcome to the joys of memory micro-management, from 1990!

Of course, I have to put in my obligitory suggestion to use an LPMUD or something that doesn't make you fiddle with pointers every three seconds of coding... but..

What you probably need to do is write an entirely new version of do_say() which mimics the behaviror of both do_cast() and the current do_say(), as well as having to add state information about the point emote.

Note how commands deal with their arguments. Arguments are passed as a single string, and then plucked apart by annoying functions like one_argument().

So, the point emote/command now has to store the victim you're pointing at in the characer data of whomever called it. That's the only way you can know if someone is pointing at something outside of the emote code itself. Make sure you clear this when you change rooms, or when you load into the game.

Once that's done, my suggestion for do_say() is to go through the motions of using one_argument() to parse it and figure out the target (if any), and the spell (if any), by whatever logic you're using...

Once you've identified the spell to cast, and the target, you can then construct a new string to pass to do_cast(), which should look JUST LIKE it would have looked, had you typed cast 'spell name' target.

If it turns out it isn't a valid spell, or whatever other criteria makes you want to say it instead, pass it to the original do_say() instead.

If you want the person casting to also speak, pass a string to do_say() after you pass it to do _cast().... you might want a slightly different string, or if you kept a copy of the original (before one_argument() mangled it), pass that one.
       
Post is unread #26 Apr 24, 2013, 9:21 pm   Last edited Apr 24, 2013, 9:25 pm by Remcon
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

ok try this out
CMDF( do_say )
{
   char buf[MSL];
   CHAR_DATA *vch;
   EXT_BV actflags;
   int sn;   
   char arg[MIL];
   char origarg[MSL];

#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }

   snprintf( origarg, sizeof( origarg ), "%s", argument );
   argument = one_argument( argument, arg );

   if( ( !argument || argument[0] == '\0' && ( sn = find_spell( ch, arg, TRUE ) ) >= 0 )
   {
      char buf1[MSL];

      /* Do this on yourself */
      if( !ch->pcdata->pointing )
      {
         do_cast( ch, arg );
         return;
      }

      /* Do it on someone/something else, if they are pointing */
      snprintf( buf1, sizeof( buf1 ), "%s %s", arg, ch->pcdata->pointing );
      STRFREE( ch->pcdata->pointing );
      do_cast( ch, buf1 );
      return;
   }

   if( xIS_SET( ch->in_room->room_flags, ROOM_SILENCE ) )
   {
      send_to_char( "You can't do that here.\r\n", ch );
      return;
   }

   actflags = ch->act;
   if( IS_NPC( ch ) )
      xREMOVE_BIT( ch->act, ACT_SECRETIVE );
   for( vch = ch->in_room->first_person; vch; vch = vch->next_in_room )
   {
      const char *sbuf = origarg;

      if( vch == ch )
         continue;

      /*
       * Check to see if character is ignoring speaker 
       */
      if( is_ignoring( vch, ch ) )
      {
         /*
          * continue unless speaker is an immortal 
          */
         if( !IS_IMMORTAL( ch ) || get_trust( vch ) > get_trust( ch ) )
            continue;
         else
         {
            set_char_color( AT_IGNORE, vch );
            ch_printf( vch, "You attempt to ignore %s, but" " are unable to do so.\r\n", ch->name );
         }
      }

#ifndef SCRAMBLE
      if( speaking != -1 && ( !IS_NPC( ch ) || ch->speaking ) )
      {
         int speakswell = UMIN( knows_language( vch, ch->speaking, ch ),
                                knows_language( ch, ch->speaking, vch ) );

         if( speakswell < 75 )
            sbuf = translate( speakswell, argument, lang_names[speaking] );
      }
#else
      if( !knows_language( vch, ch->speaking, ch ) && ( !IS_NPC( ch ) || ch->speaking != 0 ) )
         sbuf = scramble( argument, ch->speaking );
#endif
      sbuf = drunk_speech( sbuf, ch );

      MOBtrigger = FALSE;
      act( AT_SAY, "$n says '$t'", ch, sbuf, vch, TO_VICT );
   }
/*    MOBtrigger = FALSE;

   act( AT_SAY, "$n says '$T'", ch, NULL, origarg, TO_ROOM );*/
   ch->act = actflags;
   MOBtrigger = FALSE;
   act( AT_SAY, "You say '$T'", ch, NULL, drunk_speech( origarg, ch ), TO_CHAR );
   
   if( xIS_SET( ch->in_room->room_flags, ROOM_LOGSPEECH ) )
   {
      snprintf( buf, MSL, "%s: %s", IS_NPC( ch ) ? ch->short_descr : ch->name, argument );
      append_to_file( LOG_FILE, buf );
   }
   mprog_speech_trigger( argument, ch );
   if( char_died( ch ) )
      return;
   oprog_speech_trigger( argument, ch );
   if( char_died( ch ) )
      return;
   rprog_speech_trigger( argument, ch );
   return;
}

Yea quix and i considered most those lol but trying to keep it all in one function for ease of changes
       
Post is unread #27 Apr 24, 2013, 9:26 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

think i covered most of it and edited it a few times. gl off i go :)
       
Post is unread #28 Apr 24, 2013, 9:30 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

First of all, thanks for the suggestion Quixadhal and for taking the time to write it, but I prefer SMAUGFUSS19, I've worked a lot in in my smaugfuss19 based code, and I'll renounce to this way of cast spells if the only way is to use an LPMUD.
Second I'm not sure I understood half of what you said half as well as I should like, and I would like the other half to sound half the tedious it sounds.
Are you sure that it would not work if I don't rewrite entirely the two functions? I may write an entirely new mud as well after that.. What you propouse is far beyond my knowledge. But thanks anyway, I really apreciate your suggestion.
       
Post is unread #29 Apr 24, 2013, 9:47 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

Lot's of thanks Remcon, it works perfect now!!! :) :) :)
       
Post is unread #30 Apr 25, 2013, 3:09 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

yw, noticed a few more arguments that needed changed to origarg so this one should fix those as well :)

CMDF( do_say )
{
   char buf[MSL];
   CHAR_DATA *vch;
   EXT_BV actflags;
   int sn;   
   char arg[MIL];
   char origarg[MSL];

#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }

   snprintf( origarg, sizeof( origarg ), "%s", argument );
   argument = one_argument( argument, arg );

   if( ( !argument || argument[0] == '\0' && ( sn = find_spell( ch, arg, TRUE ) ) >= 0 )
   {
      char buf1[MSL];

      /* Do this on yourself */
      if( !ch->pcdata->pointing )
      {
         do_cast( ch, arg );
         return;
      }

      /* Do it on someone/something else, if they are pointing */
      snprintf( buf1, sizeof( buf1 ), "%s %s", arg, ch->pcdata->pointing );
      STRFREE( ch->pcdata->pointing );
      do_cast( ch, buf1 );
      return;
   }

   if( xIS_SET( ch->in_room->room_flags, ROOM_SILENCE ) )
   {
      send_to_char( "You can't do that here.\r\n", ch );
      return;
   }

   actflags = ch->act;
   if( IS_NPC( ch ) )
      xREMOVE_BIT( ch->act, ACT_SECRETIVE );
   for( vch = ch->in_room->first_person; vch; vch = vch->next_in_room )
   {
      const char *sbuf = origarg;

      if( vch == ch )
         continue;

      /*
       * Check to see if character is ignoring speaker 
       */
      if( is_ignoring( vch, ch ) )
      {
         /*
          * continue unless speaker is an immortal 
          */
         if( !IS_IMMORTAL( ch ) || get_trust( vch ) > get_trust( ch ) )
            continue;
         else
         {
            set_char_color( AT_IGNORE, vch );
            ch_printf( vch, "You attempt to ignore %s, but" " are unable to do so.\r\n", ch->name );
         }
      }

#ifndef SCRAMBLE
      if( speaking != -1 && ( !IS_NPC( ch ) || ch->speaking ) )
      {
         int speakswell = UMIN( knows_language( vch, ch->speaking, ch ),
                                knows_language( ch, ch->speaking, vch ) );

         if( speakswell < 75 )
            sbuf = translate( speakswell, origarg, lang_names[speaking] );
      }
#else
      if( !knows_language( vch, ch->speaking, ch ) && ( !IS_NPC( ch ) || ch->speaking != 0 ) )
         sbuf = scramble( origarg, ch->speaking );
#endif
      sbuf = drunk_speech( sbuf, ch );

      MOBtrigger = FALSE;
      act( AT_SAY, "$n says '$t'", ch, sbuf, vch, TO_VICT );
   }
/*    MOBtrigger = FALSE;

   act( AT_SAY, "$n says '$T'", ch, NULL, origarg, TO_ROOM );*/
   ch->act = actflags;
   MOBtrigger = FALSE;
   act( AT_SAY, "You say '$T'", ch, NULL, drunk_speech( origarg, ch ), TO_CHAR );
   
   if( xIS_SET( ch->in_room->room_flags, ROOM_LOGSPEECH ) )
   {
      snprintf( buf, MSL, "%s: %s", IS_NPC( ch ) ? ch->short_descr : ch->name, origarg );
      append_to_file( LOG_FILE, buf );
   }
   mprog_speech_trigger( origarg, ch );
   if( char_died( ch ) )
      return;
   oprog_speech_trigger( origarg, ch );
   if( char_died( ch ) )
      return;
   rprog_speech_trigger( origarg, ch );
   return;
}
       
Post is unread #31 Apr 25, 2013, 6:29 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

Is perfect. You did exactly what I wanted, tons of thanks Remcon :biggrin:
       
Post is unread #32 Apr 25, 2013, 7:51 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

yw, glad its working how you want it
       
Pages:<< prev 1, 2 next >>