mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Merge branch 'master' into mkxp-z
This commit is contained in:
@@ -54,6 +54,7 @@ module Events
|
||||
@@OnWildBattleOverride = Event.new
|
||||
@@OnWildBattleEnd = Event.new
|
||||
@@OnTrainerPartyLoad = Event.new
|
||||
@@OnChangeDirection = Event.new
|
||||
|
||||
# Fires whenever a map is created. Event handler receives two parameters: the
|
||||
# map (RPG::Map) and the tileset (RPG::Tileset)
|
||||
@@ -159,6 +160,10 @@ module Events
|
||||
# e[2] - Party
|
||||
def self.onTrainerPartyLoad; @@OnTrainerPartyLoad; end
|
||||
def self.onTrainerPartyLoad=(v); @@OnTrainerPartyLoad = v; end
|
||||
|
||||
# Fires whenever the player changes direction.
|
||||
def self.onChangeDirection; @@OnChangeDirection; end
|
||||
def self.onChangeDirection=(v); @@OnChangeDirection = v; end
|
||||
end
|
||||
|
||||
|
||||
@@ -254,7 +259,7 @@ Events.onMapUpdate += proc { |_sender,_e|
|
||||
# Checks per step
|
||||
#===============================================================================
|
||||
# Party Pokémon gain happiness from walking
|
||||
Events.onStepTaken += proc{
|
||||
Events.onStepTaken += proc {
|
||||
$PokemonGlobal.happinessSteps = 0 if !$PokemonGlobal.happinessSteps
|
||||
$PokemonGlobal.happinessSteps += 1
|
||||
if $PokemonGlobal.happinessSteps>=128
|
||||
@@ -363,26 +368,34 @@ def pbOnStepTaken(eventTriggered)
|
||||
Events.onStepTakenTransferPossible.trigger(nil,handled)
|
||||
return if handled[0]
|
||||
pbBattleOnStepTaken(repel) if !eventTriggered && !$game_temp.in_menu
|
||||
$PokemonTemp.encounterTriggered = false # This info isn't needed
|
||||
end
|
||||
|
||||
def pbBattleOnStepTaken(repel=false)
|
||||
return if $Trainer.ablePokemonCount==0
|
||||
# Start wild encounters while turning on the spot
|
||||
Events.onChangeDirection += proc {
|
||||
repel = ($PokemonGlobal.repel > 0)
|
||||
pbBattleOnStepTaken(repel) if !$game_temp.in_menu
|
||||
}
|
||||
|
||||
def pbBattleOnStepTaken(repel = false)
|
||||
return if $Trainer.ablePokemonCount == 0
|
||||
encounterType = $PokemonEncounters.pbEncounterType
|
||||
return if encounterType<0
|
||||
return if encounterType < 0
|
||||
return if !$PokemonEncounters.isEncounterPossibleHere?
|
||||
$PokemonTemp.encounterType = encounterType
|
||||
encounter = $PokemonEncounters.pbGenerateEncounter(encounterType)
|
||||
encounter = EncounterModifier.trigger(encounter)
|
||||
if $PokemonEncounters.pbCanEncounter?(encounter,repel)
|
||||
if $PokemonEncounters.pbCanEncounter?(encounter, repel)
|
||||
if !$PokemonTemp.forceSingleBattle && !pbInSafari? && ($PokemonGlobal.partner ||
|
||||
($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag) && rand(100)<30))
|
||||
($Trainer.ablePokemonCount > 1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag) && rand(100) < 30))
|
||||
encounter2 = $PokemonEncounters.pbEncounteredPokemon(encounterType)
|
||||
encounter2 = EncounterModifier.trigger(encounter2)
|
||||
pbDoubleWildBattle(encounter[0],encounter[1],encounter2[0],encounter2[1])
|
||||
pbDoubleWildBattle(encounter[0], encounter[1], encounter2[0], encounter2[1])
|
||||
else
|
||||
pbWildBattle(encounter[0],encounter[1])
|
||||
pbWildBattle(encounter[0], encounter[1])
|
||||
end
|
||||
$PokemonTemp.encounterType = -1
|
||||
$PokemonTemp.encounterTriggered = true
|
||||
end
|
||||
$PokemonTemp.forceSingleBattle = false
|
||||
EncounterModifier.triggerEncounterEnd
|
||||
@@ -489,6 +502,421 @@ Events.onMapSceneChange += proc { |_sender,e|
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Event locations, terrain tags
|
||||
#===============================================================================
|
||||
def pbEventFacesPlayer?(event,player,distance)
|
||||
return false if distance<=0
|
||||
# Event can't reach player if no coordinates coincide
|
||||
return false if event.x!=player.x && event.y!=player.y
|
||||
deltaX = (event.direction==6) ? 1 : (event.direction==4) ? -1 : 0
|
||||
deltaY = (event.direction==2) ? 1 : (event.direction==8) ? -1 : 0
|
||||
# Check for existence of player
|
||||
curx = event.x
|
||||
cury = event.y
|
||||
found = false
|
||||
distance.times do
|
||||
curx += deltaX
|
||||
cury += deltaY
|
||||
if player.x==curx && player.y==cury
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
return found
|
||||
end
|
||||
|
||||
def pbEventCanReachPlayer?(event,player,distance)
|
||||
return false if distance<=0
|
||||
# Event can't reach player if no coordinates coincide
|
||||
return false if event.x!=player.x && event.y!=player.y
|
||||
deltaX = (event.direction==6) ? 1 : (event.direction==4) ? -1 : 0
|
||||
deltaY = (event.direction==2) ? 1 : (event.direction==8) ? -1 : 0
|
||||
# Check for existence of player
|
||||
curx = event.x
|
||||
cury = event.y
|
||||
found = false
|
||||
realdist = 0
|
||||
distance.times do
|
||||
curx += deltaX
|
||||
cury += deltaY
|
||||
if player.x==curx && player.y==cury
|
||||
found = true
|
||||
break
|
||||
end
|
||||
realdist += 1
|
||||
end
|
||||
return false if !found
|
||||
# Check passibility
|
||||
curx = event.x
|
||||
cury = event.y
|
||||
realdist.times do
|
||||
return false if !event.passable?(curx,cury,event.direction)
|
||||
curx += deltaX
|
||||
cury += deltaY
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def pbFacingTileRegular(direction=nil,event=nil)
|
||||
event = $game_player if !event
|
||||
return [0,0,0] if !event
|
||||
x = event.x
|
||||
y = event.y
|
||||
direction = event.direction if !direction
|
||||
case direction
|
||||
when 1; y += 1; x -= 1
|
||||
when 2; y += 1
|
||||
when 3; y += 1; x += 1
|
||||
when 4; x -= 1
|
||||
when 6; x += 1
|
||||
when 7; y -= 1; x -= 1
|
||||
when 8; y -= 1
|
||||
when 9; y -= 1; x += 1
|
||||
end
|
||||
return [$game_map.map_id,x,y]
|
||||
end
|
||||
|
||||
def pbFacingTile(direction=nil,event=nil)
|
||||
return $MapFactory.getFacingTile(direction,event) if $MapFactory
|
||||
return pbFacingTileRegular(direction,event)
|
||||
end
|
||||
|
||||
def pbFacingEachOther(event1,event2)
|
||||
return false if !event1 || !event2
|
||||
if $MapFactory
|
||||
tile1 = $MapFactory.getFacingTile(nil,event1)
|
||||
tile2 = $MapFactory.getFacingTile(nil,event2)
|
||||
return false if !tile1 || !tile2
|
||||
return tile1[0]==event2.map.map_id &&
|
||||
tile1[1]==event2.x && tile1[2]==event2.y &&
|
||||
tile2[0]==event1.map.map_id &&
|
||||
tile2[1]==event1.x && tile2[2]==event1.y
|
||||
else
|
||||
tile1 = pbFacingTile(nil,event1)
|
||||
tile2 = pbFacingTile(nil,event2)
|
||||
return false if !tile1 || !tile2
|
||||
return tile1[1]==event2.x && tile1[2]==event2.y &&
|
||||
tile2[1]==event1.x && tile2[2]==event1.y
|
||||
end
|
||||
end
|
||||
|
||||
def pbGetTerrainTag(event=nil,countBridge=false)
|
||||
event = $game_player if !event
|
||||
return 0 if !event
|
||||
if $MapFactory
|
||||
return $MapFactory.getTerrainTag(event.map.map_id,event.x,event.y,countBridge)
|
||||
end
|
||||
$game_map.terrain_tag(event.x,event.y,countBridge)
|
||||
end
|
||||
|
||||
def pbFacingTerrainTag(event=nil,dir=nil)
|
||||
if $MapFactory
|
||||
return $MapFactory.getFacingTerrainTag(dir,event)
|
||||
end
|
||||
event = $game_player if !event
|
||||
return 0 if !event
|
||||
facing = pbFacingTile(dir,event)
|
||||
return $game_map.terrain_tag(facing[1],facing[2])
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Events
|
||||
#===============================================================================
|
||||
class Game_Event
|
||||
def cooledDown?(seconds)
|
||||
return true if expired?(seconds) && tsOff?("A")
|
||||
self.need_refresh = true
|
||||
return false
|
||||
end
|
||||
|
||||
def cooledDownDays?(days)
|
||||
return true if expiredDays?(days) && tsOff?("A")
|
||||
self.need_refresh = true
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
module InterpreterFieldMixin
|
||||
# Used in boulder events. Allows an event to be pushed. To be used in
|
||||
# a script event command.
|
||||
def pbPushThisEvent
|
||||
event = get_character(0)
|
||||
oldx = event.x
|
||||
oldy = event.y
|
||||
# Apply strict version of passable, which makes impassable
|
||||
# tiles that are passable only from certain directions
|
||||
return if !event.passableStrict?(event.x,event.y,$game_player.direction)
|
||||
case $game_player.direction
|
||||
when 2; event.move_down # down
|
||||
when 4; event.move_left # left
|
||||
when 6; event.move_right # right
|
||||
when 8; event.move_up # up
|
||||
end
|
||||
$PokemonMap.addMovedEvent(@event_id) if $PokemonMap
|
||||
if oldx!=event.x || oldy!=event.y
|
||||
$game_player.lock
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
break if !event.moving?
|
||||
end
|
||||
$game_player.unlock
|
||||
end
|
||||
end
|
||||
|
||||
def pbPushThisBoulder
|
||||
pbPushThisEvent if $PokemonMap.strengthUsed
|
||||
return true
|
||||
end
|
||||
|
||||
def pbSmashThisEvent
|
||||
event = get_character(0)
|
||||
pbSmashEvent(event) if event
|
||||
@index += 1
|
||||
return true
|
||||
end
|
||||
|
||||
def pbTrainerIntro(symbol)
|
||||
return if $DEBUG && !pbTrainerTypeCheck(symbol)
|
||||
trtype = PBTrainers.const_get(symbol)
|
||||
pbGlobalLock
|
||||
pbPlayTrainerIntroME(trtype)
|
||||
return true
|
||||
end
|
||||
|
||||
def pbTrainerEnd
|
||||
pbGlobalUnlock
|
||||
e = get_character(0)
|
||||
e.erase_route if e
|
||||
end
|
||||
|
||||
def pbParams
|
||||
(@parameters) ? @parameters : @params
|
||||
end
|
||||
|
||||
def pbGetPokemon(id)
|
||||
return $Trainer.party[pbGet(id)]
|
||||
end
|
||||
|
||||
def pbSetEventTime(*arg)
|
||||
$PokemonGlobal.eventvars = {} if !$PokemonGlobal.eventvars
|
||||
time = pbGetTimeNow
|
||||
time = time.to_i
|
||||
pbSetSelfSwitch(@event_id,"A",true)
|
||||
$PokemonGlobal.eventvars[[@map_id,@event_id]]=time
|
||||
for otherevt in arg
|
||||
pbSetSelfSwitch(otherevt,"A",true)
|
||||
$PokemonGlobal.eventvars[[@map_id,otherevt]]=time
|
||||
end
|
||||
end
|
||||
|
||||
def getVariable(*arg)
|
||||
if arg.length==0
|
||||
return nil if !$PokemonGlobal.eventvars
|
||||
return $PokemonGlobal.eventvars[[@map_id,@event_id]]
|
||||
else
|
||||
return $game_variables[arg[0]]
|
||||
end
|
||||
end
|
||||
|
||||
def setVariable(*arg)
|
||||
if arg.length==1
|
||||
$PokemonGlobal.eventvars = {} if !$PokemonGlobal.eventvars
|
||||
$PokemonGlobal.eventvars[[@map_id,@event_id]]=arg[0]
|
||||
else
|
||||
$game_variables[arg[0]] = arg[1]
|
||||
$game_map.need_refresh = true
|
||||
end
|
||||
end
|
||||
|
||||
def tsOff?(c)
|
||||
get_character(0).tsOff?(c)
|
||||
end
|
||||
|
||||
def tsOn?(c)
|
||||
get_character(0).tsOn?(c)
|
||||
end
|
||||
|
||||
alias isTempSwitchOn? tsOn?
|
||||
alias isTempSwitchOff? tsOff?
|
||||
|
||||
def setTempSwitchOn(c)
|
||||
get_character(0).setTempSwitchOn(c)
|
||||
end
|
||||
|
||||
def setTempSwitchOff(c)
|
||||
get_character(0).setTempSwitchOff(c)
|
||||
end
|
||||
|
||||
# Must use this approach to share the methods because the methods already
|
||||
# defined in a class override those defined in an included module
|
||||
CustomEventCommands=<<_END_
|
||||
|
||||
def command_352
|
||||
scene = PokemonSave_Scene.new
|
||||
screen = PokemonSaveScreen.new(scene)
|
||||
screen.pbSaveScreen
|
||||
return true
|
||||
end
|
||||
|
||||
def command_125
|
||||
value = operate_value(pbParams[0], pbParams[1], pbParams[2])
|
||||
$Trainer.money += value
|
||||
return true
|
||||
end
|
||||
|
||||
def command_132
|
||||
($PokemonGlobal.nextBattleBGM = pbParams[0]) ? pbParams[0].clone : nil
|
||||
return true
|
||||
end
|
||||
|
||||
def command_133
|
||||
($PokemonGlobal.nextBattleME = pbParams[0]) ? pbParams[0].clone : nil
|
||||
return true
|
||||
end
|
||||
|
||||
def command_353
|
||||
pbBGMFade(1.0)
|
||||
pbBGSFade(1.0)
|
||||
pbFadeOutIn { pbStartOver(true) }
|
||||
end
|
||||
|
||||
def command_314
|
||||
pbHealAll if pbParams[0]==0
|
||||
return true
|
||||
end
|
||||
|
||||
_END_
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Interpreter
|
||||
include InterpreterFieldMixin
|
||||
eval(InterpreterFieldMixin::CustomEventCommands)
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Game_Interpreter
|
||||
include InterpreterFieldMixin
|
||||
eval(InterpreterFieldMixin::CustomEventCommands)
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Audio playing
|
||||
#===============================================================================
|
||||
def pbCueBGM(bgm,seconds,volume=nil,pitch=nil)
|
||||
return if !bgm
|
||||
bgm = pbResolveAudioFile(bgm,volume,pitch)
|
||||
playingBGM = $game_system.playing_bgm
|
||||
if !playingBGM || playingBGM.name!=bgm.name || playingBGM.pitch!=bgm.pitch
|
||||
pbBGMFade(seconds)
|
||||
if !$PokemonTemp.cueFrames
|
||||
$PokemonTemp.cueFrames = (seconds*Graphics.frame_rate)*3/5
|
||||
end
|
||||
$PokemonTemp.cueBGM=bgm
|
||||
elsif playingBGM
|
||||
pbBGMPlay(bgm)
|
||||
end
|
||||
end
|
||||
|
||||
def pbAutoplayOnTransition
|
||||
surfbgm = pbGetMetadata(0,MetadataSurfBGM)
|
||||
if $PokemonGlobal.surfing && surfbgm
|
||||
pbBGMPlay(surfbgm)
|
||||
else
|
||||
$game_map.autoplayAsCue
|
||||
end
|
||||
end
|
||||
|
||||
def pbAutoplayOnSave
|
||||
surfbgm = pbGetMetadata(0,MetadataSurfBGM)
|
||||
if $PokemonGlobal.surfing && surfbgm
|
||||
pbBGMPlay(surfbgm)
|
||||
else
|
||||
$game_map.autoplay
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Voice recorder
|
||||
#===============================================================================
|
||||
def pbRecord(text,maxtime=30.0)
|
||||
text = "" if !text
|
||||
textwindow = Window_UnformattedTextPokemon.newWithSize(text,0,0,Graphics.width,Graphics.height-96)
|
||||
textwindow.z=99999
|
||||
if text==""
|
||||
textwindow.visible = false
|
||||
end
|
||||
wave = nil
|
||||
msgwindow = pbCreateMessageWindow
|
||||
oldvolume = Audio_bgm_get_volume()
|
||||
Audio_bgm_set_volume(0)
|
||||
delay = 2
|
||||
delay.times do |i|
|
||||
pbMessageDisplay(msgwindow,_INTL("Recording in {1} second(s)...\nPress ESC to cancel.",delay-i),false)
|
||||
Graphics.frame_rate.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
if Input.trigger?(Input::B)
|
||||
Audio_bgm_set_volume(oldvolume)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
textwindow.dispose
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
pbMessageDisplay(msgwindow,_INTL("NOW RECORDING\nPress ESC to stop recording."),false)
|
||||
if beginRecordUI
|
||||
frames = (maxtime*Graphics.frame_rate).to_i
|
||||
frames.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
if Input.trigger?(Input::B)
|
||||
break
|
||||
end
|
||||
end
|
||||
tmpFile = ENV["TEMP"]+"\\record.wav"
|
||||
endRecord(tmpFile)
|
||||
wave = getWaveDataUI(tmpFile,true)
|
||||
if wave
|
||||
pbMessageDisplay(msgwindow,_INTL("PLAYING BACK..."),false)
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
Graphics.update
|
||||
Input.update
|
||||
wave.play
|
||||
(Graphics.frame_rate*wave.time).to_i.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
end
|
||||
end
|
||||
end
|
||||
Audio_bgm_set_volume(oldvolume)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
textwindow.dispose
|
||||
return wave
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Event movement
|
||||
#===============================================================================
|
||||
@@ -895,414 +1323,6 @@ end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Event locations, terrain tags
|
||||
#===============================================================================
|
||||
def pbEventFacesPlayer?(event,player,distance)
|
||||
return false if distance<=0
|
||||
# Event can't reach player if no coordinates coincide
|
||||
return false if event.x!=player.x && event.y!=player.y
|
||||
deltaX = (event.direction==6) ? 1 : (event.direction==4) ? -1 : 0
|
||||
deltaY = (event.direction==2) ? 1 : (event.direction==8) ? -1 : 0
|
||||
# Check for existence of player
|
||||
curx = event.x
|
||||
cury = event.y
|
||||
found = false
|
||||
distance.times do
|
||||
curx += deltaX
|
||||
cury += deltaY
|
||||
if player.x==curx && player.y==cury
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
return found
|
||||
end
|
||||
|
||||
def pbEventCanReachPlayer?(event,player,distance)
|
||||
return false if distance<=0
|
||||
# Event can't reach player if no coordinates coincide
|
||||
return false if event.x!=player.x && event.y!=player.y
|
||||
deltaX = (event.direction==6) ? 1 : (event.direction==4) ? -1 : 0
|
||||
deltaY = (event.direction==2) ? 1 : (event.direction==8) ? -1 : 0
|
||||
# Check for existence of player
|
||||
curx = event.x
|
||||
cury = event.y
|
||||
found = false
|
||||
realdist = 0
|
||||
distance.times do
|
||||
curx += deltaX
|
||||
cury += deltaY
|
||||
if player.x==curx && player.y==cury
|
||||
found = true
|
||||
break
|
||||
end
|
||||
realdist += 1
|
||||
end
|
||||
return false if !found
|
||||
# Check passibility
|
||||
curx = event.x
|
||||
cury = event.y
|
||||
realdist.times do
|
||||
return false if !event.passable?(curx,cury,event.direction)
|
||||
curx += deltaX
|
||||
cury += deltaY
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def pbFacingTileRegular(direction=nil,event=nil)
|
||||
event = $game_player if !event
|
||||
return [0,0,0] if !event
|
||||
x = event.x
|
||||
y = event.y
|
||||
direction = event.direction if !direction
|
||||
case direction
|
||||
when 1; y += 1; x -= 1
|
||||
when 2; y += 1
|
||||
when 3; y += 1; x += 1
|
||||
when 4; x -= 1
|
||||
when 6; x += 1
|
||||
when 7; y -= 1; x -= 1
|
||||
when 8; y -= 1
|
||||
when 9; y -= 1; x += 1
|
||||
end
|
||||
return [$game_map.map_id,x,y]
|
||||
end
|
||||
|
||||
def pbFacingTile(direction=nil,event=nil)
|
||||
return $MapFactory.getFacingTile(direction,event) if $MapFactory
|
||||
return pbFacingTileRegular(direction,event)
|
||||
end
|
||||
|
||||
def pbFacingEachOther(event1,event2)
|
||||
return false if !event1 || !event2
|
||||
if $MapFactory
|
||||
tile1 = $MapFactory.getFacingTile(nil,event1)
|
||||
tile2 = $MapFactory.getFacingTile(nil,event2)
|
||||
return false if !tile1 || !tile2
|
||||
return tile1[0]==event2.map.map_id &&
|
||||
tile1[1]==event2.x && tile1[2]==event2.y &&
|
||||
tile2[0]==event1.map.map_id &&
|
||||
tile2[1]==event1.x && tile2[2]==event1.y
|
||||
else
|
||||
tile1 = pbFacingTile(nil,event1)
|
||||
tile2 = pbFacingTile(nil,event2)
|
||||
return false if !tile1 || !tile2
|
||||
return tile1[1]==event2.x && tile1[2]==event2.y &&
|
||||
tile2[1]==event1.x && tile2[2]==event1.y
|
||||
end
|
||||
end
|
||||
|
||||
def pbGetTerrainTag(event=nil,countBridge=false)
|
||||
event = $game_player if !event
|
||||
return 0 if !event
|
||||
if $MapFactory
|
||||
return $MapFactory.getTerrainTag(event.map.map_id,event.x,event.y,countBridge)
|
||||
end
|
||||
$game_map.terrain_tag(event.x,event.y,countBridge)
|
||||
end
|
||||
|
||||
def pbFacingTerrainTag(event=nil,dir=nil)
|
||||
if $MapFactory
|
||||
return $MapFactory.getFacingTerrainTag(dir,event)
|
||||
end
|
||||
event = $game_player if !event
|
||||
return 0 if !event
|
||||
facing = pbFacingTile(dir,event)
|
||||
return $game_map.terrain_tag(facing[1],facing[2])
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Events
|
||||
#===============================================================================
|
||||
class Game_Event
|
||||
def cooledDown?(seconds)
|
||||
return true if expired?(seconds) && tsOff?("A")
|
||||
self.need_refresh = true
|
||||
return false
|
||||
end
|
||||
|
||||
def cooledDownDays?(days)
|
||||
return true if expiredDays?(days) && tsOff?("A")
|
||||
self.need_refresh = true
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
module InterpreterFieldMixin
|
||||
# Used in boulder events. Allows an event to be pushed. To be used in
|
||||
# a script event command.
|
||||
def pbPushThisEvent
|
||||
event = get_character(0)
|
||||
oldx = event.x
|
||||
oldy = event.y
|
||||
# Apply strict version of passable, which makes impassable
|
||||
# tiles that are passable only from certain directions
|
||||
return if !event.passableStrict?(event.x,event.y,$game_player.direction)
|
||||
case $game_player.direction
|
||||
when 2; event.move_down # down
|
||||
when 4; event.move_left # left
|
||||
when 6; event.move_right # right
|
||||
when 8; event.move_up # up
|
||||
end
|
||||
$PokemonMap.addMovedEvent(@event_id) if $PokemonMap
|
||||
if oldx!=event.x || oldy!=event.y
|
||||
$game_player.lock
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
break if !event.moving?
|
||||
end
|
||||
$game_player.unlock
|
||||
end
|
||||
end
|
||||
|
||||
def pbPushThisBoulder
|
||||
pbPushThisEvent if $PokemonMap.strengthUsed
|
||||
return true
|
||||
end
|
||||
|
||||
def pbSmashThisEvent
|
||||
event = get_character(0)
|
||||
pbSmashEvent(event) if event
|
||||
@index += 1
|
||||
return true
|
||||
end
|
||||
|
||||
def pbTrainerIntro(symbol)
|
||||
return if $DEBUG && !pbTrainerTypeCheck(symbol)
|
||||
trtype = PBTrainers.const_get(symbol)
|
||||
pbGlobalLock
|
||||
pbPlayTrainerIntroME(trtype)
|
||||
return true
|
||||
end
|
||||
|
||||
def pbTrainerEnd
|
||||
pbGlobalUnlock
|
||||
e = get_character(0)
|
||||
e.erase_route if e
|
||||
end
|
||||
|
||||
def pbParams
|
||||
(@parameters) ? @parameters : @params
|
||||
end
|
||||
|
||||
def pbGetPokemon(id)
|
||||
return $Trainer.party[pbGet(id)]
|
||||
end
|
||||
|
||||
def pbSetEventTime(*arg)
|
||||
$PokemonGlobal.eventvars = {} if !$PokemonGlobal.eventvars
|
||||
time = pbGetTimeNow
|
||||
time = time.to_i
|
||||
pbSetSelfSwitch(@event_id,"A",true)
|
||||
$PokemonGlobal.eventvars[[@map_id,@event_id]]=time
|
||||
for otherevt in arg
|
||||
pbSetSelfSwitch(otherevt,"A",true)
|
||||
$PokemonGlobal.eventvars[[@map_id,otherevt]]=time
|
||||
end
|
||||
end
|
||||
|
||||
def getVariable(*arg)
|
||||
if arg.length==0
|
||||
return nil if !$PokemonGlobal.eventvars
|
||||
return $PokemonGlobal.eventvars[[@map_id,@event_id]]
|
||||
else
|
||||
return $game_variables[arg[0]]
|
||||
end
|
||||
end
|
||||
|
||||
def setVariable(*arg)
|
||||
if arg.length==1
|
||||
$PokemonGlobal.eventvars = {} if !$PokemonGlobal.eventvars
|
||||
$PokemonGlobal.eventvars[[@map_id,@event_id]]=arg[0]
|
||||
else
|
||||
$game_variables[arg[0]] = arg[1]
|
||||
$game_map.need_refresh = true
|
||||
end
|
||||
end
|
||||
|
||||
def tsOff?(c)
|
||||
get_character(0).tsOff?(c)
|
||||
end
|
||||
|
||||
def tsOn?(c)
|
||||
get_character(0).tsOn?(c)
|
||||
end
|
||||
|
||||
alias isTempSwitchOn? tsOn?
|
||||
alias isTempSwitchOff? tsOff?
|
||||
|
||||
def setTempSwitchOn(c)
|
||||
get_character(0).setTempSwitchOn(c)
|
||||
end
|
||||
|
||||
def setTempSwitchOff(c)
|
||||
get_character(0).setTempSwitchOff(c)
|
||||
end
|
||||
|
||||
# Must use this approach to share the methods because the methods already
|
||||
# defined in a class override those defined in an included module
|
||||
CustomEventCommands=<<_END_
|
||||
|
||||
def command_352
|
||||
scene = PokemonSave_Scene.new
|
||||
screen = PokemonSaveScreen.new(scene)
|
||||
screen.pbSaveScreen
|
||||
return true
|
||||
end
|
||||
|
||||
def command_125
|
||||
value = operate_value(pbParams[0], pbParams[1], pbParams[2])
|
||||
$Trainer.money += value
|
||||
return true
|
||||
end
|
||||
|
||||
def command_132
|
||||
($PokemonGlobal.nextBattleBGM = pbParams[0]) ? pbParams[0].clone : nil
|
||||
return true
|
||||
end
|
||||
|
||||
def command_133
|
||||
($PokemonGlobal.nextBattleME = pbParams[0]) ? pbParams[0].clone : nil
|
||||
return true
|
||||
end
|
||||
|
||||
def command_353
|
||||
pbBGMFade(1.0)
|
||||
pbBGSFade(1.0)
|
||||
pbFadeOutIn { pbStartOver(true) }
|
||||
end
|
||||
|
||||
def command_314
|
||||
pbHealAll if pbParams[0]==0
|
||||
return true
|
||||
end
|
||||
|
||||
_END_
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Interpreter
|
||||
include InterpreterFieldMixin
|
||||
eval(InterpreterFieldMixin::CustomEventCommands)
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Audio playing
|
||||
#===============================================================================
|
||||
def pbCueBGM(bgm,seconds,volume=nil,pitch=nil)
|
||||
return if !bgm
|
||||
bgm = pbResolveAudioFile(bgm,volume,pitch)
|
||||
playingBGM = $game_system.playing_bgm
|
||||
if !playingBGM || playingBGM.name!=bgm.name || playingBGM.pitch!=bgm.pitch
|
||||
pbBGMFade(seconds)
|
||||
if !$PokemonTemp.cueFrames
|
||||
$PokemonTemp.cueFrames = (seconds*Graphics.frame_rate)*3/5
|
||||
end
|
||||
$PokemonTemp.cueBGM=bgm
|
||||
elsif playingBGM
|
||||
pbBGMPlay(bgm)
|
||||
end
|
||||
end
|
||||
|
||||
def pbAutoplayOnTransition
|
||||
surfbgm = pbGetMetadata(0,MetadataSurfBGM)
|
||||
if $PokemonGlobal.surfing && surfbgm
|
||||
pbBGMPlay(surfbgm)
|
||||
else
|
||||
$game_map.autoplayAsCue
|
||||
end
|
||||
end
|
||||
|
||||
def pbAutoplayOnSave
|
||||
surfbgm = pbGetMetadata(0,MetadataSurfBGM)
|
||||
if $PokemonGlobal.surfing && surfbgm
|
||||
pbBGMPlay(surfbgm)
|
||||
else
|
||||
$game_map.autoplay
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Voice recorder
|
||||
#===============================================================================
|
||||
def pbRecord(text,maxtime=30.0)
|
||||
text = "" if !text
|
||||
textwindow = Window_UnformattedTextPokemon.newWithSize(text,0,0,Graphics.width,Graphics.height-96)
|
||||
textwindow.z=99999
|
||||
if text==""
|
||||
textwindow.visible = false
|
||||
end
|
||||
wave = nil
|
||||
msgwindow = pbCreateMessageWindow
|
||||
oldvolume = Audio_bgm_get_volume()
|
||||
Audio_bgm_set_volume(0)
|
||||
delay = 2
|
||||
delay.times do |i|
|
||||
pbMessageDisplay(msgwindow,_INTL("Recording in {1} second(s)...\nPress ESC to cancel.",delay-i),false)
|
||||
Graphics.frame_rate.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
if Input.trigger?(Input::B)
|
||||
Audio_bgm_set_volume(oldvolume)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
textwindow.dispose
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
pbMessageDisplay(msgwindow,_INTL("NOW RECORDING\nPress ESC to stop recording."),false)
|
||||
if beginRecordUI
|
||||
frames = (maxtime*Graphics.frame_rate).to_i
|
||||
frames.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
if Input.trigger?(Input::B)
|
||||
break
|
||||
end
|
||||
end
|
||||
tmpFile = ENV["TEMP"]+"\\record.wav"
|
||||
endRecord(tmpFile)
|
||||
wave = getWaveDataUI(tmpFile,true)
|
||||
if wave
|
||||
pbMessageDisplay(msgwindow,_INTL("PLAYING BACK..."),false)
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
Graphics.update
|
||||
Input.update
|
||||
wave.play
|
||||
(Graphics.frame_rate*wave.time).to_i.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
end
|
||||
end
|
||||
end
|
||||
Audio_bgm_set_volume(oldvolume)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
textwindow.dispose
|
||||
return wave
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Picking up an item found on the ground
|
||||
#===============================================================================
|
||||
|
||||
@@ -1,228 +1,3 @@
|
||||
#===============================================================================
|
||||
# Location signpost
|
||||
#===============================================================================
|
||||
class LocationWindow
|
||||
def initialize(name)
|
||||
@window = Window_AdvancedTextPokemon.new(name)
|
||||
@window.resizeToFit(name,Graphics.width)
|
||||
@window.x = 0
|
||||
@window.y = -@window.height
|
||||
@window.height = 64
|
||||
@window.viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@window.viewport.z = 99999
|
||||
@currentmap = $game_map.map_id
|
||||
@frames = 0
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@window.disposed?
|
||||
end
|
||||
|
||||
def dispose
|
||||
@window.dispose
|
||||
end
|
||||
|
||||
def update
|
||||
return if @window.disposed?
|
||||
@window.update
|
||||
if $game_temp.message_window_showing || @currentmap!=$game_map.map_id
|
||||
@window.dispose
|
||||
return
|
||||
end
|
||||
if @frames>80
|
||||
@window.y -= 4
|
||||
@window.dispose if @window.y+@window.height<0
|
||||
else
|
||||
@window.y += 4 if @window.y<0
|
||||
@frames += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Visibility circle in dark maps
|
||||
#===============================================================================
|
||||
class DarknessSprite < SpriteWrapper
|
||||
attr_reader :radius
|
||||
|
||||
def initialize(viewport=nil)
|
||||
super(viewport)
|
||||
@darkness = BitmapWrapper.new(Graphics.width,Graphics.height)
|
||||
@radius = radiusMin
|
||||
self.bitmap = @darkness
|
||||
self.z = 99998
|
||||
refresh
|
||||
end
|
||||
|
||||
def dispose
|
||||
@darkness.dispose
|
||||
super
|
||||
end
|
||||
|
||||
def radiusMin; return 64; end # Before using Flash
|
||||
def radiusMax; return 176; end # After using Flash
|
||||
|
||||
def radius=(value)
|
||||
@radius = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def refresh
|
||||
@darkness.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0,255))
|
||||
cx = Graphics.width/2
|
||||
cy = Graphics.height/2
|
||||
cradius = @radius
|
||||
numfades = 5
|
||||
for i in 1..numfades
|
||||
for j in cx-cradius..cx+cradius
|
||||
diff2 = (cradius * cradius) - ((j - cx) * (j - cx))
|
||||
diff = Math.sqrt(diff2)
|
||||
@darkness.fill_rect(j,cy-diff,1,diff*2,Color.new(0,0,0,255.0*(numfades-i)/numfades))
|
||||
end
|
||||
cradius = (cradius*0.9).floor
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Lights
|
||||
#===============================================================================
|
||||
class LightEffect
|
||||
def initialize(event,viewport=nil,map=nil,filename=nil)
|
||||
@light = IconSprite.new(0,0,viewport)
|
||||
if filename!=nil && filename!="" && pbResolveBitmap("Graphics/Pictures/"+filename)
|
||||
@light.setBitmap("Graphics/Pictures/"+filename)
|
||||
else
|
||||
@light.setBitmap("Graphics/Pictures/LE")
|
||||
end
|
||||
@light.z = 1000
|
||||
@event = event
|
||||
@map = (map) ? map : $game_map
|
||||
@disposed = false
|
||||
end
|
||||
|
||||
def disposed?
|
||||
return @disposed
|
||||
end
|
||||
|
||||
def dispose
|
||||
@light.dispose
|
||||
@map = nil
|
||||
@event = nil
|
||||
@disposed = true
|
||||
end
|
||||
|
||||
def update
|
||||
@light.update
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class LightEffect_Lamp < LightEffect
|
||||
def initialize(event,viewport=nil,map=nil)
|
||||
lamp = AnimatedBitmap.new("Graphics/Pictures/LE")
|
||||
@light = Sprite.new(viewport)
|
||||
@light.bitmap = Bitmap.new(128,64)
|
||||
src_rect = Rect.new(0, 0, 64, 64)
|
||||
@light.bitmap.blt(0, 0, lamp.bitmap, src_rect)
|
||||
@light.bitmap.blt(20, 0, lamp.bitmap, src_rect)
|
||||
@light.visible = true
|
||||
@light.z = 1000
|
||||
lamp.dispose
|
||||
@map = (map) ? map : $game_map
|
||||
@event = event
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class LightEffect_Basic < LightEffect
|
||||
def update
|
||||
return if !@light || !@event
|
||||
super
|
||||
@light.opacity = 100
|
||||
@light.ox = 32
|
||||
@light.oy = 48
|
||||
if (Object.const_defined?(:ScreenPosHelper) rescue false)
|
||||
@light.x = ScreenPosHelper.pbScreenX(@event)
|
||||
@light.y = ScreenPosHelper.pbScreenY(@event)
|
||||
@light.zoom_x = ScreenPosHelper.pbScreenZoomX(@event)
|
||||
else
|
||||
@light.x = @event.screen_x
|
||||
@light.y = @event.screen_y
|
||||
@light.zoom_x = 1.0
|
||||
end
|
||||
@light.zoom_y = @light.zoom_x
|
||||
@light.tone = $game_screen.tone
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class LightEffect_DayNight < LightEffect
|
||||
def update
|
||||
return if !@light || !@event
|
||||
super
|
||||
shade = PBDayNight.getShade
|
||||
if shade>=144 # If light enough, call it fully day
|
||||
shade = 255
|
||||
elsif shade<=64 # If dark enough, call it fully night
|
||||
shade = 0
|
||||
else
|
||||
shade = 255-(255*(144-shade)/(144-64))
|
||||
end
|
||||
@light.opacity = 255-shade
|
||||
if @light.opacity>0
|
||||
@light.ox = 32
|
||||
@light.oy = 48
|
||||
if (Object.const_defined?(:ScreenPosHelper) rescue false)
|
||||
@light.x = ScreenPosHelper.pbScreenX(@event)
|
||||
@light.y = ScreenPosHelper.pbScreenY(@event)
|
||||
@light.zoom_x = ScreenPosHelper.pbScreenZoomX(@event)
|
||||
@light.zoom_y = ScreenPosHelper.pbScreenZoomY(@event)
|
||||
else
|
||||
@light.x = @event.screen_x
|
||||
@light.y = @event.screen_y
|
||||
@light.zoom_x = 1.0
|
||||
@light.zoom_y = 1.0
|
||||
end
|
||||
@light.tone.set($game_screen.tone.red,
|
||||
$game_screen.tone.green,
|
||||
$game_screen.tone.blue,
|
||||
$game_screen.tone.gray)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Events.onSpritesetCreate += proc { |_sender,e|
|
||||
spriteset = e[0] # Spriteset being created
|
||||
viewport = e[1] # Viewport used for tilemap and characters
|
||||
map = spriteset.map # Map associated with the spriteset (not necessarily the current map)
|
||||
for i in map.events.keys
|
||||
if map.events[i].name[/^outdoorlight\((\w+)\)$/i]
|
||||
filename = $~[1].to_s
|
||||
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i],viewport,map,filename))
|
||||
elsif map.events[i].name.downcase=="outdoorlight"
|
||||
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i],viewport,map))
|
||||
elsif map.events[i].name[/^light\((\w+)\)$/i]
|
||||
filename = $~[1].to_s
|
||||
spriteset.addUserSprite(LightEffect_Basic.new(map.events[i],viewport,map,filename))
|
||||
elsif map.events[i].name.downcase=="light"
|
||||
spriteset.addUserSprite(LightEffect_Basic.new(map.events[i],viewport,map))
|
||||
end
|
||||
end
|
||||
spriteset.addUserSprite(Particle_Engine.new(viewport,map))
|
||||
}
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Battle start animation
|
||||
#===============================================================================
|
||||
@@ -541,6 +316,231 @@ def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Location signpost
|
||||
#===============================================================================
|
||||
class LocationWindow
|
||||
def initialize(name)
|
||||
@window = Window_AdvancedTextPokemon.new(name)
|
||||
@window.resizeToFit(name,Graphics.width)
|
||||
@window.x = 0
|
||||
@window.y = -@window.height
|
||||
@window.viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@window.viewport.z = 99999
|
||||
@currentmap = $game_map.map_id
|
||||
@frames = 0
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@window.disposed?
|
||||
end
|
||||
|
||||
def dispose
|
||||
@window.dispose
|
||||
end
|
||||
|
||||
def update
|
||||
return if @window.disposed?
|
||||
@window.update
|
||||
if $game_temp.message_window_showing || @currentmap!=$game_map.map_id
|
||||
@window.dispose
|
||||
return
|
||||
end
|
||||
if @frames>80
|
||||
@window.y -= 4
|
||||
@window.dispose if @window.y+@window.height<0
|
||||
else
|
||||
@window.y += 4 if @window.y<0
|
||||
@frames += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Visibility circle in dark maps
|
||||
#===============================================================================
|
||||
class DarknessSprite < SpriteWrapper
|
||||
attr_reader :radius
|
||||
|
||||
def initialize(viewport=nil)
|
||||
super(viewport)
|
||||
@darkness = BitmapWrapper.new(Graphics.width,Graphics.height)
|
||||
@radius = radiusMin
|
||||
self.bitmap = @darkness
|
||||
self.z = 99998
|
||||
refresh
|
||||
end
|
||||
|
||||
def dispose
|
||||
@darkness.dispose
|
||||
super
|
||||
end
|
||||
|
||||
def radiusMin; return 64; end # Before using Flash
|
||||
def radiusMax; return 176; end # After using Flash
|
||||
|
||||
def radius=(value)
|
||||
@radius = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def refresh
|
||||
@darkness.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0,255))
|
||||
cx = Graphics.width/2
|
||||
cy = Graphics.height/2
|
||||
cradius = @radius
|
||||
numfades = 5
|
||||
for i in 1..numfades
|
||||
for j in cx-cradius..cx+cradius
|
||||
diff2 = (cradius * cradius) - ((j - cx) * (j - cx))
|
||||
diff = Math.sqrt(diff2)
|
||||
@darkness.fill_rect(j,cy-diff,1,diff*2,Color.new(0,0,0,255.0*(numfades-i)/numfades))
|
||||
end
|
||||
cradius = (cradius*0.9).floor
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Lights
|
||||
#===============================================================================
|
||||
class LightEffect
|
||||
def initialize(event,viewport=nil,map=nil,filename=nil)
|
||||
@light = IconSprite.new(0,0,viewport)
|
||||
if filename!=nil && filename!="" && pbResolveBitmap("Graphics/Pictures/"+filename)
|
||||
@light.setBitmap("Graphics/Pictures/"+filename)
|
||||
else
|
||||
@light.setBitmap("Graphics/Pictures/LE")
|
||||
end
|
||||
@light.z = 1000
|
||||
@event = event
|
||||
@map = (map) ? map : $game_map
|
||||
@disposed = false
|
||||
end
|
||||
|
||||
def disposed?
|
||||
return @disposed
|
||||
end
|
||||
|
||||
def dispose
|
||||
@light.dispose
|
||||
@map = nil
|
||||
@event = nil
|
||||
@disposed = true
|
||||
end
|
||||
|
||||
def update
|
||||
@light.update
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class LightEffect_Lamp < LightEffect
|
||||
def initialize(event,viewport=nil,map=nil)
|
||||
lamp = AnimatedBitmap.new("Graphics/Pictures/LE")
|
||||
@light = Sprite.new(viewport)
|
||||
@light.bitmap = Bitmap.new(128,64)
|
||||
src_rect = Rect.new(0, 0, 64, 64)
|
||||
@light.bitmap.blt(0, 0, lamp.bitmap, src_rect)
|
||||
@light.bitmap.blt(20, 0, lamp.bitmap, src_rect)
|
||||
@light.visible = true
|
||||
@light.z = 1000
|
||||
lamp.dispose
|
||||
@map = (map) ? map : $game_map
|
||||
@event = event
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class LightEffect_Basic < LightEffect
|
||||
def update
|
||||
return if !@light || !@event
|
||||
super
|
||||
@light.opacity = 100
|
||||
@light.ox = 32
|
||||
@light.oy = 48
|
||||
if (Object.const_defined?(:ScreenPosHelper) rescue false)
|
||||
@light.x = ScreenPosHelper.pbScreenX(@event)
|
||||
@light.y = ScreenPosHelper.pbScreenY(@event)
|
||||
@light.zoom_x = ScreenPosHelper.pbScreenZoomX(@event)
|
||||
else
|
||||
@light.x = @event.screen_x
|
||||
@light.y = @event.screen_y
|
||||
@light.zoom_x = 1.0
|
||||
end
|
||||
@light.zoom_y = @light.zoom_x
|
||||
@light.tone = $game_screen.tone
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class LightEffect_DayNight < LightEffect
|
||||
def update
|
||||
return if !@light || !@event
|
||||
super
|
||||
shade = PBDayNight.getShade
|
||||
if shade>=144 # If light enough, call it fully day
|
||||
shade = 255
|
||||
elsif shade<=64 # If dark enough, call it fully night
|
||||
shade = 0
|
||||
else
|
||||
shade = 255-(255*(144-shade)/(144-64))
|
||||
end
|
||||
@light.opacity = 255-shade
|
||||
if @light.opacity>0
|
||||
@light.ox = 32
|
||||
@light.oy = 48
|
||||
if (Object.const_defined?(:ScreenPosHelper) rescue false)
|
||||
@light.x = ScreenPosHelper.pbScreenX(@event)
|
||||
@light.y = ScreenPosHelper.pbScreenY(@event)
|
||||
@light.zoom_x = ScreenPosHelper.pbScreenZoomX(@event)
|
||||
@light.zoom_y = ScreenPosHelper.pbScreenZoomY(@event)
|
||||
else
|
||||
@light.x = @event.screen_x
|
||||
@light.y = @event.screen_y
|
||||
@light.zoom_x = 1.0
|
||||
@light.zoom_y = 1.0
|
||||
end
|
||||
@light.tone.set($game_screen.tone.red,
|
||||
$game_screen.tone.green,
|
||||
$game_screen.tone.blue,
|
||||
$game_screen.tone.gray)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Events.onSpritesetCreate += proc { |_sender,e|
|
||||
spriteset = e[0] # Spriteset being created
|
||||
viewport = e[1] # Viewport used for tilemap and characters
|
||||
map = spriteset.map # Map associated with the spriteset (not necessarily the current map)
|
||||
for i in map.events.keys
|
||||
if map.events[i].name[/^outdoorlight\((\w+)\)$/i]
|
||||
filename = $~[1].to_s
|
||||
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i],viewport,map,filename))
|
||||
elsif map.events[i].name.downcase=="outdoorlight"
|
||||
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i],viewport,map))
|
||||
elsif map.events[i].name[/^light\((\w+)\)$/i]
|
||||
filename = $~[1].to_s
|
||||
spriteset.addUserSprite(LightEffect_Basic.new(map.events[i],viewport,map,filename))
|
||||
elsif map.events[i].name.downcase=="light"
|
||||
spriteset.addUserSprite(LightEffect_Basic.new(map.events[i],viewport,map))
|
||||
end
|
||||
end
|
||||
spriteset.addUserSprite(Particle_Engine.new(viewport,map))
|
||||
}
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Entering/exiting cave animations
|
||||
#===============================================================================
|
||||
|
||||
@@ -11,6 +11,7 @@ end
|
||||
|
||||
|
||||
class PokemonTemp
|
||||
attr_accessor :encounterTriggered
|
||||
attr_accessor :encounterType
|
||||
attr_accessor :evolutionLevels
|
||||
|
||||
@@ -34,8 +35,8 @@ class PokemonTemp
|
||||
when "canrun"; rules["canRun"] = true
|
||||
when "cannotrun"; rules["canRun"] = false
|
||||
when "roamerflees"; rules["roamerFlees"] = true
|
||||
when "noExp"; rules["expGain"] = false
|
||||
when "noMoney"; rules["moneyGain"] = false
|
||||
when "noexp"; rules["expGain"] = false
|
||||
when "nomoney"; rules["moneyGain"] = false
|
||||
when "switchstyle"; rules["switchStyle"] = true
|
||||
when "setstyle"; rules["switchStyle"] = false
|
||||
when "anims"; rules["battleAnims"] = true
|
||||
@@ -45,7 +46,7 @@ class PokemonTemp
|
||||
when "environment", "environ"; rules["environment"] = getID(PBEnvironment,var)
|
||||
when "backdrop", "battleback"; rules["backdrop"] = var
|
||||
when "base"; rules["base"] = var
|
||||
when "outcomevar", "outcome"; rules["outcomeVar"] = var
|
||||
when "outcome", "outcomevar"; rules["outcomeVar"] = var
|
||||
when "nopartner"; rules["noPartner"] = true
|
||||
else
|
||||
raise _INTL("Battle rule \"{1}\" does not exist.",rule)
|
||||
@@ -64,7 +65,7 @@ def setBattleRule(*args)
|
||||
else
|
||||
case arg.downcase
|
||||
when "terrain", "weather", "environment", "environ", "backdrop",
|
||||
"battleback", "base", "outcomevar", "outcome"
|
||||
"battleback", "base", "outcome", "outcomevar"
|
||||
r = arg
|
||||
next
|
||||
end
|
||||
@@ -251,7 +252,12 @@ def pbWildBattleCore(*args)
|
||||
playerTrainers = [$Trainer]
|
||||
playerParty = $Trainer.party
|
||||
playerPartyStarts = [0]
|
||||
if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && foeParty.length>1
|
||||
room_for_partner = (foeParty.length > 1)
|
||||
if !room_for_partner && $PokemonTemp.battleRules["size"] &&
|
||||
!["single", "1v1", "1v2", "1v3"].include?($PokemonTemp.battleRules["size"])
|
||||
room_for_partner = true
|
||||
end
|
||||
if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && room_for_partner
|
||||
ally = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
|
||||
ally.id = $PokemonGlobal.partner[2]
|
||||
ally.party = $PokemonGlobal.partner[3]
|
||||
@@ -391,7 +397,12 @@ def pbTrainerBattleCore(*args)
|
||||
playerTrainers = [$Trainer]
|
||||
playerParty = $Trainer.party
|
||||
playerPartyStarts = [0]
|
||||
if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && foeParty.length>1
|
||||
room_for_partner = (foeParty.length > 1)
|
||||
if !room_for_partner && $PokemonTemp.battleRules["size"] &&
|
||||
!["single", "1v1", "1v2", "1v3"].include?($PokemonTemp.battleRules["size"])
|
||||
room_for_partner = true
|
||||
end
|
||||
if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && room_for_partner
|
||||
ally = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
|
||||
ally.id = $PokemonGlobal.partner[2]
|
||||
ally.party = $PokemonGlobal.partner[3]
|
||||
@@ -553,6 +564,7 @@ def pbAfterBattle(decision,canLose)
|
||||
end
|
||||
end
|
||||
Events.onEndBattle.trigger(nil,decision,canLose)
|
||||
$game_player.straighten
|
||||
end
|
||||
|
||||
Events.onEndBattle += proc { |_sender,e|
|
||||
|
||||
@@ -241,6 +241,6 @@ def pbRoamingPokemonBattle(species, level)
|
||||
return (decision!=2 && decision!=5)
|
||||
end
|
||||
|
||||
EncounterModifier.registerEncounterEnd(proc{
|
||||
EncounterModifier.registerEncounterEnd(proc {
|
||||
$PokemonTemp.roamerIndex = nil
|
||||
})
|
||||
|
||||
@@ -393,7 +393,7 @@ Events.onAction += proc { |_sender,_e|
|
||||
divemap = i; break
|
||||
end
|
||||
end
|
||||
if PBTerrain.isDeepWater?($MapFactory.getTerrainTag(divemap,$game_player.x,$game_player.y))
|
||||
if divemap && PBTerrain.isDeepWater?($MapFactory.getTerrainTag(divemap,$game_player.x,$game_player.y))
|
||||
pbSurfacing
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class PokemonTemp
|
||||
attr_writer :dependentEvents
|
||||
|
||||
def dependentEvents
|
||||
@dependentEvents=DependentEvents.new if !@dependentEvents
|
||||
@dependentEvents = DependentEvents.new if !@dependentEvents
|
||||
return @dependentEvents
|
||||
end
|
||||
end
|
||||
@@ -41,7 +41,8 @@ class PokemonGlobalMetadata
|
||||
attr_writer :dependentEvents
|
||||
|
||||
def dependentEvents
|
||||
return @dependentEvents || []
|
||||
@dependentEvents = [] if !@dependentEvents
|
||||
return @dependentEvents
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user