• Announcements

    • RagingHobo

      Forum Upgraded!   07/17/2017

      We have successfully upgraded our forum to the latest version! Some things have moved around but don't worry everything is still there, we still need to find updated versions of the plugins we were using previously to restore everything to the way it was. There will be a running topic in the Feedback and Support in case you notice something wrong. Before you do so please clear your browser cache and close your browser completely to rule out a caching issue. Thank you for your patience during the outage and while we get everything back to 150%  
Galv

Region Effects

70 posts in this topic

Region Effects - Version 1.7
By Galv

Introduction
I created this script for myself as a "learning ruby" project. It was designed to activate effects when the player stands on designated regions so there's no need to spam events across the ground to do things.


Features
Specify effects you want to happen on designated region tiles.
Region effects can include:
-- A sound effect (automatically varies volume and pitch so not to be repetitive)
-- An event that appears at the player's location (for example, footprints. These events are stored on a designated map)
-- Activating a common event
I figure with access to these three things (and some eventing knowledge), you can create a region effect that does nearly anything you want so you don't have to spam events everywhere.

Included in the demo are some basic pre-made effects as examples - footprints, water splashes, fire trap, dust trail, bushes rustling, footstep sounds on different surfaces.


Screenshot
A screenshot of just a few of the pre-made effects in the demo:
region-effects.jpg


How to Use
Place script under Materials and above Main.
See top of the script for instructions and settings.

To transfer pre-made effects to your game:
1. Copy image from /Graphics/Characters/!Other-specials.png to your project (into same folder)
2. Copy the "EFFECTS TO SPAWN" map from this demo into your game. (Ctrl+C on the map and Ctrl+V into your game maps is quickest)
-- this map has events set up for the pre-made effects
3. Check the map ID of the copied map as it appears 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.
7. Make sure you start a new game. It will not work loading a pre-script save file.


Script
Get it here


FAQ
None yet.


Credit and Thanks
- Galv
- Yanfly and Quack for the method to spawn an event


Author's Notes


Updates
2012-11-15 Version 1.7 - made the effects work during forced move routes
2012-11-15 Version 1.6 - fixed a major bug that caused events to disappear
2012-11-04 Version 1.5 - bug fix and efficiency updates suggested by Quack
2012-10-24 Version 1.4 - updating alias naming to be compatible with my own scripts... heh.
2012-10-19 Version 1.3 - re-wrote some of the code make it more effecient when using large amounts of effects.
2012-10-09 Version 1.2 - fixed up some dumb code that should reduce lag on low-end pc's
2012-09-16 Version 1.1 - now works with Yanfly's spawn event script

Share this post


Link to post
Share on other sites

The effects looks very nice

 

I asked myself how did add those effect sprites (cuz in the script there is not sprite class defined) then i noticed that you spawn events from another maps, very good idea

Edited by Falcao

Share this post


Link to post
Share on other sites

A very nice script, and easy to edit too. However, I tested it by walking over dust and got this:

 

error.png

 

I'm sure I followed all the steps correctly, so what could be happening?

 

EDIT: Upon re-reading the scripts, it's based on regions. These regions are not tied to the tile itself, but rather, the regions in the region editor. Could this be occuring because I have 9 regions on my world map and am (testing) with region 5 on another map? Currently, the regions are there for determining the location of monster encounters... If this is not the case, then can you enlighten me? Thanks.

Edited by HotfireLegend

Share this post


Link to post
Share on other sites

I see, thanks for telling me.

I'll add a step. You need to start a new game. I am guessing you loaded a save file?

 

Yes, I loaded. Good catch. Let me go try a new game.

 

EDIT: Works beautifully now. Kudos!

Edited by HotfireLegend

Share this post


Link to post
Share on other sites

I believe I have followed the steps properly but this error message comes up when i try to launch the game

I have started a new game also

Line 92 : class Game_Player < Game_Character

I hope you can help

post-14775-0-79783800-1347953288_thumb.png

Share this post


Link to post
Share on other sites

I haven't seen this one before. I'm not sure how it could happen on new game or launching a game.

Double check that you copied the entire script.

 

If you can upload your project somewhere I will happily check if you've done it correctly.

Kegasaur likes this

Share this post


Link to post
Share on other sites

I see what you've done - you have pasted the script at the top of them all. You need to paste it below the "Materials" heading and above the "Main" heading.

That's where all scripts you try will go.

Kegasaur likes this

Share this post


Link to post
Share on other sites

Thank you, i guess I'm shit at reading, i just found where it says to put it in materials :P

It launches now so thanks again.

I noticed that the water you used can be walked through but not on mine,I was wondering how you change that

Edited by Kegasaur

Share this post


Link to post
Share on other sites

Ah, I'm never going to finish my project when people like you post fine stuff like this every other day! ... but I was really looking for something like that, and it's pretty sweet! Nice & thanks!

Share this post


Link to post
Share on other sites

Just an FYI - Updated to v.1.2.

I found that low-end PC's lagged a bit while event effects were happening. A small change to the code reduces that significantly.

At least... my old dodgy test laptop likes areas using this in Pirate Rush a whole lot better now haha.

 

EDIT: And another efficiency update to v.1.3 to run better when using large amounts of effects.

EDIT: 1.4... heh.

Edited by Galv

Share this post


Link to post
Share on other sites

Well, here's what I mean. (Forget using BGS, I have a better idea.)

 

There are X different SEs for each region, instead of just 1 as in your script at the moment. With each step the character takes, it randomly plays one of the X SEs. This would vary the sound of the footstep, making it far more realistic + enjoyable.

