Advertisement
Guest User

Untitled

a guest
Dec 13th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // SilvItemLog.js
  3. // Version: 1.06
  4. // License: https://creativecommons.org/licenses/by/4.0/
  5. //=============================================================================
  6. /*:
  7.  * @plugindesc v1.06 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.06 (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.  *
  124.  * v1.05 (12 December 2015)
  125.  * - Added a version history.
  126.  * - Fixed a bug that used the wrong amount of gold/item/etc. when using a game-variable instead of a fixed amount.
  127.  * - Added this plugin to Silv.Plugins.
  128.  * - Changed license to https://creativecommons.org/licenses/by/4.0/
  129.  *
  130.  * v1.00 - v1.04 (November 2015)
  131.  */
  132. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  133. // Utilities
  134. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  135. String.prototype.contains = function(it) { return this.indexOf(it) != -1; };
  136.  
  137. // Stack with limited size
  138. // Automatically removes the first element(s) if it exceeds it's maxsize
  139. function Queue_LSize(maxSize)
  140. {
  141.     this._maxSize = maxSize;
  142.     this.length = 0;
  143.     this._storage = [];
  144. }
  145.  
  146. Queue_LSize.prototype.itemByIdx = function(index)
  147. {
  148.     return this._storage[index];
  149. };
  150.  
  151. Queue_LSize.prototype.queue = function(data)
  152. {
  153.     this._storage[this.length] = data;
  154.     this.length++;
  155.     while (this.length > this._maxSize) { this.onAutoRemoval(this.dequeue()); }
  156. };
  157.  
  158. // For aliasing
  159. Queue_LSize.prototype.onAutoRemoval = function(removed_item) {};
  160.  
  161.  // Remove and return first item in array
  162. Queue_LSize.prototype.dequeue = function()
  163. {
  164.     if (this.length)
  165.     {
  166.         var deletedData = this._storage.shift();
  167.         this.length--;
  168.         return deletedData;
  169.     }
  170. };
  171. // Remove and return last item in array
  172. Queue_LSize.prototype.pop = function()
  173. {
  174.     if (this.length)
  175.     {
  176.         var deletedData = this._storage.pop();
  177.         this.length--;
  178.         return deletedData;
  179.     }
  180. };
  181.  
  182. function lpad(word, padStr, length)
  183. {
  184.     word = String(word);
  185.     while (word.length < length) word = padStr + word;
  186.     return word;
  187. }
  188.  
  189. function rpad(word, padStr, length)
  190. {
  191.     word = String(word);
  192.     while (word.length < length) word += padStr;
  193.     return word;
  194. }
  195. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  196. // Variables
  197. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  198. var Silv = Silv || {};
  199. Silv.Plugins = Silv.Plugins || {};
  200. Silv.Plugins.ItemLog = 1.06;
  201. Silv.Parameters = $plugins.filter(function(p) { return p.description.contains('<SilverItemLog>'); })[0].parameters;
  202. Silv.ItemLog = Silv.ItemLog || {};
  203. Silv.ItemLog.Window = null;
  204. Silv.ItemLog.AlreadyPlayedSFX = false;
  205. Silv.ItemLog.AutoLootGain = Silv.Parameters['Auto Gain Loot'].toLowerCase() == 'true';
  206. Silv.ItemLog.AutoLogItems = Silv.Parameters['Auto Log Items'].toLowerCase() == 'true';
  207. Silv.ItemLog.PickupSFXItem = Silv.Parameters['Item SFX'];
  208. Silv.ItemLog.PickupSFXGold = Silv.Parameters['Gold SFX'];
  209. Silv.ItemLog.Window_X = parseInt(Silv.Parameters['Window X']);
  210. Silv.ItemLog.Window_Y = parseInt(Silv.Parameters['Window Y']);
  211. Silv.ItemLog.WindowWidth = parseInt(Silv.Parameters['Window Width']);
  212. Silv.ItemLog.WindowHeight = parseInt(Silv.Parameters['Window Height']);
  213. Silv.ItemLog.WindowHorizontalAlignment = Silv.Parameters['Window Horizontal Alignment'].toLowerCase();
  214. Silv.ItemLog.WindowVerticalAlignment = Silv.Parameters['Window Vertical Alignment'].toLowerCase();
  215. Silv.ItemLog.FontSize = parseInt(Silv.Parameters['Font Size']);
  216. Silv.ItemLog.EntryTextOffsetX = parseInt(Silv.Parameters['Text Offset X']);
  217. Silv.ItemLog.EntryTextOffsetY = parseInt(Silv.Parameters['Text Offset Y']);
  218. Silv.ItemLog.StandardPadding = parseInt(Silv.Parameters['Standard Padding']);
  219. Silv.ItemLog.TextLines = Silv.ItemLog.TextLines || 'Error: Not yet set';
  220.  
  221. Silv.ItemLog.PositivePrefixText = Silv.Parameters['Positive Prefix Text'];
  222. if (Silv.ItemLog.PositivePrefixText.slice(-1) != ' ') { Silv.ItemLog.PositivePrefixText += ' '; }
  223. Silv.ItemLog.NegativePrefixText = Silv.Parameters['Negative Prefix Text'];
  224. if (Silv.ItemLog.NegativePrefixText.slice(-1) != ' ') { Silv.ItemLog.NegativePrefixText += ' '; }
  225.  
  226. Silv.ItemLog.IconOffsetY = parseInt(Silv.Parameters['Icon Y-offset']);
  227. Silv.ItemLog.FadeoutDelay = parseInt(Silv.Parameters['Fadeout Delay']);
  228. Silv.ItemLog.FadeoutSpeed = parseInt(Silv.Parameters['Fadeout Speed']);
  229. Silv.ItemLog.TextShadingValue = parseFloat(Silv.Parameters['Text Shading']);
  230. Silv.ItemLog.GoldIconIndex = parseInt(Silv.Parameters['Gold IconIndex']);
  231. Silv.ItemLog.WindowSkin = Silv.Parameters['Window Skin'];
  232.  
  233. // Non Parameters
  234. Silv.ItemLog.PrefixLength = Math.max(Silv.ItemLog.PositivePrefixText.length, Silv.ItemLog.NegativePrefixText.length);
  235.  
  236. (function()
  237. {
  238. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  239. // Window
  240. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  241. function Window_ItemLog() { this.initialize.apply(this, arguments); }
  242. // Inherit from base window
  243. Window_ItemLog.prototype = Object.create(Window_Base.prototype);
  244. // Set Constructor
  245. Window_ItemLog.prototype.constructor = Window_ItemLog;
  246.  
  247. Window_ItemLog.prototype.loadWindowskin = function() { this.windowskin = ImageManager.loadSystem(Silv.ItemLog.WindowSkin); };
  248. Window_ItemLog.prototype.standardPadding = function() { return Silv.ItemLog.StandardPadding; };
  249. Window_ItemLog.prototype.standardFontSize = function() { return Silv.ItemLog.FontSize; };
  250.  
  251. // Initialization
  252. Window_ItemLog.prototype.initialize = function(x, y, width, height)
  253. {
  254.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  255.     this._helpWindow = null;
  256.     this._handlers = {};
  257.     this._touching = false;
  258.     this.deactivate();
  259.     var maxStackLines = parseInt((height - Silv.ItemLog.EntryTextOffsetY * 2) / parseFloat(Silv.ItemLog.FontSize));
  260.     Silv.ItemLog.TextLines = new Queue_LSize(maxStackLines);
  261.     this.fadeOutCnt = 0;
  262.     this.isFadingOut = false;
  263.     this.isFadedOut = false;
  264.    
  265.     this.update();
  266. };
  267.  
  268. // Update
  269. Window_ItemLog.prototype.update = function()
  270. {
  271.     Window_Base.prototype.update.call(this);
  272.    
  273.     Silv.ItemLog.AlreadyPlayedSFX = false;
  274.     this.updateFadeOut();
  275.     this.drawItemLogContents();
  276. };
  277.  
  278. // Update Fading Out
  279. Window_ItemLog.prototype.updateFadeOut = function()
  280. {
  281.     if (this.isFadedOut) { return; }
  282.    
  283.     if (!this.isFadingOut)
  284.     {
  285.         this.fadeOutCnt++;
  286.         if (this.fadeOutCnt > Silv.ItemLog.FadeoutDelay)
  287.         {
  288.             this.fadeOutCnt = 0;
  289.             this.isFadingOut = true;
  290.         }
  291.     }
  292.     else
  293.     {
  294.         this.fadeOut();
  295.     }
  296. };
  297.  
  298. Window_ItemLog.prototype.fadeOut = function()
  299. {
  300.     this.opacity = this.contentsOpacity -= Silv.ItemLog.FadeoutSpeed;
  301.     this.isFadedOut = (this.opacity <= 0);
  302. };
  303.  
  304. Window_ItemLog.prototype.resetFade = function()
  305. {
  306.     this.isFadingOut = false;
  307.     this.fadeOutCnt = 0;
  308.     this.opacity = this.contentsOpacity  = 255;
  309.     this.isFadedOut = false;
  310. };
  311.  
  312. Window_ItemLog.prototype.fadeOutInstantly = function()
  313. {
  314.     this.opacity = this.contentsOpacity = 0;
  315.     this.isFadedOut = true;
  316. };
  317.  
  318. // Drawing
  319. Window_ItemLog.prototype.drawItemLogContents = function()
  320. {
  321.     if (typeof Silv.ItemLog.TextLines === 'string') { return; }
  322.     this.contents.clear();
  323.     this.resetTextColor();
  324.    
  325.     var textLinesCnt = Silv.ItemLog.TextLines.length;
  326.     var text = null;
  327.     for (var i = textLinesCnt - 1; i >= 0; i--)
  328.     {
  329.         var line = Silv.ItemLog.TextLines.itemByIdx(i);
  330.         text = line.t1;
  331.         this.drawText(text, Silv.ItemLog.EntryTextOffsetX, Silv.ItemLog.EntryTextOffsetY + i * Silv.ItemLog.FontSize, 256, 'left');
  332.         var newOffsetX = Silv.ItemLog.EntryTextOffsetX + this.contents.measureTextWidth(line.t1);
  333.         this.drawLootIcon(line.iconIndex, newOffsetX, Silv.ItemLog.EntryTextOffsetY + i * Silv.ItemLog.FontSize + Silv.ItemLog.IconOffsetY);
  334.         newOffsetX += Silv.ItemLog.FontSize + 4;
  335.         text = line.t2;
  336.         this.drawText(text, newOffsetX, Silv.ItemLog.EntryTextOffsetY + i * Silv.ItemLog.FontSize, 256, 'left');
  337.        
  338.         this.contents.textColor = shadeColor(this.contents.textColor, Silv.ItemLog.TextShadingValue);
  339.     }
  340.    
  341.     function shadeColor(color, percent)
  342.     {  
  343.         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;
  344.         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);
  345.     }
  346. };
  347.  
  348. Window_ItemLog.prototype.drawLootIcon = function(iconIndex, x, y)
  349. {
  350.     var bitmap = ImageManager.loadSystem('IconSet');
  351.     var pw = Window_Base._iconWidth;
  352.     var ph = Window_Base._iconHeight;
  353.     var sx = iconIndex % 16 * pw;
  354.     var sy = Math.floor(iconIndex / 16) * ph;
  355.     this.contents.blt(bitmap, sx, sy, pw, ph, x, y, Silv.ItemLog.FontSize, Silv.ItemLog.FontSize);
  356. };
  357. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  358. // Create the ItemLog window
  359. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  360. var alias_silv_itemlog_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
  361. Scene_Map.prototype.createDisplayObjects = function()
  362. {
  363.     alias_silv_itemlog_createDisplayObjects.call(this);
  364.     this.createItemLogWindow();
  365. };
  366.  
  367. Scene_Map.prototype.createItemLogWindow = function()
  368. {
  369.     var x = 0;
  370.     if (Silv.ItemLog.WindowHorizontalAlignment == 'right') { x = Graphics.width - Silv.ItemLog.WindowWidth; }
  371.     var y = 0;
  372.     if (Silv.ItemLog.WindowVerticalAlignment == 'bottom') { y = Graphics.height - Silv.ItemLog.WindowHeight; }
  373.    
  374.     if (Silv.ItemLog.Window !== null) { this.removeWindow(Silv.ItemLog.Window); }
  375.     Silv.ItemLog.Window = new Window_ItemLog(x + Silv.ItemLog.Window_X, y + Silv.ItemLog.Window_Y, Silv.ItemLog.WindowWidth, Silv.ItemLog.WindowHeight);
  376.     Silv.ItemLog.Window.fadeOutInstantly();
  377.     this.addChildAt(Silv.ItemLog.Window, 1);
  378. };
  379.  
  380. // Omg why does RPG Maker not have this method by default...
  381. Scene_Base.prototype.removeWindow = function(window)
  382. {
  383.     var index = this.children.indexOf(window);
  384.     if (index > -1) { this.children.splice(index, 1); }
  385. };
  386. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  387. // Saving & Loading
  388. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  389. /* Code below does not work for some reason. It does save the data but not load it properly.
  390. var alias_silv_ItemLog_makeSaveContents = DataManager.makeSaveContents;
  391. DataManager.makeSaveContents = function()
  392. {
  393.     contents = alias_silv_ItemLog_makeSaveContents.call(this);
  394.     contents.itemLogData = Silv.ItemLog.TextLines;
  395.     return contents;
  396. }
  397.  
  398. var alias_silv_ItemLog_extractSaveContents = DataManager.extractSaveContents;
  399. DataManager.extractSaveContents = function(contents)
  400. {
  401.     alias_silv_ItemLog_extractSaveContents.call(this, contents);
  402.     Silv = Silv || {};
  403.     Silv.ItemLog = Silv.ItemLog || {};
  404.     Silv.ItemLog.TextLines = contents.itemLogData;
  405. }
  406. */
  407. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  408. // Automatically add items
  409. //------------------------
  410. //
  411. // Explanation of the this._params:
  412. //
  413. // Gold
  414. // [0] = 0: increase, 1: decrease
  415. // [1] = 0: value, 1: $gameVariable was used to determine amount of gold
  416. // [2] = it is a direct amount of gold but if [1] == 1, then this is the gameVariable number that contains the gold-amount instead.
  417. //
  418. //
  419. // Items, Weapons & Armor
  420. // [0] = armor id matching the $dataArmors index
  421. // [1] = 0: increase, 1: decrease
  422. // [2] = 0: value, 1: $gameVariable was used to determine amount of armors
  423. // [3] = it is a direct amount of gold but if [2] == 1, then this is the gameVariable number that contains the gold-amount instead.
  424. // [4] = include equipment? true/false
  425. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  426. Silv.ItemLog.getAmount = function(params) // does not apply to gold! Gold has different parameters.. Yay for RPG Maker...
  427. {
  428.     return ((params[2] == 0) ? params[3] : $gameVariables.value(params[3])) * (params[1] == 1 ? -1 : 1);
  429. };
  430.  
  431. // Change Gold
  432. var alias_silv_command125 = Game_Interpreter.prototype.command125;
  433. Game_Interpreter.prototype.command125 = function()
  434. {
  435.     var amount = (this._params[1] == 0) ? this._params[2] : $gameVariables.value(this._params[2]);
  436.     if (this._params[0] == 1) { amount *= -1; }
  437.    
  438.     var retVal = alias_silv_command125.apply(this, arguments);
  439.     if (Silv.ItemLog.AutoLogItems) { PluginCommand('ItemLog', ['gold', String(amount), 'skip']); }
  440.     return retVal;
  441. };
  442.  
  443. // Change Items
  444. var alias_silv_command126 = Game_Interpreter.prototype.command126;
  445. Game_Interpreter.prototype.command126 = function()
  446. {
  447.     var retVal = alias_silv_command126.apply(this, arguments);
  448.     if (Silv.ItemLog.AutoLogItems) { PluginCommand('ItemLog', ['item', this._params[0], Silv.ItemLog.getAmount(this._params), 'skip']); }
  449.     return retVal;
  450. };
  451.  
  452. // Change Weapons
  453. var alias_silv_command127 = Game_Interpreter.prototype.command127;
  454. Game_Interpreter.prototype.command127 = function()
  455. {
  456.     var retVal = alias_silv_command127.apply(this, arguments);
  457.     if (Silv.ItemLog.AutoLogItems) { PluginCommand('ItemLog', ['weapon', this._params[0], Silv.ItemLog.getAmount(this._params), 'skip']); }
  458.     return retVal;
  459. };
  460.  
  461. // Change Armors
  462. var alias_silv_command128 = Game_Interpreter.prototype.command128;
  463. Game_Interpreter.prototype.command128 = function()
  464. {
  465.     var retVal = alias_silv_command128.apply(this, arguments);
  466.     if (Silv.ItemLog.AutoLogItems) { PluginCommand('ItemLog', ['armor', this._params[0], Silv.ItemLog.getAmount(this._params), 'skip']); }
  467.     return retVal;
  468. };
  469. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  470. // Plugin Command
  471. // Note: The items are separated by spaces. The command is the first word and any following words are args. args is an array.
  472. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  473. Silv.ItemLog.getPrefixText = function(amount)
  474. {
  475.     var prefixText = rpad((amount >= 0) ? Silv.ItemLog.PositivePrefixText : Silv.ItemLog.NegativePrefixText, ' ', Silv.ItemLog.PrefixLength);
  476.    
  477.     return prefixText;
  478. };
  479.  
  480. var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  481. Game_Interpreter.prototype.pluginCommand = function(command, args)
  482. {
  483.     _Game_Interpreter_pluginCommand.call(this, command, args);
  484.     if (command.toLowerCase() == 'itemlog') { PluginCommand(command, args); }
  485. };
  486.  
  487. function PluginCommand(cmd, args)
  488. {
  489.     if (args[0].toLowerCase() == 'show')
  490.     {
  491.         Silv.ItemLog.Window.resetFade();
  492.         return;
  493.     }
  494.    
  495.     // arg: item 1 10
  496.     // arg: weapon 2 1
  497.     // arg: weapon 2 1 skip
  498.     // arg: gold 123
  499.     var db = getDatabase(args[0]);
  500.     var lootIdx = parseInt(args[1]);
  501.     var skipAddItemToInventory = (String(args[args.length - 1]).toLowerCase() == 'skip');
  502.     if (db != 'gold')
  503.     {
  504.         var amount = args[2];
  505.         if (amount.length == 1) { amount = ' ' + amount; }
  506.         var name = db[lootIdx].name;
  507.         var iconIndex = db[lootIdx].iconIndex;
  508.        
  509.         var t1 = Silv.ItemLog.getPrefixText(amount) + lpad(Math.abs(amount), ' ', 2) + 'x ';
  510.         var t2 = name;             
  511.        
  512.         Silv.ItemLog.TextLines.queue({t1: t1, iconIndex: iconIndex, t2: t2});
  513.        
  514.         // Add loot
  515.         if (Silv.ItemLog.AutoLootGain && !skipAddItemToInventory)
  516.         {
  517.             $gameParty.gainItem(db[lootIdx], parseInt(args[2]));
  518.         }
  519.        
  520.         // sfx
  521.         if (!Silv.ItemLog.AlreadyPlayedSFX)
  522.         {
  523.             Play_SE(Silv.ItemLog.PickupSFXItem);
  524.             Silv.ItemLog.AlreadyPlayedSFX = true;
  525.         }
  526.     }
  527.     else // Gold
  528.     {
  529.         var amount = parseInt(args[1]);
  530.         Silv.ItemLog.TextLines.queue({t1: Silv.ItemLog.getPrefixText(amount) + '    ', iconIndex: Silv.ItemLog.GoldIconIndex, t2: Math.abs(amount) + ' ' + $dataSystem.currencyUnit});
  531.        
  532.         // Add loot
  533.         if (Silv.ItemLog.AutoLootGain && !skipAddItemToInventory)
  534.         {
  535.             $gameParty.gainGold(amount);
  536.         }
  537.        
  538.         // sfx
  539.         if (!Silv.ItemLog.AlreadyPlayedSFX)
  540.         {
  541.             Play_SE(Silv.ItemLog.PickupSFXGold);
  542.             Silv.ItemLog.AlreadyPlayedSFX = true;
  543.         }
  544.     }
  545.     Silv.ItemLog.Window.resetFade(); // Reset the fadeout, if any.
  546.    
  547.     function getDatabase(code)
  548.     {
  549.         code = code.toLowerCase();
  550.         if (code.contains('item') || code.contains('itm'))
  551.             return $dataItems;
  552.         if (code.contains('armor'))
  553.             return $dataArmors;
  554.         if (code.contains('weapon') || code.contains('wpn'))
  555.             return $dataWeapons;
  556.         if (code.contains('gold'))
  557.             return 'gold';
  558.        
  559.         throw('getDatabase('+ code + ') ERROR: invalid code.');
  560.     }
  561.    
  562.     function Play_SE(filename)
  563.     {
  564.         AudioManager.playSe({name: filename, volume: 90, pitch: 100, pan: 0});
  565.     }
  566. }
  567. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  568. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement