RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Geomancy

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
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


Code: [Select]
#==============================================================================
#    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.
« Last Edit: July 14, 2011, 02:19:27 AM by modern algebra »

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
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

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
You always manage to make your scripts look so purdy and efficient somehow. Good job, Modern!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
&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
« Last Edit: July 13, 2011, 02:54:23 AM by modern algebra »

***
Rep:
Level 69
RESIDENT ADONKADONK
Not compatible with BEM's Snapshot Battleback, it "is" but it kind of "overrides" it.

I'm back.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
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

***
Rep:
Level 69
RESIDENT ADONKADONK
@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.

***
Rep:
Level 74
I'm baaack!
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?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
By the tile the battle starts on.

***
Gracies New Favorite
Rep:
Level 63
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

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Not currently, no.

***
Gracies New Favorite
Rep:
Level 63
Alright, thank you!