// In doubleclick:

if (items[x].type==104) // Teleport object
  {
    chars[currchar[s]].x=items[x].morex;
    chars[currchar[s]].y=items[x].morey;
    chars[currchar[s]].z=chars[currchar[s]].dispz=items[x].morez;
    teleport(currchar[s]);
  }else

//The purpose of this is to make an object that will teleport you
//to coords stored in the item's morexyz when doubleclicked

///////////////////////////
Also in doubleclick

  if (items[x].type==105)  // For drinking
  {
   int drinksnd;
   drinksnd=rand()%2;      
    switch(drinksnd)
    {
       case 0: soundeffect2(currchar[s], 0x00, 0x31);
               break;
       case 1: soundeffect2(currchar[s], 0x00, 0x30);
               break;       
    }   
   
     int j;
     //Remove a drink
     if (items[x].amount!=1)
     {
        items[x].amount--;
        for (j=0;j<now;j++) if (perm[j] && inrange2(j,x)) senditem(j,x);
     }
     else
     {
        deleitem(x);
     }
    sysmessage(s,"You take a swig of your drink.");
  }else  

////////////////////


replacement in advancementobjects:

   if (!(strcmp("ITEM",script1)))
   {
        x=str2num(script2);            
        pos=ftell(scpfile);
        j=addmenutarget(-1, 0, x);
        openscript("advance.scp");
        fseek(scpfile, pos, SEEK_SET);
        sprintf(script1, "DUMMY");   
        packnum=packitem(s);
        items[j].x=50+(rand()%80);
        items[j].y=50+(rand()%80);
        items[j].z=9;
        if(items[j].layer==0x0b || items[j].layer==0x10)
        {
        items[j].cont1=chars[s].ser1;
        items[j].cont2=chars[s].ser2;
        items[j].cont3=chars[s].ser3;
        items[j].cont4=chars[s].ser4;
        }
        else
        {
        items[j].cont1=items[packnum].ser1;
        items[j].cont2=items[packnum].ser2;
        items[j].cont3=items[packnum].ser3;
        items[j].cont4=items[packnum].ser4;
        }
        for (i=0;i<now;i++) if (perm[i])
        senditem(i,j);                
        teleport(s);
   }

//This makes it so if you add a hair or beard, it will go on their head not in a pack

/////////////////////////


In objtele

// advancement objects
  if ((items[i].type==80)&&(items[i].x==chars[s].x)&&(items[i].y==chars[s].y)
          &&((abs(items[i].z) + 10 ) >= abs(chars[s].z)) && ((abs(items[i].z) - 10 ) <= abs(chars[s].z))
          &&!(chars[s].npc)) 
   if(items[i].more1!=0 || items[i].more2!=0 || items[i].more3!=0 || items[i].more4!=0)
    {
      if(chars[s].ser1==items[i].more1 && chars[s].ser2==items[i].more2 && chars[s].ser3==items[i].more3 && chars[s].ser4==items[i].more4)
      advancementobjects(s,items[i].morex,0);
    }
    else
    advancementobjects(s,items[i].morex,0);
  if ((items[i].type==81)&&(items[i].x==chars[s].x)&&(items[i].y==chars[s].y)
          &&((abs(items[i].z) + 10 ) >= abs(chars[s].z)) && ((abs(items[i].z) - 10 ) <= abs(chars[s].z))
          &&!(chars[s].npc))
  if(items[i].more1!=0 || items[i].more2!=0 || items[i].more3!=0 || items[i].more4!=0)
    {
      if(chars[s].ser1==items[i].more1 && chars[s].ser2==items[i].more2 && chars[s].ser3==items[i].more3 && chars[s].ser4==items[i].more4)
      advancementobjects(s,items[i].morex,1);
    }
    else
    advancementobjects(s,items[i].morex,1);

//This will need a bit of explanation. What this does is let you restrict an advancement gate
//to only one char. I found this very useful in quests where you want one person to get things
//from a gate but no one else to use the gate. If the gate's MORE values are all 0 (default)
//anyone can use it. But if you set the MORE to the char's serial number then only that char
//can use it

//////////////

// Hunger code:

// in loadchar()

chars[x].hunger=0;

// in checkauto()

