while ( ((pi_j=ContainerSearch(pc_player->serial,&ci)) != NULL) && (++loopexit < MAXLOOPS) ) {
vecContainer.clear(); vecContainer = contsp.getData(pi_j->serial); for ( ci = 0; ci < vecContainer.size(); ci++) { pi_j = FindItemBySerial(vecContainer[ci]);
void deathstuff(int i){	int z, j=0, c, l, q, ele, corpsenum, p;	int serial,serial1,serhash;	char murderername[50]; //AntiChrist	char clearmsg[8];	int nType=0;	P_CHAR pc_player = MAKE_CHARREF_LR(i);	if (pc_player->dead || pc_player->npcaitype == 17 || pc_player->isInvul()) 		return;	if(pc_player->polymorph)	{		pc_player->id1=pc_player->xid1;		pc_player->id2=pc_player->xid2;		pc_player->polymorph=false;		teleport(i);	}	pc_player->xid1=pc_player->id1; // lb bugfix	pc_player->xid2=pc_player->id2;	pc_player->xskin = pc_player->skin;	pc_player->murdererSer = 0;	// Reset previous murderer serial # to zero	if (pc_player->attacker > -1) 		strcpy(murderername,chars[pc_player->attacker].name); 	else 		murderername[0]=0;	AllCharsIterator iter_char;	for (iter_char.Begin(); iter_char.GetData() != NULL; iter_char++)	{		P_CHAR pc_t = iter_char.GetData();		if (pc_t->targ == i && !pc_t->free)		{			if (pc_t->npcaitype==4) //LB change from 0x40 to 4			{				pc_t->summontimer=(uiCurrentTime+(MY_CLOCKS_PER_SEC*20));				pc_t->npcWander=2;				pc_t->setNextMoveTime();				npctalkall(DEREF_P_CHAR(pc_t),"Thou have suffered thy punishment, scoundrel.",0);			}			pc_t->targ=-1;			pc_t->timeout=0;			if (pc_t->attacker>-1 && pc_t->attacker<cmem)			{				chars[pc_t->attacker].resetAttackFirst();				chars[pc_t->attacker].attacker=-1; // lb crashfix			}			pc_t->attacker=-1;			pc_t->resetAttackFirst();			if (pc_t->npcaitype==4 || pc_t->npcaitype==9) // Ripper...so non human npcs disapear if killed by guards.			{				if (pc_player->isNpc() && !pc_player->isHuman())					Npcs->DeleteChar(i);			}			if(pc_t->isPlayer() && !pc_t->inGuardedArea())			{//AntiChrist				Karma(DEREF_P_CHAR(pc_t),i,(0-(pc_player->karma)));				Fame(DEREF_P_CHAR(pc_t),pc_player->fame);				//murder count \/				if ((pc_player->isPlayer())&&(pc_t->isPlayer()))//Player vs Player				{					if(pc_player->isInnocent() && Guilds->Compare(DEREF_P_CHAR(pc_t),i)==0 && pc_t->attackfirst == 1)					{						// Ask the victim if they want to place a bounty on the murderer (need gump to be added to						// BountyAskViction() routine to make this a little nicer ) - no time right now						// BountyAskVictim( pc_player->serial, pc_t->serial );						pc_player->murdererSer = pc_t->serial;						pc_t->kills++;						sprintf((char*)temp, "You have killed %i innocent people.", pc_t->kills);						UOXSOCKET sock = calcSocketFromChar(pc_t);						sysmessage(sock, (char*)temp);						if (pc_t->kills==(unsigned)repsys.maxkills)							sysmessage(sock, "You are now a murderer!");						setcharflag(pc_t);//AntiChrist					}					if (SrvParms->pvp_log)					{						sprintf((char*)temp,"%s was killed by %s!\n",pc_player->name,pc_t->name);						savelog((char*)temp,"PvP.log");					}				}			}//if !npc			if (pc_t->isNpc() && pc_t->war) npcToggleCombat(DEREF_P_CHAR(pc_t)); // ripper		}	}	p=packitem(i);	z=calcSocketFromChar(i);	if (z!=-1) j=unmounthorse(z);	int ci=0,loopexit=0;	P_ITEM pi_j;		while ( ((pi_j=ContainerSearch(pc_player->serial,&ci)) != NULL) && (++loopexit < MAXLOOPS) )	{		if (pi_j->type==1 && pi_j->pos.x==26 && pi_j->pos.y==0 &&			pi_j->pos.z==0 && pi_j->id()==0x1E5E )		{			endtrade(pi_j->ser1, pi_j->ser2, pi_j->ser3, pi_j->ser4);		}	}	ele=0;	if(pc_player->isPlayer()) pc_player->id1=0x01; // Character is a ghost	if (pc_player->xid2==0x91)	{		pc_player->id2=0x93;	// Male or Female	}	else	{		pc_player->id2=0x92;	}	PlayDeathSound(i);	pc_player->skin = 0x0000; // Undyed	pc_player->dead = true;	// Dead	pc_player->hp = 0;		// With no hp left	pc_player->poisoned = 0;	pc_player->poison = 0;	//AntiChrist#ifdef DEBUG	clConsole.send("%s killed by %s.\n",pc_player->name,chars[pc_player->attacker].name);#endif	// Make the corpse	sprintf((char*)temp,"corpse of %s",pc_player->name);	const P_ITEM pi_c = Items->SpawnItem(i, 1, (char*)temp, 0, 0x2006, pc_player->xskin, 0);	if(pi_c==NULL) return;//AntiChrist to preview crashes	// Corpse highlighting.. Ripper	if(pc_player->isPlayer())	{	    if (pc_player->isInnocent()) pi_c->more2=1;	    else if (pc_player->isCriminal()) pi_c->more2=2;	    else if (pc_player->isMurderer()) pi_c->more2=3;        pi_c->ownserial=pc_player->serial;	}// end corpse highlighting.    if(pc_player->isNpc() || pc_player->isPlayer())	ele=pi_c->amount=(pc_player->xid1<<8)+pc_player->xid2; // Amount == corpse type	pi_c->morey=ishuman(i);//is human?? - AntiChrist	pi_c->carve=pc_player->carve;//store carve section - AntiChrist	strcpy(pi_c->name2,pc_player->name);	pi_c->type=1;	pi_c->MoveTo(pc_player->pos.x,pc_player->pos.y,pc_player->pos.z);	pi_c->more1=nType;	pi_c->dir=pc_player->dir;	pi_c->corpse=1;	pi_c->startDecay();	corpsenum = DEREF_P_ITEM(pi_c);		//JustMichael -- If it was a player set the ownerserial to the player's	if( pc_player->isPlayer() )	{		pi_c->SetOwnSerial(pc_player->serial);		pi_c->more4 = char( SrvParms->playercorpsedecaymultiplier&0xff ); // how many times longer for the player's corpse to decay	}	//AntiChrist -- stores the time and the murderer's name	strcpy(pi_c->murderer,murderername);	pi_c->murdertime=uiCurrentTime;	// Put objects on corpse	serial=pc_player->serial;	serhash=serial%HASHMAX;	ci=0,loopexit=0;//	P_ITEM pi_j;	while ( ((pi_j=ContainerSearch(pc_player->serial,&ci)) != NULL) && (++loopexit < MAXLOOPS) )	{		int j=DEREF_P_ITEM(pi_j);		// for BONUS ITEMS - remove bonus		pc_player->removeItemBonus(pi_j);		if ((pi_j->trigon==1) && (pi_j->layer >0) && (pi_j->layer!=15) && (pi_j->layer<19))// -Frazurbluu- Trigger Type 2 is my new trigger type *-		{			triggerwitem(z, DEREF_P_ITEM(pi_j), 1); // trigger is fired when item destroyed		}		if ((pi_j->contserial==serial) && (pi_j->layer!=0x0B) && (pi_j->layer!=0x10))		{//Let's check all items, except HAIRS and BEARD			// Ripper...so order/chaos shields disappear when on corpse backpack.			if( pi_j->id1 == 0x1B && ( pi_j->id2 == 0xC3 || pi_j->id2 == 0xC4 ) )			{				soundeffect2(i, 0x01, 0xFE);				staticeffect(i, 0x37, 0x2A, 0x09, 0x06);				Items->DeleItem( pi_j );			}			if (pi_j->type==1 && pi_j->layer!=0x1A && pi_j->layer!=0x1B &&				pi_j->layer!=0x1C && pi_j->layer!=0x1D)			{//if this is a pack but it's not a VendorContainer(like the buy container) or a bankbox				serial1=pi_j->serial;				int ci1=0;				int loopexit1=0;				P_ITEM pi_k;				while ( ((pi_k=ContainerSearch(serial1,&ci1)) != NULL) && (++loopexit1 < MAXLOOPS) )				{//let's search for all the items in the pack ( now that we now this' the character's backpack )					if ( (!(pi_k->priv&0x02)) && (pi_k->type!=9))//Morrolan spellbook disappearance fix					{//put the item in the corpse only of we're sure it's not a newbie item or a spellbook						pi_k->layer=0;						setserial(DEREF_P_ITEM(pi_k), corpsenum, 1);						pi_k->SetRandPosInCont(pi_c);						// Ripper...so order/chaos shields disappear when on corpse backpack.						if( pi_k->id1 == 0x1B && ( pi_k->id2 == 0xC3 || pi_k->id2 == 0xC4 ) )						{							soundeffect2(i, 0x01, 0xFE);							staticeffect(i, 0x37, 0x2A, 0x09, 0x06);							Items->DeleItem( pi_k );						}						RefreshItem(pi_k);//AntiChrist					}				}			}			else if (pi_j->layer==0x1A)			{//else if it's a NPC vendor special container				clearmsg[0]=0x3B;				clearmsg[1]=0x00;				clearmsg[2]=0x08;				clearmsg[3]=pc_player->ser1;				clearmsg[4]=pc_player->ser2;				clearmsg[5]=pc_player->ser3;				clearmsg[6]=pc_player->ser4;				clearmsg[7]=0x00;				for (l=0;l<now;l++)					if (perm[l] && inrange1p(i, currchar[l])) Xsend(l, clearmsg, 8);			}//else if it's a normal item but ( not newbie and not bank items )			else if ((!(pi_j->priv&0x02)) && pi_j->layer!=0x1D)			{				if (j!=p)				{					pi_j->SetContSerial(items[corpsenum].serial);				}			}			else if(p!=-1 && pi_j->layer!=0x1D)			{//else if the item is newbie put it into char's backpack				if(j!=p)				{					pi_j->layer=0;					pi_j->SetContSerial(items[p].serial);				}			}			if ((pi_j->layer==0x15)&&(pc_player->shop==0)) pi_j->layer=0x1A;			pi_j->pos.x = RandomNum(20, 70);			pi_j->pos.y = RandomNum(85, 160);			pi_j->pos.z=9;			SndRemoveitem(pi_j->serial);			RefreshItem(pi_j);//AntiChrist		}		if ((pi_j->contserial==serial)&& ((pi_j->layer==0x0B)||(pi_j->layer==0x10)))		{			strcpy(pi_j->name,"Hair/Beard");			pi_j->pos.x=0x47;			pi_j->pos.y=0x93;			pi_j->pos.z=0;		}	}	if (pc_player->isPlayer())	{		strcpy((char*)temp,"a Death Shroud");		c=Items->SpawnItem(z, i, 1, (char*)temp, 0, 0x20, 0x4E, 0, 0, 0, 0);		if(c==-1) return;//AntiChrist to preview crashes		const P_ITEM pi_c=MAKE_ITEMREF_LR(c);	// on error return		pc_player->robe = pi_c->serial; 		pi_c->SetContSerial(chars[i].serial);		pi_c->layer=0x16;		pi_c->def=1;	}	if (SrvParms->showdeathanim) deathaction(i, corpsenum);	if (pc_player->account!=-1) // LB	{				teleport(i);			q = calcSocketFromChar(i);		if (q>-1) deathmenu(q);	}//	if ((ele==13)||(ele==15)||(ele==16)||(ele==574))//-Frazurbluu, we're gonna remove this strange little function :)// it becomes OSI exact with it removed! -Fraz- I DO NEED TO CHECK ENERGY VORTEXS!!!!!!!!!!!!!!!!!!!!!!//	{		// *** This looks very strange to me! Turning the shroud into a backpack ??? Duke 9.8.2k ***//		strcpy(pi_c->name,"a backpack");//		pi_c->color1=0;//		pi_c->color2=0;//		pi_c->amount = 1;//		pi_c->setId(0x09B2);//		pi_c->corpse=0; //	}	RefreshItem(corpsenum);//AntiChrist	if (pc_player->isNpc()) Npcs->DeleteChar(i);	if(ele==65535) Items->DeleItem(corpsenum);}