setserial(n,s,4);
items[n].SetContSerial(chars[s].serial);
void monstergate(int s, int x){	int tmp, n, z, lovalue, hivalue, mypack, retitem;	int storeval, shoppack1, shoppack2, shoppack3;	char sect[512];	P_CHAR pc_s = MAKE_CHARREF_LR(s);	if (pc_s->isNpc()) return;	mypack=-1;	retitem=-1;	storeval=-1;	shoppack1=-1;	shoppack2=-1;	shoppack3=-1;	sprintf(sect, "NPC %i", x);	Script *pScpBase=i_scripts[npc_script];	Script *pScp=pScpBase->Select(sect,custom_npc_script);	if (!pScp) return;	pc_s->title[0] = 0;	for(z=0;z<itemcount;z++)	{		if (pc_s->Wears(&items[z]) &&			items[z].layer!=0x15 && items[z].layer!=0x1D &&			items[z].layer!=0x10 && items[z].layer!=0x0B && (items[z].free==0))		{			if (mypack==-1)			{				mypack=packitem(s);							}			if (mypack==-1)			{				scpMark m=pScp->Suspend();				pc_s->packitem=n=Items->SpawnItem(calcSocketFromChar(s),s,1,"#",0,0x0E,0x75,0,0,0,0);				if(n==-1) return;//AntiChrist to preview crashes				pScp->Resume(m);				setserial(n,s,4);				items[n].layer=0x15;				items[n].type=1;				items[n].dye=1;				mypack=n;								retitem=n;			}			items[z].pos.x = RandomNum(50, 130);			items[z].pos.y = RandomNum(50, 130);			items[z].pos.z=9;			items[z].SetContSerial(items[mypack].serial);			items[z].layer=0x00;			SndRemoveitem(items[z].serial);			RefreshItem(z);//AntiChrist		}		else if (pc_s->Wears(&items[z]) &&			(items[z].layer==0x0B || items[z].layer==0x10))		{			Items->DeleItem(z);		}	}	int loopexit=0;	do	{		pScp->NextLineSplitted();		if (script1[0]!='}')		{			if (!(strcmp("NAME",(char*)script1)))			{				strcpy(pc_s->name,(char*)script2);			}			if (!(strcmp("NAMELIST", (char*)script1)))			{				scpMark m=pScp->Suspend();				setrandomname(s,(char*)script2);				pScp->Resume(m);				strcpy((char*)script1, "DUMMY"); // To prevent accidental exit of loop.			}			if (!(strcmp("TITLE",(char*)script1))) strcpy(pc_s->title,(char*)script2);			if (!(strcmp("KARMA",(char*)script1))) pc_s->karma=str2num(script2);			if (!(strcmp("FAME",(char*)script1))) pc_s->fame=str2num(script2);			if (!(strcmp("ID",(char*)script1)))			{				tmp=hstr2num(script2);				pc_s->id1=tmp>>8;				pc_s->id2=tmp%256;				pc_s->xid1=pc_s->id1;				pc_s->xid2=pc_s->id2;			}			if (!(strcmp("SKIN",(char*)script1)))			{				pc_s->skin = pc_s->xskin = hstr2num(script2);			}			if (!(strcmp("GOLD", (char*)script1)))			{				scpMark m=pScp->Suspend();				retitem=n=Items->SpawnItem(calcSocketFromChar(s),s,1,"#",1,0x0E,0xED,0,0,1,0);				if(n==-1) return;//AntiChrist to preview crashes				pScp->Resume(m);				strcpy((char*)script1, "DUMMY"); // To prevent accidental exit of loop.				gettokennum((char*)script2, 0);				lovalue=str2num(gettokenstr);				gettokennum((char*)script2, 1);				hivalue=str2num(gettokenstr);				if (hivalue==0)				{					if (lovalue/2!=0) items[n].amount=lovalue/2 + (rand()%(lovalue/2));					else items[n].amount=lovalue/2;				}				else				{					if ((hivalue-lovalue)!=0) items[n].amount=lovalue + (rand()%(hivalue-lovalue));					else items[n].amount=lovalue;				}			}			if (!(strcmp("LOOT",(char*)script1)))			{				scpMark m=pScp->Suspend();				retitem=Npcs->AddRandomLoot(mypack, (char*)script2);				pScp->Resume(m);				strcpy((char*)script1, "DUMMY"); // Prevents unexpected matchups...			}			if (!(strcmp("ITEM",(char*)script1)))			{				storeval=str2num(script2);				scpMark m=pScp->Suspend();				retitem=Targ->AddMenuTarget(-1, 0, storeval);				pScp->Resume(m);				if (retitem>-1)				{					setserial(retitem,s,4);					if (items[retitem].layer==0)					{						clConsole.send("Warning: Bad NPC Script %d with problem item %d executed!\n", x, storeval);					}				}				strcpy((char*)script1, "DUMMY"); // Prevents unexpected matchups...			}			if (!(strcmp("PACKITEM",(char*)script1)))			{				storeval=str2num(script2);				scpMark m=pScp->Suspend();				retitem=Targ->AddMenuTarget(-1, 0, storeval);				pScp->Resume(m);				if (retitem >-1)				{					setserial(retitem,mypack,1);					items[retitem].pos.x=50+(rand()%80);					items[retitem].pos.y=50+(rand()%80);					items[retitem].pos.z=9;				}				strcpy((char*)script1, "DUMMY"); // Prevents unexpected matchups...			}			if (!(strcmp("COLOR",(char*)script1)))			{				if (retitem>-1)				{					items[retitem].color1=(hstr2num(script2))>>8;					items[retitem].color2=(hstr2num(script2))%256;				}			}			if (!(strcmp("POISON",(char*)script1))) pc_s->poison=str2num(script2);			//--------------------- NEW STAT & SKILL FORMAT ----------------			//Handle Stats			if ((!(strcmp("STR",(char*)script1)))||(!(strcmp("STRENGTH",(char*)script1))))			{				pc_s->st = getstatskillvalue((char*)script2);				pc_s->st2 = pc_s->st;				pc_s->hp = pc_s->st;			}			if ((!(strcmp("DEX",(char*)script1)))||(!(strcmp("DEXTERITY",(char*)script1))))			{				pc_s->setDex(getstatskillvalue((char*)script2));				pc_s->stm = pc_s->realDex();			}			if ((!(strcmp("INT",(char*)script1)))||(!(strcmp("INTELLIGENCE",(char*)script1))))			{				pc_s->in = getstatskillvalue((char*)script2);				pc_s->in2 = pc_s->in;				pc_s->mn = pc_s->in;			}			//Done Handling Stats			//Handle Skills			if ((!(strcmp("ALCHEMY",(char*)script1)))||(!(strcmp("SKILL0",(char*)script1))))				pc_s->baseskill[ALCHEMY] = getstatskillvalue((char*)script2);			if ((!(strcmp("ANATOMY",(char*)script1)))||(!(strcmp("SKILL1",(char*)script1))))				pc_s->baseskill[ANATOMY] = getstatskillvalue((char*)script2);			if ((!(strcmp("ANIMALLORE",(char*)script1)))||(!(strcmp("SKILL2",(char*)script1))))				pc_s->baseskill[ANIMALLORE] = getstatskillvalue((char*)script2);			if ((!(strcmp("ITEMID",(char*)script1)))||(!(strcmp("SKILL3",(char*)script1))))				pc_s->baseskill[ITEMID] = getstatskillvalue((char*)script2);			if ((!(strcmp("ARMSLORE",(char*)script1)))||(!(strcmp("SKILL4",(char*)script1))))				pc_s->baseskill[ARMSLORE] = getstatskillvalue((char*)script2);			if ((!(strcmp("PARRYING",(char*)script1)))||(!(strcmp("SKILL5",(char*)script1))))				pc_s->baseskill[PARRYING] = getstatskillvalue((char*)script2);			if ((!(strcmp("BEGGING",(char*)script1)))||(!(strcmp("SKILL6",(char*)script1))))				pc_s->baseskill[BEGGING] = getstatskillvalue((char*)script2);			if ((!(strcmp("BLACKSMITHING",(char*)script1)))||(!(strcmp("SKILL7",(char*)script1))))				pc_s->baseskill[BLACKSMITHING] = getstatskillvalue((char*)script2);			if ((!(strcmp("BOWCRAFT",(char*)script1)))||(!(strcmp("SKILL8",(char*)script1))))				pc_s->baseskill[BOWCRAFT] = getstatskillvalue((char*)script2);			if ((!(strcmp("PEACEMAKING",(char*)script1)))||(!(strcmp("SKILL9",(char*)script1))))				pc_s->baseskill[PEACEMAKING] = getstatskillvalue((char*)script2);			if ((!(strcmp("CAMPING",(char*)script1)))||(!(strcmp("SKILL10",(char*)script1))))				pc_s->baseskill[CAMPING] = getstatskillvalue((char*)script2);			if ((!(strcmp("CARPENTRY",(char*)script1)))||(!(strcmp("SKILL11",(char*)script1))))				pc_s->baseskill[CARPENTRY] = getstatskillvalue((char*)script2);			if ((!(strcmp("CARTOGRAPHY",(char*)script1)))||(!(strcmp("SKILL12",(char*)script1))))				pc_s->baseskill[CARTOGRAPHY] = getstatskillvalue((char*)script2);			if ((!(strcmp("COOKING",(char*)script1)))||(!(strcmp("SKILL13",(char*)script1))))				pc_s->baseskill[COOKING] = getstatskillvalue((char*)script2);			if ((!(strcmp("DETECTINGHIDDEN",(char*)script1)))||(!(strcmp("SKILL14",(char*)script1))))				pc_s->baseskill[DETECTINGHIDDEN] = getstatskillvalue((char*)script2);			if ((!(strcmp("ENTICEMENT",(char*)script1)))||(!(strcmp("SKILL15",(char*)script1))))				pc_s->baseskill[ENTICEMENT] = getstatskillvalue((char*)script2);			if ((!(strcmp("EVALUATINGINTEL",(char*)script1)))||(!(strcmp("SKILL16",(char*)script1))))				pc_s->baseskill[EVALUATINGINTEL] = getstatskillvalue((char*)script2);			if ((!(strcmp("HEALING",(char*)script1)))||(!(strcmp("SKILL17",(char*)script1))))				pc_s->baseskill[HEALING] = getstatskillvalue((char*)script2);			if ((!(strcmp("FISHING",(char*)script1)))||(!(strcmp("SKILL18",(char*)script1))))				pc_s->baseskill[FISHING] = getstatskillvalue((char*)script2);			if ((!(strcmp("FORENSICS",(char*)script1)))||(!(strcmp("SKILL19",(char*)script1))))				pc_s->baseskill[FORENSICS] = getstatskillvalue((char*)script2);			if ((!(strcmp("HERDING",(char*)script1)))||(!(strcmp("SKILL20",(char*)script1))))				pc_s->baseskill[HERDING] = getstatskillvalue((char*)script2);			if ((!(strcmp("HIDING",(char*)script1)))||(!(strcmp("SKILL21",(char*)script1))))				pc_s->baseskill[HIDING] = getstatskillvalue((char*)script2);			if ((!(strcmp("PROVOCATION",(char*)script1)))||(!(strcmp("SKILL22",(char*)script1))))				pc_s->baseskill[PROVOCATION] = getstatskillvalue((char*)script2);			if ((!(strcmp("INSCRIPTION",(char*)script1)))||(!(strcmp("SKILL23",(char*)script1))))				pc_s->baseskill[INSCRIPTION] = getstatskillvalue((char*)script2);			if ((!(strcmp("LOCKPICKING",(char*)script1)))||(!(strcmp("SKILL24",(char*)script1))))				pc_s->baseskill[LOCKPICKING] = getstatskillvalue((char*)script2);			if ((!(strcmp("MAGERY",(char*)script1)))||(!(strcmp("SKILL25",(char*)script1))))				pc_s->baseskill[MAGERY] = getstatskillvalue((char*)script2);			if ((!(strcmp("MAGICRESISTANCE",(char*)script1)))||(!(strcmp("RESIST",(char*)script1)))||(!(strcmp("SKILL26",(char*)script1))))				pc_s->baseskill[MAGICRESISTANCE] = getstatskillvalue((char*)script2);			if ((!(strcmp("TACTICS",(char*)script1)))||(!(strcmp("SKILL27",(char*)script1))))				pc_s->baseskill[TACTICS] = getstatskillvalue((char*)script2);			if ((!(strcmp("SNOOPING",(char*)script1)))||(!(strcmp("SKILL28",(char*)script1))))				pc_s->baseskill[SNOOPING] = getstatskillvalue((char*)script2);			if ((!(strcmp("MUSICIANSHIP",(char*)script1)))||(!(strcmp("SKILL29",(char*)script1))))				pc_s->baseskill[MUSICIANSHIP] = getstatskillvalue((char*)script2);			if ((!(strcmp("POISONING",(char*)script1)))||(!(strcmp("SKILL30",(char*)script1))))				pc_s->baseskill[POISONING] = getstatskillvalue((char*)script2);			if ((!(strcmp("ARCHERY",(char*)script1)))||(!(strcmp("SKILL31",(char*)script1))))				pc_s->baseskill[ARCHERY] = getstatskillvalue((char*)script2);			if ((!(strcmp("SPIRITSPEAK",(char*)script1)))||(!(strcmp("SKILL32",(char*)script1))))				pc_s->baseskill[SPIRITSPEAK] = getstatskillvalue((char*)script2);			if ((!(strcmp("STEALING",(char*)script1)))||(!(strcmp("SKILL33",(char*)script1))))				pc_s->baseskill[STEALING] = getstatskillvalue((char*)script2);			if ((!(strcmp("TAILORING",(char*)script1)))||(!(strcmp("SKILL34",(char*)script1))))				pc_s->baseskill[TAILORING] = getstatskillvalue((char*)script2);			// Taming skill disabled for now for npcs - as they wont be training people			// nor taming things on their own for a while. - Eventually.. when they can			// train players how the taming skill, they themselves will need it. Then			// it will require use of the "TOTAME" property outlined above.			// if ((!(strcmp("TAMING",script1)))||(!(strcmp("SKILL35",script1))))			//		pc_s->baseskill[TAMING] = getstatskillvalue(script2);			if ((!(strcmp("TASTEID",(char*)script1)))||(!(strcmp("SKILL36",(char*)script1))))				pc_s->baseskill[TASTEID] = getstatskillvalue((char*)script2);			if ((!(strcmp("TINKERING",(char*)script1)))||(!(strcmp("SKILL37",(char*)script1))))				pc_s->baseskill[TINKERING] = getstatskillvalue((char*)script2);			if ((!(strcmp("TRACKING",(char*)script1)))||(!(strcmp("SKILL38",(char*)script1))))				pc_s->baseskill[TRACKING] = getstatskillvalue((char*)script2);			if ((!(strcmp("VETERINARY",(char*)script1)))||(!(strcmp("SKILL39",(char*)script1))))				pc_s->baseskill[VETERINARY] = getstatskillvalue((char*)script2);			if ((!(strcmp("SWORDSMANSHIP",(char*)script1)))||(!(strcmp("SKILL40",(char*)script1))))				pc_s->baseskill[SWORDSMANSHIP] = getstatskillvalue((char*)script2);			if ((!(strcmp("MACEFIGHTING",(char*)script1)))||(!(strcmp("SKILL41",(char*)script1))))				pc_s->baseskill[MACEFIGHTING] = getstatskillvalue((char*)script2);			if ((!(strcmp("FENCING",(char*)script1)))||(!(strcmp("SKILL42",(char*)script1))))				pc_s->baseskill[FENCING] = getstatskillvalue((char*)script2);			if ((!(strcmp("WRESTLING",(char*)script1)))||(!(strcmp("SKILL43",(char*)script1))))				pc_s->baseskill[WRESTLING] = getstatskillvalue((char*)script2);			if ((!(strcmp("LUMBERJACKING",(char*)script1)))||(!(strcmp("SKILL44",(char*)script1))))				pc_s->baseskill[LUMBERJACKING] = getstatskillvalue((char*)script2);			if ((!(strcmp("MINING",(char*)script1)))||(!(strcmp("SKILL45",(char*)script1))))				pc_s->baseskill[MINING] = getstatskillvalue((char*)script2);			// lb, new skills			if ((!(strcmp("MEDITATION",(char*)script1)))||(!(strcmp("SKILL46",(char*)script1))))				pc_s->baseskill[MEDITATION] = getstatskillvalue((char*)script2);			if ((!(strcmp("STEALTH",(char*)script1)))||(!(strcmp("SKILL47",(char*)script1))))				pc_s->baseskill[STEALTH] = getstatskillvalue((char*)script2);			if ((!(strcmp("REMOVETRAPS",(char*)script1)))||(!(strcmp("SKILL48",(char*)script1))))				pc_s->baseskill[REMOVETRAPS] = getstatskillvalue((char*)script2);			//Done Handling Skills			//Handle Extras			if ((!(strcmp("DAMAGE",(char*)script1)))||(!(strcmp("ATT",(char*)script1))))			{				gettokennum((char*)script2, 0);				lovalue=str2num(gettokenstr);				gettokennum((char*)script2, 1);				hivalue=str2num(gettokenstr);				pc_s->lodamage = lovalue;				pc_s->hidamage = lovalue;				if(hivalue) pc_s->hidamage = hivalue;			}			if (!(strcmp("DEF",(char*)script1))) pc_s->def = getstatskillvalue((char*)script2);			//Done Handling Extras			//Handle Obsolete Stuff			if (!(strcmp("LODAMAGE",(char*)script1))) pc_s->lodamage=str2num(script2);			if (!(strcmp("HIDAMAGE",(char*)script1))) pc_s->hidamage=str2num(script2);			if (!(strcmp("SKILL", (char*)script1)))			{				gettokennum((char*)script2, 0);				z=str2num(gettokenstr);				gettokennum((char*)script2, 1);				pc_s->baseskill[z]=str2num(gettokenstr);			}			//Done Handling Obsolete Stuff	}	//--------------- DONE NEW STAT & SKILL FORMAT --------------------- } while ( (script1[0]!='}') && (++loopexit < MAXLOOPS) ); pScp->Close();  //Now find real 'skill' based on 'baseskill' (stat modifiers) for(z=0;z<TRUESKILLS;z++) {	 Skills->updateSkillLevel(s,z); } updatechar(s); staticeffect(s, 0x37, 0x3A, 0, 15); soundeffect2(s, 0x01, 0xE9);}