Game
Game
Game
======
# * Game Mode Script
#
# * What it will do:
#
# - changing the AI inteligence depending on the Mode, you choose.
# - changing the Pokmon level's of trainers, depending on the Mode, you choose.
#
# Tips:
#
# - if you want to choose the game mode just a single time, set
#
GAME_MODE=false (in the Settings Script).
# - you can call the Scene, whenever you want during the game with GameMode.new
#===============================================================================
====
CHOOSED_MODE_BY_DEFAULT=2 # (Normal Mode)
UNLOCKED_MODES=[-1,true,true,false] #
#(Easy Mode: unlocked; Normal Mode: unlocked;Challenge Mode: locked)
#===============================================================================
# * adding variables to PokemonSystem.
#===============================================================================
class Game_System
attr_accessor :gamemode
attr_accessor :unlocked_mode
end
#===============================================================================
# * adding GameMode variables to PokemonSystem.
#===============================================================================
class GameMode
def initialize
$game_system.gamemode=CHOOSED_MODE_BY_DEFAULT if !$game_system.gamemode
$game_system.unlocked_mode=UNLOCKED_MODES if !$game_system.unlocked_mode
pbFadeInAndShow(@sprites)
pbBGMPlay("GameModeScene")
@select=1; @back=0
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites={}
@sprites["bg"]=IconSprite.new(0,0,@viewport)
@sprites["bg"].setBitmap("Graphics/Pictures/GameMode/background")
@sprites["bg"].y = -100
@sprites["ui"]=IconSprite.new(0,0,@viewport)
@sprites["ui"].setBitmap("Graphics/Pictures/GameMode/main_ui")
@sprites["panel_1"]=IconSprite.new(0,0,@viewport)
@sprites["panel_1"].setBitmap("Graphics/Pictures/GameMode/panel1_select")
@sprites["panel_1"].x=242
@sprites["panel_2"]=IconSprite.new(0,0,@viewport)
@sprites["panel_2"].setBitmap("Graphics/Pictures/GameMode/panel2_select")
@sprites["panel_2"].x=290
@sprites["panel_2"].y=232
@sprites["panel_2"].visible=false
@sprites["choosed"]=IconSprite.new(0,0,@viewport)
@sprites["choosed"].setBitmap("Graphics/Pictures/GameMode/choosed_mode")
@sprites["choosed"].x=210
@sprites["locked_1"]=IconSprite.new(0,0,@viewport)
@sprites["locked_1"].setBitmap("Graphics/Pictures/GameMode/locked")
@sprites["locked_1"].x=465
@sprites["locked_1"].y=47
@sprites["locked_2"]=IconSprite.new(0,0,@viewport)
@sprites["locked_2"].setBitmap("Graphics/Pictures/GameMode/locked")
@sprites["locked_2"].x=465
@sprites["locked_2"].y=47
@sprites["locked_3"]=IconSprite.new(0,0,@viewport)
@sprites["locked_3"].setBitmap("Graphics/Pictures/GameMode/locked")
@sprites["locked_3"].x=465
@sprites["locked_3"].y=175
for i in 1..3
if $game_system.unlocked_mode[i]
@sprites["locked_#{i}"].visible=false
end
end
@sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height, @viewp
ort)
overlay= @sprites["overlay"].bitmap
overlay.clear
heading=Color.new(90,82,82)
heading2=Color.new(165,165,173)
base=Color.new(222,231,231)
base2=Color.new(140,140,148)
pbSetSystemFont(@sprites["overlay"].bitmap)
textos=[]
textos.push([_INTL("Key System"),54,16,false,heading,heading2])
textos.push([_INTL("EASY MODE"),256,47,false,base,base2])
textos.push([_INTL("NORMAL MODE"),256,111,false,base,base2])
textos.push([_INTL("CHALLENGE MODE"),256,175,false,base,base2])
textos.push([_INTL("BACK"),304,239,false,base,base2])
pbDrawTextPositions(overlay,textos)
main_method
end
def main_method
while @back==0
self.update
self.input
end
end
def update
Graphics.update
Input.update
y=[5000,40,104,168,5000]
@sprites["panel_1"].y=y[@select]
y2=[5000,47,111,175]
@sprites["choosed"].y=y2[$game_system.gamemode]
@sprites["bg"].y+=2
@sprites["bg"].y= -100 if @sprites["bg"].y == -6 #-10
end
def input
if Input.trigger?(Input::DOWN)
pbSEPlay("BW2MenuSelect")
@select=0 if @select==4
@select+=1
end
if Input.trigger?(Input::UP)
pbSEPlay("BW2MenuSelect")
@select=5 if @select==1
@select-=1
end
if @select==4
@sprites["panel_2"].visible=true
else
@sprites["panel_2"].visible=false
end
if Input.trigger?(Input::B) || ( @select==4 && Input.trigger?(Input::C) )
pbSEPlay("BW2MenuChoose")
closescene
end
if Input.trigger?(Input::C) && @select != 4
pbSEPlay("BW2MenuChoose")
mode_1 if @select==1
mode_2 if @select==2
mode_3 if @select==3
end
if $mouse.inAreaLeft?(290,47,220,40) && defined?($mouse)
pbSEPlay("BW2MenuChoose")
@select=1
@sprites["panel_1"].y =40
10.times do
pbWait(1)
end
@sprites["panel_1"].visible=false
5.times do
pbWait(1)
end
@sprites["panel_1"].visible=true
mode_1
end
if $mouse.inAreaLeft?(290,111,220,40) && defined?($mouse)
pbSEPlay("BW2MenuChoose")
@select=2
@sprites["panel_1"].y =104
10.times do
pbWait(1)
end
@sprites["panel_1"].visible=false
5.times do
pbWait(1)
end
@sprites["panel_1"].visible=true
mode_2
end
if $mouse.inAreaLeft?(290,175,220,40) && defined?($mouse)
pbSEPlay("BW2MenuChoose")
@select=3
@sprites["panel_1"].y =168
10.times do
pbWait(1)
end
@sprites["panel_1"].visible=false
5.times do
pbWait(1)
end
@sprites["panel_1"].visible=true
mode_3
end
if $mouse.inAreaLeft?(290,232,220,45) && defined?($mouse)
pbSEPlay("BW2MenuChoose")
@select=4
@sprites["panel_1"].y=4000
@sprites["panel_2"].visible=true
10.times do
pbWait(1)
end
@sprites["panel_2"].visible=false
5.times do
pbWait(1)
end
@sprites["panel_2"].visible=true
closescene
end
end
def closescene
@back=1
pbFadeOutAndHide(@sprites)
pbDisposeSpriteHash(@sprites)
@viewport.dispose
pbBGMStop()
end
def mode_1
if $game_system.unlocked_mode[1]
$game_system.gamemode=1
@sprites["choosed"].y=47
Kernel.pbMessage("Difficulty was set to Easy Mode.")
Kernel.pbMessage("The level of Pokmon Trainers use will be lower then norma
l.")
else
Kernel.pbMessage("The Easy Mode isn't unlocked yet.")
end
end
def mode_2
if $game_system.unlocked_mode[2]
$game_system.gamemode=2
@sprites["choosed"].y=111
Kernel.pbMessage("Difficulty was set to Normal Mode.")
Kernel.pbMessage("The level of Pokmon Trainers use will be the same as norm
al.")
else
Kernel.pbMessage("The Normal Mode isn't unlocked yet.")
end
end
def mode_3
if $game_system.unlocked_mode[3]
$PokemonSystem.gamemode=3
@sprites["choosed"].y=175
Kernel.pbMessage("Difficulty was set to Challenge Mode.")
Kernel.pbMessage("The level of Pokmon Trainers use will be higher then norm
al.")
else
Kernel.pbMessage("The Challenge Mode isn't unlocked yet.")
end
end
end
def pbUnlockMode(mode)
$game_system.unlocked_mode[mode]=true
end
def pbLockMode(mode)
$game_system.unlocked_mode[mode]=false
end
#===============================================================================
# * changing/updating AI inteligence.
#===============================================================================
module PBTrainerAI
# Minimum skill level to be in each AI category
def PBTrainerAI.minimumSkill; 1; end
def PBTrainerAI.mediumSkill
32*1.2 if $game_system.gamemode==1
32
if $game_system.gamemode==2
32*0.8 if $game_system.gamemode==3
end
def PBTrainerAI.highSkill
48*1.2 if $game_system.gamemode==1
48
if $game_system.gamemode==2
48*0.8 if $game_system.gamemode==3
end
def PBTrainerAI.bestSkill
100*1.2 if $game_system.gamemode==1
100
if $game_system.gamemode==2
100*0.8 if $game_system.gamemode==3
end
end
#===============================================================================
# * changing/updating levels of trainer's Pokmon.
#===============================================================================
def pbLoadTrainer(trainerid,trainername,partyid=0)
if trainerid.is_a?(String) || trainerid.is_a?(Symbol)
if !hasConst?(PBTrainers,trainerid)
raise _INTL("Trainer type does not exist ({1}, {2}, ID {3})",trainerid,tra
inername,partyid)
end
trainerid=getID(PBTrainers,trainerid)
end
success=false
items=[]
party=[]
opponent=nil
trainers=load_data("Data/trainers.dat")
for trainer in trainers
name=trainer[1]
thistrainerid=trainer[0]
thispartyid=trainer[4]
next if trainerid!=thistrainerid || name!=trainername || partyid!=thispartyi
d
items=trainer[2].clone
name=pbGetMessageFromHash(MessageTypes::TrainerNames,name)
for i in RIVALNAMES
if isConst?(trainerid,PBTrainers,i[0]) && $game_variables[i[1]]!=0
name=$game_variables[i[1]]
end
end
opponent=PokeBattle_Trainer.new(name,thistrainerid)
opponent.setForeignID($Trainer) if $Trainer
for poke in trainer[3]
species=poke[TPSPECIES]
level=poke[TPLEVEL]
# Level changes here.
if $game_system.gamemode==1
level=(poke[TPLEVEL]*0.8).round
poke[TPLEVEL]=1 if poke[TPLEVEL]<1
elsif $game_system.gamemode==3
level=(poke[TPLEVEL]*1.2).round
level=MAXIMUMLEVEL if level>MAXIMUMLEVEL
end
pokemon=PokeBattle_Pokemon.new(species,level,opponent)
pokemon.form=poke[TPFORM]
pokemon.resetMoves
pokemon.setItem(poke[TPITEM])
if poke[TPMOVE1]>0 || poke[TPMOVE2]>0 || poke[TPMOVE3]>0 || poke[TPMOVE4]>
0
k=0
for move in [TPMOVE1,TPMOVE2,TPMOVE3,TPMOVE4]
pokemon.moves[k]=PBMove.new(poke[move])
k+=1
end
pokemon.moves.compact!
end
pokemon.setAbility(poke[TPABILITY])
pokemon.setGender(poke[TPGENDER])
if poke[TPSHINY] # if this is a shiny Pokmon
pokemon.makeShiny
else
pokemon.makeNotShiny
end
pokemon.setNature(poke[TPNATURE])
iv=poke[TPIV]
for i in 0...6
pokemon.iv[i]=iv&0x1F
pokemon.ev[i]=[85,level*3/2].min
end
pokemon.happiness=poke[TPHAPPINESS]
pokemon.name=poke[TPNAME] if poke[TPNAME] && poke[TPNAME]!=""
if poke[TPSHADOW] # if this is a Shadow Pokmon
pokemon.makeShadow rescue nil
pokemon.pbUpdateShadowMoves(true) rescue nil
pokemon.makeNotShiny
end
pokemon.ballused=poke[TPBALL]
pokemon.calcStats
party.push(pokemon)
end
success=true
break
end
return success ? [opponent,items,party] : nil
end