if ((hungerdamagetimer<=currenttime)||(overflow)) // Bookmark
   {
    hungerdamagetimer=currenttime+(server_data.hungerdamagerate*CLOCKS_PER_SEC);
    if (chars[i].hp>0 && chars[i].hunger<3 && server_data.hungerdamage && !(chars[i].priv&0x80))
    {     
     chars[i].hp=chars[i].hp-server_data.hungerdamage;
     updatestats(i, 0);
      if(chars[i].hp<=0)
      { 
        sysmessage(calcSocketFromChar(i),"You have died of starvation");
        deathstuff(i);
      }
    }
   }


// this REPLACES something in checkauto()

if ((chars[i].regen<=currenttime)||(overflow))
   {
    chars[i].regen=currenttime+(server_data.hitpointrate*CLOCKS_PER_SEC);
    if (chars[i].hp<chars[i].st && chars[i].hunger>3)
    {
     if (chars[i].skill[17]<500) chars[i].hp++;
     else if (chars[i].skill[17]<800) chars[i].hp += 2;
     else chars[i].hp += 3;
     if (chars[i].hp>chars[i].st) chars[i].hp=chars[i].st;
     updatestats(i, 0);
    }
   }

// AS DOES THIS

if ((chars[i].hungertime<=getclock())||(overflow))
   {
    if (chars[i].hunger) chars[i].hunger--;
    switch(chars[i].hunger)
    {
      case 5:
      sysmessage(calcSocketFromChar(i),"You are still stuffed from your last meal");
      break;
      case 4:
      sysmessage(calcSocketFromChar(i),"You are not very hungry but could eat more");
      break;
      case 3:
      sysmessage(calcSocketFromChar(i),"You are feeling fairly hungry");
      break;
      case 2:
      sysmessage(calcSocketFromChar(i),"You are extremely hungry");
      break;
      case 1:
      sysmessage(calcSocketFromChar(i),"You are very weak from starvation");
      break;
      case 0:
      sysmessage(calcSocketFromChar(i),"You must eat very soon or you will die!");
      break;
    }
    chars[i].hungertime=currenttime+(server_data.hungerrate*CLOCKS_PER_SEC); // Bookmark
   }

// At end of saveserverscript()

 fprintf(file,"HUNGER_DAMAGE %i\n",server_data.hungerdamage);
 fprintf(file,"HUNGER_DAMAGE_RATE %i\n",server_data.hungerdamagerate);

// in loadserver()

  if(!(strcmp(script1,"HUNGER_DAMAGE"))) server_data.hungerdamage=str2num(script2);
  if(!(strcmp(script1,"HUNGER_DAMAGE_RATE"))) server_data.hungerdamagerate=str2num(script2);

// in GLOBALS.CPP

int hungerdamagetimer=0;

// in UOX3.H

extern int hungerdamagetimer;

// add to server_st

 unsigned char hungerdamage;
 unsigned int hungerdamagerate;

// What all of that does it make it so that when your hunger reaches 3 you no longer regen HP,
// and at below 3 you lose server_data.hungerdamage HP each server_data.hungerrate seconds.


////////////////////////////////////////////////

// new wipe function, basically it prints output on the console when someone wipes so that
// if a malicious GM wipes the world you know who to blame

void wipe(int s)
{
 int k;

 printf("UOX3: %s has initiated an item wipe\n",chars[currchar[s]].name);

 for(k=0;k<=itemcount;k++)
 {
  if(items[k].cont1==255 && items[k].cont2==255 && items[k].cont3==255 && items[k].cont4==255 && items[k].wipe==0)
  {
   deleitem(k);
  }
 }
 sysbroadcast("All items have been wiped."); 
}

//Note that wipe() will have to be changed to take int s as a parameter

////////////////////////

// Function to wipe all NPCS

void wipenpcs (int s) // remove ALL npcs
{
 int j,i,deleted=0;

 printf("UOX3: %s has initiated an NPC wipe\n",chars[currchar[s]].name);

 for(j=0;j<charcount;j++)
 {
 if(chars[j].npc)
 {
 removeitem[1]=chars[j].ser1;
 removeitem[2]=chars[j].ser2;
 removeitem[3]=chars[j].ser3;
 removeitem[4]=chars[j].ser4;
 for (i=0;i<now;i++)
 {
  xsend(i, removeitem, 5, 0);
  if (currchar[i]>j) currchar[i]--;
 }
  chars[j].free=1;
  chars[j].x=20+(rand()%40);
  chars[j].y=50+(rand()%80);
  chars[j].z=9;
  chars[j].summontimer=0;
 if (cmemcheck<300)
  {
  cmemcheck++;
  freecharmem[cmemcheck]=k;
  }
 else cmemover=1;
 deleted++; 
}
}
gcollect();
charcount=charcount-deleted;
sysbroadcast("All NPC's have been wiped.");
}

