Login
User Name:

Password:



Register

Forgot your password?
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
SWRFUSS 1.4
Author: Various
Submitted by: Samson
Users Online
AhrefsBot, Google, DotBot

Members: 0
Guests: 44
Stats
Files
Topics
Posts
Members
Newest Member
488
3,788
19,631
595
Khonsu

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » General » Coding » CalareyMud Coding Help
Forum Rules | Mark all | Recent Posts

CalareyMud Coding Help
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2, 3, 4, 5 next >>
Post is unread #81 Sep 9, 2013 10:53 pm   
Go to the top of the page
Go to the bottom of the page

mystickdreamer
Magician
GroupMembers
Posts128
JoinedApr 9, 2010

 
please explain about the format

I mean I understand what the word format means, but I fail to see what I did wrong in the format

Post is unread #82 Sep 10, 2013 4:43 am   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,914
JoinedJul 26, 2005

 
You have
void do_invoke( CHAR_DATA * ch, char *argument )
{
	OBJ_DATA *fire, *shard;
	bool found;
	int mana;
	 
	 
if( !can_use_skill( ch, 0, gsn_invoke ) )
   {
      send_to_char( "A skill such as this requires more magical ability than you have.\n\r", ch );
      return;
   }
if( argument[0] == '\0' )
	{
		send_to_char( "Invoke which element?\n\r", ch);
		return;
	}
   
		mana = (ch->max_mana / 5);
	if( !str_cmp( argument, "fireshard" ) )
	{
			found = FALSE;
			for( fire = ch->in_room->first_content; fire; fire = fire->next_content )
				{
					if( fire->item_type == ITEM_FIRE )
					{
					found = TRUE;
					break;
					}
				}
			if( !found )
			{
				send_to_char(" There must be a fire here to invoke a FireShard.\n\r", ch);
				return;
			}
		   if( !can_use_skill( ch, number_percent(  ), gsn_invoke ) )
			{
				set_char_color( AT_MAGIC, ch );
				send_to_char( "You failed to make a FireShard.\n\r", ch );
				// Decided against PCs learning from failure
				//learn_from_failure( ch, gsn_invoke );
				ch->mana -= ( mana );
				return;
			}

					//SUCCESS
					
					shard = create_object( get_obj_index( OBJ_VNUM_SM_FIRESHARD ), 0 );
					learn_from_success(ch, gsn_invoke);
					ch->mana -= (ch->mana / 10);
					act( AT_MAGIC, "$n invokes the fire and creates a FireShard.", ch, NULL, NULL, TO_ROOM );
					act( AT_MAGIC, "You invoke the fire and create a FireShard.", ch, NULL, NULL, TO_CHAR );
					obj_to_char( shard, ch);
					learn_noncombat( ch, SK_CHANNEL);
			
	}

when this is so much easier to follow and look at :)
void do_invoke( CHAR_DATA * ch, char *argument )
{
   OBJ_DATA *fire, *shard;
   bool found;
   int mana;

   if( !can_use_skill( ch, 0, gsn_invoke ) )
   {
      send_to_char( "A skill such as this requires more magical ability than you have.\n\r", ch );
      return;
   }
   if( argument[0] == '\0' )
   {
      send_to_char( "Invoke which element?\n\r", ch);
      return;
   }

   mana = (ch->max_mana / 5);

   if( !str_cmp( argument, "fireshard" ) )
   {
      found = FALSE;

      for( fire = ch->in_room->first_content; fire; fire = fire->next_content )
      {
         if( fire->item_type == ITEM_FIRE )
         {
            found = TRUE;
            break;
         }
      }
      if( !found )
      {
         send_to_char(" There must be a fire here to invoke a FireShard.\n\r", ch);
         return;
      }

      if( !can_use_skill( ch, number_percent(  ), gsn_invoke ) )
      {
         set_char_color( AT_MAGIC, ch );
         send_to_char( "You failed to make a FireShard.\n\r", ch );
         // Decided against PCs learning from failure
         // learn_from_failure( ch, gsn_invoke );
         ch->mana -= ( mana );
         return;
      }

      // SUCCESS
      shard = create_object( get_obj_index( OBJ_VNUM_SM_FIRESHARD ), 0 );
      learn_from_success(ch, gsn_invoke);
      ch->mana -= (ch->mana / 10);
      act( AT_MAGIC, "$n invokes the fire and creates a FireShard.", ch, NULL, NULL, TO_ROOM );
      act( AT_MAGIC, "You invoke the fire and create a FireShard.", ch, NULL, NULL, TO_CHAR );
      obj_to_char( shard, ch);
      learn_noncombat( ch, SK_CHANNEL);
   }

You would be amazed by how much faster an issue can be found and fixed in a nicely formated code compared to one where you spend time trying to figure out what is going on first.

Post is unread #83 Sep 10, 2013 9:40 am   
Go to the top of the page
Go to the bottom of the page

mystickdreamer
Magician
GroupMembers
Posts128
JoinedApr 9, 2010

 
Ah so just make sure everything lines up

I will definitely keep that in mind and try to format it correctly

thank you

Post is unread #84 Sep 13, 2013 8:57 am   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,914
JoinedJul 26, 2005

 
yw and thanks :)

