- 1,224
- Posts
- 10
- Years
- Omnipresence
- Seen Aug 8, 2023
This is not yet even close to a completed script, posting it here so that others who have expressed interest can view it and collaborate (since it goes over the character limit of most forums). Feel free to use this as a basis for your own/ give input on mine. I will update this post as I move forward in the coding. Will move to the scripts and tutorials section when it becomes more complete.
What the script currently does: lets you determine opponent pokemon and lets you choose yours to enter in the contest. Does an intro sort of thing. Goes through a first round using randomly selected moves of the pokemon (user move selection coming soon), though it does output any scoring for the moves nor the move animations yet.
What it doesn't do: A lot
Update 1: Displays hearts based on the moves base damage/20, or gives it one heart if the basedamage is 0
You need these for it to work. Name each of them "hearts_.png", the _ being the number of hearts there are, including zero.
You will need these , put them in a new folder in Graphics/Pictures named Contest. Name the files Roundone.png, contestbg.png, and moves.png respectively.
As I said before, this is a work in progress. And I also know my coding is kinda messy, so I apologize if it is confusing. If this is the wrong section, please move it or delete it, but I did not see any other section that would be fit.
What the script currently does: lets you determine opponent pokemon and lets you choose yours to enter in the contest. Does an intro sort of thing. Goes through a first round using randomly selected moves of the pokemon (user move selection coming soon), though it does output any scoring for the moves nor the move animations yet.
What it doesn't do: A lot
Update 1: Displays hearts based on the moves base damage/20, or gives it one heart if the basedamage is 0
You need these for it to work. Name each of them "hearts_.png", the _ being the number of hearts there are, including zero.
Code:
class PokeContestScene
attr_reader :index
attr_reader :name
attr_accessor :selected
attr_reader(:basedamage)
def update
pbUpdateSpriteHash(@sprites)
end
def pbStartContest(chosen,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level)
pbBGMPlay("021-Field04")
@lastcmd=[0,0,0,0]
@pkmn1=$Trainer.party[chosen]
@pkmn2=PokeBattle_Pokemon.new(opponent1,opponent1level,$Trainer)
@pkmn3=PokeBattle_Pokemon.new(opponent2,opponent2level,$Trainer)
@pkmn4=PokeBattle_Pokemon.new(opponent3,opponent3level,$Trainer)
@pkmn2.form=0
@pkmn3.form=0
@pkmn4.form=0
@fastest=@pkmn1
@second=@pkmn2
@third=@pkmn3
@fourth=@pkmn4
@firstnumber=0
@secondnumber=0
@thirdnumber=0
@fourthnumber=0
@pkmn1hearts=0
@pkmn2hearts=0
@pkmn3hearts=0
@pkmn4hearts=0
@sprites["Judge"]=IconSprite.new(0,0,@viewport)
@sprites["Judge"].setBitmap("Graphics/Characters/trainer017")
Kernel.pbMessage(_INTL("Judge: \\c[1]Welcome to today's Pokemon Contest\nIt's heartwarming to see all these young trainers here to show off their Pokemon's skills!")) #add variable to say contest type later
Kernel.pbMessage(_INTL("\\c[1]I'm going to be the judge for this competition, so let's get started!"))
pbDisposeSprite(@sprites,"Judge")
sleep(1.0/3.0)
Graphics.update
@sprites["RoundOne"]=IconSprite.new(0,0,@viewport)
@sprites["RoundOne"].setBitmap("Graphics/Pictures/Contest/Roundone")
sleep(1.0/2.0)
Graphics.update
roundoneupdown=0
for i in 0...9
if roundoneupdown==0 or roundoneupdown==1 or roundoneupdown==4 or roundoneupdown==5 or roundoneupdown==8 or roundoneupdown==9
@sprites["RoundOne"].y+=6
else
@sprites["RoundOne"].y-=6
end
roundoneupdown+=1
Graphics.update
sleep(1.0/8.0)
end
sleep(1)
pbDisposeSprite(@sprites,"RoundOne")
@sprites["overlay"]=BitmapSprite.new(
Graphics.width,Graphics.height,@viewport)
pbSetSystemFont(@sprites["overlay"].bitmap)
pbFindFastestOrderRanking
pbDisplayFastest
pbDrawTextRoundOne
Kernel.pbMessage(_INTL("Judge: \\c[1]Alright {1}, let's see what you can do!",@fastest.name))
i=rand(@fastest.moves.length)
movedata=PBMoveData.new(@fastest.moves[i].id)
@currentbasedamage=movedata.basedamage
@currentpoke=@fastest
@currentmove=PBMoves.getName(@fastest.moves[i].id)
Kernel.pbMessage(_INTL("{1} used {2}",@fastest.name,@currentmove))
@fastestlastmove=@currentmove
pbHearts
pbAssignHearts
pbDisplayAddingPositiveHearts
Graphics.update
sleep(1.0/10.0)
Kernel.pbMessage(_INTL("Judge: \\c[1]Good job {1}, now onto the next pokemon!",@fastest.name))
sleep(1.0/10.0)
pbDisposeSprite(@sprites,"pokemon#{@firstnumber}")
Graphics.update
sleep(1.0/10.0)
Kernel.pbMessage(_INTL("Judge: \\c[1]Next up we have {1}!",@second.name))
pbDisplaySecondFastest
Graphics.update
sleep(1.0/10.0)
i=rand(@second.moves.length)
movedata=PBMoveData.new(@second.moves[i].id)
@currentbasedamage=movedata.basedamage
@currentpoke=@second
@currentmove=PBMoves.getName(@second.moves[i].id)
Kernel.pbMessage(_INTL("{1} used {2}",@second.name,@currentmove))
@secondlastmove=@currentmove
pbHearts
pbAssignHearts
pbDisplayAddingPositiveHearts
Graphics.update
sleep(1.0/10.0)
pbDisposeSprite(@sprites,"pokemon#{@secondnumber}")
Graphics.update
sleep(1.0/10.0)
Kernel.pbMessage(_INTL("Judge: \\c[1]Next up we have {1}!",@third.name))
pbDisplayThirdFastest
Graphics.update
sleep(1.0/10.0)
i=rand(@third.moves.length)
movedata=PBMoveData.new(@third.moves[i].id)
@currentbasedamage=movedata.basedamage
@currentpoke=@third
@currentmove=PBMoves.getName(@third.moves[i].id)
Kernel.pbMessage(_INTL("{1} used {2}",@third.name,@currentmove))
@thirdlastmove=@currentmove
pbHearts
pbAssignHearts
pbDisplayAddingPositiveHearts
Graphics.update
sleep(1.0/10.0)
pbDisposeSprite(@sprites,"pokemon#{@thirdnumber}")
Graphics.update
sleep(1.0/10.0)
Kernel.pbMessage(_INTL("Judge: \\c[1]Next up we have {1}!",@fourth.name))
pbDisplayFourthFastest
Graphics.update
sleep(1.0/10.0)
i=rand(@fourth.moves.length)
movedata=PBMoveData.new(@fourth.moves[i].id)
@currentbasedamage=movedata.basedamage
@currentpoke=@fourth
@currentmove=PBMoves.getName(@fourth.moves[i].id)
Kernel.pbMessage(_INTL("{1} used {2}",@fourth.name,@currentmove))
@fourthlastmove=@currentmove
pbHearts
pbAssignHearts
pbDisplayAddingPositiveHearts
Graphics.update
sleep(1.0/10.0)
end
def pbAssignHearts
if @currentpoke==@pkmn1
@pkmn1hearts=@hearts
elsif @currentpoke==@pkmn2
@pkmn2hearts=@hearts
elsif @currentpoke==@pkmn3
@pkmn3hearts=@hearts
else
@pkmn4hearts=@hearts
end
end
def pbDrawTextRoundOne
overlay=@sprites["overlay"].bitmap
overlay.clear
pokeone=_INTL("{1}",@fastest.name)
poketwo=_INTL("{1}",@second.name)
pokethree=_INTL("{1}",@third.name)
pokefour=_INTL("{1}",@fourth.name)
baseColor=Color.new(72,72,72)
shadowColor=Color.new(160,160,160)
textPositions=[
[pokeone,353,5,false,baseColor,shadowColor],
[poketwo,353,100,false,baseColor,shadowColor],
[pokethree,353,195,false,baseColor,shadowColor],
[pokefour,353,290,false,baseColor,shadowColor],
]
pbDrawTextPositions(overlay,textPositions)
end
def initialize
@sprites={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites["background"]=IconSprite.new(0,0,@viewport)
@sprites["background"].setBitmap("Graphics/Pictures/Contest/contestbg")
end
def pbInputUpdate
Input.update
if Input.trigger?(Input::B) && @abortable && !@aborted
@aborted=true
@battle.pbAbort
end
end
def pbHearts
if @currentbasedamage>0
@hearts=(@currentbasedamage/20).floor+ 1
else @hearts=1
end
end
def pbDisplayAddingPositiveHearts
if @currentpoke==@pkmn1
if @currentpoke==@fastest
for i in 0..@pkmn1hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["firstpokehearts"]=IconSprite.new(408,51,@viewport)
@sprites["firstpokehearts"].setBitmap(heartfile)
i+=1
end
elsif @currentpoke==@second
for i in 0..@pkmn1hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["secondpokehearts"]=IconSprite.new(408,145,@viewport)
@sprites["scondepokehearts"].setBitmap(heartfile)
i+=1
end
elsif @currentpoke==@third
for i in 0..@pkmn1hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["thirdpokehearts"]=IconSprite.new(408,241,@viewport)
@sprites["thirdpokehearts"].setBitmap(heartfile)
i+=1
end
else
for i in 0..@pkmn1hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["fourthpokehearts"]=IconSprite.new(358,336,@viewport)
@sprites["fourthpokehearts"].setBitmap(heartfile)
i+=1
end
end
elsif @currentpoke==@pkmn2
if @currentpoke==@fastest
for i in 0..@pkmn2hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["firstpokehearts"]=IconSprite.new(408,51,@viewport)
@sprites["firstpokehearts"].setBitmap(heartfile)
i+=1
end
elsif @currentpoke==@second
for i in 0..@pkmn2hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["secondpokehearts"]=IconSprite.new(408,145,@viewport)
@sprites["secondpokehearts"].setBitmap(heartfile)
i+=1
end
elsif @currentpoke==@third
for i in 0..@pkmn2hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["thirdpokehearts"]=IconSprite.new(408,241,@viewport)
@sprites["thirdpokehearts"].setBitmap(heartfile)
i+=1
end
else
for i in 0..@pkmn2hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["fourthpokehearts"]=IconSprite.new(408,336,@viewport)
@sprites["fourthpokehearts"].setBitmap(heartfile)
i+=1
end
end
elsif @currentpoke==@pkmn3
if @currentpoke==@fastest
for i in 0..@pkmn3hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["firstpokehearts"]=IconSprite.new(408,51,@viewport)
@sprites["firstpokehearts"].setBitmap(heartfile)
i+=1
end
elsif @currentpoke==@second
for i in 0..@pkmn3hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["secondpokehearts"]=IconSprite.new(408,145,@viewport)
@sprites["secondpokehearts"].setBitmap(heartfile)
i+=1
end
elsif @currentpoke==@third
for i in 0..@pkmn3hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["thirdpokehearts"]=IconSprite.new(408,241,@viewport)
@sprites["thirdpokehearts"].setBitmap(heartfile)
i+=1
end
else
for i in 0..@pkmn3hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["fourthpokehearts"]=IconSprite.new(408,336,@viewport)
@sprites["fourthpokehearts"].setBitmap(heartfile)
i+=1
end
end
else
if @currentpoke==@fastest
for i in 0..@pkmn4hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["firstpokehearts"]=IconSprite.new(408,151,@viewport)
@sprites["firstpokehearts"].setBitmap(heartfile)
i+=1
end
elsif @currentpoke==@second
for i in 0..@pkmn4hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["secondpokehearts"]=IconSprite.new(408,145,@viewport)
@sprites["secondpokehearts"].setBitmap(heartfile)
i+=1
end
elsif @currentpoke==@third
for i in 0..@pkmn4hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["thirdpokehearts"]=IconSprite.new(408,241,@viewport)
@sprites["thirdpokehearts"].setBitmap(heartfile)
i+=1
end
else
for i in 0..@pkmn4hearts
heartfile=sprintf("Graphics/Pictures/Contest/heart%d",i)
Graphics.update
sleep(1.0/7.0)
@sprites["fourthpokehearts"]=IconSprite.new(408,336,@viewport)
@sprites["fourthpokehearts"].setBitmap(heartfile)
i+=1
end
end
end
end
def pbFindFastestOrderRanking #Finds the fastest pokemon in the contest
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,@pkmn1.species,13)
basespeed1=dexdata.fgetb
pokespeed1=basespeed1
pbDexDataOffset(dexdata,@pkmn2.species,13)
basespeed2=dexdata.fgetb
pokespeed2=basespeed2
pbDexDataOffset(dexdata,@pkmn3.species,13)
basespeed3=dexdata.fgetb
pokespeed3=basespeed3
pbDexDataOffset(dexdata,@pkmn4.species,13)
basespeed4=dexdata.fgetb
pokespeed4=basespeed4
dexdata.close
fastest = [basespeed1, basespeed2, basespeed3, basespeed4]
fastest=fastest.sort.reverse
@firstnumber=(fastest[0]== pokespeed1)? 1 : ((fastest[0]==pokespeed2) ? 2 : ((fastest[0]==pokespeed3)? 3: 4))
@fastest=(fastest[0]== pokespeed1)? @pkmn1 : ((fastest[0]==pokespeed2) ? @pkmn2 : ((fastest[0]==pokespeed3)? @pkmn3 : @pkmn4))
@secondnumber=(fastest[1]== pokespeed1)? 1 : ((fastest[1]==pokespeed2) ? 2 : ((fastest[1]==pokespeed3)? 3: 4))
@second=(fastest[1]== pokespeed1)? @pkmn1 : ((fastest[1]==pokespeed2) ? @pkmn2 : ((fastest[1]==pokespeed3)? @pkmn3 : @pkmn4))
@thirdnumber=(fastest[2]== pokespeed1)? 1 : ((fastest[2]==pokespeed2) ? 2 : ((fastest[2]==pokespeed3)? 3: 4))
@third=(fastest[2]== pokespeed1)? @pkmn1 : ((fastest[2]==pokespeed2) ? @pkmn2 : ((fastest[2]==pokespeed3)? @pkmn3 : @pkmn4))
@fourthnumber=(fastest[3]== pokespeed1)? 1 : ((fastest[3]==pokespeed2) ? 2 : ((fastest[3]==pokespeed3)? 3: 4))
@fourth=(fastest[3]== pokespeed1)? @pkmn1 : ((fastest[3]==pokespeed2) ? @pkmn2 : ((fastest[3]==pokespeed3)? @pkmn3 : @pkmn4))
end
def pbDisplayFastest #Displays the sprite of the fastest pokemon, as per FindFastest
@sprites["pokemon#{@firstnumber}"]=PokemonSprite.new(@viewport)
@sprites["pokemon#{@firstnumber}"].setPokemonBitmap(@fastest,true)
@sprites["pokemon#{@firstnumber}"].mirror=true
pokemony=Graphics.height/2-32
pokemonyadjust=pokemony-32
pbPositionPokemonSprite(@sprites["pokemon#{@firstnumber}"],178,112)
end
def pbDisplaySecondFastest
@sprites["pokemon#{@secondnumber}"]=PokemonSprite.new(@viewport)
@sprites["pokemon#{@secondnumber}"].setPokemonBitmap(@second,true)
@sprites["pokemon#{@secondnumber}"].mirror=true
pokemony=Graphics.height/2-32
pokemonyadjust=pokemony-32
pbPositionPokemonSprite(@sprites["pokemon#{@secondnumber}"],178,112)
end
def pbDisplayThirdFastest
@sprites["pokemon#{@thirdnumber}"]=PokemonSprite.new(@viewport)
@sprites["pokemon#{@thirdnumber}"].setPokemonBitmap(@third,true)
@sprites["pokemon#{@thirdnumber}"].mirror=true
pokemony=Graphics.height/2-32
pokemonyadjust=pokemony-32
pbPositionPokemonSprite(@sprites["pokemon#{@thirdnumber}"],178,112)
end
def pbDisplayFourthFastest
@sprites["pokemon#{@fourthnumber}"]=PokemonSprite.new(@viewport)
@sprites["pokemon#{@fourthnumber}"].setPokemonBitmap(@fourth,true)
@sprites["pokemon#{@fourthnumber}"].mirror=true
pokemony=Graphics.height/2-32
pokemonyadjust=pokemony-32
pbPositionPokemonSprite(@sprites["pokemon#{@fourthnumber}"],178,112)
end
def pbMoveButtons
pokemon=@pkmn1
pokename=pokemon.name
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites["moves"]=IconSprite.new(0,257,@viewport)
@sprites["moves"].setBitmap("Graphics/Pictures/Contest/moves")
base=Color.new(248,248,248)
shadow=Color.new(104,104,104)
@sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
overlay=@sprites["overlay"].bitmap
pbSetSmallFont(overlay)
textpos=[
[_INTL("MOVES"),12,225,0,base,shadow]]
imagepos=[]
yPos=258
xPos=2
count=0
for i in 0...pokemon.moves.length
if pokemon.moves[i].id>0
imagepos.push(["Graphics/Pictures/types",xPos,yPos+2,0,
pokemon.moves[i].type*28,64,28])
textpos.push([PBMoves.getName(pokemon.moves[i].id),xPos+68,yPos+2,0,
Color.new(64,64,64),Color.new(176,176,176)])
else
textpos.push(["-",316,yPos,0,Color.new(64,64,64),Color.new(176,176,176)])
end
count=count+1
yPos+=64 if count<=1
yPos=258 if count==2
yPos=322 if count==3
xPos=170 if count>1
end
pbDrawTextPositions(overlay,textpos)
pbDrawImagePositions(overlay,imagepos)
end
def pbEndScene
$game_map.autoplay
pbFadeOutAndHide(@sprites) { update }
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
def middleScene
loop do
Graphics.update
Input.update
self.update
if Input.trigger?(Input::C)
pbMoveButtons
end
if Input.trigger?(Input::B)
break
end
end
end
end
class PokeContest
def initialize(scene)
@scene=scene
end
def pbStartContest(chosen,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level)
@scene.pbStartContest(chosen,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level)
@scene.middleScene
@scene.pbEndScene
end
end
def pbContest(opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level)
scene=PokemonScreen_Scene.new
screen=PokemonScreen.new(scene,$Trainer.party)
screen.pbStartScene(_INTL("Choose a Pokémon?"),false)
chosen=screen.pbChoosePokemon
if chosen>=0
scene=PokeContestScene.new
screen=PokeContest.new(scene)
return screen.pbStartContest(chosen,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level)
else
return false
end
end
You will need these , put them in a new folder in Graphics/Pictures named Contest. Name the files Roundone.png, contestbg.png, and moves.png respectively.
As I said before, this is a work in progress. And I also know my coding is kinda messy, so I apologize if it is confusing. If this is the wrong section, please move it or delete it, but I did not see any other section that would be fit.
Last edited: