This thread pertains to v18 of Pokémon Essentials.

ValiantSoul

World Traveller
Member
Hey everyone, so I'm attempting to add an icon much like the Delta icon in Pokemon Insurgence. I thought I had done the script properly, but I get two errors persistently. First, I modified my scripts. I followed these instructions: Scripting Question: Giving icon to some pokemon forms?

I added this under each instance of #Draw Shiny icon
Ruby:
#Draw Rosen icon
alterX = ((@battler.index&1)==0) ? 10 : 201   # Player's/foe's
imagepos.push(["Graphics/Pictures/rosen",@spritebaseX+alterX,36,0,0,-1,-1]) if isRosen?

And I added this under IsMega?
Ruby:
def isRosen?
return true if isConst?(pokemon,PBSpecies,:FLAREON) && pokemon.form== 1
end

But I get this error when I attempt to open the Party Screen:
---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 18.1.dev]

Exception: NoMethodError

Message: undefined method index' for nil:NilClass

Backtrace:

FRLG Party Screen:403:in refresh'

FRLG Party Screen:229:in initialize'

FRLG Party Screen:463:in new'

FRLG Party Screen:463:in pbStartScene'

FRLG Party Screen:461:in each'

FRLG Party Screen:461:in pbStartScene'

FRLG Party Screen:1124:in pbPokemonScreen'

PScreen_PauseMenu:180:in pbStartPokemonMenu'

PScreen_PauseMenu:182:in pbStartPokemonMenu'

And this error when attempting to enter battle:
---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 18.1.dev]

Exception: NoMethodError

Message: undefined method isRosen?' for #<PokemonDataBox:0xc97d550>

Backtrace:

PokeBattle_SceneElements:234:in refresh'

PokeBattle_SceneElements:38:in initialize'

Scene_Initialize:79:in new'

Scene_Initialize:79:in _bugContest_pbInitSprites'

Scene_Initialize:77:in each_with_index'

Scene_Initialize:77:in each'

Scene_Initialize:77:in each_with_index'

Scene_Initialize:77:in _bugContest_pbInitSprites'

PokeBattle_BugContest:8:in pbInitSprites'

Scene_Initialize:21:in pbStartBattle

And I can't for the life of me figure out why. I'll attach the parts of the script I modfied in the spoiler below as well for clarity.

PokeBattle_SceneElements:
# Draw shiny icon
if @battler.shiny?
shinyX = (@battler.opposes?(0)) ? 206 : -6   # Foe's/player's
imagePos.push(["Graphics/Pictures/shiny",@spriteBaseX+shinyX,36])
end
#Draw Rosen icon
alterX = ((@battler.index&1)==0) ? 10 : 201   # Player's/foe's
imagepos.push(["Graphics/Pictures/rosen",@spritebaseX+alterX,36,0,0,-1,-1]) if isRosen?

PScreen_Party:
# Draw shiny icon
if @pokemon.shiny?
pbDrawImagePositions(@overlaysprite.bitmap,[[
"Graphics/Pictures/shiny",80,48,0,0,16,16]])
end
end
# Draw Rosen icon
alterX = ((@battler.index&1)==0) ? 10 : 201   # Player's/foe's
imagepos.push(["Graphics/Pictures/rosen",@spritebaseX+alterX,36,0,0,-1,-1]) if isRosen?
pbDrawTextPositions(@overlaysprite.bitmap,textpos)
# Draw level text
if !@pokemon.egg?
pbDrawImagePositions(@overlaysprite.bitmap,[[
"Graphics/Pictures/Party/overlay_lv",20,70,0,0,22,14]])
pbSetSmallFont(@overlaysprite.bitmap)
pbDrawTextPositions(@overlaysprite.bitmap,[
])
end

FRLG Party Screen:
# Draw shiny icon
if @pokemon.shiny?
pbDrawImagePositions(@overlaysprite.bitmap,[[
"Graphics/Pictures/shiny",80,48,0,0,16,16]])
end
end
# Draw Rosen icon
alterX = ((@battler.index&1)==0) ? 10 : 201   # Player's/foe's
imagepos.push(["Graphics/Pictures/rosen",@spritebaseX+alterX,36,0,0,-1,-1]) if isRosen?#

pbDrawTextPositions(@overlaysprite.bitmap,textpos)
# Draw level text
if !@pokemon.egg?
pbDrawImagePositions(@overlaysprite.bitmap,[[
"Graphics/Pictures/Party/overlay_lv",20,70,0,0,22,14]])
pbSetSmallFont(@overlaysprite.bitmap)
pbDrawTextPositions(@overlaysprite.bitmap,[
])
end

PokeBattle_Battler:
 #=============================================================================
# Mega Evolution, Primal Reversion, Shadow Pokémon, Rosen Formes
#=============================================================================
def hasMega?
return false if @effects[PBEffects::Transform]
return @pokemon && @pokemon.hasMegaForm?
end

def mega?; return @pokemon && @pokemon.mega?; end
alias isMega? mega?

def hasPrimal?
return false if @effects[PBEffects::Transform]
return @pokemon && @pokemon.hasPrimalForm?
end

def primal?; return @pokemon && @pokemon.primal?; end
alias isPrimal? primal?

def inHyperMode?; return false; end

def isRosen?
return true if isConst?(pokemon,PBSpecies,:FLAREON) && pokemon.form== 1
end

Any help would of course, be HUGELY appreciated!

NettoHikari

