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, Yandex, DotBot

Members: 0
Guests: 4
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 » mana regen "mp5"
Forum Rules | Mark all | Recent Posts

mana regen "mp5"
< Newer Topic :: Older Topic > For those acquainted with WoW

Pages:<< prev 1 next >>
Post is unread #1 Jan 8, 2007, 8:28 pm   Last edited Jan 8, 2007, 8:29 pm by tphegley
Go to the top of the page
Go to the bottom of the page

tphegley
Magician
GroupMembers
Posts176
JoinedMay 21, 2006

I'm wanting to put a type of mana regen in that's different from regular mana_gain.

I named it mp5_gain and what it does will be like world of warcraft's mp5 system. Meaning every 5 seconds, you gain a certain amount of mana based off of a peice of eq you're wearing. Here's what I have so far with it compiling cleanly but just crashing when it updates.

void mp5_update( void )
{
	CHAR_DATA *ch;

	ch->mana += mp5_gain(ch);

	if (ch->mana >= ch->max_mana)
		ch->mana = ch->max_mana;
	  
   return;
}

int mp5_gain( CHAR_DATA * ch )
{
   int gain = 0;
   AFFECT_DATA *paf;
   OBJ_DATA *obj;


   for( obj = ch->first_carrying; obj; obj = obj->next_content )
   {
      if( obj->wear_loc != WEAR_NONE )
      {
         for( paf = obj->first_affect; paf; paf = paf->next )
      if( paf->location == APPLY_MP5 )
			 gain += paf->modifier;

         for( paf = obj->pIndexData->first_affect; paf; paf = paf->next )
      if( paf->location == APPLY_MP5 )
			 gain += paf->modifier;
      }
   }
   return gain;
}


Here's the segment fault:
if( obj->wear_loc != WEAR_NONE )


I created a new update in update_handler

if ( --pulse_mp5 <=0 )
{
  pulse_mp5 = ( PULSE_TICK / 5);
  mp5_update ( );
}


This is explained a little better on Nick Gammon's forum.
http://www.gammon.com.au/forum/bbshowpost.php?id=7581&page=1
       
Post is unread #2 Jan 9, 2007, 2:05 pm
Go to the top of the page
Go to the bottom of the page

tphegley
Magician
GroupMembers
Posts176
JoinedMay 21, 2006

So this is where I'm at:

Update.c
void mp5_update( void )
{
	CHAR_DATA *ch;
	DESCRIPTOR_DATA *d;

	  for (d = first_descriptor; d; d = d->next)
	  {
		  if (d->connected == CON_PLAYING)
		  {
			  ch = d->character;

			 if( ch->mana < ch->max_mana )
				ch->mana += mp5_gain( ch );
		  }
	  }
 return;


}
int mp5_gain( CHAR_DATA *ch )
{

	int gain;

   AFFECT_DATA *paf;
   OBJ_DATA * obj;
	DESCRIPTOR_DATA * d;


  for (d = first_descriptor; d; d = d->next)
  {
	  if (d->connected == CON_PLAYING)
	  {
		  ch = d->character;

			   for( ch = first_char; ch; ch = ch->next )
			   {
					   for( obj = ch->first_carrying; obj; obj = obj->next_content )
					   {
						  if( obj->wear_loc != WEAR_NONE )
						  {
							 for( paf = obj->first_affect; paf; paf = paf->next )
						  if( paf->location == APPLY_MP5 )
								gain += paf->modifier;
							 for( paf = obj->pIndexData->first_affect; paf; paf = paf->next )
						  if( paf->location == APPLY_MP5 )
								gain += paf->modifier;
						  }
					   }
			   }
	  }
  }
   return gain;

}


further down in update_handler:
   if( --pulse_mp5 <= 0 )
   {
      
	  pulse_mp5 = ( PULSE_TICK / 5  );
      mp5_update(  );
   }


Handler.c
in affect_modify:

      case APPLY_MP5:
         ch->mp5 += mod;
         break;

further down in affect_loc_name:
      case APPLY_NUM_ATTACK:
		 return "num_attack";
      case APPLY_MP5:
         return "mp5"; *****For some reason when I add an mp5 affect to an item it says "num_attack" from above.

Mud.h
   APPLY_TELEDELAY, APPLY_NUM_ATTACK, APPLY_MP5, MAX_APPLY_TYPE


I've got everything in the save file correct. I have everything in the build file and the short mp5's in mud.h
The mud is not crashing right now, but it's also not adding the mp5_gain integer. Whenever I made this:
int mp5_gain( CHAR_DATA *ch )
{
   int gain;

if (IS_NPC (ch)
gain = ch->level;
else
gain = 100;

return gain;
}


it worked fine and would update the 100 mana every 5-9 seconds.

So I believe the problem is with these lines:
	
 for( paf = obj->first_affect; paf; paf = paf->next )
  if( paf->location == APPLY_MP5 )
     gain += paf->modifier;
 for( paf = obj->pIndexData->first_affect; paf; paf = paf->next )
  if( paf->location == APPLY_MP5 )
     gain += paf->modifier;


It's not calculating correctly in there and it's giving a bad argument to mp5_gain(ch) in mp5_update.
       
Post is unread #3 Jan 9, 2007, 4:15 pm
Go to the top of the page
Go to the bottom of the page

tphegley
Magician
GroupMembers
Posts176
JoinedMay 21, 2006

got it all fixed now. Wo0t
       
Post is unread #4 Jan 13, 2007, 3:59 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Sorry for letting it seem like you got ignored here, but out of curiosity, what was your eventual fix? It looked like your last post had the IS_NPC(ch) check reversed in mp5_gain()
       
Pages:<< prev 1 next >>