General tidying up

This commit is contained in:
Maruno17
2020-12-28 15:46:08 +00:00
parent d3d7222fd3
commit fb29c6b760
44 changed files with 1822 additions and 2650 deletions

View File

@@ -1,30 +1,9 @@
#===============================================================================
# Message variables
#===============================================================================
class Game_Temp
attr_accessor :background
attr_writer :message_window_showing
attr_writer :player_transferring
attr_writer :transition_processing
def message_window_showing
return @message_window_showing || false
end
def player_transferring
return @player_transferring || false
end
def transition_processing
return @transition_processing || false
end
end
class Game_Message
attr_writer :background
attr_writer :visible
attr_writer :background
def visible
return @visible || false
@@ -37,16 +16,6 @@ end
class Game_System
attr_writer :message_position
def message_position
return @message_position || 2
end
end
#===============================================================================
#
#===============================================================================
@@ -155,8 +124,6 @@ def pbUpdateSceneMap
end
end
#===============================================================================
#
#===============================================================================
@@ -189,330 +156,6 @@ def pbCurrentEventCommentInput(elements,trigger)
return pbEventCommentInput(event,elements,trigger)
end
def pbButtonInputProcessing(variableNumber=0,timeoutFrames=0)
ret=0
timeoutFrames = timeoutFrames*Graphics.frame_rate/20
loop do
Graphics.update
Input.update
pbUpdateSceneMap
for i in 1..18
ret=i if Input.trigger?(i)
end
break if ret!=0
if timeoutFrames>0
i+=1
break if i>=timeoutFrames
end
end
Input.update
if variableNumber && variableNumber>0
$game_variables[variableNumber]=ret
$game_map.need_refresh = true if $game_map
end
return ret
end
#===============================================================================
# Interpreter functions for displaying messages
#===============================================================================
module InterpreterMixin
# Freezes all events on the map (for use at the beginning of common events)
def pbGlobalLock
for event in $game_map.events.values
event.minilock
end
end
# Unfreezes all events on the map (for use at the end of common events)
def pbGlobalUnlock
for event in $game_map.events.values
event.unlock
end
end
def pbRepeatAbove(index)
index=@list[index].indent
loop do
index-=1
return index+1 if @list[index].indent==indent
end
end
def pbBreakLoop(index)
indent = @list[index].indent
temp_index=index
# Copy index to temporary variables
loop do
# Advance index
temp_index += 1
# If a fitting loop was not found
return index+1 if temp_index >= @list.size-1
return temp_index+1 if @list[temp_index].code == 413 and
@list[temp_index].indent < indent
end
end
def pbJumpToLabel(index,label_name)
temp_index = 0
loop do
return index+1 if temp_index >= @list.size-1
return temp_index+1 if @list[temp_index].code == 118 and
@list[temp_index].parameters[0] == label_name
temp_index += 1
end
end
# Gets the next index in the interpreter, ignoring
# certain events between messages
def pbNextIndex(index)
return -1 if !@list || @list.length==0
i=index+1
loop do
return i if i>=@list.length-1
case @list[i].code
when 118, 108, 408 # Label, Comment
i+=1
when 413 # Repeat Above
i=pbRepeatAbove(i)
when 113 # Break Loop
i=pbBreakLoop(i)
when 119 # Jump to Label
newI=pbJumpToLabel(i,@list[i].parameters[0])
i = (newI>i) ? newI : i+1
else
return i
end
end
end
# Helper function that shows a picture in a script. To be used in
# a script event command.
def pbShowPicture(number,name,origin,x,y,zoomX=100,zoomY=100,opacity=255,blendType=0)
number = number + ($game_temp.in_battle ? 50 : 0)
$game_screen.pictures[number].show(name,origin,
x, y, zoomX,zoomY,opacity,blendType)
end
# Erases an event and adds it to the list of erased events so that
# it can stay erased when the game is saved then loaded again. To be used in
# a script event command.
def pbEraseThisEvent
if $game_map.events[@event_id]
$game_map.events[@event_id].erase
$PokemonMap.addErasedEvent(@event_id) if $PokemonMap
end
@index+=1
return true
end
# Runs a common event. To be used in a script event command.
def pbCommonEvent(id)
common_event = $data_common_events[id]
if $game_temp.in_battle
if common_event != nil
interp = Interpreter.new
interp.setup(common_event.list,0)
loop do
Graphics.update
Input.update
interp.update
pbUpdateSceneMap
break if !interp.running?
end
end
else
$game_system.battle_interpreter.setup(common_event.list, 0)
end
end
# Sets another event's self switch (eg. pbSetSelfSwitch(20,"A",true) ).
# To be used in a script event command.
def pbSetSelfSwitch(event,swtch,value,mapid=-1)
mapid = @map_id if mapid<0
oldValue = $game_self_switches[[mapid,event,swtch]]
$game_self_switches[[mapid,event,swtch]] = value
if value!=oldValue && $MapFactory.hasMap?(mapid)
$MapFactory.getMap(mapid,false).need_refresh = true
end
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_242
pbBGMFade(pbParams[0])
return true
end
def command_246
pbBGSFade(pbParams[0])
return true
end
def command_251
pbSEStop
return true
end
def command_241
pbBGMPlay(pbParams[0])
return true
end
def command_245
pbBGSPlay(pbParams[0])
return true
end
def command_249
pbMEPlay(pbParams[0])
return true
end
def command_250
pbSEPlay(pbParams[0])
return true
end
_END_
end
class Interpreter # Used by RMXP
include InterpreterMixin
eval(InterpreterMixin::CustomEventCommands)
@@immediateDisplayAfterWait=false
@buttonInput=false
def pbParams
return @parameters
end
def command_105
return false if @buttonInput
@buttonInput=true
pbButtonInputProcessing(@list[@index].parameters[0])
@buttonInput=false
@index+=1
return true
end
def command_101
if $game_temp.message_window_showing
return false
end
message=""
commands=nil
numInputVar=nil
numInputDigitsMax=nil
text=""
firstText=nil
if @list[@index].parameters.length==1
text+=@list[@index].parameters[0]
firstText=@list[@index].parameters[0]
text+=" " if text[text.length-1,1]!=" "
message+=text
else
facename=@list[@index].parameters[0]
faceindex=@list[@index].parameters[1]
if facename && facename!=""
text+="\\ff[#{facename},#{faceindex}]"
message+=text
end
end
messageend=""
loop do
nextIndex=pbNextIndex(@index)
code=@list[nextIndex].code
if code == 401
text=@list[nextIndex].parameters[0]
text+=" " if text[text.length-1,1]!=" "
message+=text
@index=nextIndex
else
if code == 102
commands=@list[nextIndex].parameters
@index=nextIndex
elsif code == 106 && @@immediateDisplayAfterWait
params=@list[nextIndex].parameters
if params[0]<=10
nextcode=@list[nextIndex+1].code
if nextcode==101 || nextcode==102 || nextcode==103
@index=nextIndex
else
break
end
else
break
end
elsif code == 103
numInputVar=@list[nextIndex].parameters[0]
numInputDigitsMax=@list[nextIndex].parameters[1]
@index=nextIndex
elsif code == 101
if @list[@index].parameters.length==1
text=@list[@index].parameters[0]
if text[/\A\\ignr/] && text==firstText
text+=" " if text[text.length-1,1]!=" "
message+=text
@index=nextIndex
continue
end
end
messageend="\1"
end
break
end
end
@message_waiting=true # needed to allow parallel process events to work while
# a message is displayed
message=_MAPINTL($game_map.map_id,message)
if commands
cmdlist=[]
for cmd in commands[0]
cmdlist.push(_MAPINTL($game_map.map_id,cmd))
end
command=pbMessage(message+messageend,cmdlist,commands[1])
@branch[@list[@index].indent] = command
elsif numInputVar
params=ChooseNumberParams.new
params.setMaxDigits(numInputDigitsMax)
params.setDefaultValue($game_variables[numInputVar])
$game_variables[numInputVar]=pbMessageChooseNumber(message+messageend,params)
$game_map.need_refresh = true if $game_map
else
pbMessage(message+messageend,nil)
end
@message_waiting=false
return true
end
def command_102
@message_waiting=true
command=pbShowCommands(nil,@list[@index].parameters[0],@list[@index].parameters[1])
@message_waiting=false
@branch[@list[@index].indent] = command
Input.update # Must call Input.update again to avoid extra triggers
return true
end
def command_103
varnumber=@list[@index].parameters[0]
@message_waiting=true
params=ChooseNumberParams.new
params.setMaxDigits(@list[@index].parameters[1])
params.setDefaultValue($game_variables[varnumber])
$game_variables[varnumber]=pbChooseNumber(nil,params)
$game_map.need_refresh = true if $game_map
@message_waiting=false
return true
end
end
#===============================================================================