Cooltrainer
Member
You have defined the function "isRosen?" inside class PokeBattle_Battler - that means that if you're trying to use the function outside of that class, you have to call it ON a battler object (e.g. battler.isRosen?) as opposed to just calling it by itself. Your code in PokeBattle_SceneElements should look like this:
Ruby:
# Draw Rosen icon
alterX = ((@battler.index&1)==0) ? 10 : 201   # Player's/foe's
imagepos.push(["Graphics/Pictures/rosen",@spritebaseX+alterX,36,0,0,-1,-1]) if @battler.isRosen?

PScreen_Party and FRLG Party Screen work a little bit differently, in that there is no "@battler" variable - only "@pokemon". There is an issue, however - while @battler in the previous code was a PokeBattle_Battler object, @pokemon is a PokeBattle_Pokemon, which is a different class. Thus, you will have to define isRosen? AGAIN for class PokeBattle_Pokemon. You also won't be able to access "index" anymore, because the party screen is only meant to show the player's Pokemon. Your code in PScreen_Party should look like this:
Ruby:
# Draw Rosen icon
alterX = 10 # Player's
imagepos.push(["Graphics/Pictures/rosen",@spritebaseX+alterX,36,0,0,-1,-1]) if @pokemon.isRosen?

Your FRLG Party Screen code should look like this:
Ruby:
# Draw Rosen icon
alterX = 10 # Player's
imagepos.push(["Graphics/Pictures/rosen",@spritebaseX+alterX,36,0,0,-1,-1]) if @pokemon.isRosen?

Your "isRosen?" method inside PokeBattle_Battler has a slight mistake - there is no variable called "pokemon". Try replacing it in PokeBattle_Battler with this:
Ruby:
def isRosen?
return @pokemon && @pokemon.isRosen?
end

As I mentioned before, you also need to define "isRosen?" inside script section PokeBattle_Pokemon. You could write it, say, below "def shiny?", but it doesn't really matter so long as its somewhere within the bounds of the class:
Ruby:
def isRosen?
return isSpecies?(:FLAREON) && self.form == 1
end

ValiantSoul

World Traveller
Member
First, let me say a HUGE thanks for sorting out my mess of a code! Really appreciated bud :)

---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 18.1.dev]

Exception: NameError

Message: undefined local variable or method imagepos' for #<PokemonPartyPanel:0xc469000>

Backtrace:

FRLG Party Screen:405:in refresh'

FRLG Party Screen:229:in initialize'

FRLG Party Screen:462:in new'

FRLG Party Screen:462:in pbStartScene'

FRLG Party Screen:460:in each'

FRLG Party Screen:460:in pbStartScene'

FRLG Party Screen:1123:in pbPokemonScreen'

PScreen_PauseMenu:180:in pbStartPokemonMenu'

PScreen_PauseMenu:182:in pbStartPokemonMenu'

I got the above bug though, so I took another look and changed the FRLG Party Screen thing to be:

Ruby:
    if @pokemon.isRosen?
pbDrawImagePositions(@overlaysprite.bitmap,[[
"Graphics/Pictures/rosen",80,48,0,0,16,16]])

Which actually makes it appear, yay! It also stops the crashes. The only thing now is, though I know "80,48,0,0,16,16" likely corresponds to the position (as I copied the shiny code for this edit) I don't know which numbers so what - though I'm sure I can work that out.

I got the same error on the Battle Screen, so I altered it to:

Ruby:
alterX = ((@battler.index&1)==0) ? 10 : 201   # Player's/foe's
imagePos.push(["Graphics/Pictures/rosen",@spriteBaseX+alterX,36,0,0,-1,-1]) if @battler.isRosen?

And it works! The only thing now is how to reposition the icon; on the battle screen it's okay for the trainer's Pokemon, but I need to shift it for the opposing Pokemon - and of course, there's the party screen I mentioned before. Any further help appreciated - I'll post here if I work it out before anyone jumps in :)

NettoHikari

Cooltrainer
Member
Ah, good thing you fixed the remaining syntax errors! I believe the x and y coordinates are simply the first two numbers (80, 48) in the FRLG Party Screen. For the Battle Screen, it would be (@spriteBaseX+alterX, 36), so you can have code to alter those values depending on if the Pokemon's side.

ValiantSoul

World Traveller
Member
Mmm I was just messing around with them myself; almost got it working just the way I'd want! Last and only remaining query is on the battle screen, is there any way to position the icon on the player side and the enemy side separately? The current script used seems to link them haha

NettoHikari

Cooltrainer
Member
That should be handled by this code right?
Ruby:
alterX = ((@battler.index&1)==0) ? 10 : 201   # Player's/foe's
imagePos.push(["Graphics/Pictures/rosen",@spriteBaseX+alterX,36,0,0,-1,-1]) if @battler.isRosen?
I'm not sure what you mean by the icons being "linked" - are you saying that it's only showing one icon instead of two (one for each battler)? That's strange, I see nothing wrong with this code. I suppose you could try changing the first line to exactly what the shiny code does (but different x-coordinates):
Ruby:
alterX = (@battler.opposes?(0)) ? 201 : 10   # Foe's/player's`

ValiantSoul

World Traveller
Member
Oh I mean that the x & y coordinates for the opponents Rosen icon, and the players Rosen icon, are linked. You can't set one individual X/Y coordinate for the opponent icon and THEN the player icon which is what's throwing me.

The alterX line sets the starting position for the two icons, and then adjusting imagePos moves both icons instead of just 1. That's why I'm stuck amigo

NettoHikari

Cooltrainer
Member
Well, the way the code works right now is that the difference in x-coordinates between the opponent and player's rosen icons is exactly 201 - 10 = 191 pixels, and the y-coordinates are the exact same. When you change the imagePos, you're not changing how far apart the two icons are - which is why it looks like it's "linked". If you want to change the distance between the two icons, you need to edit the values in the alterX line, and possibly add an "alterY" line if you want to have two different y-coordinates as well.