The RPG Maker Resource Kit

RMRK RPG Maker Creation => MV => MV Scripts Database => Topic started by: modern algebra on October 31, 2015, 11:01:19 PM

Title: [MV] Geomancy 1.0.0
Post by: modern algebra on October 31, 2015, 11:01:19 PM
Geomancy
Version: 1.0.0
Author: modern algebra
Date: 31 October 2015

Version History



Description


Set terrain and region restrictions on skill use. If you don't want your mage to be able to use lightning skills when he is underground for instance, then you can do that with this plugin.

Features


Instructions

Save the .js file in your plugins folder and import it through the Plugin Manager.

To set up a skill so that it can only be used in certain terrains, you need to put one of the following codes in its notebox:

       <onlyTerrains:x>
       <prohibitedTerrains:y>
 
If you use the onlyTerrains code, then the skill can be used only on terrains with ID x. If you use the prohibitedTerrains code, then the skill can only be used if the party is not on the terrain with ID y. In both cases, x and y must be set to integers. You can set as many terrain tags as you want; just separate them with a space or a comma.

The region codes work essentially the same way.

       <onlyRegions:x>
       <prohibitedRegions:x>
 
Examples:

       <onlyRegions:1 3 4 76>
          The skill can only be used when the party is in regions 1, 3, 4, or 76

       <prohibitedRegions:5 10>
          The skill can be used in every region except regions 5 and 10
 
      <onlyTerrains:7>
          The skill can only be used on tiles marked with terrain tag 7.

Plugin


You can download the .js file from Pastebin: http://pastebin.com/15vqEPUr

Code: [Select]
//=============================================================================
//  Geomancy.js
//=============================================================================
//  Version: 1.0.0
//  Date: 31 October 2015
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*:
 * @plugindesc Set terrain and region restrictions on skill use
 * @author Modern Algebra (rmrk.net)
 * @help To set up a skill so that it can only be used in certain terrains, you
 * need to put one of the following codes in its notebox:
 *
 * <onlyTerrains:x>
 * <prohibitedTerrains:y>
 *
 * If you use the onlyTerrains code, then the skill can be used only on terrains
 * with ID x. If you use the prohibitedTerrains code, then the skill can only be
 * used if the party is not on the terrain with ID y. In both cases, x and y
 * must be set to integers. You can set as many terrain tags as you want; just
 * separate them with a space or a comma.
 *
 * The region codes work essentially the same way.
 *
 * <onlyRegions:x>
 * <prohibitedRegions:x>
 *
 * Examples:
 *
 * <onlyRegions:1 3 4 76>
 * The skill can only be used when the party is in regions 1, 3, 4, or 76
 *
 * <prohibitedRegions:5 10>
 * The skill can be used in every region except regions 5 and 10
 *
 * <onlyTerrains:7>
 * The skill can only be used on tiles marked with terrain tag 7.
 */
//=============================================================================

(function() {

// Game_BattlerBase - meetsSkillConditions
//   Test terrain and region too
var _mag_Game_BattlerBase_meetsSkillConditions =
Game_BattlerBase.prototype.meetsSkillConditions;
Game_BattlerBase.prototype.meetsSkillConditions = function(skill) {
var skillTest = _mag_Game_BattlerBase_meetsSkillConditions.apply(this, arguments);
if (!skillTest || DataManager.isBattleTest()) { return skillTest; }
return this.magMeetsSkillTerrainConditions(skill);
};

// Game_BattlerBase - Test terrain and region conditions for skills
Game_BattlerBase.prototype.magMeetsSkillTerrainConditions = function(skill) {
var terrainTag = $gamePlayer.terrainTag();
var regionId = $gamePlayer.regionId();
var rpatt = /\d+/g
// Can't use if on an expressly prohibited terrain
var prohibitedTerrains = skill.meta.prohibitedTerrains;
if (prohibitedTerrains) {
var match = prohibitedTerrains.match(rpatt);
if (match && match.map(Number).contains(terrainTag)) { return false; }
}
// Can't use if in an expressly prohibited region
var prohibitedRegions = skill.meta.prohibitedRegions;
if (prohibitedRegions) {
var match = prohibitedRegions.match(rpatt);
if (match && match.map(Number).contains(regionId)) { return false; }
}
// Can't use if exclusive terrains defined and not on one
var onlyTerrains = skill.meta.onlyTerrains;
if (onlyTerrains) {
var match = onlyTerrains.match(rpatt);
if (match && !match.map(Number).contains(terrainTag)) { return false; }
}
// Can't use if exclusive regions defined and not in one
var onlyRegions = skill.meta.onlyRegions;
if (onlyRegions) {
var match = onlyRegions.match(rpatt);
if (match && !match.map(Number).contains(regionId)) { return false; }
}
return true; // Can use the skill otherwise
};

})();

Credit



Support


Post in this thread if you have any comments or questions. It is perfectly fine to post here even if this topic has not been posted in for a very long time.

Please do not message me privately, as any concerns you have are likely shared by others and they will benefit from our correspondence being public. Additionally, I am often absent, and posting publicly will allow other members to assist you when I am unable to do so quickly.

Terms of Use


You are welcome to use this script in any project of yours, whether it is commercial or non-commercial. There is no need to credit me, and please feel free to modify the plugin in whatever ways suit your project.

Basically, my plugin is your plugin, but please do not re-post this plugin or any modified version of it on another forum or website.
Title: Re: [MV] Geomancy 1.0.0
Post by: &&&&&&&&&&&&& on October 31, 2015, 11:18:27 PM
I love you thank you.
Title: Re: [MV] Geomancy 1.0.0
Post by: bluntsword on November 01, 2015, 01:47:22 AM
I will add a character in my game just to use this.
Title: Re: [MV] Geomancy 1.0.0
Post by: yuyu! on November 01, 2015, 03:29:04 AM
Breaking news:

Modern algebra continues to be amazing. 99% chance of love showers.

:ma: