PDA

View Full Version : Pokémon Essentials Add-ons


Wichu
December 30th, 2007, 06:09 AM
As I promised, here are a couple of add-ons I made for poccil's Pokémon Essentials (http://pokecommunity.org/showthread.php?t=105731).
Poccil, if you want, add them to Essentials, but let me know when, and what ones, you add, so I can edit this to say which ones are included in the newest version.
Hopefully, these should come in useful in your games, but please give credit if used!

Day/Night Music Change - Included in Essentials
To use this, replace these lines in Game_Map* (lines 134-144): #--------------------------------------------------------------------------
# ● BGM / BGS 自動切り替え
#--------------------------------------------------------------------------
def autoplay
if @map.autoplay_bgm
$game_system.bgm_play(@map.bgm)
end
if @map.autoplay_bgs
$game_system.bgs_play(@map.bgs)
end
end
with these: #--------------------------------------------------------------------------
# ● BGM / BGS 自動切り替え
#--------------------------------------------------------------------------
def autoplay
if @map.autoplay_bgm # Checks whether the map has an autoplay BGM
if (Time.now.hour<6||Time.now.hour>=20) && # Checks if it's night time - the values are editable
FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "n") # Checks whether a BGM file with the filename [normal BGM]n exists
$game_system.bgm_play(@map.bgm.name+"n") # Plays it
else
$game_system.bgm_play(@map.bgm) # Plays the normal BGM
end
end
if @map.autoplay_bgs
$game_system.bgs_play(@map.bgs)
end
end
Basically, to have a map play different music at night, name the BGM file for night the same as the BGM for day, but with an "n" on the end. For example, if the day BGM was 018-Field01.mid, the night BGM would be named 018-Field01n.mid. It will play automatically at night if it finds it.

Map Details on Region Map - Included in Essentials
I was slightly annoyed that the map details didn't show up on the region map on the PokéGear, so I found out how from poccil. If you felt the same,I've attached a modified version of PokemonRegionMap. To use it, just replace PokemonRegionMap in the scripts with the text in my file. Here's a preview screenshot:
http://img187.imageshack.us/img187/2900/capture000iw0.png

Sunlight Weather Effect - Partly Included in Essentials
I also thought it would be good to have a harsh sunlight weather effect, like in Pokémon Ruby when you awaken Groudon. So I made one. To use, replace PokemonWeather with the attached file.
Then replace these lines (203 to 212) of PokemonField: if $game_screen.weather_type==1 || $game_screen.weather_type==2
battle.weather=PBWeather::RAINDANCE
battle.weatherduration=-1
elsif $game_screen.weather_type==3
battle.weather=PBWeather::HAIL
battle.weatherduration=-1
elsif $game_screen.weather_type==4
battle.weather=PBWeather::SANDSTORM
battle.weatherduration=-1
end
with: if $game_screen.weather_type==1 || $game_screen.weather_type==2
battle.weather=PBWeather::RAINDANCE
battle.weatherduration=-1
elsif $game_screen.weather_type==3
battle.weather=PBWeather::HAIL
battle.weatherduration=-1
elsif $game_screen.weather_type==4
battle.weather=PBWeather::SANDSTORM
battle.weatherduration=-1
elsif $game_screen.weather_type==5
battle.weather=PBWeather::SUNNYDAY
battle.weatherduration=-1
end
Finally, replace this line in Compiler (about line 481):
"Weather"=>[7,"eu",["","Rain","Storm","Snow","Sandstorm"]],
with: "Weather"=>[7,"eu",["","Rain","Storm","Snow","Sandstorm","Sun"]],
This will let you use the word "Sun" in the Metadata.txt file, under Weather, i.e. Weather=Sun,100.

Preview:
http://img444.imageshack.us/img444/4821/capture001ys3.png

