WCouillard

Star Ocean The Last Hope Elemental Item Checks v1.00

Sep 25th, 2025 (edited)
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2.  * @plugindesc v1.00 Star Ocean: The Last Hope - Elemental Item Checks
  3.  * @author Coolie (William Couillard)
  4.  *
  5.  * @param Fire Ring Item ID
  6.  * @type item
  7.  * @desc The item that represents the Fire element.
  8.  * @default 1
  9.  *
  10.  * @param Fire Ring Charges Variable
  11.  * @type variable
  12.  * @desc Game variable that tracks Fire Ring's charges.
  13.  * @default 1
  14.  *
  15.  * @param Ice Ring Item ID
  16.  * @type item
  17.  * @desc The item that represents the Ice element.
  18.  * @default 2
  19.  *
  20.  * @param Ice Ring Charges Variable
  21.  * @type variable
  22.  * @desc Game variable that tracks Ice Ring's charges.
  23.  * @default 2
  24.  *
  25.  * @param Lightning Ring Item ID
  26.  * @type item
  27.  * @desc The item that represents the Lightning element.
  28.  * @default 3
  29.  *
  30.  * @param Lightning Ring Charges Variable
  31.  * @type variable
  32.  * @desc Game variable that tracks Lightning Ring's charges.
  33.  * @default 3
  34.  *
  35.  * @param Water Ring Item ID
  36.  * @type item
  37.  * @desc The item that represents the Water element.
  38.  * @default 4
  39.  *
  40.  * @param Water Ring Charges Variable
  41.  * @type variable
  42.  * @desc Game variable that tracks Water Ring's charges.
  43.  * @default 4
  44.  *
  45.  * @param Earth Ring Item ID
  46.  * @type item
  47.  * @desc The item that represents the Earth element.
  48.  * @default 5
  49.  *
  50.  * @param Earth Ring Charges Variable
  51.  * @type variable
  52.  * @desc Game variable that tracks Earth Ring's charges.
  53.  * @default 5
  54.  *
  55.  * @param Wind Ring Item ID
  56.  * @type item
  57.  * @desc The item that represents the Wind element.
  58.  * @default 6
  59.  *
  60.  * @param Wind Ring Charges Variable
  61.  * @type variable
  62.  * @desc Game variable that tracks Wind Ring's charges.
  63.  * @default 6
  64.  *
  65.  * @param Light Ring Item ID
  66.  * @type item
  67.  * @desc The item that represents the Light element.
  68.  * @default 7
  69.  *
  70.  * @param Light Ring Charges Variable
  71.  * @type variable
  72.  * @desc Game variable that tracks Light Ring's charges.
  73.  * @default 7
  74.  *
  75.  * @param Dark Ring Item ID
  76.  * @type item
  77.  * @desc The item that represents the Dark element.
  78.  * @default 8
  79.  *
  80.  * @param Dark Ring Charges Variable
  81.  * @type variable
  82.  * @desc Game variable that tracks Dark Ring's charges.
  83.  * @default 8
  84.  *
  85.  * @param Ring Max Charges
  86.  * @type number
  87.  * @min 1
  88.  * @desc The maximum number of charges any ring can have.
  89.  * @default 20
  90.  *
  91.  * @help
  92.  * -----------------------------------------------------------------------------
  93.  *  ABOUT THIS PLUGIN (Star Ocean: The Last Hope Elemental Item Checks)
  94.  * -----------------------------------------------------------------------------
  95.  * In Star Ocean: The Last Hope, players can find a variety of elemental rings
  96.  * that are required to interact with certain map objects, like doors, chests,
  97.  * and other objects. Each ring has a limited number of charges and must be
  98.  * recharged when they run out of them.
  99.  *
  100.  * For example, a chest wreathed in flames would require an Ice Ring to break
  101.  * the seal and open the chest. This would deplete one charge from the ring.
  102.  * Each ring had a maximum of 20 charges.
  103.  *
  104.  * -----------------------------------------------------------------------------
  105.  *  HOW TO USE
  106.  * -----------------------------------------------------------------------------
  107.  * In a Conditional Branch, select Script and use one of the following:
  108.  *
  109.  *   HasFireRing
  110.  *   HasIceRing
  111.  *   HasLightningRing
  112.  *   HasWaterRing
  113.  *   HasEarthRing
  114.  *   HasWindRing
  115.  *   HasLightRing
  116.  *   HasDarkRing
  117.  *
  118.  * These will return TRUE if the player has the item AND its charges are > 0.
  119.  *
  120.  * To check against the number of charges an elemental item has, use a Script
  121.  * Call, changing the element for the one you want to check. For example:
  122.  *
  123.  *   FireRingCharges    - Returns current charges
  124.  *   FireRingMaxCharges - Returns max charges
  125.  *
  126.  * In order to recharge a ring to its maximum charges, use a Plugin Command:
  127.  *
  128.  *   RechargeFireRing
  129.  *   RechargeIceRing
  130.  *   RechargeLightningRing
  131.  *   RechargeWaterRing
  132.  *   RechargeEarthRing
  133.  *   RechargeWindRing
  134.  *   RechargeLightRing
  135.  *   RechargeDarkRing
  136.  *
  137.  * The requirements to recharge an item is up to you. Perhaps it should cost
  138.  * the player some Gold, or perhaps there should be some other requirement. It's
  139.  * up to you.
  140.  *
  141.  * -----------------------------------------------------------------------------
  142.  *  PLUGIN PARAMETERS
  143.  * -----------------------------------------------------------------------------
  144.  * Each item has a plugin parameter for the item's ID and an in-game variable
  145.  * to track the item's current number of charges. The plugin parameters also
  146.  * allow the user to set a maximum number of charges that is shared by all of
  147.  * the elemental items.
  148.  *
  149.  * -----------------------------------------------------------------------------
  150.  *  IMPORTANT NOTE!!
  151.  * -----------------------------------------------------------------------------
  152.  * 1. The plugin does not deplete charges on its own. You can easily do this
  153.  *    manually via the Change Variables event command.
  154.  * 2. You can display the number of charges for a specific elemental item by
  155.  *    using the escape code \v[x] where x is the variable ID tied to the item
  156.  *    in the plugin parameters.
  157.  *
  158.  * -----------------------------------------------------------------------------
  159.  * TERMS OF USE
  160.  * -----------------------------------------------------------------------------
  161.  * It is OK to use this plugin in both commercial and non-commercial projects.
  162.  *
  163.  * Credit is appreciated, but not required. Happy game making!
  164.  *
  165.  * -----------------------------------------------------------------------------
  166.  * VERSION & UPDATE HISTORY
  167.  * -----------------------------------------------------------------------------
  168.  * > v1.00 : - Initial Release
  169.  *   > September 25, 2025
  170.  */
  171.  
  172. (function() {
  173.     var parameters = PluginManager.parameters('ElementalItemChecks') || {};
  174.     var fireRingId      = Number(parameters['Fire Ring Item ID'] || 1);
  175.     var iceRingId       = Number(parameters['Ice Ring Item ID'] || 2);
  176.     var lightningRingId = Number(parameters['Lightning Ring Item ID'] || 3);
  177.     var waterRingId     = Number(parameters['Water Ring Item ID'] || 4);
  178.     var earthRingId     = Number(parameters['Earth Ring Item ID'] || 5);
  179.     var windRingId      = Number(parameters['Wind Ring Item ID'] || 6);
  180.     var lightRingId     = Number(parameters['Light Ring Item ID'] || 7);
  181.     var darkRingId      = Number(parameters['Dark Ring Item ID'] || 8);
  182.     var fireRingVar      = Number(parameters['Fire Ring Charges Variable'] || 1);
  183.     var iceRingVar       = Number(parameters['Ice Ring Charges Variable'] || 2);
  184.     var lightningRingVar = Number(parameters['Lightning Ring Charges Variable'] || 3);
  185.     var waterRingVar     = Number(parameters['Water Ring Charges Variable'] || 4);
  186.     var earthRingVar     = Number(parameters['Earth Ring Charges Variable'] || 5);
  187.     var windRingVar      = Number(parameters['Wind Ring Charges Variable'] || 6);
  188.     var lightRingVar     = Number(parameters['Light Ring Charges Variable'] || 7);
  189.     var darkRingVar      = Number(parameters['Dark Ring Charges Variable'] || 8);
  190.     var maxCharges = Number(parameters['Ring Max Charges'] || 20);
  191.  
  192.     function hasRing(itemId, varId) {
  193.         return $gameParty.hasItem($dataItems[itemId]) && $gameVariables.value(varId) > 0;
  194.     }
  195.  
  196.     function getRingCharges(varId) {
  197.         return $gameVariables.value(varId);
  198.     }
  199.  
  200.     function setRingCharges(varId, value) {
  201.         $gameVariables.setValue(varId, Math.max(0, Math.min(value, maxCharges)));
  202.     }
  203.  
  204.     function getMaxCharges() {
  205.         return maxCharges;
  206.     }
  207.  
  208.     Object.defineProperty(window, 'HasFireRing', {
  209.         get: function() { return hasRing(fireRingId, fireRingVar); },
  210.         configurable: true
  211.     });
  212.     Object.defineProperty(window, 'HasIceRing', {
  213.         get: function() { return hasRing(iceRingId, iceRingVar); },
  214.         configurable: true
  215.     });
  216.     Object.defineProperty(window, 'HasLightningRing', {
  217.         get: function() { return hasRing(lightningRingId, lightningRingVar); },
  218.         configurable: true
  219.     });
  220.     Object.defineProperty(window, 'HasWaterRing', {
  221.         get: function() { return hasRing(waterRingId, waterRingVar); },
  222.         configurable: true
  223.     });
  224.     Object.defineProperty(window, 'HasEarthRing', {
  225.         get: function() { return hasRing(earthRingId, earthRingVar); },
  226.         configurable: true
  227.     });
  228.     Object.defineProperty(window, 'HasWindRing', {
  229.         get: function() { return hasRing(windRingId, windRingVar); },
  230.         configurable: true
  231.     });
  232.     Object.defineProperty(window, 'HasLightRing', {
  233.         get: function() { return hasRing(lightRingId, lightRingVar); },
  234.         configurable: true
  235.     });
  236.     Object.defineProperty(window, 'HasDarkRing', {
  237.         get: function() { return hasRing(darkRingId, darkRingVar); },
  238.         configurable: true
  239.     });
  240.  
  241.     Object.defineProperty(window, 'FireRingCharges', {
  242.         get: function() { return getRingCharges(fireRingVar); },
  243.         set: function(v) { setRingCharges(fireRingVar, v); },
  244.         configurable: true
  245.     });
  246.     Object.defineProperty(window, 'IceRingCharges', {
  247.         get: function() { return getRingCharges(iceRingVar); },
  248.         set: function(v) { setRingCharges(iceRingVar, v); },
  249.         configurable: true
  250.     });
  251.     Object.defineProperty(window, 'LightningRingCharges', {
  252.         get: function() { return getRingCharges(lightningRingVar); },
  253.         set: function(v) { setRingCharges(lightningRingVar, v); },
  254.         configurable: true
  255.     });
  256.     Object.defineProperty(window, 'WaterRingCharges', {
  257.         get: function() { return getRingCharges(waterRingVar); },
  258.         set: function(v) { setRingCharges(waterRingVar, v); },
  259.         configurable: true
  260.     });
  261.     Object.defineProperty(window, 'EarthRingCharges', {
  262.         get: function() { return getRingCharges(earthRingVar); },
  263.         set: function(v) { setRingCharges(earthRingVar, v); },
  264.         configurable: true
  265.     });
  266.     Object.defineProperty(window, 'WindRingCharges', {
  267.         get: function() { return getRingCharges(windRingVar); },
  268.         set: function(v) { setRingCharges(windRingVar, v); },
  269.         configurable: true
  270.     });
  271.     Object.defineProperty(window, 'LightRingCharges', {
  272.         get: function() { return getRingCharges(lightRingVar); },
  273.         set: function(v) { setRingCharges(lightRingVar, v); },
  274.         configurable: true
  275.     });
  276.     Object.defineProperty(window, 'DarkRingCharges', {
  277.         get: function() { return getRingCharges(darkRingVar); },
  278.         set: function(v) { setRingCharges(darkRingVar, v); },
  279.         configurable: true
  280.     });
  281.  
  282.     Object.defineProperty(window, 'FireRingMaxCharges', {
  283.         get: function() { return getMaxCharges(); },
  284.         configurable: true
  285.     });
  286.     Object.defineProperty(window, 'IceRingMaxCharges', {
  287.         get: function() { return getMaxCharges(); },
  288.         configurable: true
  289.     });
  290.     Object.defineProperty(window, 'LightningRingMaxCharges', {
  291.         get: function() { return getMaxCharges(); },
  292.         configurable: true
  293.     });
  294.     Object.defineProperty(window, 'WaterRingMaxCharges', {
  295.         get: function() { return getMaxCharges(); },
  296.         configurable: true
  297.     });
  298.     Object.defineProperty(window, 'EarthRingMaxCharges', {
  299.         get: function() { return getMaxCharges(); },
  300.         configurable: true
  301.     });
  302.     Object.defineProperty(window, 'WindRingMaxCharges', {
  303.         get: function() { return getMaxCharges(); },
  304.         configurable: true
  305.     });
  306.     Object.defineProperty(window, 'LightRingMaxCharges', {
  307.         get: function() { return getMaxCharges(); },
  308.         configurable: true
  309.     });
  310.     Object.defineProperty(window, 'DarkRingMaxCharges', {
  311.         get: function() { return getMaxCharges(); },
  312.         configurable: true
  313.     });
  314.  
  315.     var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  316.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  317.         _Game_Interpreter_pluginCommand.call(this, command, args);
  318.         switch (command) {
  319.             case 'RechargeFireRing':
  320.                 setRingCharges(fireRingVar, maxCharges);
  321.                 break;
  322.             case 'RechargeIceRing':
  323.                 setRingCharges(iceRingVar, maxCharges);
  324.                 break;
  325.             case 'RechargeLightningRing':
  326.                 setRingCharges(lightningRingVar, maxCharges);
  327.                 break;
  328.             case 'RechargeWaterRing':
  329.                 setRingCharges(waterRingVar, maxCharges);
  330.                 break;
  331.             case 'RechargeEarthRing':
  332.                 setRingCharges(earthRingVar, maxCharges);
  333.                 break;
  334.             case 'RechargeWindRing':
  335.                 setRingCharges(windRingVar, maxCharges);
  336.                 break;
  337.             case 'RechargeLightRing':
  338.                 setRingCharges(lightRingVar, maxCharges);
  339.                 break;
  340.             case 'RechargeDarkRing':
  341.                 setRingCharges(darkRingVar, maxCharges);
  342.                 break;
  343.         }
  344.     };
  345. })();
Advertisement
Add Comment
Please, Sign In to add comment