/////////////////////////
// This is code to make armor hindering mana regen an option, not mandatory. 1=yes it will
// hinder it, 0 means no

// In server_st in uox3.h

char armoraffectmana; // Should armor slow mana regen ?

// replace the mana regen part of checkauto with this slightly modified one

if ((chars[i].regen3<=currenttime)||(overflow))
   {
    if(server_data.armoraffectmana)chars[i].regen3=currenttime+((server_data.manarate+(calcdef(i,0)-2))*CLOCKS_PER_SEC);    
    else
    chars[i].regen3=currenttime+(server_data.manarate*CLOCKS_PER_SEC);    
    if (chars[i].mn<chars[i].in)
    {
     chars[i].mn++;
     updatestats(i, 1);
    }
   }

// This is in saveserverscript

fprintf(file,"ARMOR_AFFECT_MAMA_REGEN %i\n",server_data.armoraffectmana);

// And this goes in loadserver

if(!(strcmp(script1,"ARMOR_AFFECT_MANA_REGEN"))) server_data.armoraffectmana=str2num(script2);

////////////////////////
//This next bit was originally coded as an army enlistment deed that gave a player some armor (
//was used in a quest on a shard) but I expanded it to add any items in an itemlist to the player
//'s pack when they use it (list number is in the morex of the item). I think it could be useful

void enlist(int s, int listnum) // listnum is stored in items morex
{
 int x,pos,i,j;
 char sect[50];

 openscript("items.scp");
 sprintf(sect, "ITEMLIST %i", listnum);
 if (!items_script.find(sect))
 {
  closescript();
  printf("UOX3: ITEMLIST not found, aborting.\n");
  return;
 }
 
 do
 {
  read2();
  if (script1[0]!='}')
  {
        x=str2num(script1);
        pos=ftell(scpfile);
        j=SpawnItemBackpack2(s, x, 0);
        openscript("items.scp");
        fseek(scpfile, pos, SEEK_SET);
        sprintf(script1, "DUMMY");
        for (i=0;i<now;i++) if (perm[i]) senditem(i,j);
  }
  } while(strcmp(script1,"}"));
}

// in doubleclick()

 if (items[x].type==103) //Army enlistment
  {
    deleitem(x);
    enlist(s);
  }else  

if ((items[x].id1==0x14)&&(items[x].id2==0xF0) && items[x].type!=103) {  //experimental house code

// That previous line replaces another one in doubleclick(). It checks if the enlistment object
// is in the form of a deed, since if this code were not there when you used the object it would
// try and build a house not give you the items.


// in uox3.h

void enlist(int s); // For enlisting in army

//If you can think of a better name than enlist then feel free to change it hehe

////////////////////////
// This is a bufix in combat.cpp by Dupois (dupois@home.net) it has to do with bow selection

// replace getbow with this

int getbowtype(int i)
{
 int j;
 for(j=0;j<itemcount;j++)
 {
  if
((items[j].cont1==chars[i].ser1)&&(items[j].cont2==chars[i].ser2)&&(items[j].cont3==chars[i].ser3)&&(items[j].cont4==chars[i].ser4)&&((items[j].layer==1)||(items[j].layer==2)))
  {
      if ((items[j].id1==0x13)&&(items[j].id2==0xB1)) return(1); // Bows
   if ((items[j].id1==0x13)&&(items[j].id2==0xB2)) return(1);
   if ((items[j].id1==0x0F)&&(items[j].id2==0x4F)) return(2); // Crossbows
      if ((items[j].id1==0x0F)&&(items[j].id2==0x50)) return(2);
      if ((items[j].id1==0x13)&&(items[j].id2==0xFC)) return(3); // Heavy Crossbows
   if ((items[j].id1==0x13)&&(items[j].id2==0xFD)) return(3);
  }
 }
 return 0;
}

