pc->setStm( pc->effDex() );
pc->setStamina( pc->maxStamina() );
void checkRegeneration( P_CHAR pc, unsigned int currenttime ){	if( !pc )		return;	INT32 oldHealth = pc->hp();	INT32 oldStamina = pc->stm();	INT32 oldMana = pc->mn();	// Regeneration stuff	if( !pc->dead() )	{		// Health regeneration		if( pc->regen() <= currenttime )		{			UINT32 interval = SrvParams->hitpointrate() * MY_CLOCKS_PER_SEC;			// If it's not disabled hunger affects our health regeneration			if( pc->hp() < pc->st() && pc->hunger() > 3 || SrvParams->hungerRate() == 0 )			{				for( UINT16 c = 0; c < pc->st() + 1; ++c )				{					if( pc->regen() + ( c * interval ) <= currenttime && pc->hp() <= pc->st() )					{						if( pc->skillValue( HEALING ) < 500 )							pc->setHp( pc->hp() + 1 );											else if (pc->skillValue( HEALING ) < 800)							pc->setHp( pc->hp() + 2 );						else 							pc->setHp( pc->hp() + 3 );						if( pc->hp() > pc->st() )						{							pc->setHp( pc->st() );							break;						}					}				}			}			pc->setRegen( currenttime + interval );		}		// Stamina regeneration		if( pc->regen2() <= currenttime )		{			UINT32 interval = SrvParams->staminarate()*MY_CLOCKS_PER_SEC;			for( UINT16 c = 0; c < pc->effDex() + 1; ++c )			{				if (pc->regen2() + (c*interval) <= currenttime && pc->stm() <= pc->effDex())				{					pc->setStm( pc->stm() + 1 );					if( pc->stm() > pc->effDex() )					{						pc->setStm( pc->effDex() );						break;					}				}			}			pc->setRegen2( currenttime + interval );					}		// OSI Style Mana regeneration by blackwind		// if (pc->in>pc->mn)  this leads to the 'mana not subtracted' bug (Duke)		if( pc->regen3() <= currenttime )		{			unsigned int interval = SrvParams->manarate()*MY_CLOCKS_PER_SEC;			for( UINT16 c = 0; c < pc->in() + 1 ; ++c )			{				if (pc->regen3() + (c*interval) <= currenttime && pc->mn() <= pc->in())				{				pc->setMn( pc->mn() + 1 );				if( pc->med() )									if (pc->mn()>pc->in())					{						if ( pc->med() )						{							pc->socket()->sysMessage( tr("You are at peace." ) );							pc->setMed( false );						}						pc->setMn( pc->in() );						break;					}				}			}			if( SrvParams->armoraffectmana() )			{				int ratio = ( ( 100 + 50 ) / SrvParams->manarate() );				// 100 = Maximum skill (GM)				// 50 = int affects mana regen (%50)				int armorhandicap = ((Skills->GetAntiMagicalArmorDefence(pc) + 1) / SrvParams->manarate());				int charsmeditsecs = (1 + SrvParams->manarate() - ((((pc->skillValue(MEDITATION) + 1)/10) + ((pc->in() + 1) / 2)) / ratio));				if (pc->med())				{					pc->setRegen3( currenttime + ((armorhandicap + charsmeditsecs/2)* MY_CLOCKS_PER_SEC) );				}				else					pc->setRegen3( currenttime + ((armorhandicap + charsmeditsecs)* MY_CLOCKS_PER_SEC) );			}			else 				pc->setRegen3( currenttime + interval );			}			// end Mana regeneration			/* should be a temporal effect!		// only if not permanently hidden			if( ( pc->hidden() == 2 ) && ( pc->invistimeout() <= currenttime ) && !pc->isHiddenPermanently() )			{				pc->setHidden( 0 );				pc->setStealth(-1);				pc->resend( false );			}*/	}	// Check if the character died	if( pc->hp() <= 0 && !pc->dead() )		pc->kill();	if( pc->hp() > pc->st() )		pc->setHp( pc->st() );	if( pc->stm() > pc->effDex() )		pc->setStm( pc->effDex() );	if( pc->mn() > pc->in() )		pc->setMn( pc->in() );	// Now check if our Health, Stamina or Mana has changed	if( oldHealth != pc->hp() )		pc->updateHealth();	if( pc->socket() )	{		if( oldStamina != pc->stm() )			pc->socket()->updateStamina();		if( oldMana != pc->mn() )			pc->socket()->updateMana();	}}