v18 Obedience Check

This thread pertains to v18 of Pokémon Essentials.

ValiantSoul

World Traveller
Member
Joined
Sep 12, 2020
Posts
27
Age
26
Hey guys,

I was just wondering, is there a way to change the obedience chgeck script from this:
Ruby:
def pbObedienceCheck?(choice)
    return true if usingMultiTurnAttack?
    return true if choice[0]!=:UseMove
    return true if !@battle.internalBattle
    return true if !@battle.pbOwnedByPlayer?(@index)
    disobedient = false
    # Pokémon may be disobedient; calculate if it is
   [B] badgeLevel = 10*(@battle.pbPlayer.numbadges+1)[/B]
    badgeLevel = PBExperience.maxLevel if @battle.pbPlayer.numbadges>=8
    if @pokemon.foreign?(@battle.pbPlayer) && @level>badgeLevel
      a = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
      disobedient |= (a>=badgeLevel)
    end

to a script that links each badge to a specific level, rather than relying on that formula? Say Badge 1 = 20, Badge 2= 25, Badge 3=35? Basically, irregular levels. Cheers in advance!
 
Solution
You can replace the following line:
Ruby:
badgeLevel = 10*(@battle.pbPlayer.numbadges+1)
with the following:
Ruby:
badgeLevels = [XX, 20, 25, 35, XX, XX, XX, XX, XX]
badgeLevel = badgeLevels[@battle.pbPlayer.numbadges]
...

NettoHikari

Trainer
Member
Joined
Jan 4, 2019
Posts
99
You can replace the following line:
Ruby:
badgeLevel = 10*(@battle.pbPlayer.numbadges+1)
with the following:
Ruby:
badgeLevels = [XX, 20, 25, 35, XX, XX, XX, XX, XX]
badgeLevel = badgeLevels[@battle.pbPlayer.numbadges]
Where you fill in "XX" with your levels (and the 20, 25, 35 are just the examples you provided), and the first XX is for when the player has NO badges. Also keep in mind that this still checks the number of badges, e.g. if the player has Badge 1 and 3, then that is two badges and will correspond to level 25. Is this what you want, or do you want Badge 3 to always map to level 35, even if the player doesn't have Badges 1 and 2? If that's the case, you would need this code instead:
Ruby:
badgeLevels = [XX, 20, 25, 35, XX, XX, XX, XX, XX]
badgeIndex = 0
for i in 0...@battle.pbPlayer.badges.length
    badgeIndex = i + 1 if @battle.pbPlayer.badges[i]
end
badgeLevel = badgeLevels[badgeIndex]
So this code simply checks for the highest badge. Let me know which one you use!
 
Solution

ValiantSoul

World Traveller
Member
Joined
Sep 12, 2020
Posts
27
Age
26
You can replace the following line:
Ruby:
badgeLevel = 10*(@battle.pbPlayer.numbadges+1)
with the following:
Ruby:
badgeLevels = [XX, 20, 25, 35, XX, XX, XX, XX, XX]
badgeLevel = badgeLevels[@battle.pbPlayer.numbadges]
Where you fill in "XX" with your levels (and the 20, 25, 35 are just the examples you provided), and the first XX is for when the player has NO badges. Also keep in mind that this still checks the number of badges, e.g. if the player has Badge 1 and 3, then that is two badges and will correspond to level 25. Is this what you want, or do you want Badge 3 to always map to level 35, even if the player doesn't have Badges 1 and 2? If that's the case, you would need this code instead:
Ruby:
badgeLevels = [XX, 20, 25, 35, XX, XX, XX, XX, XX]
badgeIndex = 0
for i in 0...@battle.pbPlayer.badges.length
    badgeIndex = i + 1 if @battle.pbPlayer.badges[i]
end
badgeLevel = badgeLevels[badgeIndex]
So this code simply checks for the highest badge. Let me know which one you use!
Hey bud! The former is what I was after; huge thanks for taking up my request! The community here is awesomely helpful and I'm appreciating it massively (my game is too!)

I'll try it out when I get home,
Cheers!
 
Top