if ( (pc->questType()==ESCORTQUEST) && (pc->ftarg == INVALID_SERIAL) ) { MsgBoardQuestEscortRemovePost( pc ); MsgBoardQuestEscortDelete( pc ); return; }   soundeffect2(pc, 0x01FE); pc->dead=true; Npcs->DeleteChar(pc);
MsgBoardQuestEscortRemovePost( pc ); MsgBoardQuestEscortDelete( pc );
void checkNPC(P_CHAR pc, unsigned int currenttime){	if (pc == NULL)		return;	if (pc->stablemaster_serial() != INVALID_SERIAL) return;	int pcalc;	char t[120];	Npcs->CheckAI( currenttime, pc );	Movement->NpcMovement( currenttime, pc );    setcharflag( pc );	if( !pc->dead && pc->swingtarg() == -1 )		Combat->DoCombat( pc, currenttime );	else if( !pc->dead && ( pc->swingtarg() >= 0 && pc->timeout <= currenttime ) )		Combat->CombatHitCheckLoS(pc,currenttime);	Magic->CheckFieldEffects2( currenttime, pc, 0 );	if( pc->shop )		restockNPC( currenttime, pc );	if( !pc->free )	{		if ((pc->disabled()>0)&&((pc->disabled()<=currenttime)||(overflow)))		{			pc->setDisabled(0);		}		if (pc->summontimer<=currenttime||(overflow))		{			if(pc->summontimer>0)			{				// Dupois - Added Dec 20, 1999				// QUEST expire check - after an Escort quest is created a timer is set				// so that the NPC will be deleted and removed from the game if it hangs around				// too long without every having its quest accepted by a player so we have to remove				// its posting from the message board before icing the NPC				// Only need to remove the post if the NPC does not have a follow target set				if ( (pc->questType()==ESCORTQUEST) && (pc->ftarg == INVALID_SERIAL) )				{					MsgBoardQuestEscortRemovePost( pc );					MsgBoardQuestEscortDelete( pc );					return;				}				// Dupois - End				soundeffect2(pc, 0x01FE);				pc->dead=true;				Npcs->DeleteChar(pc);				return;			}		}	}	// Character is not fleeing but reached the border	if( pc->npcWander != 5 && pc->hp < pc->st*pc->fleeat() / 100 )	{		pc->oldnpcWander = pc->npcWander;		pc->npcWander=5;		pc->setNextMoveTime();	}    // Character is fleeing and has regenerated	if( pc->npcWander == 5 && pc->hp > pc->st*pc->reattackat() / 100 )	{		pc->npcWander = pc->oldnpcWander;		pc->setNextMoveTime();		pc->oldnpcWander = 0;	}	// new poisoning code	if (pc->poisoned() && !(pc->isInvul()) )	{		if ((pc->poisontime()<=currenttime)||(overflow))		{			if (pc->poisonwearofftime()>currenttime) // lb, makes poison wear off pc's			{				switch (pc->poisoned())				{				case 1:					pc->setPoisontime(currenttime+(5*MY_CLOCKS_PER_SEC));					if ((pc->poisontxt()<=currenttime)||(overflow))					{						pc->setPoisontxt(currenttime+(10*MY_CLOCKS_PER_SEC));						sprintf(t,"* %s looks a bit nauseous *",pc->name.c_str());						pc->emotecolor = 0x0026;//buffer[s][4];						npcemoteall(pc,t,1);					}					pc->hp -= RandomNum(1,2);					updatestats(pc, 0);					break;				case 2:					pc->setPoisontime(currenttime+(4*MY_CLOCKS_PER_SEC));					if ((pc->poisontxt()<=currenttime)||(overflow))					{						pc->setPoisontxt(currenttime+(10*MY_CLOCKS_PER_SEC));						sprintf(t,"* %s looks disoriented and nauseous! *",pc->name.c_str());						pc->emotecolor = 0x0026; //buffer[s][4];						npcemoteall(pc,t,1);					}					pcalc = ( ( pc->hp * RandomNum(2,5) ) / 100) + RandomNum(0,2); // damage: 1..2..5% of hp's+ 1..2 constant					pc->hp -= pcalc;					updatestats(pc, 0);					break;				case 3:					pc->setPoisontime(currenttime+(3*MY_CLOCKS_PER_SEC));					if ((pc->poisontxt()<=currenttime)||(overflow))					{						pc->setPoisontxt(currenttime+(10*MY_CLOCKS_PER_SEC));						sprintf(t,"* %s is in severe pain! *",pc->name.c_str());						pc->emotecolor = 0x0026;//buffer[s][4];						npcemoteall(pc,t,1);					}					pcalc=( ( pc->hp * RandomNum(5,10) ) / 100 ) + RandomNum(1,3); // damage: 5..10% of hp's+ 1..2 constant					pc->hp -= pcalc;					updatestats(pc, 0);					break; // lb !!!				case 4:					pc->setPoisontime(currenttime+(3*MY_CLOCKS_PER_SEC));					if ((pc->poisontxt()<=currenttime)||(overflow))					{						pc->setPoisontxt(currenttime+(10*MY_CLOCKS_PER_SEC));						sprintf(t,"* %s looks extremely weak and is wrecked in pain! *",pc->name.c_str());						pc->emotecolor = 0x0026;//buffer[s][4];						npcemoteall(pc,t,1);					}					pcalc=( (pc->hp * RandomNum(10,15) ) / 100 ) + RandomNum(3,6); // damage:10 to 15% of hp's+ 3..6 constant, quite deadly <g>					pc->hp -= pcalc;					updatestats(pc, 0);					break;				default:					clConsole.send("ERROR: Fallout of switch statement without default. wolfpack.cpp, checkNPC()\n"); //Morrolan					pc->setPoisoned(0);					return;				}				if( pc->hp < 1 )				{					pc->kill();				}			} // end switch		} // end if poison-wear off-timer	} // end if poison-damage timer	if ((pc->poisonwearofftime()<=currenttime))	{		if ((pc->poisoned()))		{			pc->setPoisoned(0);			impowncreate(calcSocketFromChar(pc), pc, 1); // updating to blue stats-bar ...		}	}	//hunger code for npcs	if (SrvParams->hungerRate()>1 && (pc->hungertime()<=currenttime || overflow))	{		t[0] = '\0';		if (pc->hunger()) 			pc->setHunger( pc->hunger()-1 ); //Morrolan GMs and Counselors don't get hungry		if(pc->tamed() && pc->npcaitype() != 17)		{//if tamed let's display his hungry status			switch(pc->hunger())			{			case 6:			case 5:	break;			case 4:	sprintf(t,"* %s looks a little hungry *",pc->name.c_str());			break;			case 3:	sprintf(t,"* %s looks fairly hungry *",pc->name.c_str());			break;			case 2:	sprintf(t,"* %s looks extremely hungry *",pc->name.c_str());		break;			case 1:	sprintf(t,"* %s looks weak from starvation *",pc->name.c_str());	break;			case 0:				//maximum hunger - untame code - AntiChrist				//pet release code here				if(pc->tamed())				{					pc->ftarg = INVALID_SERIAL;					pc->npcWander=2;					pc->setTamed(false);					if(pc->ownserial!=-1) 						pc->SetOwnSerial(-1);					sprintf((char*)temp, "* %s appears to have decided that it is better off without a master *", pc->name.c_str());					npctalkall(pc, (char*)temp,0);					{						soundeffect2(pc, 0x01FE);						if(SrvParams->tamedDisappear()==1)						Npcs->DeleteChar(pc);					}				}				//sprintf(t,"* %s must eat very soon or he will die! *",pc->name);				break;			}			if(strlen(t))			{//display message ( if there's one				pc->emotecolor = 0x0026;//buffer[s][4];				npcemoteall(pc,t,1);			}		}//if tamed		pc->setHungerTime( currenttime+(SrvParams->hungerRate()*MY_CLOCKS_PER_SEC) );	}//if hungerrate>1}