Galv’s Region Effects V.1.9

Requires demo for the pre-made effects – Demo – Version 1.9 >

#------------------------------------------------------------------------------#
#  Galv's Region Effects
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.9
#  Credit to Yanfly and Quack for event spawning method
#------------------------------------------------------------------------------#
#  2014-01-07 - Version 1.9 - upgrade to not stop animations playing when a 
#                             region effect is drawn.
#  2013-01-24 - Version 1.8 - minor tweaks
#  2013-01-22 - Version 1.7 - Made effects work during forced move routes
#  2012-11-15 - Version 1.6 - Fixed a major bug caused with last update.
#  2012-11-04 - Version 1.5 - streamline updates and bug fix suggested by Quack
#  2012-10-23 - Version 1.4 - updated alias naming convention for compatability
#  2012-10-09 - Version 1.3 - re-wrote the code to be more efficient when
#                           - using many different region effects.
#  2012-10-09 - Version 1.2 - code tweak that may reduce lag on low-end pc's
#  2012-09-16 - Version 1.1 - now compatible with Yanfly's spawn events
#  2012-09-15 - Version 1.0 - release
#------------------------------------------------------------------------------#
#  Designed to activate effects when regions are stood on.
#  An effect can include:
#     - Sound Effect
#     - An event that appears at the player's location
#     - Activating a common event
#
# 
#  INSTRUCTIONS:
#  1. Copy image from /Graphics/Characters/!Other-specials.png to your project
#  2. Copy the map from this demo into your game.
#        - this map has events set up for the pre-made effects
#  3. Check the map ID of the map you copied in your game
#  4. Change the SPAWN_MAP_ID number to this map ID
#  5. Change REGION_EFFECT_SWITCH to a switch you are not using in your game.
#  6. Add some regions to your map to test.
# 
#
#
#  To disable region effects use
#  $game_player.region_effects = false
#
#------------------------------------------------------------------------------#

$imported = {} if $imported.nil?
$imported["Region_Effects"] = true

module Region_Effects
#------------------------------------------------------------------------------#
#  SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#

   REGION_EFFECT_SWITCH = 1   # Turn this switch ON to disable the effects.

   MAX_EFFECTS = 20           # Number of effects that can be on screen
                              # before being removed. (To prevent lag)
                               
   SPAWN_MAP_ID = 2           # Map ID of the map you store event effects in.
   
   

#------------------------------------------------------------------------------#
#  ENVIRONMENT REGIONS SETUP
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
#
#  region => ["sound", vol, pitch, event_id, common_event_id]
#
#  region          -  the region ID the effect will activate on
#  sound           -  the name of the SE file. "" for no sound
#  vol             -  the volume of the SE (0 - 100)
#  pitch           -  the pitch of the SE (50 - 150)
#  event_id        -  event ID called from the spawn map. 0 for none.
#  common_event_id -  common event ID to call. 0 for no common event.
#
#------------------------------------------------------------------------------#
    EFFECT = { # ! don't touch this
#------------------------------------------------------------------------------#

    0 => ["", 0, 0, 0, 0],              # No Effect (no region)
    
    # Pre-made effects (requires demo events)
    1 => ["", 0, 0, 5, 0],              # Dirt dust
    2 => ["Blow7", 60, 150, 0, 0],      # Wood surface noise only
    3 => ["Water1", 60, 110, 1, 0],     # Shallow Water
    
    18 => ["Earth2", 40, 130, 0, 0],     # Hard surface noise only
    5 => ["Damage3", 40, 150, 2, 0],    # Footprints
    6 => ["Ice9", 50, 130, 3, 0],       # Walking over thick grass
    7 => ["", 0, 0, 0, 1],              # Calls common event 1 only
    8 => ["Fire3", 80, 120, 4, 2],      # Calls fire trap
    37 => ["", 80, 120, 6, 0],          # Dust cloud
    
    # You can add more as required. eg:
    # 42 => ["", 0, 0, 0, 0],
    # 18 => ["", 0, 0, 0, 0],
    # etc. etc.
    
    # Only one effect per region number will work
    
#------------------------------------------------------------------------------#
    } # ! don't touch this
#------------------------------------------------------------------------------#
#  END SCRIPT SETUP
#------------------------------------------------------------------------------#
    
end # Region_Effects

module DataManager

#--------------------------------------------------------------------------
# alias method: load_normal_database
#--------------------------------------------------------------------------
class <<self; alias load_normal_database_spawn_alias load_normal_database; end
  def self.load_normal_database
    load_normal_database_spawn_alias
    $data_spawn_map = load_data(sprintf("Data/Map%03d.rvdata2", Region_Effects::SPAWN_MAP_ID))
  end
