• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] ALWAYS Disobey instead of only sometimes?

  • 30
    Posts
    12
    Years
    • Seen Apr 9, 2023
    Hey guys, quick question that I hope some one has a quick answer to.
    I'm looking to make it so when a pokemon would disobey he would ALWAYS disobey in some way, instead of only some times doing it.

    Using the concept where overleveling equals disobedience, but I'd like to wall it off entirely to prevent the use of rare candies from accelerating pokemon high enough that it was worth the risk.

    Looking at the script in _battler, I don't see anything super obvious about where this chance occurs, so I wonder if anyone could explain it to me? Frankly, even though I've been making my game for a long time now, I'm still pretty new to ruby and a lot of the way the scripts are structured confuse me.

    I'd ideally set it to 99 percent chance to disobey, but open to any option as long as it happens extremely often whenever it should.

    If anyone is able to explain how to do this to me, I would greatly appreciate it!
     
    Do you know where in the code the obedience check happens? I figure you ought to be able to find that pretty easy by searching for something like "obey" or "obedien" (for obedient and obedience), or search for the message that is displayed when a Pokémon disobeys. Try Ctrl+Shift+F to search in all the scripts if you can't find it in the ones you're looking at.

    Once you find the place where obedience happens I think it should be pretty easy to locate the chance part of the code, because it will almost certainly involve the word "random"..
     
    Oh ya, I know where it is, I just don't understand whats happening with it.

    There are two parts that LOOK relevant to me, but honestly I'm not sure.

    if @level>badgelevel
    a=((@level+badgelevel)*@battle.pbRandom(256)/255).floor
    disobedient|=a<badgelevel
    end

    and

    if self.status!=PBStatuses::SLEEP
    c=@level-b
    [email protected](256)
    if r<c && pbCanSleep?(false,true)
    pbSleepSelf()
    @battle.pbDisplay(_INTL("{1} took a nap!",pbThis))
    return false
    end
    r-=c
    if r<c
    @battle.pbDisplay(_INTL("{1} won't obey!",pbThis))
    @battle.pbDisplay(_INTL("It hurt itself from its confusion!"))
    pbConfusionDamage
    else
    [email protected](4)
    @battle.pbDisplay(_INTL("{1} ignored orders!",pbThis)) if message==0
    @battle.pbDisplay(_INTL("{1} turned away!",pbThis)) if message==1
    @battle.pbDisplay(_INTL("{1} is loafing around!",pbThis)) if message==2
    @battle.pbDisplay(_INTL("{1} pretended not to notice!",pbThis)) if message==3
    end

    Is this relevant?
    If so, what should I change there to make it near if not 100 percent?
    The number "256" appears twice, so I have to imagine it has something to do with that number, but the number seems so arbitrary I wouldn't understand which direction to change it to affect the percentage.

    I'm probably just overlooking something though. As I said, I'm still pretty new to ruby so if you guys can assist I'd appreciate it!
     
    Yeah, those look pretty relevant. Do you know how random works? pbRandom(10) generates a number from 0 to 9 (inclusive), which means that "pbRandom(256)/255" will generate a number between 0 and 1, so we're kinda saying "disobedient if ((@level+badgelevel) * (0..1)) < badgelevel". In your case I think you want something like:
    Code:
    if @level > badgelevel
      disobedient |= @battle.pbRandom(100) < 99
    end
    i.e. "generate a number between 0 and 99 (inclusive)" which is 100 numbers, and then exclude 99 of those numbers (everything except 99), this disobeys 99% of the time. You can of course change that 99 to a smaller or bigger number to change the percentage chance of disobeying.

    I think that second block of code is what to do when disobeying, and the random number looks like it chooses from those options.

    NOTE: If you want a random number between 0 and 1 I would recommend using a ".0" at the end of the second number to be safe, like this: "pbRandom(256)/255.0". If you divide by a non-decimal number you need to have already multiplied the pbRandom(...) number by something.
     
    Thanks so much for taking the time to help me!
    This is the first time I've dealt with how randomness is processed while making my game, so I am still a bit unsure, but you explanation has made things much clearer.

    The only follow up I would have is what should I change, exactly.

    I'm confused further by these letters that are seemingly being used for something I don't recognize.
    There are three potions that seem to be dealing with randomness.

    You ruled out the third as being something specific for AFTER you fail to obey, but there are still these two preceding it.

    Code:
    if @level>badgelevel
            a=((@level+badgelevel)*@battle.pbRandom(256)/255).floor
            disobedient|=a<badgelevel
          end
          if self.respond_to?("pbHyperModeObedience")
            disobedient|=!self.pbHyperModeObedience(move)
          end
          if disobedient
            @effects[PBEffects::Rage]=false
            if self.status==PBStatuses::SLEEP && 
               (move.function==0x11 || move.function==0xB4) # Snore, Sleep Talk
              @battle.pbDisplay(_INTL("{1} ignored orders while asleep!",pbThis)) 
              return false
            end
            b=((@level+badgelevel)*@battle.pbRandom(256)/255).floor

    So, which one should I edit and how, specifically?
    Also, what do those letter's refer to? a=, b=, etc.

    Anyway, thanks for your patience. I hope I don't sound too much like a noob!
     
    The only follow up I would have is what should I change, exactly.
    I'm afraid I can't tell you that, I'm just making some educated guesses based on the code you've posted so you'll have to try things and see what works.

    Does changing that first if in the way I suggested in my last post make the Pokémon disobey more often?

    As for what the variables are. Well I'm not sure that there's a good way to describe them but it appears that a is related to the probability of disobeying (hence why it sets "disobedient" to true), and that b and c are related to which action to take when disobeying.

    The exact relationship between b, c and which action isn't clear to me. IMO you'd be better off rewriting that part of the code (specifically the ifs) if you want control over what happens.
     
    Alright, so I'll try messing around with the first part then and see what happens.
     
    Back
    Top