Edited by Jinjo

Share this post


Link to post
Share on other sites

Nice script, love it.

 

However, the way you choose ids for the events you spawn make it kind of incompatible with Spawn Event script.

Also, using Yanflys method of loading the data for a whole map everytime you spawn an event just sounds very inefficient to me.

Share this post


Link to post
Share on other sites

Well, here's what I mean. (Forget using BGS, I have a better idea.)

 

There are X different SEs for each region, instead of just 1 as in your script at the moment. With each step the character takes, it randomly plays one of the X SEs. This would vary the sound of the footstep, making it far more realistic + enjoyable.

 

The sound effect played varies pitch and volume to try to add that "realistic and enjoyable" feel.

But if you want to use multiple SE's, you could use the common event part of the effect to do it instead and not use the normal SE for it.

 

 

 

Nice script, love it.

 

However, the way you choose ids for the events you spawn make it kind of incompatible with Spawn Event script.

Also, using Yanflys method of loading the data for a whole map everytime you spawn an event just sounds very inefficient to me.

Still learning scripting. Don't know how to make it any more efficient. I use this in my own game with no issues.

 

Which spawn event script is in incompatible with?

Share this post


Link to post
Share on other sites

Not sure if anyone else's noticed, but when using Yami's Overlay script, the region effects won't appear visually when you use a ground layer, unless it's transparent. (Meaning basically, the effect is still occuring, it's just occuring under the ground so you can't see it, not so bad if you only want the sound effects though.)

Share this post


Link to post
Share on other sites
Still learning scripting. Don't know how to make it any more efficient. I use this in my own game with no issues.

 

Which spawn event script is in incompatible with?

 

I'm new to scripting too. And I never said it wasn't efficient enough, it just sounds to me like it would be pretty slow to load the data for a whole map everytime you want to spawn an event. But if it works it works.

 

As for the possible icompatibility, you calculate the new id for an event this way:

 

if @effect_var == 0		  
 key_id = Region_Effects::START_ID		  
 @effect_var = Region_Effects::START_ID + 1		  
elsif @effect_var <= Region_Effects::MAX_EFFECTS + Region_Effects::START_ID - 1		  
 key_id = @effect_var		  
 @effect_var = @effect_var + 1		  
else		  
 key_id = Region_Effects::START_ID		  
 @effect_var = Region_Effects::START_ID + 1		  
end		

 

If the id is already in use you overwrite the old event.

 

The way Yanflys and Kals Spawn Event scripts choose a new id is this way: id = @events.keys.max + 1

 

So if for example you are on a map and one ore or more events are spawned by your script, and an event is then spawned by Yanflys Spawn Event script. The next time an event is spawned by your script, that new event will overwrite the event spawned by Yanflys script (assuming the amount of events that were spawned by your script before an event was spawned by Yanflys script was lower than the MAX_EFFECTS constant in your script).

Share this post


Link to post
Share on other sites

Not sure if anyone else's noticed, but when using Yami's Overlay script, the region effects won't appear visually when you use a ground layer, unless it's transparent. (Meaning basically, the effect is still occuring, it's just occuring under the ground so you can't see it, not so bad if you only want the sound effects though.)

 

The region effect spawned events are just normal events - nothing special about them.

Unrelated to this script - in my game I changed the z value for the ground layer in yami's script as it was displaying above events for me, too. I wasn't sure if that was intentional or why nobody had commented on that, I thought it was just me haha.

 

 

Still learning scripting. Don't know how to make it any more efficient. I use this in my own game with no issues.

 

Which spawn event script is in incompatible with?

 

I'm new to scripting too. And I never said it wasn't efficient enough, it just sounds to me like it would be pretty slow to load the data for a whole map everytime you want to spawn an event. But if it works it works.

 

As for the possible icompatibility, you calculate the new id for an event this way:

 

if @effect_var == 0		  
 key_id = Region_Effects::START_ID		  
 @effect_var = Region_Effects::START_ID + 1		  
elsif @effect_var <= Region_Effects::MAX_EFFECTS + Region_Effects::START_ID - 1		  
 key_id = @effect_var		  
 @effect_var = @effect_var + 1		  
else		  
 key_id = Region_Effects::START_ID		  
 @effect_var = Region_Effects::START_ID + 1		  
end		

 

If the id is already in use you overwrite the old event.

 

The way Yanflys and Kals Spawn Event scripts choose a new id is this way: id = @events.keys.max + 1

 

So if for example you are on a map and one ore or more events are spawned by your script, and an event is then spawned by Yanflys Spawn Event script. The next time an event is spawned by your script, that new event will overwrite the event spawned by Yanflys script (assuming the amount of events that were spawned by your script before an event was spawned by Yanflys script was lower than the MAX_EFFECTS constant in your script).

 

This was what I came up with to solve a lag issue and also to make it compatible with yanfly's event spawning script. (Using the same method as yanfly's script didn't seem to see each other and the events overwrote the last when used together.)

 

I chose to have a start ID (which you can set to whatever you want... to thousands if you are going to have that many events...) and then it will only use from the START_ID to the MAX_EFFECTS IDs... for example, START ID = 1000, MAX_EFFECT = 10... then the script will only ever use event ID's 1000 - 1010 and will keep cycling through those so as not to infinitely generate events and lag it up.

I originally had it working as Yanfly did, but every region effect event spawned would remain on the map and would cause lag after a while if so many have been generated.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.