end

class Game_Player < Game_Character
  attr_accessor :region_effects
  
  alias galv_region_effects_update_update_nonmoving update_nonmoving
  def update_nonmoving(last_moving)
    if last_moving
      galv_region_check unless $game_switches[Region_Effects::REGION_EFFECT_SWITCH] == true
    end
    galv_region_effects_update_update_nonmoving(last_moving)
  end
  
  def galv_region_check
    return if Input.trigger?(:C)
    v = rand(10) - rand(10)
    p = rand(40) - rand(40)
    
    r_id = $game_map.region_id($game_player.x, $game_player.y)
    return if Region_Effects::EFFECT[r_id] == nil
    
    sound = Region_Effects::EFFECT[r_id][0]
    vol = Region_Effects::EFFECT[r_id][1]
      pit = Region_Effects::EFFECT[r_id][2]
      eve = Region_Effects::EFFECT[r_id][3]
      com_eve = Region_Effects::EFFECT[r_id][4]

      RPG::SE.new(sound, vol + v, pit + p).play
      if eve > 0
        $game_map.region_event($game_player.x, $game_player.y, eve, Region_Effects::SPAWN_MAP_ID)
      end
      $game_temp.reserve_common_event(com_eve) unless com_eve == nil
  end
  

end # Game_Player



class Game_Map
  attr_accessor :effectlist
  attr_accessor :r_events

  alias galv_region_effects_setup setup
  def setup(map_id)
    @effectlist = []
    @r_events = {}
    galv_region_effects_setup(map_id)
    
    @eid = 0
  end
  
  def region_event(dx, dy, event_id, map_id)
    map_id = @map_id if map_id == 0
    map = $data_spawn_map
    event = generated_region_event(map, event_id)

    @eid += 1
    @effectlist.push(@eid)
    @effectlist.shift if @effectlist.count > Region_Effects::MAX_EFFECTS

    @r_events[@eid] = Game_Event.new(@map_id, event)
    @r_events[@eid].moveto(dx, dy)
    SceneManager.scene.spriteset.refresh_region_effects

    @eid = 0 if @eid >= Region_Effects::MAX_EFFECTS
  end

  
  def generated_region_event(map, event_id)
    for key in map.events
      event = key[1]
      next if event.nil?
      return event if event.id == event_id
    end
    return nil
  end

  alias galv_region_effects_gm_refresh refresh
  def refresh
    @r_events.each_value {|event| event.refresh }
    galv_region_effects_gm_refresh
  end
  
  alias galv_region_effects_gm_update_events update_events
  def update_events
    @r_events.each_value {|event| event.update }
    galv_region_effects_gm_update_events
  end
  
end # Game_Map



class Spriteset_Map
  def refresh_region_effects
    dispose_region_sprites
    create_region_sprites
  end
  
  alias galv_region_effect_sm_sb_create_characters create_characters
  def create_characters
    create_region_sprites
    galv_region_effect_sm_sb_create_characters
  end
  
  alias galv_region_effect_sm_sb_update_characters update_characters
  def update_characters
    galv_region_effect_sm_sb_update_characters
    @region_sprites.each { |sprite| sprite.update }
  end
  
  alias galv_region_effect_sm_sb_dispose_characters dispose_characters
  def dispose_characters
    dispose_region_sprites
    galv_region_effect_sm_sb_dispose_characters
  end
  
  def create_region_sprites
    @region_sprites = []
    $game_map.effectlist.each_with_index { |id,i|
      @region_sprites[i] = Sprite_Character.new(@viewport1,$game_map.r_events[id])
    }
  end
  
  def dispose_region_sprites
    @region_sprites.each { |sprite| sprite.dispose }
  end
end



class Scene_Map < Scene_Base
  attr_accessor :spriteset
  
  alias galv_region_effects_start start
  def start
    galv_region_effects_start
    SceneManager.scene.spriteset.refresh_region_effects
  end
end # Scene_Map
Advertisements

