iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

The 2nd Quarter Contest has arrived! Go check it out in the Community Announcements now!
 
Reply to this topicStart new topic
> Simple Area Extender, Version 1.0
Rating 5 V
Niclas
post Dec 13 2011, 10:21 PM
Post #1


Whats this?
Group Icon


Type: Designer
Alignment: Lawful Good




Simple Area Extender

Version: 1.0


Introduction
Another small script that will make your life easier with selfswitches and events. Ever wanted a big area the player could enter and it will active a certain selfswitch? Well, with this script you get the possiblity to do so.

Features
  • Easy and well explained how to use it.
  • The option to turn the script on/off.
  • The ability to have it disable the area once the player has entered it. You use a switch to turn the disabler option on/off.
  • Great if you have alot of things occuring on your map and you don't want to setup 10 events to do the same cutscene for example. You can just draw the specific path with the area and thats it.

Screenshots
No, not for this.

How to Use
Instructions how to use it can be find inside the script.
To install this script, open up your script editor and copy/paste this script to an open slot below Materials but above Main. Remember to save.

Script
Spoiler:
CODE
#==============================================================================
#   Simple Area Extender
#   Author: Nicke
#   Created: 07/12/2011
#   Edited: 04/01/2012
#   Version: 1.0
#
#   Special thanks to Zetu and FenixFyreX for helping me with a few things!
#==============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main. Remember to save.
#
# To use this script simply make an area in a map you want it with the following
# settings:
#
# Name <ss switch_id A-D true/false>
# Examples:
# Cave <ss 23 B false>
# Outside <ss 2 A true>
# -----------------------------------------------------------------------------
# Note: AREA_SWITCH is off from the beginning so you will need to turn it on if
# you want to active this script.
#
# To disable a area from being actived more then once uses the AREA_DISABLER
# switch.
#==============================================================================
($imported ||= {})["NICKE-AREA-EXTENDER"] = true

module NICKE
  module AREA_EX
#==============================================================================#
# ** Settings
#==============================================================================#
      # Switch variable to turn the script on/off.
      AREA_SWITCH = 3
      
      # Switch ID to disable a area once the player go inside it.
      # Note: If this is on all areas the players enter will be disabled until
      # you turn off the switch.
      AREA_DISABLER = 4
  end
end
# *** Don't edit below unless you know what you are doing. ***
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
  
  # // Imported method from Event SelfSwitches.
  def setSelfSwitch(eID, selfSwitch, trueFalse)
    switch = [$game_map.map_id, eID, selfSwitch]
    $game_self_switches[switch] = trueFalse
    $game_map.need_refresh = true
  end # // End of importing.

  # // Update.
  alias nicke_area_ex_update update unless $@
  def update(*args, &block)
    nicke_area_ex_update(*args, &block)
    return unless $game_switches[NICKE::AREA_EX::AREA_SWITCH] # // Return if AREA_SWITCH off.
    for area in $data_areas.values
      area.name.scan(/<ss (\d+)\s+([A-D]+)\s+(true|false)>/i)
      s1 = $1.to_i
      s2 = $2.to_s
      s3 = eval($3)
      # // Is the player in the area section?
      if $game_player.in_area?(area) && !$game_system.activated_areas[area.id]
        setSelfSwitch(s1,s2,s3)
        $game_system.activated_areas[area.id] = true if $game_switches[NICKE::AREA_EX::AREA_DISABLER]
      end
    end
  end # // End update.
  
end
#==============================================================================
# ** Game_System
#==============================================================================
class Game_System
  
  attr_accessor :activated_areas
  
  # // Initialize.
  alias nicke_area_ex_init initialize unless $@
  def initialize(*args, &block)
    nicke_area_ex_init(*args, &block)
    @activated_areas = []
  end
  
end # END OF FILE

#=*==========================================================================*=#
# ** END OF FILE
#=*==========================================================================*=#


Updates
Fixed a future bug if someone would type E in the area name as selfswitch for instance. The script now only allows the right self switches.

Credit
Do credit me, Nicke, if you are planing on using this script. Thanks.
Also, a small thanks to Bulletxt for his idea.

This post has been edited by Niclas: Jan 4 2012, 03:29 PM


--------------------
Go to the top of the page
 
+Quote Post
   
rgangsta
post Dec 20 2011, 02:34 AM
Post #2


The Handyman
Group Icon


Type: Designer
Alignment: Neutral Evil




O.o This can come in very handy for something I'm eventing, once I find out how to check if an event is in an area.


--------------------
Go to the top of the page
 
+Quote Post
   
Niclas
post Dec 20 2011, 06:20 PM
Post #3


Whats this?
Group Icon


Type: Designer
Alignment: Lawful Good




@rgangsta: Yeah, that could also work but I have to change the script if you want that option.


--------------------
Go to the top of the page
 
+Quote Post
   
Digioso
post Dec 21 2011, 11:05 AM
Post #4



Group Icon


Type: Designer
Alignment: Unaligned




Oh, the Self-Switch idea is nice!
If you're OK with this I'll add this to the Area Script of BulletXT and me as well.
Link: http://www.rpgmakervx.net/index.php?showtopic=51301


--------------------
Leg dich nie mit einem BAOD an, oder du bist selber dran.

Das Leben ist grausam.
Wenn es mal nicht grausam ist, ist es grausamer.

Go to the top of the page
 
+Quote Post
   
Niclas
post Dec 21 2011, 11:41 AM
Post #5


Whats this?
Group Icon


Type: Designer
Alignment: Lawful Good




@Digioso: Yeah, sure!


