Main Menu
  • Welcome to The RPG Maker Resource Kit.

Geomancy

Started by modern algebra, July 12, 2011, 11:28:14 PM

0 Members and 2 Guests are viewing this topic.

modern algebra

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




  • modern algebra

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.

exhydra

Looks all snazzy! I didn't realize '&block' was so neat ...

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

cozziekuns

You always manage to make your scripts look so purdy and efficient somehow. Good job, Modern!

modern algebra

#3
&block was unnecessary in this script; it'd be pretty weird for someone to modify that method to expect a block. I get pretty paranoid though :P

@cozzie - If that's the case, it's probably because I haven't written a complicated script for like a decade and I have to do something to occupy my time :P

Adon

Not compatible with BEM's Snapshot Battleback, it "is" but it kind of "overrides" it.

I'm back.

pacdiggity

That's weird. Make sure Geomancy is below Battleback. This script only makes one new method and aliases another, so it should be compatible.
What exactly is wrong with the script processing?
it's like a metaphor or something i don't know

Adon

@Pacman
No errors or anything, it just makes the BEM snapshot battle back script worthless. It doesn't even do anything.
EDIT:
Ohh sorry! MA's Terrain script isn't compatible with YEM, or does above.

I'm back.

Infinate X

If your using the whole YEM engine then I see why it's uncompatable but if you try to figure out which scripts you need and which ones don't work then it will work. When I use YERD script I just take the ones I need and I leave the rest.

MA, this script is awesome as the rest of your scripts are, I just want to know if it's by the tile the battle starts on or if it's every tile on the map?

modern algebra

By the tile the battle starts on.

Zodiac

I actually have a question about this script, as it looks pretty cool and it's something I wouldn't mind using.  Is there any way to make a single skilled named Geomancy, and have it use the other skills depending on what terrain you're on? Like, I use the skill "Geomancy" on a road, and it uses an earth-based move, but if I'm in water, I use that same "Geomancy" Skill, and it uses a water-based move.  I was curious if that was possible instead of just graying out skills when they couldn't be used

modern algebra


Zodiac