SHARE
TWEET

Untitled

a guest Dec 13th, 2015 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // SilvItemLog.js
  3. // Version: 1.06a
  4. // License: https://creativecommons.org/licenses/by/4.0/
  5. //=============================================================================
  6. /*:
  7.  * @plugindesc v1.06a Item Log. Displays the last looted items.
  8.    <SilverItemLog>
  9.  * @author Silver
  10.  *
  11.  * @param Auto Gain Loot
  12.  * @desc Automatically add the loot to the party's inventory? true/false
  13.  * @default true
  14.  *
  15.  * @param Auto Log Items
  16.  * @desc Automatically add items to the log window when added through the GainItem command? true/false
  17.  * @default true
  18.  *
  19.  * @param Item SFX
  20.  * @desc Automatically play this sound when picking up items, armors or weapons. Leave blank to disable.
  21.  * @default Item1
  22.  *
  23.  * @param Gold SFX
  24.  * @desc Automatically play this sound when picking up gold (currency). Leave blank to disable.
  25.  * @default Coin
  26.  *
  27.  * @param Window X
  28.  * @desc x-location of itemlog window. If window-alignment is set to Right, this will act as an offset value instead
  29.  * @default -2
  30.  *
  31.  * @param Window Y
  32.  * @desc y-location of itemlog window. If window-alignment is set to Top, this will act as an offset value instead
  33.  * @default 2
  34.  *
  35.  * @param Window Horizontal Alignment
  36.  * @desc Left/Right
  37.  * @default Right
  38.  *
  39.  * @param Window Vertical Alignment
  40.  * @desc Top/Bottom
  41.  * @default Top
  42.  *
  43.  * @param Window Width
  44.  * @desc width of the itemlog window
  45.  * @default 400
  46.  *
  47.  * @param Window Height
  48.  * @desc height of the itemlog window
  49.  * @default 160
  50.  *
  51.  * @param Font Size
  52.  * @desc Size of the font
  53.  * @default 24
  54.  *
  55.  * @param Text Offset X
  56.  * @desc Text offset X for the log entries
  57.  * @default 10
  58.  *
  59.  * @param Text Offset Y
  60.  * @desc Text offset Y for the log entries
  61.  * @default 6
  62.  *
  63.  * @param Standard Padding
  64.  * @desc Leave at default (it's basically an X and Y offset)
  65.  * @default 0
  66.  *
  67.  * @param Positive Prefix Text
  68.  * @desc Prefix text
  69.  * @default Received
  70.  *
  71.  * @param Negative Prefix Text
  72.  * @desc Prefix text
  73.  * @default Lost
  74.  *
  75.  * @param Icon Y-offset
  76.  * @desc Extra Y-offset for the drawing of the icons to better align them with the sentences
  77.  * @default 4
  78.  *
  79.  * @param Fadeout Delay
  80.  * @desc How long before the window starts fading out (in frames)
  81.  * @default 240
  82.  *
  83.  * @param Fadeout Speed
  84.  * @desc How fast the window fades out
  85.  * @default 2
  86.  *
  87.  * @param Text Shading
  88.  * @desc Displays previously looted items in darker text. Set to 0 to disable.
  89.  * @default -0.15
  90.  *
  91.  * @param Gold IconIndex
  92.  * @desc iconindex for the gold/currency icon
  93.  * @default 163
  94.  *
  95.  * @param Window Skin
  96.  * @desc Name of the window skin to use for this window
  97.  * @default Window_ItemLog
  98.  *
  99.  * @help
  100.  * Plugin Command:
  101.  * ItemLog <loot type> <loot database-index> <amount> <optional: skip (override: does not actually add the item to the inventory)>
  102.  * example to loot 3 potions: ItemLog item 1 3
  103.  * example to loot 5 swords:  ItemLog weapon 1 5
  104.  * example to loot 6 axes:    ItemLog weapon 2 6
  105.  * example to log (but does not add to inventory regardless of the "Auto Gain Loot" parameter) 6 axes:    ItemLog weapon 2 6 skip
  106.  *
  107.  * The exception is gold, examples:
  108.  *                            ItemLog gold 123
  109.  *                            ItemLog gold 999
  110.  *
  111.  * Use the plugin command "ItemLog show" (w/o quotes) to show the window
  112.  * again without adding anything.
  113.  *
  114.  * Note that all commands & parameters are NOT case sensitive.
  115.  *
  116.  *
  117.  *--------------------------------------
  118.  * Version History:
  119.  *--------------------------------------
  120.  * v1.06a (13 December 2015) [parameters changed]
  121.  * - Now supports losing items/gold.
  122.  * - Fixed a minor alignment issue when gaining < 10 items, armors or weapons.
  123.  * - Minor refactoring of the 1.06 code.
  124.  *
  125.  * v1.05 (12 December 2015)
  126.  * - Added a version history.
  127.  * - Fixed a bug that used the wrong amount of gold/item/etc. when using a game-variable instead of a fixed amount.
  128.  * - Added this plugin to Silv.Plugins.
  129.  * - Changed license to https://creativecommons.org/licenses/by/4.0/
  130.  *
  131.  * v1.00 - v1.04 (November 2015)
  132.  */
  133. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  134. // Utilities
  135. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  136. String.prototype.contains = function(it) { return this.indexOf(it) != -1; };
  137.  
  138. // Stack with limited size
  139. // Automatically removes the first element(s) if it exceeds it's maxsize
  140. function Queue_LSize(maxSize)
  141. {
  142.         this._maxSize = maxSize;
  143.     this.length = 0;
  144.     this._storage = [];
  145. }
  146.  
  147. Queue_LSize.prototype.itemByIdx = function(index)
  148. {
  149.         return this._storage[index];
  150. };
  151.  
  152. Queue_LSize.prototype.queue = function(data)
  153. {
  154.     this._storage[this.length] = data;
  155.         this.length++;
  156.         while (this.length > this._maxSize) { this.onAutoRemoval(this.dequeue()); }
  157. };
  158.  
  159. // For aliasing
  160. Queue_LSize.prototype.onAutoRemoval = function(removed_item) {};
  161.  
  162.  // Remove and return first item in array
  163. Queue_LSize.prototype.dequeue = function()
  164. {
  165.     if (this.length)
  166.         {
  167.         var deletedData = this._storage.shift();
  168.         this.length--;
  169.         return deletedData;
  170.     }
  171. };
  172. // Remove and return last item in array
  173. Queue_LSize.prototype.pop = function()
  174. {
  175.     if (this.length)
  176.         {
  177.         var deletedData = this._storage.pop();
  178.         this.length--;
  179.         return deletedData;
  180.     }
  181. };
  182.  
  183. function lpad(word, padStr, length)
  184. {
  185.     word = String(word);
  186.     while (word.length < length) word = padStr + word;
  187.     return word;
  188. }
  189.  
  190. function rpad(word, padStr, length)
  191. {
  192.     word = String(word);
  193.     while (word.length < length) word += padStr;
  194.     return word;
  195. }
  196. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  197. // Variables
  198. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  199. var Silv = Silv || {};
  200. Silv.Plugins = Silv.Plugins || {};
  201. Silv.Plugins.ItemLog = 1.06;
  202. Silv.Parameters = $plugins.filter(function(p) { return p.description.contains('<SilverItemLog>'); })[0].parameters;
  203. Silv.ItemLog = Silv.ItemLog || {};
  204. Silv.ItemLog.Window = null;
  205. Silv.ItemLog.AlreadyPlayedSFX = false;
  206. Silv.ItemLog.AutoLootGain = Silv.Parameters['Auto Gain Loot'].toLowerCase() == 'true';
  207. Silv.ItemLog.AutoLogItems = Silv.Parameters['Auto Log Items'].toLowerCase() == 'true';
  208. Silv.ItemLog.PickupSFXItem = Silv.Parameters['Item SFX'];
  209. Silv.ItemLog.PickupSFXGold = Silv.Parameters['Gold SFX'];
  210. Silv.ItemLog.Window_X = parseInt(Silv.Parameters['Window X']);
  211. Silv.ItemLog.Window_Y = parseInt(Silv.Parameters['Window Y']);
  212. Silv.ItemLog.WindowWidth = parseInt(Silv.Parameters['Window Width']);
  213. Silv.ItemLog.WindowHeight = parseInt(Silv.Parameters['Window Height']);
  214. Silv.ItemLog.WindowHorizontalAlignment = Silv.Parameters['Window Horizontal Alignment'].toLowerCase();
  215. Silv.ItemLog.WindowVerticalAlignment = Silv.Parameters['Window Vertical Alignment'].toLowerCase();
  216. Silv.ItemLog.FontSize = parseInt(Silv.Parameters['Font Size']);
  217. Silv.ItemLog.EntryTextOffsetX = parseInt(Silv.Parameters['Text Offset X']);
  218. Silv.ItemLog.EntryTextOffsetY = parseInt(Silv.Parameters['Text Offset Y']);
  219. Silv.ItemLog.StandardPadding = parseInt(Silv.Parameters['Standard Padding']);
  220. Silv.ItemLog.TextLines = Silv.ItemLog.TextLines || 'Error: Not yet set';
  221.  
  222. Silv.ItemLog.PositivePrefixText = Silv.Parameters['Positive Prefix Text'];
  223. if (Silv.ItemLog.PositivePrefixText.slice(-1) != ' ') { Silv.ItemLog.PositivePrefixText += ' '; }
  224. Silv.ItemLog.NegativePrefixText = Silv.Parameters['Negative Prefix Text'];
  225. if (Silv.ItemLog.NegativePrefixText.slice(-1) != ' ') { Silv.ItemLog.NegativePrefixText += ' '; }
  226.  
  227. Silv.ItemLog.IconOffsetY = parseInt(Silv.Parameters['Icon Y-offset']);
  228. Silv.ItemLog.FadeoutDelay = parseInt(Silv.Parameters['Fadeout Delay']);
  229. Silv.ItemLog.FadeoutSpeed = parseInt(Silv.Parameters['Fadeout Speed']);
  230. Silv.ItemLog.TextShadingValue = parseFloat(Silv.Parameters['Text Shading']);
  231. Silv.ItemLog.GoldIconIndex = parseInt(Silv.Parameters['Gold IconIndex']);
  232. Silv.ItemLog.WindowSkin = Silv.Parameters['Window Skin'];
  233.  
  234. // Non Parameters
  235. Silv.ItemLog.PrefixLength = Math.max(Silv.ItemLog.PositivePrefixText.length, Silv.ItemLog.NegativePrefixText.length);
  236.  
  237. (function()
  238. {
  239. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  240. // Window
  241. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  242. function Window_ItemLog() { this.initialize.apply(this, arguments); }
  243. // Inherit from base window
  244. Window_ItemLog.prototype = Object.create(Window_Base.prototype);
  245. // Set Constructor
  246. Window_ItemLog.prototype.constructor = Window_ItemLog;
  247.  
  248. Window_ItemLog.prototype.loadWindowskin = function() { this.windowskin = ImageManager.loadSystem(Silv.ItemLog.WindowSkin); };
  249. Window_ItemLog.prototype.standardPadding = function() { return Silv.ItemLog.StandardPadding; };
  250. Window_ItemLog.prototype.standardFontSize = function() { return Silv.ItemLog.FontSize; };
  251.  
  252. // Initialization
  253. Window_ItemLog.prototype.initialize = function(x, y, width, height)
  254. {
  255.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  256.     this._helpWindow = null;
  257.     this._handlers = {};
  258.     this._touching = false;
  259.     this.deactivate();
  260.         var maxStackLines = parseInt((height - Silv.ItemLog.EntryTextOffsetY * 2) / parseFloat(Silv.ItemLog.FontSize));
  261.         Silv.ItemLog.TextLines = new Queue_LSize(maxStackLines);
  262.         this.fadeOutCnt = 0;
  263.         this.isFadingOut = false;
  264.         this.isFadedOut = false;
  265.        
  266.         this.update();
  267. };
  268.  
  269. // Update
  270. Window_ItemLog.prototype.update = function()
  271. {
  272.     Window_Base.prototype.update.call(this);
  273.        
  274.         Silv.ItemLog.AlreadyPlayedSFX = false;
  275.         this.updateFadeOut();
  276.     this.drawItemLogContents();
  277. };
  278.  
  279. // Update Fading Out
  280. Window_ItemLog.prototype.updateFadeOut = function()
  281. {
  282.         if (this.isFadedOut) { return; }
  283.        
  284.         if (!this.isFadingOut)
  285.         {
  286.                 this.fadeOutCnt++;
  287.                 if (this.fadeOutCnt > Silv.ItemLog.FadeoutDelay)
  288.                 {
  289.                         this.fadeOutCnt = 0;
  290.                         this.isFadingOut = true;
  291.                 }
  292.         }
  293.         else
  294.         {
  295.                 this.fadeOut();
  296.         }
  297. };
  298.  
  299. Window_ItemLog.prototype.fadeOut = function()
  300. {
  301.         this.opacity = this.contentsOpacity -= Silv.ItemLog.FadeoutSpeed;
  302.         this.isFadedOut = (this.opacity <= 0);
  303. };
  304.  
  305. Window_ItemLog.prototype.resetFade = function()
  306. {
  307.         this.isFadingOut = false;
  308.         this.fadeOutCnt = 0;
  309.         this.opacity = this.contentsOpacity  = 255;
  310.         this.isFadedOut = false;
  311. };
  312.  
  313. Window_ItemLog.prototype.fadeOutInstantly = function()
  314. {
  315.         this.opacity = this.contentsOpacity = 0;
  316.         this.isFadedOut = true;
  317. };
  318.  
  319. // Drawing
  320. Window_ItemLog.prototype.drawItemLogContents = function()
  321. {
  322.         if (typeof Silv.ItemLog.TextLines === 'string') { return; }
  323.         this.contents.clear();
  324.         this.resetTextColor();
  325.        
  326.         var textLinesCnt = Silv.ItemLog.TextLines.length;
  327.         var text = null;
  328.         for (var i = textLinesCnt - 1; i >= 0; i--)
  329.         {
  330.                 var line = Silv.ItemLog.TextLines.itemByIdx(i);
  331.                 text = line.t1;
  332.                 this.drawText(text, Silv.ItemLog.EntryTextOffsetX, Silv.ItemLog.EntryTextOffsetY + i * Silv.ItemLog.FontSize, 256, 'left');
  333.                 var newOffsetX = Silv.ItemLog.EntryTextOffsetX + this.contents.measureTextWidth(line.t1);
  334.                 this.drawLootIcon(line.iconIndex, newOffsetX, Silv.ItemLog.EntryTextOffsetY + i * Silv.ItemLog.FontSize + Silv.ItemLog.IconOffsetY);
  335.                 newOffsetX += Silv.ItemLog.FontSize + 4;
  336.                 text = line.t2;
  337.                 this.drawText(text, newOffsetX, Silv.ItemLog.EntryTextOffsetY + i * Silv.ItemLog.FontSize, 256, 'left');
  338.                
  339.                 this.contents.textColor = shadeColor(this.contents.textColor, Silv.ItemLog.TextShadingValue);
  340.         }
  341.        
  342.         function shadeColor(color, percent)
  343.         {  
  344.                 var f=parseInt(color.slice(1),16),t=percent<0?0:255,p=percent<0?percent*-1:percent,R=f>>16,G=f>>8&0x00FF,B=f&0x0000FF;
  345.                 return "#"+(0x1000000+(Math.round((t-R)*p)+R)*0x10000+(Math.round((t-G)*p)+G)*0x100+(Math.round((t-B)*p)+B)).toString(16).slice(1);
  346.         }
  347. };
  348.  
  349. Window_ItemLog.prototype.drawLootIcon = function(iconIndex, x, y)
  350. {
  351.     var bitmap = ImageManager.loadSystem('IconSet');
  352.     var pw = Window_Base._iconWidth;
  353.     var ph = Window_Base._iconHeight;
  354.     var sx = iconIndex % 16 * pw;
  355.     var sy = Math.floor(iconIndex / 16) * ph;
  356.     this.contents.blt(bitmap, sx, sy, pw, ph, x, y, Silv.ItemLog.FontSize, Silv.ItemLog.FontSize);
  357. };
  358. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  359. // Create the ItemLog window
  360. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  361. var alias_silv_itemlog_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
  362. Scene_Map.prototype.createDisplayObjects = function()
  363. {
  364.         alias_silv_itemlog_createDisplayObjects.call(this);
  365.         this.createItemLogWindow();
  366. };
  367.  
  368. Scene_Map.prototype.createItemLogWindow = function()
  369. {
  370.         var x = 0;
  371.         if (Silv.ItemLog.WindowHorizontalAlignment == 'right') { x = Graphics.width - Silv.ItemLog.WindowWidth; }
  372.         var y = 0;
  373.         if (Silv.ItemLog.WindowVerticalAlignment == 'bottom') { y = Graphics.height - Silv.ItemLog.WindowHeight; }
  374.        
  375.         if (Silv.ItemLog.Window !== null) { this.removeWindow(Silv.ItemLog.Window); }
  376.         Silv.ItemLog.Window = new Window_ItemLog(x + Silv.ItemLog.Window_X, y + Silv.ItemLog.Window_Y, Silv.ItemLog.WindowWidth, Silv.ItemLog.WindowHeight);
  377.         Silv.ItemLog.Window.fadeOutInstantly();
  378.         this.addChildAt(Silv.ItemLog.Window, 1);
  379. };
  380.  
  381. // Omg why does RPG Maker not have this method by default...
  382. Scene_Base.prototype.removeWindow = function(window)
  383. {
  384.         var index = this.children.indexOf(window);
  385.         if (index > -1) { this.children.splice(index, 1); }
  386. };
  387. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  388. // Saving & Loading
  389. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  390. /* Code below does not work for some reason. It does save the data but not load it properly.
  391. var alias_silv_ItemLog_makeSaveContents = DataManager.makeSaveContents;
  392. DataManager.makeSaveContents = function()
  393. {
  394.         contents = alias_silv_ItemLog_makeSaveContents.call(this);
  395.         contents.itemLogData = Silv.ItemLog.TextLines;
  396.         return contents;
  397. }
  398.  
  399. var alias_silv_ItemLog_extractSaveContents = DataManager.extractSaveContents;
  400. DataManager.extractSaveContents = function(contents)
  401. {
  402.         alias_silv_ItemLog_extractSaveContents.call(this, contents);
  403.         Silv = Silv || {};
  404.         Silv.ItemLog = Silv.ItemLog || {};
  405.         Silv.ItemLog.TextLines = contents.itemLogData;
  406. }
  407. */
  408. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  409. // Automatically add items
  410. //------------------------
  411. //
  412. // Explanation of the this._params:
  413. //
  414. // Gold
  415. // [0] = 0: increase, 1: decrease
  416. // [1] = 0: value, 1: $gameVariable was used to determine amount of gold
  417. // [2] = it is a direct amount of gold but if [1] == 1, then this is the gameVariable number that contains the gold-amount instead.
  418. //
  419. //
  420. // Items, Weapons & Armor
  421. // [0] = armor id matching the $dataArmors index
  422. // [1] = 0: increase, 1: decrease
  423. // [2] = 0: value, 1: $gameVariable was used to determine amount of armors
  424. // [3] = it is a direct amount of gold but if [2] == 1, then this is the gameVariable number that contains the gold-amount instead.
  425. // [4] = include equipment? true/false
  426. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  427. Silv.ItemLog.getAmount = function(params) // does not apply to gold! Gold has different parameters.. Yay for RPG Maker...
  428. {
  429.         return ((params[2] == 0) ? params[3] : $gameVariables.value(params[3])) * (params[1] == 1 ? -1 : 1);
  430. };
  431.  
  432. // Change Gold
  433. var alias_silv_command125 = Game_Interpreter.prototype.command125;
  434. Game_Interpreter.prototype.command125 = function()
  435. {
  436.         var amount = (this._params[1] == 0) ? this._params[2] : $gameVariables.value(this._params[2]);
  437.         if (this._params[0] == 1) { amount *= -1; }
  438.        
  439.     var retVal = alias_silv_command125.apply(this, arguments);
  440.         if (Silv.ItemLog.AutoLogItems) { PluginCommand('ItemLog', ['gold', String(amount), 'skip']); }
  441.     return retVal;
  442. };
  443.  
  444. // Change Items
  445. var alias_silv_command126 = Game_Interpreter.prototype.command126;
  446. Game_Interpreter.prototype.command126 = function()
  447. {
  448.     var retVal = alias_silv_command126.apply(this, arguments);
  449.         if (Silv.ItemLog.AutoLogItems) { PluginCommand('ItemLog', ['item', this._params[0], Silv.ItemLog.getAmount(this._params), 'skip']); }
  450.     return retVal;
  451. };
  452.  
  453. // Change Weapons
  454. var alias_silv_command127 = Game_Interpreter.prototype.command127;
  455. Game_Interpreter.prototype.command127 = function()
  456. {
  457.     var retVal = alias_silv_command127.apply(this, arguments);
  458.         if (Silv.ItemLog.AutoLogItems) { PluginCommand('ItemLog', ['weapon', this._params[0], Silv.ItemLog.getAmount(this._params), 'skip']); }
  459.     return retVal;
  460. };
  461.  
  462. // Change Armors
  463. var alias_silv_command128 = Game_Interpreter.prototype.command128;
  464. Game_Interpreter.prototype.command128 = function()
  465. {
  466.     var retVal = alias_silv_command128.apply(this, arguments);
  467.         if (Silv.ItemLog.AutoLogItems) { PluginCommand('ItemLog', ['armor', this._params[0], Silv.ItemLog.getAmount(this._params), 'skip']); }
  468.     return retVal;
  469. };
  470. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  471. // Plugin Command
  472. // Note: The items are separated by spaces. The command is the first word and any following words are args. args is an array.
  473. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  474. Silv.ItemLog.getPrefixText = function(amount)
  475. {
  476.         var prefixText = rpad((amount >= 0) ? Silv.ItemLog.PositivePrefixText : Silv.ItemLog.NegativePrefixText, ' ', Silv.ItemLog.PrefixLength);
  477.        
  478.         return prefixText;
  479. };
  480.  
  481. var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  482. Game_Interpreter.prototype.pluginCommand = function(command, args)
  483. {
  484.         _Game_Interpreter_pluginCommand.call(this, command, args);
  485.         if (command.toLowerCase() == 'itemlog') { PluginCommand(command, args); }
  486. };
  487.  
  488. function PluginCommand(cmd, args)
  489. {
  490.         if (args[0].toLowerCase() == 'show')
  491.         {
  492.                 Silv.ItemLog.Window.resetFade();
  493.                 return;
  494.         }
  495.        
  496.         // arg: item 1 10
  497.         // arg: weapon 2 1
  498.         // arg: weapon 2 1 skip
  499.         // arg: gold 123
  500.         var db = getDatabase(args[0]);
  501.         var lootIdx = parseInt(args[1]);
  502.         var skipAddItemToInventory = (String(args[args.length - 1]).toLowerCase() == 'skip');
  503.         if (db != 'gold')
  504.         {
  505.                 var amount = parseInt(args[2]);
  506.                 var amountStr = String(args[2]);
  507.                 var name = db[lootIdx].name;
  508.                 var iconIndex = db[lootIdx].iconIndex;
  509.                
  510.                 var t1 = Silv.ItemLog.getPrefixText(amount) + lpad(Math.abs(amountStr), ' ', 2) + 'x ';
  511.                 var t2 = name;                         
  512.                
  513.                 Silv.ItemLog.TextLines.queue({t1: t1, iconIndex: iconIndex, t2: t2});
  514.                
  515.         // Add loot
  516.                 if (Silv.ItemLog.AutoLootGain && !skipAddItemToInventory)
  517.                 {
  518.                         $gameParty.gainItem(db[lootIdx], amount);
  519.                 }
  520.                
  521.                 // sfx
  522.                 if (!Silv.ItemLog.AlreadyPlayedSFX)
  523.                 {
  524.                         Play_SE(Silv.ItemLog.PickupSFXItem);
  525.                         Silv.ItemLog.AlreadyPlayedSFX = true;
  526.                 }
  527.         }
  528.         else // Gold
  529.         {
  530.                 var amount = parseInt(args[1]);
  531.                 Silv.ItemLog.TextLines.queue({t1: Silv.ItemLog.getPrefixText(amount) + '    ', iconIndex: Silv.ItemLog.GoldIconIndex, t2: Math.abs(amount) + ' ' + $dataSystem.currencyUnit});
  532.                
  533.                 // Add loot
  534.                 if (Silv.ItemLog.AutoLootGain && !skipAddItemToInventory)
  535.                 {
  536.                         $gameParty.gainGold(amount);
  537.                 }
  538.                
  539.                 // sfx
  540.                 if (!Silv.ItemLog.AlreadyPlayedSFX)
  541.                 {
  542.                         Play_SE(Silv.ItemLog.PickupSFXGold);
  543.                         Silv.ItemLog.AlreadyPlayedSFX = true;
  544.                 }
  545.         }
  546.         Silv.ItemLog.Window.resetFade(); // Reset the fadeout, if any.
  547.        
  548.         function getDatabase(code)
  549.         {
  550.                 code = code.toLowerCase();
  551.                 if (code.contains('item') || code.contains('itm'))
  552.                         return $dataItems;
  553.                 if (code.contains('armor'))
  554.                         return $dataArmors;
  555.                 if (code.contains('weapon') || code.contains('wpn'))
  556.                         return $dataWeapons;
  557.                 if (code.contains('gold'))
  558.                         return 'gold';
  559.                
  560.                 throw('getDatabase('+ code + ') ERROR: invalid code.');
  561.         }
  562.        
  563.         function Play_SE(filename)
  564.         {
  565.                 AudioManager.playSe({name: filename, volume: 90, pitch: 100, pan: 0});
  566.         }
  567. }
  568. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  569. })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top