Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function addItem(temp.itemName, temp.qty)
  2. {
  3.   temp.caller = getCallStack()[1];
  4.   temp.logPath = "rpg/" @ this.subDir @ this.id @ "/addLog.log";
  5.   temp.logText = "Added " @ temp.qty @ " " @ temp.itemName @ "(s) to player.";
  6.   savelog2(temp.logPath, temp.logText);
  7.  
  8.   for(temp.i = 0; temp.i < this.items.size(); temp.i ++)
  9.   {
  10.     if(this.items[temp.i][0] == temp.itemName)
  11.     {
  12.       this.items[temp.i][1] += temp.qty;
  13.       this.reflectItems();
  14.       return;
  15.     }
  16.   }
  17.   this.items.add({temp.itemName, temp.qty});
  18.   this.reflectItems();
  19. }
  20.  
  21. public function removeItem(temp.itemName, temp.qty)
  22. {
  23.   temp.caller = getCallStack()[1];
  24.   temp.logPath = "rpg/" @ this.subDir @ this.id @ "/removeLog.log";
  25.   temp.logText = "Removed " @ temp.qty @ " " @ temp.itemName @ "(s) from player.";
  26.   savelog2(temp.logPath, temp.logText);
  27.  
  28.   for(temp.i = 0; temp.i < this.items.size(); temp.i ++)
  29.   {
  30.     if(this.items[temp.i][0] == temp.itemName)
  31.     {
  32.       if(this.items[temp.i][1] - temp.qty > 0)
  33.       {
  34.         this.items[temp.i][1] -= temp.qty;
  35.       }
  36.       else
  37.       {
  38.         this.items.delete(temp.i);
  39.       }
  40.       this.reflectItems();
  41.       return;
  42.     }
  43.   }
  44. }
  45.  
  46. public function equipItem(temp.itemName)
  47. {
  48.   for(temp.item: this.items)
  49.   {
  50.     if(temp.item[0] == temp.itemName)
  51.     {
  52.       temp.itemObj = makevar("item_" @ temp.item[0]);
  53.       switch(temp.itemObj.catagory)
  54.       {
  55.         case "Weapons":
  56.           return({temp.itemObj.speed, temp.itemObj.power, temp.itemObj.image, temp.itemObj.gani, temp.itemObj.displayName, temp.itemObj.itemType, temp.itemObj.arrowImage, temp.itemObj.arrowsShot});
  57.         break;
  58.        
  59.         case "Instruments":
  60.           return({0.5, 0, temp.itemObj.image, temp.itemObj.gani, temp.itemObj.displayName, 7, null, null});
  61.         break;
  62.        
  63.         case "Tools":
  64.           return({0.5, 0, temp.itemObj.image, temp.itemObj.gani, temp.itemObj.displayName, 7, null, null});
  65.         break;
  66.        
  67.         case "Armor":
  68.           return({temp.itemObj.iconImage, temp.itemObj.armorSlot, temp.itemObj.dmgPlus, temp.itemObj.defPlus, temp.itemObj.hpPlus, temp.itemObj.mpPlus, temp.itemObj.displayName, temp.itemObj.levelReq});
  69.         break;
  70.        
  71.         case "Items":
  72.           return({temp.itemObj.iconImage, temp.itemObj.armorSlot, temp.itemObj.dmgPlus, temp.itemObj.defPlus, temp.itemObj.hpPlus, temp.itemObj.mpPlus, temp.itemObj.displayName, temp.itemObj.levelReq});
  73.         break;
  74.        
  75.       }
  76.     }
  77.   }
  78.   return({ 0.35, 1.0, "end_punch.png", "end_punch_", "Weapons/Punch", NULL});
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement