deathstuff(currchar[ts]);
deathstuff(DEREF_P_CHAR(pc_ts));
void triggernpc(UOXSOCKET ts, int ti, int ttype) // Changed by Magius(CHE) {	char sect[512], effect[29];	signed int j;	int p, c;	unsigned int i;	int itemnum=-1;	int npcnum=-1;	int needitem=-1;	long int pos;	char fmsg[512];		// Added by Magius(CHE) 	int evti=-1, tl;	tile_st tile;	char tempname2[512], tempname3[512], buff[512], dismsg[512], tempstr[512], cmsg[512];	float total;	char clr1, clr2;	char memcolor1, memcolor2;	int coloring=-1, trig=-1, loopexit = 0;	tempname2[0] = 0;	buff[0] = 0;	dismsg[0] = 0;	tempstr[0] = 0;	cmsg[0] = 0;	fmsg[0] = 0;		if (ts < 0)		return; // Magius crash fix	P_CHAR pc_ts = MAKE_CHARREF_LR(currchar[ts]);		if (ttype == 1)	{		openscript("ntrigrs.scp");		sprintf(sect, "TRG %i", chars[ti].trigger);		if (ti>-1)			trig = chars[ti].trigger;		if (!i_scripts[ntrigger_script]->find(sect))		{			closescript();			return;		}	}	else		{		openscript("wtrigrs.scp");		sprintf(buff, "x%x%x", buffer[ts][0x11], buffer[ts][0x12]);		if (!i_scripts[wtrigger_script]->isin(buff))		{			strcpy(sect, "You cant think of a way to use that.");			sysmessage(ts, sect);			closescript();			return;		}	}	if (chars[ti].disabled>uiCurrentTime) // Added by Magius(CHE) 	{		if (!chars[ti].disabledmsg[0] == 0x0)			strcpy((char*)temp, chars[ti].disabledmsg);		else 			strcpy((char*)temp, "You cant work now! Wait more time!");		sysmessage(ts, (char*)temp);		closescript();		return;	}	do	{		read2();		if (script1[0] != '}')		{			switch (script1[0])			{				case 'A':					if (!(strcmp("ACT", (char*)script1)))  // Make player perform an action					{						cline = &script2[0];						splitline();						action(ts, hexnumber(0));					}					break;				case 'C':					if (!(strcmp("CSKL", (char*)script1)))  // Make a check on the players skill -- Rewrite by Magius(CHE) 					{						// Magius(CHE) 						cline = &script2[0];						splitline();						p = makenumber(0);						j = makenumber(1);						// End Magius(CHE) 												i = (rand()%1000) + 1;						// Taur 69.02 added to get some chance of						// skill gain on failure						unsigned int skill = p; // Magius(CHE) 						unsigned int baseskill = pc_ts->baseskill[skill];						if (i > baseskill)						{							Skills->AdvanceSkill(currchar[ts], skill, 0);							Skills->updateSkillLevel(currchar[ts], skill);							updateskill(ts, skill);							if (strlen(fmsg))								sysmessage(ts, fmsg); // by Magius(CHE) 							else 							{								strcpy((char*)temp, "You fail in your attempt..."); // by Magius(CHE) 								sysmessage(ts, (char*)temp); // by Magius(CHE) 							}							closescript();							return;						} // Taur end 69.02 change						if (j>0)						{							// Magius(CHE) 							closescript();							triggernpc(ts, ti, 1);							return;						}					}					break;				case 'D':					if (!(strcmp("DEX", (char*)script1)))  // Do math on players dexterity					{						j = str2num(script2);						if (j < 0)						{							sysmessage(ts, "You are getting clumsier!");						}						else 						{							sysmessage(ts, "You are getting more agile!");						}						pc_ts->chgRealDex(j);					}					else if (!(strcmp("DISABLE", (char*)script1)))  // Disable NPC for n seconds					{						if (ti>-1)						{							chars[ti].disabled = (uiCurrentTime +(MY_CLOCKS_PER_SEC*str2num(script2)));							strcpy(chars[ti].disabledmsg, dismsg); // Added by Magius(CHE) 						}					}					else if (!(strcmp("DISABLEMSG", (char*)script1)))  // Disable NPC Message --- by Magius(CHE) 					{						strcpy(dismsg, (char*)script2);					}					break;				case 'E':					if (!(strcmp("EVDUR", (char*)script1)))  // Math on Evoked item HP ---- Rewrite by Magius(CHE) 					{						cline = &script2[0];						splitline();						j = makenumber(0);						p = makenumber(1);						if (p <= 0)							p = 100;						if (evti>-1)						{							c = items[evti].hp;							if (items[evti].maxhp>0)							{								if ((rand()%(100)) + 1 <= p)								{									if ((c >= items[evti].maxhp) &&(j>0))									{										sysmessage(ts, "Your %s is already totally repaired!", tempname2);									}									items[evti].hp += j;									if (items[evti].hp >= items[evti].maxhp)										items[evti].hp = items[evti].maxhp;									if (items[evti].hp - c>0)									{										if (strlen(cmsg))											sysmessage(ts, cmsg);										else 										{											total = (float) items[evti].hp/items[evti].maxhp;											sysmessage(ts, "Your %s is now repaired! [%.1f%%]", tempname2, total*100);										}									}									else if (items[evti].hp - c < 0)									{										if (strlen(fmsg))											sysmessage(ts, fmsg);										else 										{											sysmessage(ts, "Your %s appears to be more ruined than before!", tempname2);										}									}									if (items[evti].hp <= 0)									{										sysmessage(ts, "Your %s was too old and it has been destroyed!", tempname2);										if (items[evti].amount>1)											items[evti].amount--;										else 											Items->DeleItem(evti);									}								}							}							else 							{								sysmessage(ts, "You can't repair %s !", tempname2);							}						}					}					else if (!(strcmp("EMT", (char*)script1)))  // Player says something when trigger is activated -- Changed by Magius(CHE) 					{						strcpy(sect, (char*)script2);						for (i = 0; i < now; i++)						{							if (inrange1p(currchar[ts], currchar[i]) && perm[i])							{								tl = 44 + strlen(sect) + 1;								talk[1] = tl >> 8;								talk[2] = tl%256;								talk[3] = pc_ts->ser1;								talk[4] = pc_ts->ser2;								talk[5] = pc_ts->ser3;								talk[6] = pc_ts->ser4;								talk[7] = pc_ts->id1;								talk[8] = pc_ts->id2;								talk[9] = 0; // Type								ShortToCharPtr(pc_ts->saycolor, &talk[10]);								talk[12] = 0;								talk[13] = pc_ts->fonttype;								Xsend(i, talk, 14);								Xsend(i, pc_ts->name, 30);								Xsend(i, sect, strlen(sect) + 1);							}						}					}					else if (!(strcmp("EVMAXDUR", (char*)script1)))  // Math on Evoked item MAXHP ---- Rewrite by Magius(CHE) 					{						cline = &script2[0];						splitline();						j = makenumber(0);						p = makenumber(1);						if (p <= 0)							p = 100;						if (evti>-1)						{							if (items[evti].maxhp>0)							{								if ((rand()%(100)) + 1 <= p)								{									items[evti].maxhp += j; // Magius(CHE) 									if (items[evti].hp >= items[evti].maxhp)										items[evti].hp = items[evti].maxhp;									if (str2num(script2) >= 0)									{										if (strlen(cmsg))											sysmessage(ts, cmsg);										else 										{											sysmessage(ts, "You increased the maximum durability of your %s !", tempname2);										}									}									else 									{										if (strlen(fmsg))											sysmessage(ts, fmsg);										else 										{											sysmessage(ts, "Your %s appears to be not resistant as before!", tempname2);										}									}									if (items[evti].maxhp <= 0)									{										sysmessage(ts, "Your %s was too old and it has been destroyed!", tempname2);										if (items[evti].amount>1)											items[evti].amount--;										else 											Items->DeleItem(evti);									}								}							}							else 							{								sysmessage(ts, "You can't increase durability of %s !", tempname2);							}						}					}					break;					case 'F':						if (!(strcmp("FAME", (char*)script1)))  // Do math on the players fame - Magius(CHE)						{							cline = &script2[0];							splitline();							j = makenumber(0);							c = pc_ts->fame;							if ((j>0) &&(c >= 10000))								sysmessage(ts, "You are already the most gloriosus person in this world!");							if ((j < 0) &&(c <=-10000))								sysmessage(ts, "You are already the most unknown person in this world!");							pc_ts->fame += j;							if (pc_ts->fame>10000)								pc_ts->fame = 10000;							if (pc_ts->fame < -10000)								pc_ts->fame=-10000;							j = pc_ts->fame - c;							if (j>0)							{								if (j < 25)									sysmessage(ts, "You have gained a little fame!");								else if (j < 75)									sysmessage(ts, "You have gained some fame!");								else if (j < 100)									sysmessage(ts, "You have gained a lot of fame!");								else 									sysmessage(ts, "You have gained a huge amount of fame!");							}														else if (j < 0)							{								if (abs(j) < 25)									sysmessage(ts, "You have lost a little fame!");								else if (abs(j) < 75)									sysmessage(ts, "You have lost some fame!");								else if (abs(j) < 100)									sysmessage(ts, "You have lost a lot of fame!");								else 									sysmessage(ts, "You have lost a huge amount of fame!");							}																					// refresh title						}						else if (!(strcmp("FMSG", (char*)script1)))  // Set fail message						{							strcpy(fmsg, (char*)script2);						}						break;					case 'H':						if (!(strcmp("HEA", (char*)script1)))  // Do math on players health						{							j = str2num(script2);														if ((j < 0) &&(pc_ts->hp < abs(j)) &&(!(pc_ts->isInvul())))							{								deathstuff(currchar[ts]);								closescript();								return;							}							pc_ts->hp += j;							if (pc_ts->hp>pc_ts->st)								pc_ts->hp = pc_ts->st;							updatestats(currchar[ts], 0);						}						else if (!(strcmp("HUNGER", (char*)script1)))  // Do math on players hunger from 0 to 6 - Magius(CHE)						{							j = str2num(script2);							pc_ts->hunger += j;							if (pc_ts->hunger>6)								pc_ts->hunger = 6;							if (pc_ts->hunger < 1)								pc_ts->hunger = 1;							switch (pc_ts->hunger)							{							case 0:									sysmessage(ts, "You eat the food, but are still extremely hungry.");								break;							case 1: 								sysmessage(ts, "You eat the food, but are still extremely hungry.");								break;							case 2: 								sysmessage(ts, "After eating the food, you feel much less hungry.");								break;							case 3: 								sysmessage(ts, "You eat the food, and begin to feel more satiated.");								break;							case 4: 								sysmessage(ts, "You feel quite full after consuming the food.");								break;							case 5: 								sysmessage(ts, "You are nearly stuffed, but manage to eat the food.");								break;							case 6: 								sysmessage(ts, "You are simply too full to eat any more!");								break;							}						}						break;					case 'I':						if (!strcmp("IFREQ", (char*)script1))						{							// Check Envoked ID, if true JUMP to another trigger (in ntrig.scp)							cline = &script2[0];							splitline();							j = makenumber(1);							sprintf(sect, "x%x%x", pc_ts->envokeid1, pc_ts->envokeid2);							if (strstr((char*)comm[0], sect))							{								// IEnvoked item found in IFREQ --> Jump Trigger								// clConsole.send("IFREQ %s  -> Jumping to NPC trigger %i\n",comm[0],j);								closescript();								triggernpc(ts, ti, 1);								return;							}						}						else if (!(strcmp("IFKARMA", (char*)script1)))  // If karma meets a certain criteria - Magius(CHE)						{							char opt;							gettokennum((char*)script2, 0);							opt = gettokenstr[0];							gettokennum((char*)script2, 1);							j = str2num(gettokenstr);							// clConsole.send("Script2: %s\nOPT: %c\n%i %c %i\n",script2,opt,chars[p].karma,opt,j);							if (opt == '>')							{								if (!(pc_ts->karma >= j))								{									if (strlen(fmsg))										sysmessage(ts, fmsg);									else 										sysmessage(ts, "You need more Karma to do that!");									closescript();									return;								}							}							else if (opt == '<')							{								if (!(pc_ts->karma <= j))								{									if (strlen(fmsg))										sysmessage(ts, fmsg);									else 										sysmessage(ts, "You need less Karma to do that!");									closescript();									return;								}							}							else 								clConsole.send("TRIGGER.SCP:Triggerwitem() Syntax Error in IFKARMA token.\n   IFKARMA <opt> <value>\n    <opt>= '<' or '>'\n    <value> range from '-10000' to '10000'.\n");						}						else if (!(strcmp("IFFAME", (char*)script1)))  // If karma meets a certain criteria - Magius(CHE)						{							char opt;							gettokennum((char*)script2, 0);							opt = gettokenstr[0];							gettokennum((char*)script2, 1);							j = str2num(gettokenstr);							if (opt == '>')							{								if (!(pc_ts->fame >= j))								{									if (strlen(fmsg))										sysmessage(ts, fmsg);									else 										sysmessage(ts, "You need more Fame to do that!");									closescript();									return;								}							}							else if (opt == '<')							{								if (!(pc_ts->fame <= abs(j)))																	{									if (strlen(fmsg))										sysmessage(ts, fmsg);									else 										sysmessage(ts, "You need less Fame to do that!");									closescript();									return;								}							}							else 								clConsole.send("TRIGGER.SCP:Triggerwitem() Syntax Error in IFFAME token.\n   IFFAME <opt> <value>\n    <opt>= '<' or '>'\n    <value> range from '-10000' to '10000'.\n");						}						else if (!(strcmp("IFHUNGER", (char*)script1)))  // If hunger meets a certain criteria - Magius(CHE)						{							j = str2num(script2);							if (j >= 0)							{								if (!(pc_ts->hunger >= j))								{									if (strlen(fmsg))										sysmessage(ts, fmsg);									closescript();									return;								}							}							else 							{								if (!(pc_ts->hunger <= abs(j)))																	{									if (strlen(fmsg))										sysmessage(ts, fmsg);									closescript();									return;								}							}						}						else if (!(strcmp("IFOWNER", (char*)script1)))  // If character is owned by triggerer						{							if (ti>-1)							{								if (!pc_ts->Owns(&chars[ti]))								{									sysmessage(ts, "You do not own this creature.");									closescript();									return;								}							}						}						else if (!(strcmp("IDADD", (char*)script1)))  // Add item in player pack by ID						{							cline = &script2[0];							splitline();							// c=memitemfree();							p = packitem(currchar[ts]);							if (p==-1)								p = 0;							// Antichrist							pos = ftell(scpfile);							closescript();							c = Items->SpawnItem(ts, currchar[ts], 1, "#", 1, hexnumber(0), hexnumber(1), 0, 0, 1, 1);							if (c==-1)								return;// AntiChrist to preview crashes							// Added colormem token here! by Magius(CHE) 							if (c>-1 && coloring>-1)							{								items[c].color1 = memcolor1;								items[c].color2 = memcolor2;								RefreshItem(c);							}							// end addons								if (ttype)								openscript("ntrigrs.scp"); // Added by Magius(CHE) 							else 								openscript("wtrigrs.scp");  // Added by Magius(CHE) 							fseek(scpfile, pos, SEEK_SET);						}						else if (!(strcmp("IDFX", (char*)script1)))  // Makes an effect at players by ID						{							if (ti>-1)							{								for (i = 0; i < 29; i++)								{									effect[i] = 0;								}								cline = &script2[0];								splitline();								effect[0] = 0x70; // Effect message								effect[1] = 0x00; // Moving effect								effect[2] = chars[ti].ser1;								effect[3] = chars[ti].ser2;								effect[4] = chars[ti].ser3;								effect[5] = chars[ti].ser4;								effect[6] = pc_ts->ser1;								effect[7] = pc_ts->ser2;								effect[8] = pc_ts->ser3;								effect[9] = pc_ts->ser4;								effect[10] = hexnumber(0);// Object id of the effect								effect[11] = hexnumber(1);								effect[12] = chars[ti].pos.x >> 8;								effect[13] = chars[ti].pos.x%256;								effect[14] = chars[ti].pos.y >> 8;								effect[15] = chars[ti].pos.y%256;								effect[16] = chars[ti].pos.z;								effect[17] = pc_ts->pos.x >> 8;								effect[18] = pc_ts->pos.x%256;								effect[19] = pc_ts->pos.y >> 8;								effect[20] = pc_ts->pos.y%256;								effect[21] = pc_ts->pos.z;								effect[22] = 0x09;								effect[23] = 0x06; // 0 is really long.  1 is the shortest.								effect[24] = 0; // This value is unknown								effect[25] = 0; // This value is unknown								effect[26] = 1; // This value is unknown								effect[27] = 0x00; // This value is used for moving effects that explode on impact.								for (j = 0; j < now; j++)								{									if ((inrange1p(currchar[j], currchar[ts])) &&(perm[j]))									{										Xsend(j, effect, 28);									}								}							}						}						else if (!(strcmp("INT", (char*)script1)))  // Do math on players intelligence						{							j = str2num(script2);							if (j < 0)							{								sysmessage(ts, "Your mind is growing weaker!");							}							else 							{								sysmessage(ts, "Your mind is getting stronger!");							}							pc_ts->in += j;							if (pc_ts->in < 1)								pc_ts->in = 1;						}						else if (!(strcmp("IADD", (char*)script1)))  // Add item in front of player //if 2nd param. is 1, add item into player's backpack - AntiChrist (with autostack)						{							handle_IADD(ts, ttype, coloring, memcolor1, memcolor2, "ntrigrs.scp");						}						break;					case 'K':						if (!(strcmp("KARMA", (char*)script1)))  // Do math on the players karma - Magius(CHE)						{							cline = &script2[0];							splitline();							j = makenumber(0);							c = pc_ts->karma;							if ((j>0) &&(c >= 10000))								sysmessage(ts, "You are already the most honest person in this world!");							if ((j < 0) &&(c <=-10000))								sysmessage(ts, "You are already the most evil person in this world!");							pc_ts->karma += j;							if (pc_ts->karma>10000)								pc_ts->karma = 10000;							if (pc_ts->karma < -10000)								pc_ts->karma=-10000;							j = pc_ts->karma - c;							if (j>0)							{								if (j < 25)									sysmessage(ts, "You have gained a little karma!");								else if (j < 75)									sysmessage(ts, "You have gained some karma!");								else if (j < 100)									sysmessage(ts, "You have gained a lot of karma!");								else 									sysmessage(ts, "You have gained a huge amount of karma!");							}							else if (j < 0)							{								if (abs(j) < 25)									sysmessage(ts, "You have lost a little karma!");								else if (abs(j) < 75)									sysmessage(ts, "You have lost some karma!");								else if (abs(j) < 100)									sysmessage(ts, "You have lost a lot of karma!");																else 									sysmessage(ts, "You have lost a huge amount of karma!");							}						}						break;					case 'M':						if (!(strcmp("MAKE", (char*)script1)))  // Give user the make menu						{							cline = &script2[0];							splitline();							itemmake[ts].Mat1id = ((hexnumber(2)) << 8) + hexnumber(3);							itemmake[ts].has = getamount(currchar[ts], itemmake[ts].Mat1id); 							itemmake[ts].has2 = getamount(currchar[ts], itemmake[ts].Mat2id);							itemmake[ts].coloring = coloring; // Magius(CHE) 							if (coloring>-1)							{								itemmake[ts].newcolor1 = memcolor1; // Magius(CHE) 								itemmake[ts].newcolor2 = memcolor2; // Magius(CHE) 							}							pos = ftell(scpfile);							closescript();							Skills->MakeMenu(ts, makenumber(0), makenumber(1));							if (ttype)								openscript("ntrigrs.scp");							else 								openscript("wtrigrs.scp");							fseek(scpfile, pos, SEEK_SET);							strcpy((char*)script1, "DUMMY");						}						else if (!(strcmp("MISC", (char*)script1)))  // Perform a miscellaneous function						{							if (!(strcmp("bank", strlwr((char*)script2))))								openbank(ts, currchar[ts]);							if (!(strcmp("ware", strlwr((char*)script2))))								openspecialbank(ts, currchar[ts]);// AntiChrist							if (!(strcmp("balance", strlwr((char*)script2))))							{								sprintf(sect, "You have %i gp in your bank account!", pc_ts->CountBankGold());								npctalk(ts, ti, sect, 0);							}						}						else if (!(strcmp("MSG", (char*)script1)))  // Display a message when trigger is activated						{							if ((pc_ts->isPlayer()))							{								sysmessage(ts, script2);							}						}						else if (!(strcmp("MAN", (char*)script1)))  // Do math on players mana						{							j = str2num(script2);							if ((j < 0) &&(pc_ts->mn < abs(j)))															{								sysmessage(ts, "Your mind is too tired to do that.");								closescript();								return;							}							pc_ts->mn += j;							if (pc_ts->mn>pc_ts->in)								pc_ts->mn = pc_ts->in;							updatestats(currchar[ts], 1);						}						else if (!(strcmp("MEMCOLOR", (char*)script1)))  // Store the item color in memory by Magius(CHE) 						{							p=-1;							if (!strcmp((char*)script2, "EMPTY"))							{								coloring=-1;								closescript();								return;							}							else if (!strcmp((char*)script2, "REQ"))								p = evti;							else if (!strcmp((char*)script2, "NEED"))								p = needitem;							if (p>-1)							{								memcolor1 = items[p].color1;								memcolor2 = items[p].color2;								coloring = 1;							}							else 							{								clConsole.send("WOLFPACK: Error in Trigger script.\n Check MEMCOLOR %s in SECTION ", script2);								if (ttype == 1)									clConsole.send("%i.\n", trig);								else 									clConsole.send("...x%x%x...\n", buffer[ts][0x11], buffer[ts][0x12]);								clConsole.send(" Make sure that it was after %s.\n", script2);							}						}						break;					case 'N':						if (!(strcmp("NPCACT", (char*)script1)))  // Make player perform an action						{							cline = &script2[0];							splitline();							npcaction(ti, hexnumber(0));						}						else if (!(strcmp("NADD", (char*)script1)))  // Add a NPC at given location - AntiChrist -- Fixed here by Magius(CHE) 						{// Usage: NADD <npc_number> <life_in_seconds>							// uiCompleted=0;							cline = &script2[0];							splitline();							unsigned int uiNpcNum = makenumber(0);							unsigned int uiTimer = makenumber(1);							/*unsigned int uiTamed = makenumber(2); */														triggerx = pc_ts->pos.x + 1;							triggery = pc_ts->pos.y + 1;							triggerz = pc_ts->pos.z;														pos = ftell(scpfile);							closescript();							Npcs->AddRespawnNPC(ti, uiNpcNum, 1);							npcnum = triggerx;														if (uiTimer>0)							{// if we have a timer								chars[npcnum].summontimer = uiCurrentTime +(uiTimer*MY_CLOCKS_PER_SEC);							}														triggerx = 0;							if (ttype)								openscript("ntrigrs.scp"); // Added by Magius(CHE) 							else 								openscript("wtrigrs.scp");  // Added by Magius(CHE) 							fseek(scpfile, pos, SEEK_SET);							strcpy((char*)script1, "DUMMY");						}						else if (!(strcmp("NEWOWNER", (char*)script1)))  // Set ownership of NPC						{							if (itemnum>-1)							{// item								p = currchar[ts];								items[itemnum].SetOwnSerial(chars[p].serial);							}							if (npcnum>-1)							{// char								p = currchar[ts];								chars[npcnum].SetOwnSerial(chars[p].serial);							}						}						else if (!(strcmp("NEEDCOLOR", (char*)script1)))  // Set the color check on NEEDED item by Magius(CHE) 						{							cline = &script2[0];							splitline();							clr1 = hexnumber(0);							clr2 = hexnumber(1);							j = makenumber(2);							if (needitem==-1)							{								closescript();								return;							}							if (clr1 != items[needitem].color1 || clr2 != items[needitem].color2)							{								if (strlen(fmsg))									sysmessage(ts, fmsg);								else 								{									sysmessage(ts, "You need another type of %s!", tempname3);								}								closescript();								return;							}							if (j>0)							{								pc_ts->targtrig = j;								closescript();								triggerwitem(ts, ti, 1);								return;							}						}						else if (!(strcmp("NEED", (char*)script1)))  // The item here is required and will be removed						{							p = packitem(currchar[ts]);							for (i = 0; i < itemcount; i++)							{								if (p!=-1)									if (items[i].contserial == items[p].serial)									{										sprintf(sect, "x%x%x", items[i].id1, items[i].id2);										if (strstr((char*)script2, sect))										{											needitem = i;											break;										}									}							}							if (needitem < 0)							{								if (strlen(fmsg))									sysmessage(ts, fmsg); // Added by Magius(CHE)								else 									sysmessage(ts, "You don't have the neccessary supplies to do that."); // Changed by Magius(CHE)								closescript();								return;							}							else 							{								// Get Temporany Name of the NEED Item - Magius(CHE) 								if (items[i].name[0] != '#') // Get Temporany Name of the NEED Item - Magius(CHE) 									strcpy(tempname3, items[i].name);								else 								{									Map->SeekTile(items[i].id(), &tile);									strcpy(tempname3, (char*)tile.name);								}								// End Get Temporany Name of the NEED Item - Magius(CHE) 							}						}						else if ((!(strcmp("NEWTYPE", (char*)script1))) ||(!(strcmp("SETTYPE", (char*)script1))))  // Set active item type						{							if (itemnum>-1)								items[itemnum].type = str2num(script2);						}						else if (!(strcmp("NEWNAME", (char*)script1)))  // Give the new item/npc a name						{							if (itemnum>-1)							{								strcpy(items[itemnum].name, (char*)script2);							}							if (npcnum>-1)							{								strcpy(chars[npcnum].name, (char*)script2);							}						}						else if (!(strcmp("NEWTRIG", (char*)script1)))  // Give the new item/npc a dynamic trigger number						{							if (itemnum>-1)							{								items[itemnum].trigger = str2num(script2);							}							if (npcnum>-1)							{								chars[npcnum].trigger = str2num(script2);							}						}						else if (!(strcmp("NEWWORD", (char*)script1)))  // Give the new npc a triggerword						{							if (npcnum>-1)							{								strcpy(chars[npcnum].trigword, (char*)script2);							}						}						else if (!(strcmp("NEWSPEECH", (char*)script1)))  // Give the new npc a new spech -- MAgius(CHE) 						{							if (npcnum>-1)							{								chars[npcnum].speech = str2num(script2);							}						}						break;					case 'O':						if (!strcmp("OPENGUMP", (char*)script1))							Gumps->Menu(ts, str2num(script2), -1);						break;											case 'P':						if (!(strcmp("PUT", (char*)script1)))  // Send player to X Y Z when triggered						{							cline = &script2[0];							splitline();														pc_ts->pos.x = makenumber(0);							pc_ts->pos.y = makenumber(1);							pc_ts->pos.z = makenumber(2);							teleport(currchar[ts]);						}						break;					case 'R':						if (!(strcmp("REQCOLOR", (char*)script1)))  // Set the color check on REQUIRED item by Magius(CHE) 						{							cline = &script2[0];							splitline();							clr1 = hexnumber(0);							clr2 = hexnumber(1);							j = makenumber(2);							if (evti==-1)							{								closescript();								return;							}							if (clr1 != items[evti].color1 || clr2 != items[evti].color2)							{								if (strlen(fmsg))									sysmessage(ts, fmsg);								else 								{									sysmessage(ts, "You need another type of %s!", tempname2);								}								closescript();								return;							}							if (j>0)							{								pc_ts->targtrig = j;								closescript();								triggerwitem(ts, ti, 1);								return;							}						}						else if (!(strcmp("RAND", (char*)script1)))  // Does a random check						{							cline = &script2[0];							splitline();							if (makenumber(0) != 0)								p = (rand()%(makenumber(0))) + 1;							else 								p = 1;														if (p>makenumber(1))							{								if (strlen(fmsg))									sysmessage(ts, fmsg);								closescript();								return;							}						}						else if (!(strcmp("REQ", (char*)script1)))  // Check if envoked by certain item. Added By Magius(CHE) to fix Targ trigger						{							sprintf(sect, "x%x%x", pc_ts->envokeid1, pc_ts->envokeid2);							if (!strstr((char*)script2, sect))							{								sysmessage(ts, "That didn't seem to work.");								closescript();								return;							}							else 							{								evti = pc_ts->envokeitem;								if (items[pc_ts->envokeitem].name[0] != '#') // Get Temporany Name of the REQUIRED Item - Magius(CHE)									sprintf(tempname2, "%s", items[pc_ts->envokeitem].name);								else 								{									Map->SeekTile(items[evti].id(), &tile);									strcpy(tempname2, (char*)tile.name);								}							} // End Addon						}						break;					case 'S':						if (!(strcmp("SND", (char*)script1)))  // Play a sound when trigger is activated						{							cline = &script2[0];							splitline();							soundeffect2(ti, hexnumber(0), hexnumber(1));						}						else if (!(strcmp("SETTRG", (char*)script1)))  // Set npcs trigger to new trigger						{							if (ti>-1)								chars[ti].trigger = str2num(script2);						}						else if (!(strcmp("SPEECH", (char*)script1)))  // Set the triggered npc a new spech -- Magius(CHE) 						{							if (ti>-1)							{								chars[ti].speech = str2num(script2);							}						}						// End NPC Triggers						else if (!(strcmp("SETID", (char*)script1)))  // Set chars id to new id						{							if (ti>-1)							{								cline = &script2[0];								splitline();								chars[ti].id1 = hexnumber(0);								chars[ti].id2 = hexnumber(1);								chars[ti].xid1 = hexnumber(0);								chars[ti].xid2 = hexnumber(1);								for (j = 0; j < now; j++)									if (perm[j] && inrange1p(currchar[j], ti))										updatechar(ti);							}						}						else if (!(strcmp("STAM", (char*)script1)))  // Do math on players stamina						{							j = str2num(script2);														if ((j < 0) &&(pc_ts->stm < abs(j)))															{								sysmessage(ts, "You are too tired to do that.");								closescript();								return;							}							pc_ts->stm += j;							if (pc_ts->stm>pc_ts->effDex())								pc_ts->stm = pc_ts->effDex();							updatestats(currchar[ts], 2);						}						else if (!(strcmp("STR", (char*)script1)))  // Do math on players strength						{							j = str2num(script2);							if (j < 0)							{								sysmessage(ts, "You lost strength!");							}							else 							{								sysmessage(ts, "You are getting stronger!");							}							pc_ts->st += j;							if (pc_ts->st < 1)								pc_ts->st = 1;						}						else if (!(strcmp("SETWORD", (char*)script1)))  // Sets the trigger word of an NPC						{							if (ti>-1)								strcpy(chars[ti].trigword, script2);						}						else if (!(strcmp("SKL", (char*)script1)))  // Do math on the players skill						{							cline = &script2[0];							splitline();							p = makenumber(0);							j = makenumber(1);														if (j)							{								if (pc_ts->baseskill[p] < 1000)								{									pc_ts->baseskill[p] += j;									if (pc_ts->baseskill[p]>1000)										pc_ts->baseskill[p] = 1000;								}							}							else 							{								Skills->AdvanceSkill(currchar[ts], p, 1);							}						}						else if (!(strcmp("SETOWNER", (char*)script1)))  // Set ownership of NPC						{							if (ti>-1)							{								p = currchar[ts];								chars[ti].SetOwnSerial(chars[p].serial);							}						}						break;					case 'T':						if (!(strcmp("TALK", (char*)script1)))  // the triggered NPC now talking! --- by Magius(CHE) 						{							if (ti>-1 && strlen((char*)script2)>0)								npctalk(ts, ti, (char*)script2, 0);						}						break;					case 'U':						if (!(strcmp("USEUP", (char*)script1)))  // The item here is required and will be removed						{							p = packitem(currchar[ts]);							if (p!=-1) // lb								if (needitem < 0)								{									for (i = 0; i < itemcount; i++)									{										if (items[i].contserial == items[p].serial)										{											sprintf(sect, "x%x%x", items[i].id1, items[i].id2);											if (strstr((char*)script2, sect))											{												needitem = i;												break;											}										}									}								}								if (needitem < 0)								{									sysmessage(ts, "It appears as though you have insufficient supplies to make that with.");									closescript();									return;								}								else 								{									if (items[needitem].amount>1)										items[needitem].amount--;									else										Items->DeleItem(needitem);								}						}						break;					default:						break;				}		}  }  while ((script1[0] != '}')  &&(++loopexit < MAXLOOPS));  closescript();}