--------------------
Go to the top of the page
 
+Quote Post
   
rgangsta
post Dec 22 2011, 12:00 AM
Post #6


The Handyman
Group Icon


Type: Designer
Alignment: Neutral Evil




QUOTE (Niclas @ Dec 20 2011, 02:20 PM) *
@rgangsta: Yeah, that could also work but I have to change the script if you want that option.


Can you really? That would be much appreciated! I needed help with this and no one helped so far.
Just so you get what I'm eventing,here's the scenario:
Spoiler:
The player has to escort an event to a different map but for the player to be able to be transferred to another map, the event he is escorting must be close to him, i.e. the area which is around the map transfer. I don't want to player to wander off without the event being near him because what's the point of escorting?
So I need to check if the event the player is escorting is in the area before the player can be transferred.



--------------------
Go to the top of the page
 
+Quote Post
   
Niclas
post Dec 22 2011, 05:30 PM
Post #7


Whats this?
Group Icon


Type: Designer
Alignment: Lawful Good




@rgangsta: Mind telling me how you solved it? Then I can implement it to my script as well. I noticed you solved it yourself so smile.gif


--------------------
Go to the top of the page
 
+Quote Post
   
rgangsta
post Dec 23 2011, 03:59 AM
Post #8


The Handyman
Group Icon


Type: Designer
Alignment: Neutral Evil




QUOTE (Niclas @ Dec 22 2011, 01:30 PM) *
@rgangsta: Mind telling me how you solved it? Then I can implement it to my script as well. I noticed you solved it yourself so smile.gif

I didn't really solve it myself, IMP1 made a script for me back at Omega-Dev. Here it is.
Spoiler:
CODE
class Game_Character

  def in_area?(area)
    return false if area == nil
    return false if $game_map.map_id != area.map_id
    return false if @x < area.rect.x
    return false if @y < area.rect.y
    return false if @x >= area.rect.x + area.rect.width
    return false if @y >= area.rect.y + area.rect.height
    return true
  end
  
end

module IMP_Area
  
  def self.areas_on_map(map_id = $game_map.map_id)
    outcome = []
    for area in $data_areas.values
      outcome.push(area) if area.map_id == map_id
    end
    return outcome
  end
  
  def self.area_with_name(name, map_id = $game_map.map_id)
    for area in $data_areas.values
      return area if area.map_id == map_id && area.name == name
    end
  end
  
end

class Game_Interpreter
  
  def event_in_area?(event_id, area_name)
    area = IMP_Area.area_with_name(area_name)
    return $game_map.events[event_id].in_area?(area)
  end
  
end

It works like a charm except that I want to use the area's ID instead of name. Because if I name two or more areas the same name, there might be problems. This is only in theory. No time to try it.


--------------------
Go to the top of the page
 
+Quote Post
   
Digioso
post Dec 23 2011, 03:39 PM
Post #9



Group Icon


Type: Designer
Alignment: Unaligned




QUOTE (Niclas @ Dec 21 2011, 12:41 PM) *
@Digioso: Yeah, sure!


Thanks and I started working on it a couple of minutes ago.
But it didn't take me long to find out that this is not going to work.
With the current setup in my script I only have one "layer". The switch or event.
For self switches I'd need two: The Event and the Self Switch.
And for this I'd have to basically make a copy of everything I have, edit it for self switches and then paste it.
In that case - your script already exists so no need to try to make a copy of it.

But I found one possible bug in your script.

area.name.scan(/<ss (\d+)\s+([A-Z]+)\s+(true|false)>/)

Your're checking for [A-Z] here.
I didn't test what the game does if it encounters a self switch > D. My guess is that it crashes. So the best thing is to not even allow this.

I didn't check what area.name.scan returns when the regex isn't matched. If it returns false then you could do a [A-D] instead of [A-Z] here and do a if(area.name.scan ...).
If it doesn't return anything usable you could check the content of s2 after s2 = $2.to_s and see whether there's only A-D in there. And if not do a print or whatever so that the developer sees that he did something wrong.

And you could add an /i at the end of the scan to allow lower case as well. I don't know if the game allows the self switches to be lowercase. If it doesn't you have to convert it to uppercase (with s2.upcase) again but at least the user has the option to use lowercase. smile.gif

Anyway, good work and I'll keep this script in mind in case I need it. More options are always good. smile.gif

This post has been edited by Digioso: Dec 23 2011, 03:42 PM


--------------------
Leg dich nie mit einem BAOD an, oder du bist selber dran.

Das Leben ist grausam.
Wenn es mal nicht grausam ist, ist es grausamer.

Go to the top of the page
 
+Quote Post
   
Niclas
post Dec 23 2011, 04:27 PM
Post #10


Whats this?
Group Icon


Type: Designer
Alignment: Lawful Good




@Digioso: Oh, thanks for that. I am gonna change it then. smile.gif


--------------------
Go to the top of the page
 
+Quote Post
   
Digioso
post Jan 4 2012, 12:04 PM
Post #11



Group Icon


Type: Designer
Alignment: Unaligned




You're welcome. smile.gif


--------------------
Leg dich nie mit einem BAOD an, oder du bist selber dran.

Das Leben ist grausam.
Wenn es mal nicht grausam ist, ist es grausamer.

Go to the top of the page
 
+Quote Post
   
Niclas
post Jan 4 2012, 03:30 PM
Post #12


Whats this?
Group Icon


Type: Designer
Alignment: Lawful Good




OK updated the script, thanks to Digioso.


--------------------
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 16th April 2014 - 04:21 AM

RPGMakerVX.net is an Privacy Policy, Legal.