Post is unread #85 Sep 18, 2013 11:19 am   
Go to the top of the page
Go to the bottom of the page

mystickdreamer
Magician
GroupMembers
Posts128
JoinedApr 9, 2010

 
I once again need some help from the most excellent coders here.


I'm importing the istagged and isflagged with variables to be able to assign variables to players

I'm getting this error when compiling

variables.c:585: warning: passing arg 1 of `free' discards qualifiers from pointer target type



this is the section of code

        case 'E':
            if( !str_cmp( word, "End" ) )
            {
               switch ( pvd->type )
               {
                  default:
                  {
                     bug( "%s: invalid/incomplete variable: %s", __FUNCTION__, pvd->tag );
                     DISPOSE( pvd->tag );
                     DISPOSE( pvd );
                     break;
                  }
                  case vtSTR:
                  case vtXBIT:
                     if( !pvd->data )
                     {
                        bug( "%s: invalid/incomplete variable: %s", __FUNCTION__, pvd->tag );
  line 585 ->                      DISPOSE( pvd->tag );
                        DISPOSE( pvd );
                        break;
                     }
                  case vtINT:
                     tag_char( ch, pvd, 1 );
                     break;
               }
               return;
            }
            break;



in fact I have a bunch of these same errors all over, but I figure I can fix all the same errors from this one example

Post is unread #86 Sep 18, 2013 11:49 am   Last edited Sep 18, 2013 1:34 pm by mystickdreamer
Go to the top of the page
Go to the bottom of the page

mystickdreamer
Magician
GroupMembers
Posts128
JoinedApr 9, 2010

 
Ah answered my own question

I was passing is a const char when it took just a char




ah and my last warning I have

variables.c:66: warning: passing arg 1 of `free' discards qualifiers from pointer target type



in the code

void delete_variable( VARIABLE_DATA * var )
{
   delete_vdata( var );
line 66 ->   DISPOSE( var->tag );
   DISPOSE( var );
}

Post is unread #87 Sep 18, 2013 5:24 pm   Last edited Sep 18, 2013 5:29 pm by mystickdreamer
Go to the top of the page
Go to the bottom of the page

mystickdreamer
Magician
GroupMembers
Posts128
JoinedApr 9, 2010

 
Ok so I'm having a couple of problems with istagged

the first problem I'm having is it just doesn't do anything it stops the prog right where the istagged if check is

The test prog is

>speech_prog test
if istagged($n, test) >= 1
say Your test tag is not 0.
else
say Your test tag is ZERO.
endif



here is the code for istagged in mudprog.c

if( !str_cmp( chck, "istagged" ) )
      {
         VARIABLE_DATA *vd;
         int vnum = mob->pIndexData->vnum;

         if( argc < 3 )
            return BERR;

         if( argc > 3 )
            vnum = atoi( argv[3] );
         if( ( p = strchr( argv[2], ':' ) ) != NULL )
         {
            *p++ = '\0';
            vnum = atoi( p );
         }
         if( ( vd = get_tag( chkchar, argv[2], vnum ) ) == NULL )
            return FALSE;

         if( !*opr && !*rval )
            return TRUE;

         switch ( vd->type )
         {
            case vtSTR:
               return mprog_seval( ( char * )vd->data, opr, rval, mob );

            case vtINT:
               return mprog_veval( ( long )vd->data, opr, atoi( rval ), mob );

            case vtXBIT:
               return FALSE;  /* for now */
         }
         return FALSE;
      }



I am able to successfully tag a player with a variable.






The second problem I'm having is the variable isn't actually saving to the player file.... I'm definitely going to need some help with that

Pages:<< prev 1, 2, 3, 4, 5 next >>