HUNTERMiér Oct 10, 2012 11:13 pm
Super Usuario
Regiones con Efectos
COMENTARIO:
Su utilidad sirve que al caminar por ejemplo en
la Nieve, Agua etc... se muestren los pasos
en el terreno.
IMAGEN DE MUESTRA:
DEMO:
Click para Descargar.
SCRIPT:
- Código:
#------------------------------------------------------------------------------#
# Galv's Region Effects
#------------------------------------------------------------------------------#
# For: RPGMAKER VX ACE
# Version 1.2
# Credit to Yanfly for his event spawning method
#------------------------------------------------------------------------------#
# 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.
#
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
# !!!!! WARNING - I am a learning scripter. Use this at your own risk!!!!!!
#------------------------------------------------------------------------------#
$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 = 30 # 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.
START_ID = 1000 # Don't change this unless you have more than
# 1000 events on a map...
#------------------------------------------------------------------------------#
# ENVIRONMENT REGIONS SETUP
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
#
# EFFECT[id] = ["sound", vol, pitch, event_id, common_event_id, region]
#
# id - the id of the effect (must be unique and in order)
# 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.
# region - the region ID the effect will activate on
#
#------------------------------------------------------------------------------#
EFFECT = [] # ! don't touch this
EFFECT[0] = ["", 0, 0, 0, 0, 0] # No Effect (no region)
# Pre-made effects (requires demo events)
EFFECT[1] = ["", 0, 0, 5, 0, 1] # Dirt dust
EFFECT[2] = ["Blow7", 60, 150, 0, 0, 2] # Wood surface noise only
EFFECT[3] = ["Water1", 60, 110, 1, 0, 3] # Shallow Water
EFFECT[4] = ["Earth2", 40, 130, 0, 0, 4] # Hard surface noise only
EFFECT[5] = ["Damage3", 40, 150, 2, 0, 5] # Footprints
EFFECT[6] = ["Ice9", 50, 130, 3, 0, 6] # Walking over thick grass
EFFECT[7] = ["", 0, 0, 0, 1, 7] # Calls common event 1 only
EFFECT[8] = ["Fire3", 80, 120, 4, 2, 8] # Calls fire trap
EFFECT[9] = ["", 80, 120, 6, 0, 9] # Dust cloud
# You can add more as required. eg:
# EFFECT[9] = ["", 0, 0, 0, 0, 0]
# EFFECT[10] = ["", 0, 0, 0, 0, 0]
# etc. etc.
#------------------------------------------------------------------------------#
# END SCRIPT SETUP
#------------------------------------------------------------------------------#
end # Region_Effects
class Game_Player < Game_Character
alias galv_check_event_trigger_here check_event_trigger_here
def check_event_trigger_here(triggers)
galv_check_event_trigger_here(triggers)
galv_region_check unless $game_switches[Region_Effects::REGION_EFFECT_SWITCH] == true
end
def galv_region_check
return if Input.trigger?(:C)
v = rand(10) - rand(10)
p = rand(40) - rand(40)
no_effects = Region_Effects::EFFECT.count - 1
no_effects.times {|i|
if $game_map.region_id($game_player.x, $game_player.y) == Region_Effects::EFFECT[i+1][5]
sound = Region_Effects::EFFECT[i+1][0]
vol = Region_Effects::EFFECT[i+1][1]
pit = Region_Effects::EFFECT[i+1][2]
eve = Region_Effects::EFFECT[i+1][3]
com_eve = Region_Effects::EFFECT[i+1][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
end # Game_Player
#==============================================================================
# Credit to Yanfly for modified Spawn event script below
#==============================================================================
class Game_Map
alias galv_initialize initialize
def initialize
galv_initialize
@effect_var = 0
end
def effect_var
effect_var = @effect_var
end
def region_event(dx, dy, event_id, map_id)
map_id = @map_id if map_id == 0
map = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
event = generated_region_event(map, event_id)
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 key_id <= Region_Effects::MAX_EFFECTS + Region_Effects::START_ID - 1
@events[key_id] = Game_Event.new(@map_id, event)
end
@events[key_id].moveto(dx, dy)
SceneManager.scene.spriteset.refresh_characters
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
end # Game_Map
class Scene_Map < Scene_Base
attr_accessor :spriteset
end # Scene_Map
Eso fue todo.
Aconsejo descargar la demo ya que para utilizarlo es un
proceso bastante complicado.