77 thoughts on “Galv’s Region Effects V.1.9

  1. guest says:

    reupload the demo please

    • Galv says:

      I wasn’t sure why you asked me to do this, but then I read that mediafire free only allows 10 downloads of a file per day per week. Ouch. Come back and try again later, I’ll fix it up :)

  2. Baqiao Liu says:

    Sorry for bothering you. It might be rude to ask this, however, can I reproduce this script to a Chinese website? Because as you know, in China, we cannot go to wordpress websites because the government blocks it. This is the first time I do something about this. Could you give me some advice about this?
    By the way, here is the website url I am going to reproduce this script: bbs.66rpg.com

  3. Galv says:

    It’s not rude, thank you for asking permission. Yes, you may reproduce it on another site as long as you give credit :)

    • Dalton Sayre says:

      Galv,
      Thank you for this awesome script. Is there a way that I could add specific battlebacks to the existing tags?
      It would ease the tedium of setting them for individual battles on a map that has desert, beach, snow & grass.

      i.e.:
      region => [“sound”, vol, pitch, event_id, common_event_id, battleback_1_id, battleback_2_id]

      # region – the region ID the effect will activate on
      # sound – the name of the SE file. “” for no sound
      # vol – the volume of the SE (0 – 100)
      # pitch – the pitch of the SE (50 – 150)
      # event_id – event ID called from the spawn map. 0 for none.
      # common_event_id – common event ID to call. 0 for no common event.
      # battleback_1 – floor of battleback
      # battleback_2 – background of battleback

      I tried to figure it out myself, but I am no scripter.

      • Galv says:

        Don’t forget about the common event feature of this script. It was added so you could do pretty much whatever you want and this is something you can do. All you’d need is one common event that uses conditional branches to check what region the player is on (or even terrain tag if you preferred) and change the battlebacks accordingly.

  4. Pretty-Belle says:

    Wow, what a nice script! Would you mind if I disclose it in a brazilian forum? :)

  5. yobuko says:

    I may sound stupid for asking this but it doesn’t work for my game. :/

    I uploaded the script and did everything it told me to do (images, copy the map and place regions etc)
    but it doesn’t do anything.

    I don’t really know what you mean by “Change REGION_EFFECT_SWITCH to a switch you are not using in your game.”.
    (again sorry, I’m new to this)

    • Galv says:

      At the top of the script there are settings you can change. One of those settings says “REGION_EFFECT_SWITCH =” and then has a number next to it. That number is the number of a switch in your game. The switch you want to use to turn the script ON or OFF.

      If you did everything correctly, it will work. I don’t know what you’ve done wrong as I can’t see it.

  6. TZ says:

    ummm… the demo link is gone?

  7. Aleks says:

    Can you make it work for followers too? Not the sounds, but the animations, like when walking through water your followers make the water move too

  8. Bleuw says:

    Ok, I have a dumb problem… (I guess)
    How can i low the Volume… i know the script says something about it, but in game when I try to low it a little, it doesn’t work.. When I walk on water the spash sounds way to high compared to the rest of the BGS and Music.
    Sorry to bug you with a noob question.

    • Galv says:

      In the settings, the number after the sound effect name is the volume.
      region => [“sound”, vol, pitch, event_id, common_event_id]

      the water region is:
      3 => [“Water1”, 60, 110, 1, 0],
      so you change 60 to change the volume.

  9. Kovain says:

    I had a lot of problems trying to use this script because I DID NOT realized that you had to change the SPAWN_MAP_ID value to the value of the map called “effects to spawn” that you copied into your project. I used the Map ID from the “test Map”. I think that is really necessary to say this to anyone who wants to implement your cool project. That’s why i leave it on the comments.

    Great Stuff!! Thank You :)

    • jesserocker says:

      Sorry Kovain to ask a silly question but I just recently bought RPG Maker VX Ace and I’m not so certain of how to work scripts. Could you explain to me how to “change the SPAWN_MAP_ID value to the value of the map called “effects to spawn”” please? Thank you so much :)

      • Galv says:

        Each map in your game has an ID (a number).
        One way to see what the number is, is right click on the map and go to “map properties” and you will see a number in the title bar like: 003

        If it’s 003, that means the map ID = 3

        So you need to copy the map from the demo to your project and then check it’s map ID in your project.

        Then in the script, you would change it to the ID you find.

  10. Max says:

    Hi Galv, awesome script! :) I was wondering if you considered using “Terrain tag” from the database’s tileset. This way, the script would be much more easy (and quick) to set-up!

    • Galv says:

      Someone wrote a patch that does this but it doesn’t appear to be there any more.
      I didn’t originally use terrain tags because I wrote this for myself and I do full parallax mapping. I’m actually very busy of late so I cannot make this change for you soon, but I will one day.

  11. Meo says:

    how can I make a region impassable?

  12. Ellen says:

    Hi Galv, this is really ridiculous-sounding but it doesn’t work for me. Whenever I move it makes the desired tracks, but they overlap several times and don’t go away until I move a certain amount of steps, so it’s like I’m carrying a tail of tractor trails behind me :\ I’m using Victor’s Pixel Movement and Diagonal Movement scripts, do you think that’s why? Thanks in advance.

  13. Emjenoeg says:

    Hello, Galv! I love this awesome script of yours, but I have a little problem about the script.

    while the the sound effect when the character moving is perfect. But when I make them run (pressed SHIFT) the sound of footsteps sound too fast and unnatural. Is there any way to “slow down” the frequency of the footsteps when the character is running?

  14. chris says:

    The download link doesn’t work for me, can anyone help with that?

  15. Dominique says:

    Hey Galv, I had a bit of a problem with your script, you see I was using an SE that isn’t from the Resource Audio folder. I was wondering if there’s a way to use imported SE rather than the default ones. Ty for reading

    • Galv says:

      There is a resource manager in rpgmaker that allows you to import your own SE. Then you just need to add the right sound effect name into the script settings.

  16. Wada says:

    To be honest, it took me quite some time to figure this out, but after a while I did start to get it. However, I was wondering about how the effect section of the script says not to touch it. Does that include adding our own thing without actually erasing any part of the script? I’m sorry if it’s a stupid question.

  17. Wada says:

    I’m sorry to bother you again, but I was wondering:
    I noticed that when I interact with an event that changes the player’s graphic the sound effects I used for walking disappears. Did I do something wrong or is there something I missed?

  18. Karsomir says:

    thank you very much for this script and others

  19. Angry Argonian says:

    Hi! Whenever i try to enter game.rvproj2 is gives me an error “Failed to load actor data.” If you could help that would be great. Thanks.

    • Galv says:

      I recommend asking in forums about that or trying to google a solution. Sounds like you may have corrupt files but I don’t do rpgmaker support here, sorry.

  20. Locuranis says:

    Hello. This is an awesome script when I can get it to work, but occasionally I will try to enter a map and I get the following: line 198: NoMethodError occurred. undefined method ‘each_value’ for nil:NilClass. Not sure why I get this on some maps but not on the tester map I created to try the script out.

    • Galv says:

      It looks like you have another script that is refreshing the map before the region effects script creates the @r_events hash.

      Check for script incompatibilities

      • Locuranis says:

        Thanks for the reply! Narrowed it down to Tsukihime’s Overlay Maps, which is too bad because I really like both scripts.

      • Galv says:

        try changing that line from:
        @r_events.each_value {|event| event.refresh }
        to:
        @r_events.each_value {|event| event.refresh } if @r_events

        See what happens

      • Locuranis says:

        Replaced it, then the error popped up on another line. But it was the same line of code so I replaced it there, too. I was able to access the map, but I noticed for the water region the splash graphic wasn’t disappearing correctly after each step. It acted more like snow footprints. When I tried to leave the map I got an error on line 244 for undefined method ‘each’.

      • Galv says:

        Ah well, was worth a try at a quick fix. Unfortunately I don’t have time to do compatibility changes

      • Locuranis says:

        Understand. Fortunately I managed to duplicate a similar effect even if not quite the same. It will have to do. Thanks anyway.

  21. freezegazer says:

    Great script, Thank You very much!
    But I have a little problem with it:
    I have a lags, when this scrpt is working. What could be a reason?

    • Galv says:

      Check for script conflicts. You might have another script that processes more each time the region events are created

      • Freezegazer says:

        Yes, I tryed to make a new project, without any others scripts, but the lag is still there ( Especially the first step on region – about a second).
        Sorry =( It so sad. I love this script, but do not know what happens.

      • Galv says:

        Do other things take a long time to load like transferring to a new map in your game?
        What are the specs of the computer you are using?

      • Freezegazer says:

        Oh sorry, I messed up the page = (
        Strangely, I do not know how to explain it.
        I added to the project a new sound. And named it, for example “water” – I had a lags.
        When I replaced this sound on “water7″ – lags disappeared!
        The problem was in the numbers?!!! (I tested it several times)

      • Freezegazer says:

        “Do other things take a long time to load like transferring to a new map in your game?
        What are the specs of the computer you are using?”
        I’m sorry that I did not answered on these questions.
        I just asked a question and at the same time experimenting with a script’s settings.

  22. Galv. I love u! I like your scripts a lot. I ‘m working on rpg maker from a week, so maybe this question can be stupid because im not so expert.
    However, here my problem: i did all you told to set up and all work fine except that the animation of splash, or fire and others do not appear. When i try the game i listen to just the sounds.

  23. sadsad says:

    I downloaded the demo where should I put it?>

    • Galv says:

      You can put the demo wherever you like. Then extract it, start it up and look around to learn how it works. Read instructions and comments above to try to solve anything you don’t understand.

  24. Flannyr says:

    Soo, uhh, still no way to slow down the frequency of the footstep sounds?? Everything works and looks very good, the frequency only problem :(

    • Galv says:

      The script hasn’t been changed because I’m busy and don’t do requests. So no… still no way and I don’t plan to add that function any time soon.

  25. TsubasaG says:

    Hi :D

    I would just like to know what you can do with this script.I haven’t found anything on YouTube,so I’m goin to ask you :3

  26. Alberto Cerrone says:

    i tried it..but i not understand nothing…even on the demo..if i try add some more snow..nothing appear

    • Galv says:

      Unfortunately I do not have time to teach everyone who doesn’t understand :( Keep trying, look at everything in the demo and look up some tutorials on what regions are to maybe help out

      • Alberto Cerrone says:

        thanks for the reply.i checked everythin but not able to make it worl..i thinked it was just and add this tile ..i tryend even on the dmo adding more snow but nothing appear…the tile skin was the same u used o i thinked it was the right tile

  27. Crono Blazer says:

    Hello Galv,
    I am using your script. But for some reason the right images are not loading. I try to use the water splash, but it loads a picture of my staris instead. im not sure why. any help would be very nice.
    Thank you.
    Mathew,
    P.S.
    not sure if you need to know but i have not changed or edited
    any part of your script.

  28. Crono Blazer says:

    Galv,
    Not to double post. but when i run your demo all images show up as a plant. Images being footprints, splashs and all that. Thanks again

  29. Crono Blazer says:

    and i change it to? the map name i will be using it on? and do i place all map names seperated by a ( , )? sorry about all the questions

    • Galv says:

      # INSTRUCTIONS:
      # 1. Copy image from /Graphics/Characters/!Other-specials.png to your project
      # 2. Copy the map from this demo into your game.
      # – this map has events set up for the pre-made effects
      # 3. Check the map ID of the map you copied in your game
      # 4. Change the SPAWN_MAP_ID number to this map ID
      # 5. Change REGION_EFFECT_SWITCH to a switch you are not using in your game.
      # 6. Add some regions to your map to test.

      Please spend some time examining the demo and trying to work this out. I cannot see what you are doing and I write all these instructions and make a demo to help out

      • Crono Blazer says:

        Galv,

        Lol. I would like too thank you for the massive help you have given me.
        My problem the whole time was ” SPAWN_MAP_ID = 19 ” I had it left as ” 2 ” not knowing
        that it was which map Number it was on my lists of maps. Yes a rather noob mistake lol.
        I have used RPGM sense RPGM 98. So i feel rather foolish. It works fine. If anyone else has this problem i hope this helps.
        Thank you,
        Mathew B. a.k.a Crono Blazer
        P.S. i am also using your Character effects script
        Having a little problem getting it to work right
        but so far so good. thanks again Galv, Love all of your scripts

      • Galv says:

        Glad you worked it out :D

  30. LaylaFi says:

    Hey, Galv
    Can i ask you something? I’d like to have my character player have the footsteos sound effect. But I want her to be able to change graphic. When I change her outfit, the effect dissapear. I’ve tried it with your demo, but it worked perfectly fine. Do you know what happen? And also I don’t understand a single bit about the spawn map ID what’s that for? Sorry, i’m not someone who’s good at scripting…

    I would really appreciate it if you want to reply this comment of mine. Thanks ^^

    • Galv says:

      Changing graphic shouldn’t affect this script.
      I have included instructions and a demo for you to examine and work out how to use this. Please spend the time working this out for yourself. It’s the best way to learn.

  31. Kirby says:

    Hi Galv!
    I’m having trouble with this script when combined with the Effectus: Performance Enhancer script. Your script has been a great improvement to a project i have been working on and i really hope i don’t have to take it out. The problem is that when i have the Effectus script in my project as well as your script when i enter a battle i get this error message:

    Script ‘Effectus’ line 1556: NoMethodError occured.

    undefined method ‘viewport1’ for nil:NilClass

    I know that this is an error from the Effectus script and i’m not sure how familiar you are with it. All i’m asking is if you could perhaps point me to what part of your script might be causing this problem or maybe it’s actually an easy fix. Anyway if you can’t help its not harm done i just wanted to get your opinion.

    Thanks

    • Galv says:

      Unfortunately I don’t have time to do compatibility with effectus. I recommend contacting the author of that script instead as it is changing how default rpgmaker works.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s