Added decent spacing to all scripts thanks to Rubocop

This commit is contained in:
Maruno17
2021-12-18 15:25:40 +00:00
parent f7b76ae62e
commit d17fc40a47
207 changed files with 18577 additions and 18587 deletions

View File

@@ -1,22 +1,22 @@
#===============================================================================
# Register contacts
#===============================================================================
def pbPhoneRegisterNPC(ident,name,mapid,showmessage = true)
def pbPhoneRegisterNPC(ident, name, mapid, showmessage = true)
$PokemonGlobal.phoneNumbers = [] if !$PokemonGlobal.phoneNumbers
exists = pbFindPhoneTrainer(ident,name)
exists = pbFindPhoneTrainer(ident, name)
if exists
return if exists[0] # Already visible
exists[0] = true # Make visible
else
phonenum = [true,ident,name,mapid]
phonenum = [true, ident, name, mapid]
$PokemonGlobal.phoneNumbers.push(phonenum)
end
pbMessage(_INTL("\\me[Register phone]Registered {1} in the Pokégear.",name)) if showmessage
pbMessage(_INTL("\\me[Register phone]Registered {1} in the Pokégear.", name)) if showmessage
end
def pbPhoneRegister(event,trainertype,trainername)
def pbPhoneRegister(event, trainertype, trainername)
$PokemonGlobal.phoneNumbers = [] if !$PokemonGlobal.phoneNumbers
return if pbFindPhoneTrainer(trainertype,trainername)
return if pbFindPhoneTrainer(trainertype, trainername)
phonenum = []
phonenum.push(true)
phonenum.push(trainertype)
@@ -33,29 +33,29 @@ end
def pbPhoneDeleteContact(index)
$PokemonGlobal.phoneNumbers[index][0] = false # Remove from contact list
if $PokemonGlobal.phoneNumbers[index].length==8
if $PokemonGlobal.phoneNumbers[index].length == 8
$PokemonGlobal.phoneNumbers[index][3] = 0 # Reset countdown
$PokemonGlobal.phoneNumbers[index][4] = 0 # Reset countdown
end
end
def pbPhoneRegisterBattle(message,event,trainertype,trainername,maxbattles)
def pbPhoneRegisterBattle(message, event, trainertype, trainername, maxbattles)
return if !$player.has_pokegear # Can't register without a Pokégear
return false if !GameData::TrainerType.exists?(trainertype)
trainertype = GameData::TrainerType.get(trainertype).id
contact = pbFindPhoneTrainer(trainertype,trainername)
contact = pbFindPhoneTrainer(trainertype, trainername)
return if contact && contact[0] # Existing contact and is visible
message = _INTL("Let me register you.") if !message
return if !pbConfirmMessage(message)
displayname = _INTL("{1} {2}", GameData::TrainerType.get(trainertype).name,
pbGetMessageFromHash(MessageTypes::TrainerNames,trainername))
pbGetMessageFromHash(MessageTypes::TrainerNames, trainername))
if contact # Previously registered, just make visible
contact[0] = true
else # Add new contact
pbPhoneRegister(event,trainertype,trainername)
pbPhoneIncrement(trainertype,trainername,maxbattles)
pbPhoneRegister(event, trainertype, trainername)
pbPhoneIncrement(trainertype, trainername, maxbattles)
end
pbMessage(_INTL("\\me[Register phone]Registered {1} in the Pokégear.",displayname))
pbMessage(_INTL("\\me[Register phone]Registered {1} in the Pokégear.", displayname))
end
#===============================================================================
@@ -76,7 +76,7 @@ def pbRandomPhoneTrainer
next if caller_map_metadata.town_map_position[0] != currentRegion
temparray.push(num)
end
return nil if temparray.length==0
return nil if temparray.length == 0
return temparray[rand(temparray.length)]
end
@@ -99,7 +99,7 @@ end
def pbPhoneReadyToBattle?(tr_type, tr_name)
trainer = pbFindPhoneTrainer(tr_type, tr_name)
return (trainer && trainer[4]>=2)
return (trainer && trainer[4] >= 2)
end
#===============================================================================
@@ -108,7 +108,7 @@ end
def pbPhoneIncrement(tr_type, tr_name, maxbattles)
trainer = pbFindPhoneTrainer(tr_type, tr_name)
return if !trainer
trainer[5] += 1 if trainer[5]<maxbattles # Increment battle count
trainer[5] += 1 if trainer[5] < maxbattles # Increment battle count
trainer[3] = 0 # reset time to can-battle
trainer[4] = 0 # reset can-battle flag
end
@@ -123,20 +123,20 @@ end
def pbSetReadyToBattle(num)
return if !num[6] || !num[7]
$game_self_switches[[num[6],num[7],"A"]] = false
$game_self_switches[[num[6],num[7],"B"]] = true
$game_self_switches[[num[6], num[7], "A"]] = false
$game_self_switches[[num[6], num[7], "B"]] = true
$game_map.need_refresh = true
end
#===============================================================================
# Phone-related counters
#===============================================================================
Events.onMapUpdate += proc { |_sender,_e|
Events.onMapUpdate += proc { |_sender, _e|
next if !$player || !$player.has_pokegear
# Reset time to next phone call if necessary
if !$PokemonGlobal.phoneTime || $PokemonGlobal.phoneTime<=0
$PokemonGlobal.phoneTime = 20*60*Graphics.frame_rate
$PokemonGlobal.phoneTime += rand(20*60*Graphics.frame_rate)
if !$PokemonGlobal.phoneTime || $PokemonGlobal.phoneTime <= 0
$PokemonGlobal.phoneTime = 20 * 60 * Graphics.frame_rate
$PokemonGlobal.phoneTime += rand(20 * 60 * Graphics.frame_rate)
end
# Don't count down various phone times if other things are happening
$PokemonGlobal.phoneNumbers = [] if !$PokemonGlobal.phoneNumbers
@@ -145,30 +145,30 @@ Events.onMapUpdate += proc { |_sender,_e|
# Count down time to next phone call
$PokemonGlobal.phoneTime -= 1
# Count down time to next can-battle for each trainer contact
if $PokemonGlobal.phoneTime%Graphics.frame_rate==0 # Every second
if $PokemonGlobal.phoneTime % Graphics.frame_rate == 0 # Every second
for num in $PokemonGlobal.phoneNumbers
next if !num[0] || num.length!=8 # if not visible or not a trainer
next if !num[0] || num.length != 8 # if not visible or not a trainer
# Reset time to next can-battle if necessary
if num[4]==0
num[3] = 20*60+rand(20*60) # 20-40 minutes
if num[4] == 0
num[3] = 20 * 60 + rand(20 * 60) # 20-40 minutes
num[4] = 1
end
# Count down time to next can-battle
num[3] -= 1
# Ready to battle
if num[3]<=0 && num[4]==1
if num[3] <= 0 && num[4] == 1
num[4] = 2 # set ready-to-battle flag
pbSetReadyToBattle(num)
end
end
end
# Time for a random phone call; generate one
if $PokemonGlobal.phoneTime<=0
if $PokemonGlobal.phoneTime <= 0
# find all trainer phone numbers
phonenum = pbRandomPhoneTrainer
if phonenum
call = pbPhoneGenerateCall(phonenum)
pbPhoneCall(call,phonenum)
pbPhoneCall(call, phonenum)
end
end
}
@@ -176,18 +176,18 @@ Events.onMapUpdate += proc { |_sender,_e|
#===============================================================================
# Player calls a contact
#===============================================================================
def pbCallTrainer(trtype,trname)
trainer = pbFindPhoneTrainer(trtype,trname)
def pbCallTrainer(trtype, trname)
trainer = pbFindPhoneTrainer(trtype, trname)
return if !trainer
# Special NPC contacts
if trainer.length!=8
if trainer.length != 8
if !pbCommonEvent(trtype)
pbMessage(_INTL("{1}'s messages not defined.\nCouldn't call common event {2}.",trainer[2],trtype))
pbMessage(_INTL("{1}'s messages not defined.\nCouldn't call common event {2}.", trainer[2], trtype))
end
return
end
# Trainer contacts
if $game_map.map_id==trainer[6]
if $game_map.map_id == trainer[6]
pbMessage(_INTL("The Trainer is close by.\nTalk to the Trainer in person!"))
return
end
@@ -200,7 +200,7 @@ def pbCallTrainer(trtype,trname)
return # Can't call if in different region
end
call = pbPhoneGenerateCall(trainer)
pbPhoneCall(call,trainer)
pbPhoneCall(call, trainer)
end
#===============================================================================
@@ -213,18 +213,18 @@ def pbPhoneGenerateCall(phonenum)
time = pbGetTimeNow
if PBDayNight.isMorning?(time)
modcall = pbRandomPhoneItem(phoneData.greetingsMorning)
call = modcall if modcall && modcall!=""
call = modcall if modcall && modcall != ""
elsif PBDayNight.isEvening?(time)
modcall = pbRandomPhoneItem(phoneData.greetingsEvening)
call = modcall if modcall && modcall!=""
call = modcall if modcall && modcall != ""
end
call += "\\m"
if phonenum[4]==2 || (rand(2)==0 && phonenum[4]==3)
if phonenum[4] == 2 || (rand(2) == 0 && phonenum[4] == 3)
# If "can battle" is set, make ready to battle
call += pbRandomPhoneItem(phoneData.battleRequests)
pbSetReadyToBattle(phonenum)
phonenum[4] = 3
elsif rand(4)<3
elsif rand(4) < 3
# Choose random body
call += pbRandomPhoneItem(phoneData.bodies1)
call += "\\m"
@@ -239,7 +239,7 @@ end
def pbRandomPhoneItem(array)
ret = array[rand(array.length)]
ret = "" if !ret
return pbGetMessageFromHash(MessageTypes::PhoneMessages,ret)
return pbGetMessageFromHash(MessageTypes::PhoneMessages, ret)
end
def pbRandomEncounterSpecies(enc_table)
@@ -285,18 +285,18 @@ end
#===============================================================================
# The phone call itself
#===============================================================================
def pbPhoneCall(call,phonenum)
def pbPhoneCall(call, phonenum)
pbMessage(_INTL("......\\wt[5] ......\\1"))
encspecies = pbEncounterSpecies(phonenum)
trainerspecies = pbTrainerSpecies(phonenum)
trainermap = pbTrainerMapName(phonenum)
messages = call.split("\\m")
for i in 0...messages.length
messages[i].gsub!(/\\TN/,phonenum[2])
messages[i].gsub!(/\\TP/,trainerspecies)
messages[i].gsub!(/\\TE/,encspecies)
messages[i].gsub!(/\\TM/,trainermap)
messages[i] += "\\1" if i<messages.length-1
messages[i].gsub!(/\\TN/, phonenum[2])
messages[i].gsub!(/\\TP/, trainerspecies)
messages[i].gsub!(/\\TE/, encspecies)
messages[i].gsub!(/\\TM/, trainermap)
messages[i] += "\\1" if i < messages.length - 1
pbMessage(messages[i])
end
pbMessage(_INTL("Click!\\wt[10]\n......\\wt[5] ......\\1"))