Geomancy
Version: 1.0
Author: modern algebra
Date: July 12, 2011
Version History
- <Version 1.0> 2011.07.12 - Original Release
Description
This script, used in conjunction with a terrain tags script, allows you to set it so that specified skills can only be used on particular types of terrain.
Features
- Allows you to prevent actors from using certain skills depending on the terrain they are at. This allows you to, for instance, only allow the use of air spells while above ground, or only allow earth spells when not in the water, etc...
- Works with several terrain tags script
- Very easy to configure
Instructions
This script
REQUIRES a script that restores the terrain tag feature to RMVX. It is designed for either my
Terrain Types script or DerVVulfman's
Tileset Reader script, but may work with other scripts which restore the feature (so long as they have a method in Game_Map named "terrain_tag" that takes the x and y position as arguments and returns the tag for that square).
Paste this script below Materials and above Main. If you are using the Note Editor and want to be able to edit geomancy notes, then you need the Note Editor's General Compatibility Patch and this script must be below both in the script order.
For instructions on setting the terrains on which skills can be used, see the header of the script.
Script
#==============================================================================
# Geomancy
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: July 12, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script, used in conjunction with a terrain tags script, allows you to
# set it so that certain skills can only be used on particular types of
# terrain.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# This script REQUIRES a terrain tag script (designed for my Terrain Types
# 1.0 and DerVVulfman's Tileset Reader, but most would likely work).
#
# To set it so that a skill can only be used on particular terrain tags,
# simply put the following code in the notebox of the skill:
#
# \Terrains[x, y, ..., z]
#
# where x, y, ..., z are the terrain tags you want to enable it for. If you
# don't set this code at all, then the skill can be used on any non-excluded
# terrains.
#
# You can also do it backwards - if you want the skill to be usable on all
# terrains EXCEPT specified terrains, then you use the following code:
#
# \!Terrains[x, y, ..., z]
#
# where x, y, ..., z are this time the tags you DON'T want to be able to use
# the skill on.
#==============================================================================
#==============================================================================
# ** RPG::Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - valid_terrain?
#==============================================================================
class RPG::Skill
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Valid Terrain?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def valid_terrain? (terrain_tag)
if !@valid_terrains
@valid_terrains, @invalid_terrains = [], []
$1.gsub! (/\d+/) { |tag| @invalid_terrains.push (tag.to_i) } if self.note[/\\!TERRAINS\[(.+?)\]/i]
$1.gsub! (/\d+/) { |tag| @valid_terrains.push (tag.to_i) } if self.note[/\\TERRAINS\[(.+?)\]/i]
end
return (!@invalid_terrains.include? (terrain_tag)) && (@valid_terrains.empty? || @valid_terrains.include? (terrain_tag))
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Note Editor Compatibility - Reset Note
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if self.method_defined? (:ma_reset_note_values)
alias maga_geom_rst_note_6yc1 ma_reset_note_values
def ma_reset_note_values (*args, &block)
maga_geom_rst_note_6yc1 (*args, &block) # Run Original Method
@valid_terrains, @invalid_terrains = nil, nil
end
end
end
#==============================================================================
# ** Game_Battler
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - skill_can_use?
#==============================================================================
class Game_Battler
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Skill Available?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mab_kf_geomancy_canuse_8hf9 skill_can_use?
def skill_can_use? (skill, *args, &block)
return false if skill.nil?
if Game_Player.method_defined? (:ma_terrain_tag) # My Terrain Types
return false unless skill.valid_terrain? ($game_player.ma_terrain_tag)
elsif Game_Map.method_defined? (:terrain_tag) # Dervvulfman's Tileset Reader
x, y = $game_player.x, $game_player.y
return false unless skill.valid_terrain? ($game_map.terrain_tag (x, y))
end
return mab_kf_geomancy_canuse_8hf9 (skill, *args, &block) # Run Original Method
end
end
Credit
Thanks
Support
Please post in this topic at RMRK for support, no matter how old the topic is.
Known Compatibility Issues
This script is designed to work with my
Terrain Tags script and DerVVulfman's
Tileset Reader. It will likely work with other scripts that reintroduce the terrain tag feature as well.