The PokéCommunity Forums Fan Games Custom Game Development Pokémon Essentials
Type3 & PBTypes.maxValue

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.

Thread Tools
Old August 2nd, 2013 (5:41 PM). Edited August 3rd, 2013 by dexter1o6.
dexter1o6 dexter1o6 is offline
Join Date: Jul 2013
Age: 29
Gender: Male
Posts: 64
Hi all,

I've been trying to add a Type3. With this I mean that pokemon can have 3 types. For example: Gyarados becomes Water, Flying, Dragon, and Masquerain becomes Bug, Water, Flying.

This means adding 'Type3', adding a line to the compiler to read Pokemon.txt, altering the effectiveness check and changing 'modtype' (was 0, 1, 2, -4-, 8, 16; becomes 0, 1, 2, 4, -8-, 16, 32, 64).

So far most things seem to work. Except that I have some problems with the DARK type. When using a DARK-type move, the move is sometimes skipped: Krokorok used Bite! ... Zubat used Supersonic! (and supersonic is executed).

It is not always skipped. I know it fails on Zubat, Wingull, Surskit, Sewaddle, Weepinbell, Emolga, Pansage and Sandile. But it succeeds on for example Marill, Psyduck and Sandshrew.

Because the DARK-type is the last move of Types.txt, I tried switching the DARK-type with, in this case, the FIRE-type. After this, the FIRE-type failed. That makes me think it may be related to PBTypes.maxValue. But I have no clue of the exact location of the error.

I logged every change, but the log is not self-explanatory (without looking into the script). I included it anyway to give an idea of the changes I made:

Adding Type3

Changed def PBTypes.getCombinedEffectiveness (and others) in PBTypesExtra line 27 to:

class PBTypes
@@TypeData=nil # internal

def PBTypes.loadTypeData # internal
if !@@TypeData
return @@TypeData

def PBTypes.isPseudoType?(type)
return PBTypes.loadTypeData()[0].include?(type)

def PBTypes.isSpecialType?(type)
return PBTypes.loadTypeData()[1].include?(type)

def PBTypes.getEffectiveness(attackType,opponentType)
return PBTypes.loadTypeData()[2][attackType*(PBTypes.maxValue+1)+opponentType]

# changed this def to add type3
def PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2
if opponentType2==nil
return PBTypes.getEffectiveness(attackType,opponentType1)*2
if opponentType3==nil
mod2=(opponentType1==opponentType2) ? 2 : PBTypes.getEffectiveness(attackType,opponentType2)
return (mod1*mod2)
mod2=(opponentType1==opponentType2) ? 2 : PBTypes.getEffectiveness(attackType,opponentType2)
mod3=(opponentType1==opponentType3||opponentType2==opponentType3) ? 2 : PBTypes.getEffectiveness(attackType,opponentType3)
return (mod1*mod2*mod3)

# changed this def to add type3
def PBTypes.isNotVeryEffective?(attackType,opponentType1,opponentType2
return e>0 && e<8

# changed this def to add type3
def PBTypes.isNormalEffective?(attackType,opponentType1,opponentType2
return e==8

# changed this def to add type3
def PBTypes.isIneffective?(attackType,opponentType1,opponentType2
return e==0

# changed this def to add type3
def PBTypes.isSuperEffective?(attackType,opponentType1,opponentType2=nil,opponentType3
return e>8

In PokeBattle_Battler added the extra type around line 16, line 159, line 198, line 386, line 865, line 866 (typemod=8), line 942, line 1663 (typemod<=8), line 2145 (typemod>8), line 2147 (typemod<8), line 2205 (typemod=8), line 2211 (typemod=8), line 2219 (typemod=8).

Also in PokeBattle_Battler around line 457:

# changed this def to support type3
def pbHasType?(type)
if type.is_a?(Symbol) || type.is_a?(String)
ret=isConst?(self.type1,PBTypes,type.to_sym) ||
isConst?(self.type2,PBTypes,type.to_sym) ||
return ret
return (self.type1==type||self.type2==type||self.type3==type)

In PokeBattle_Move added the extra type around line 140 (return 8), line 141 (return 8), line 146, line 163 (typemod3), line 167 (typemod3), line 175 + 176, line 184 + 189, line 191 (edited), line 195 (edited), line 709, line 754 (edited), line 761 (edited), line 798 (edited), line 890 (edited), line 892 (edited), line 912 (edited), line 914 (edited), line 1017 (edited),

Also in PokeBattle_Move around line 157:

# added this if block
if isConst?(otype3,PBTypes,:FLYING) && opponent.effects[PBEffects::Roost]

In PokeBattle_Pokemon added the extra type around line 333 (edited), line 335 (edited)

Added a def Type3 around line 357 in PokeBattle_Pokemon.

In PokeBattle_Battle added the extra type around line 61 (edited), line 71 (edited), line 73 (edited), line 81 (edited), line 1805 (edited), line 1981.

In PokeBattle_AI added the extra type around line 1510 (edited), line 1532 (edited), line 1534 (edited), 1563, 1564, 1569, 1586, 1592 + 1593, 1598, 1600, 1932, 1935, 2044, 2102, 2105.

In PokeBattle_AI around line 1603 edited pbTypeModifier2 (and lines: 2044, 2053)

In PokeBattle_MoveEffects added the extra type around line 2420, 2466, 2504, 2529, 2549, 2552, 2559, 2758, 7187.

In PokemonPokedex around line 583 (and 639, 652, 683, 712, 714, 963) skipped the search on type function!

In PokemonSummary added the extra type around line 258, 262, 265-269, 656, 660, 663-667.

In PokemonStorage added the extra type around line 2335, 2339, 2342-2346.

In PokemonMultipleForms added the extra type around line 21, line 53 (added ‘def type3’), line 277 (added type3 as a block).

In PokemonShadowPokemon added the extra type around line 529.


In PokemonOrgBattleGenerator added the extra type around line 584, 586, 1055.

In PokemonOrgBattleGenerator edited ‘def pbDecideWinnerEffectiveness’ and ‘def getTypes’.

In PokemonEditor added the extra type around line 114, 148, 149, 150, 151.

In Compiler added the extra type around line 2251, 2280, 2288, 2289.

Thanks in advance for your help,


...and there's the next thing that apparently doesn't work yet. The FIRE-type seems to be super-effective at Hoothoot. So, that's no good And it means the problem probably doesn't lie with .maxValue...

To make it a bit more clear, all hints help. I may be able to fix the problem myself, but I need guidance through the script. Like, what scripts are likely to be part of the problem?

I now have a large list of pokemon on which the problem does (not) occur, and I've concluded that pokemon with two types are the problem. If the defending pokemon has one or three types, it works.

I think the problem might be in pbExtraTypes. Does anyone know what kind of parameter is returned by PBTypes.getEffectiveness? Is that a boolean or an integer? And why is the argument 'opponentType2' set to 'nil'? Just to get to know the pieces of code I'm working with...
Reply With Quote

Relevant Advertising!

Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 5:21 PM.