EDIT:The next script doesn't work properly at the moment, and is therefore not included in Essentials!
Alternatively, if you want the weather to go back to normal during the night, replace lines 126-149 in the NEW script:
def update
case @type
when 0
@viewport.tone.set(0,0,0,0)
when 1
@viewport.tone.set(-@max*3/4,-@max*3/4,-@max*3/4,10)
when 2
@viewport.tone.set(-@max*6/4,-@max*6/4,-@max*6/4,20)
when 3
@viewport.tone.set(@max*3/4,@max*3/4,@max*3/4,0)
when 4
@viewport.tone.set(@max*2/4,0,-@max*2/4,0)
when 5
unless @sun==@max || @sun==-@max
@sun=@max
end
if @sunvalue>@max
@sun=-@sun
end
if @sunvalue<0
@sun=-@sun
end
@sunvalue=@sunvalue+@sun/32
@viewport.tone.set(@sunvalue+63,@sunvalue+63,@sunvalue/2+31,0)
end
with these lines:
case @type
when 0
@viewport.tone.set(0,0,0,0)
if @sun!=0 && (Time.now.hour>=6||Time.now.hour<20)
$game_screen.weather(5,8,0)
end
when 1
@viewport.tone.set(-@max*3/4,-@max*3/4,-@max*3/4,10)
when 2
@viewport.tone.set(-@max*6/4,-@max*6/4,-@max*6/4,20)
when 3
@viewport.tone.set(@max*3/4,@max*3/4,@max*3/4,0)
when 4
@viewport.tone.set(@max*2/4,0,-@max*2/4,0)
when 5
unless @sun==@max || @sun==-@max
@sun=@max
end
if Time.now.hour<6||Time.now.hour>=20
$game_screen.weather(0,0,0)
else
if @sunvalue>@max
@sun=-@sun
end
if @sunvalue<0
@sun=-@sun
end
@sunvalue=@sunvalue+@sun/20
@viewport.tone.set(@sunvalue+63,@sunvalue+63,@sunvalue/2+31,0)
end
end

Finally, you can make it alternate between Storm and Sunlight (like in Emerald) by adding these lines:
@timer+=1
if @timer==160
if @type==2 && rand(2)==0 && $game_switches[##]==true # where ## is the ID of a switch with which it is turned on
$game_screen.weather(5,8,0)
end
if @type==5 && rand(2)==0 && $game_switches[##]==true # same here
$game_screen.weather(2,8,0)
end
@timer=0
end
here: if rnd<4 && @type==2
@viewport.flash(Color.new(255,255,255,230),rnd*20)
end
@timer+=1
if @timer==160
if @type==2 && rand(2)==0 && $game_switches[##]==true
$game_screen.weather(5,8,0)
end
if @type==5 && rand(2)==0 && $game_switches[##]==true
$game_screen.weather(2,8,0)
end
@timer=0
end
@viewport.update
return if @type == 0 || @type == 5
nomwidth=480
nomheight=320
and put this line:
@timer=0
below where it says @sun=0 near the beginning.
Basically, replace the ## with the ID of a switch. While that switch is on, the weather has a 1/2 chance to change every 160 frames, but only if the weather is Storm or Sun.


Random Name Generator (by Poccil and Myself)
Basically, it generates a random name when called, and stores it in a variable. To use it, call getRandomName(W,X,Y,Z) as a script command, where W is either 0 for male, 1 for female, or 2 for poccil's original script (can be male or female), X is the ID of a variable to store the name in, and X is 0 for fully upper case, 1 for first letter upper case, and anything else for lower case. The parameter Z is optional - it describes the order of the letters in the name. Look at the script for the possible values. The name can be displayed by using Show Text, then typing \v*Y* where *Y* is the ID of the variable.

This is not designed for use in-game; rather, it is for creating random names for trainers, like on Colosseum and XD. However, it can be used in-game, for example with the Name Rater to change the name of a Pokémon. For this, you'd have to make conditional branches to check whether the Pokémon is male or female: use Conditional Branch: Script: $Trainer.party[$game_variables[1]].gender == *gender*, where *gender* is either 0,1 or 2 (0=male,1=female,2=genderless).
To make the name fully upper case, use Script: $game_variables[*ID of variable with name stored*].upcase

Replace the section beginning "def getRandomName" in PokemonUtilities with this script - it should be at about line 380 if you haven't got the Map View script, and about line 400 if you do.
def getRandomName(type,variable,upper,*formats)
if formats.length==0
case type
when 0
formats=%w( 1423 2341 23441 14235 1415 14141 142314 41423 4141 42341 )
when 1
formats=%w( 1416 14416 141416 23416 41416 423416 414236 14236 1414236 14146 )
when 2
formats=%w( cvcvvc cvvcvc cvcvcv vcvvc cvcv cvvc cvcv cvve bvc bve cve bvvc bvcv bvcvc)
end
end
format=formats[rand(formats.length)]
name=""
format.scan(/./) {|c|
case c
when "c"
set=%w( b c d f g h j k l l m n n p r r s s t t v w x z )
name+=set[rand(set.length)]
when "v"
set=%w( a a a e e e i i i o o o u u u y )
name+=set[rand(set.length)]
when "b" # two-letter "blends"
set=%w( br bl ch cl cr dr fr fl gh gl gr ph pl pr sc sh sk sl
sm sn sp st sw th tr tw wh wr )
name+=set[rand(set.length)]
when "e" # two-letter "blends" at end
set=%w( ck ch dd ff bb gg gh ld ll mm nd nt ng ph pt ps sk sh sp ss st rd
rn rp rm rk ns bs ft )
name+=set[rand(set.length)]
when "1"
set=%w( b c d f g h j k l m n p q r s t v w x z )
name+=set[rand(set.length)]
when "2"
set=%w( c f g k l p r s t )
name+=set[rand(set.length)]
when "3"
set=%w( h k l s t )
name+=set[rand(set.length)]
when "4"
set=%w( a e i o u )
name+=set[rand(set.length)]
when "5"
set=%w( e o u )
name+=set[rand(set.length)]
when "6"
set=%w( a e i )
name+=set[rand(set.length)]
end
}
case upper
when 0
name=name.upcase
when 1
name[0,1]=name[0,1].upcase
end
$game_variables[variable]=name
return name
end


Change Map View Type in an Event (by Poccil)

This script lets you change the map view type with a Script event command. It was made by Poccil, but isn't in Essentials yet. To use it, useScript: setMapView(X)
where X is the map view (0=normal, 1=custom, 2=perspective).

Again, copy this into PokemonUtilities.
def setMapView(mapView)
$PokemonSystem.tilemap=mapView
ObjectSpace.each_object(TilemapLoader){|o|
next if o.disposed?
case mapView
when 0 # Default
o.setClass($ResizeFactor==1.0 ? Tilemap : CustomTilemap)
when 1 # Custom
o.setClass(CustomTilemap)
when 2 # Perspective
o.setClass(Draw_Tilemap)
end
}
end



That's all the scripts for now. If you get a problem with one of these, tell me and I'll try to fix it. I'm also open to ideas for new add-ons - the night BGM one was a request.

BTW, think of these as teasers for the game I'm making :P.

Wichu
December 31st, 2007, 07:19 AM
Of course you can use them, but please give credit, not only to me, but mainly to poccil. The amount of work put into Essentials dwarfs my add-ons.

Anyway, Coming Soon:
A fix for the script that turns off sunlight at night, and:
A random name generator. Now you, too, can name all the [insert evil team here] Grunts (and others) with crazy names, like in Colosseum and XD, without much effort!

poccil
January 2nd, 2008, 07:07 AM
Thanks for the new additions. However, I already have a random name generator in PokemonUtilities -- it's called getRandomName . And also, setMapView on the script should be called pbSetMapView .

EDIT: After looking at the name script's instructions, I can better see its intent. Rather clever.

Wichu
January 2nd, 2008, 09:42 AM
Thanks for the new additions. However, I already have a random name generator in PokemonUtilities -- it's called getRandomName .
I wish I'd known that earlier -_-.
And also, setMapView on the script should be called pbSetMapView .
Oh whoops, I'll change it now. Thanks for pointing it out.

Devil_Silver
January 2nd, 2008, 10:23 AM
It works for me, except for the alternative map view.

poccil
January 2nd, 2008, 12:53 PM
I can suggest another add-on I created today. It allows the creation of "move tutor" events, like in Pokemon FireRed and LeafGreen. To use it, call the script function pbMoveTutorChoose(PBMoves::X, Y) where X is the name of a move, and Y is a list of species that can use that move. An example of its use follows. The move tutor here teaches the move Softboiled.


@>Conditional Branch: Script: pbMoveTutorChoose(PBMoves::SOFTBOILED,::SOFTBOILEDLIST)
@>Text: Move learned.
@>
: Else
@>Text: Move not learned.
@>
: Branch End


The script code in the conditional branch refers to the array called "::SOFTBOILEDLIST", which is a list of species that can learn Softboiled. It can appear in a new script section like this:


::SOFTBOILEDLIST=[
PBSpecies::CHANSEY,
PBSpecies::HAPPINY,
PBSpecies::BLISSEY,
PBSpecies::TOGEPI,
PBSpecies::TOGETIC,
PBSpecies::TOGEKISS
]


The script code for move tutors follows.


def pbMoveTutorAnnotations(move,movelist)
ret=[]
for i in 0...6
ret[i]=nil
next if i>=$Trainer.party.length
found=false
for j in 0...4
if !$Trainer.party[i].egg? && $Trainer.party[i].moves[j].id==move
ret[i]=_INTL("LEARNED")
found=true
end
end
next if found
species=$Trainer.party[i].species
if !$Trainer.party[i].egg? && movelist.any?{|j| j==species }
ret[i]=_INTL("ABLE")
else
ret[i]=_INTL("NOT ABLE")
end
end
return ret
end

def pbMoveTutorChoose(move,movelist)
ret=false
pbFadeOutIn(99999){
scene=PokemonScreen_Scene.new
movename=PBMoves.getName(move)
screen=PokemonScreen.new(scene,$Trainer.party)
annot=pbMoveTutorAnnotations(move,movelist)
screen.pbStartScene(_INTL("Teach which Pokemon?"),false,annot)
chosen=screen.pbChoosePokemon
if chosen>=0
pokemon=$Trainer.party[chosen]
if pokemon.egg?
Kernel.pbMessage(_INTL("{1} can't be taught to an Egg.",movename))
elsif !movelist.any?{|j| j==pokemon.species }
Kernel.pbMessage(_INTL("{1} is not compatible with {2}.",pokemon.name,movename))
Kernel.pbMessage(_INTL("{1} can't be learned.",movename))
else
if pbLearnMove(pokemon,move)
ret=true
end
end
end
screen.pbEndScene
}
return ret
end

Wichu
January 3rd, 2008, 04:48 AM
For the move tutors, I was thinking of having extra, unobtainable, TMs for each move tutor move.
Then I'd make the game check whether the TM was learnable, and teach the move to the Pokémon.
Your way is probably easier, though.

Devil_Silver: It might be because I accidentally wrote the wrong event command - use setMapView instead of pbSetMapView. I've corrected it now.
You probably won't be using setMapView(1) - use setMapView(2) to change to perspective, and setMapView(0) to change back.

EDIT: I've combined mine and poccil's name generators, and added the edited getRandomName to the first post.

EDIT 2: I fixed a bug in the random name generator - it was missing a line under "when v". The correct section is:
when "v"
set=%w( a a a e e e i i i o o o u u u y )
name+=set[rand(set.length)]

Henry987
February 14th, 2008, 08:19 AM
This is nice, Wichu when will your game release?
Is there any demo out yet?

Wichu
February 15th, 2008, 02:47 AM
The game is still a long way from a demo - I'm still working on adding DP moves, abilities and items. If you want, I could PM you when the demo comes out.

Henry987
February 15th, 2008, 03:13 AM
yea that would be nice if u pm me back when the demo is out

NeoStar
February 15th, 2008, 03:10 PM
they look good ill try them in my game after i format my hard drive. Keep up the good work.

nmorr
May 2nd, 2010, 07:16 AM
The map view changer come up with an error.

EDIT: nvm, I accidentally copied the "Script" part too.

EDIT2: nvm again, the error still comes up. Here it is.
Message: Script error within event 9, map 36 (Essential Town):
Exception: NoMethodError
Message: (eval):1:in `pbExecuteScript'undefined method `pbSetMapView' for #<Interpreter:0x4e53250>
***Full script:
pbSetMapView(2)

Interpreter:239:in `pbExecuteScript'
Interpreter:1583:in `eval'
Interpreter:239:in `pbExecuteScript'
Interpreter:1583:in `command_355'
Interpreter:492:in `execute_command'
Interpreter:191:in `update'
Interpreter:104:in `loop'
Interpreter:196:in `update'
Scene_Map:96:in `update'
Scene_Map:94:in `loop'

Interpreter:274:in `pbExecuteScript'
Interpreter:1583:in `command_355'
Interpreter:492:in `execute_command'
Interpreter:191:in `update'
Interpreter:104:in `loop'
Interpreter:196:in `update'
Scene_Map:96:in `update'
Scene_Map:94:in `loop'
Scene_Map:107:in `update'
Scene_Map:63:in `main'
Exception: RuntimeError
Message: Script error within event 9, map 36 (Essential Town):
Exception: NoMethodError
Message: (eval):1:in `pbExecuteScript'undefined method `pbSetMapView' for #<Interpreter:0x4d92cd8>
***Full script:
pbSetMapView(2)

Interpreter:239:in `pbExecuteScript'
Interpreter:1583:in `eval'
Interpreter:239:in `pbExecuteScript'
Interpreter:1583:in `command_355'
Interpreter:492:in `execute_command'
Interpreter:191:in `update'
Interpreter:104:in `loop'
Interpreter:196:in `update'
Scene_Map:96:in `update'
Scene_Map:94:in `loop'

Interpreter:274:in `pbExecuteScript'
Interpreter:1583:in `command_355'
Interpreter:492:in `execute_command'
Interpreter:191:in `update'
Interpreter:104:in `loop'
Interpreter:196:in `update'
Scene_Map:96:in `update'
Scene_Map:94:in `loop'
Scene_Map:107:in `update'
Scene_Map:63:in `main'

Alexandre
May 2nd, 2010, 08:43 AM
The map view changer come up with an error.

EDIT: nvm, I accidentally copied the "Script" part too.

EDIT2: nvm again, the error still comes up. Here it is.
Message: Script error within event 9, map 36 (Essential Town):
Exception: NoMethodError
Message: (eval):1:in `pbExecuteScript'undefined method `pbSetMapView' for #<Interpreter:0x4e53250>
***Full script:
pbSetMapView(2)

Interpreter:239:in `pbExecuteScript'
Interpreter:1583:in `eval'
Interpreter:239:in `pbExecuteScript'
Interpreter:1583:in `command_355'
Interpreter:492:in `execute_command'
Interpreter:191:in `update'
Interpreter:104:in `loop'
Interpreter:196:in `update'
Scene_Map:96:in `update'
Scene_Map:94:in `loop'

Interpreter:274:in `pbExecuteScript'
Interpreter:1583:in `command_355'
Interpreter:492:in `execute_command'
Interpreter:191:in `update'
Interpreter:104:in `loop'
Interpreter:196:in `update'
Scene_Map:96:in `update'
Scene_Map:94:in `loop'
Scene_Map:107:in `update'
Scene_Map:63:in `main'
Exception: RuntimeError
Message: Script error within event 9, map 36 (Essential Town):
Exception: NoMethodError
Message: (eval):1:in `pbExecuteScript'undefined method `pbSetMapView' for #<Interpreter:0x4d92cd8>
***Full script:
pbSetMapView(2)

Interpreter:239:in `pbExecuteScript'
Interpreter:1583:in `eval'
Interpreter:239:in `pbExecuteScript'
Interpreter:1583:in `command_355'
Interpreter:492:in `execute_command'
Interpreter:191:in `update'
Interpreter:104:in `loop'
Interpreter:196:in `update'
Scene_Map:96:in `update'
Scene_Map:94:in `loop'

Interpreter:274:in `pbExecuteScript'
Interpreter:1583:in `command_355'
Interpreter:492:in `execute_command'
Interpreter:191:in `update'
Interpreter:104:in `loop'
Interpreter:196:in `update'
Scene_Map:96:in `update'
Scene_Map:94:in `loop'
Scene_Map:107:in `update'
Scene_Map:63:in `main'

Woah. Massive necropost.

Maybe its not working because you are using a 2 year old script designed for a version of essentials from two years ago...

Wichu
May 2nd, 2010, 08:43 AM
That might be because the scripts are two and a half years old.

EDIT: Ninja'd :(

Neo-Dragon
May 2nd, 2010, 12:22 PM
Don't revive super old threads please.