• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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.

A couple move effect questions

  • 32
    Posts
    9
    Years
    • Seen Jun 15, 2015
    Okay, there are a couple move effects I wanted to get statted up but there's no uniform documentation on all the functions available in PE. That, and I'm not that great with Ruby syntax, so I was wondering if anyone could help me because I have quite a few quick questions and if anyone could help a little it would be much appreciated.

    Okay, this first one is simple, it needs debugging:
    Code:
    class PokeBattle_Move_162 < PokeBattle_Move
      def pbType(type,attacker,opponent)
        type=attacker.type1
        return type
      end
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        #type=attacker.type1
        #typename=PBTypes.getName(type)
        #@battle.pbDisplay(_INTL("The attack became {1} type!",typename))
        return super(attacker,opponent,hitnum,alltargets,showanimation) if @basedamage>0
      end
    
    end

    For some reason, the commented lines always call "Normal", but the type actually works correctly. What variable should I be calling?

    Also, I had a question about random functions. So I want to introduce a move that takes an unweighted, random type and uses that as it's type. How would I do this? Is there something that describes how to make a little table and randomly select from it? I tried, but I think I'm not loaning in right or something. I have two places I want to do this, one isn't in Move Effects.

    Also, are there any moves that can conditionally check something about the target, like it's type? I want to make something that lowers the Defenses of Steel types.
     
    1. When I test your code above with the lines in question uncommented I get the name of the user's first type—"bug" when I tested a vivillon, "ghost" when I tested a giratina, etc.. That sounds like it's doing what I think you're expecting it to do. Maybe the code that's actually in your PokeBattle_MoveEffects is different from what you've posted here, or maybe there's something else affecting it?

    2. I'm not up on the best ways to do this in RGSS or what might already be in Essentials' scripts, but I doubt you'd need a "table". You can get a random number using rand(number), where "number" is the maximum number you want minus 1 because it's going to count 0 as a result—so if you have 18 types you want rand(17), where a result of 0 gives the first type and a result of 17 gives the last. Then you just need a way to assign a number to each type you want. You could look at judgment/techno blast's code for one way to do it (you would change the "if holding this plate" part of each line to "if randomvariable == whatevernumber"), but a better method would probably be to put all the types you want into an array, then set the move's type equal to a random index in that array. So if your array of types is in the variable "typearray" and the first type you list in the array is normal, "type = typearray[rand(17)]" would be normal-type if the random number comes up 0, and maybe fairy if it comes up 17, and so on. That should be the rough idea; maybe there's some method already in Essentials that contains an array of types, I dunno.

    Does that help put you on the right track, at least as far as MoveEffects goes? I don't know what "other place" you want to put this sort of code in or what you need it to do, but the principle should be the same for that as well.

    3. There are moves that check type—look at soak (function code 061), for example, which needs to show a failure message if the target is already pure water-type. Check for steel-type in a similar manner to soak's check. Then you'd only apply your defense drop if the condition is true, and show "But it failed!" or whatever otherwise. You may also want to look at captivate, which has nothing to do with type but does only apply the special attack drop under a certain condition (the gender of the target).
     
    Last edited:
    Thanks, Delusions.

    Actually, I already thought of what you thought of for the whole "just call a random number", and I didn't do it for this reason: The avoidance of a "while" loop.
    There's one little teensy thing you forgot about, under your scenario, it would have a 1-19 (1 in 21, in my game) chance of calling "QMARKS" as the type.
    I knew WHAT I needed was an array, I just don't know HOW an array is defined. XD I don't know Ruby. I'll go looking in the spots you mentioned.

    By "Other place" I was referring to some other spot in the code that used an array, I'm very familiar with scripting, just not in Ruby, so I wanted a general idea of what that would look like. But you gave me a good place to look, so thanks.

    If you're curious, it's called the Mystery Safari. To double-check and ensure all non-legendary Pokemon are accessible, I'm going to create a zone that shifts it's encounters based on the day (cribbing the daily seed code from the lotto- sneaky little dude I am) so that you can encounter 10 different Pokemon based on the day you chose to access it. This makes sure everything gets in.
     
    Sorry to double post, but I did some playtesting.

    Okay, for some odd reason, Heart Power (My type copy move) works just fine all the sudden, but I still can't get my random type move working.
    Here's the effect description:
    Code:
    class PokeBattle_Move_163 < PokeBattle_Move
      def pbType(type,attacker,opponent)
        call=rand(20)
        case call
          when 0
            return getConst(PBTypes,:NORMAL)
          when 1
            return getConst(PBTypes,:FIGHTING)
          when 2
            return getConst(PBTypes,:FLYING)
          when 3
            return getConst(PBTypes,:POISON)
          when 4
            return getConst(PBTypes,:GROUND)
          when 5
            return getConst(PBTypes,:ROCK)
          when 6
            return getConst(PBTypes,:BUG)
          when 7
            return getConst(PBTypes,:GHOST)
          when 8
            return getConst(PBTypes,:STEEL)
          when 9
            return getConst(PBTypes,:FIRE)
          when 10
            return getConst(PBTypes,:WATER)
          when 11
            return getConst(PBTypes,:GRASS)
          when 12
            return getConst(PBTypes,:ELECTRIC)
          when 13
            return getConst(PBTypes,:PSYCHIC)
          when 14
            return getConst(PBTypes,:ICE)
          when 15
            return getConst(PBTypes,:DRAGON)
          when 16
            return getConst(PBTypes,:DARK)
          when 17
            return getConst(PBTypes,:FAIRY)
          when 18
            return getConst(PBTypes,:SOUND)
          when 19
            return getConst(PBTypes,:LIGHT)
        end
      end
    end

    I also have NO idea how to get it to call the type out, like with my other one, because there's no predetermined variable to go off of. Type even seems the wrong place for this, since I know it's called not once but a few times.
    EDIT: Scratch that, it works just fine, just sort of glitches out Protean a little bit. XD I was using that as my testing mechanism. Still, is there some creative way that's not on my mind to get it to call out the type? Like, get it to call type only once, because I know that check happens a few times.
     
    Last edited:
    You can set a number at battle start, and use with the pokémon personalID and turncount for setting a formula for your move type. Something like

    ((personalID+randomNumberDefinedAtBattleStart)^turncount)%20

    A note: A better way of doing your script with a very smaller code:

    Code:
      def pbType(type,attacker,opponent)
        call=rand(20)
        moveType = [
            :NORMAL,:FIGHTING,:FLYING,:POISON,:GROUND,:ROCK,:BUG,
            :GHOST,:STEEL,:FIRE,:WATER,:GRASS,:ELECTRIC,:PSYCHIC,
            :ICE,:DRAGON,:DARK,:FAIRY,:SOUND,:LIGHT
        ][call]
        return getConst(PBTypes,moveType)
      end
     
    Thanks FL. I'll probably go with a different random algo, but that's a fantastic idea.
     
    Okay, so I've run into a new problem with Dismantle, my Steel-hating Dark move.

    I tried it but it doesn't work as intended. I inspired the function code from Low Sweep, but something about trying to patch in the conditional makes it not function right.

    Code:
    class PokeBattle_Move_064 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        return super(attacker,opponent,hitnum,alltargets,showanimation) if @basedamage>0
        return -1 if !opponent.pbCanReduceStatStage?(PBStats::DEFENSE,true,false,attacker) || !(opponent.type1=getConst(PBTypes,:STEEL) || opponent.type2=getConst(PBTypes,:STEEL))
        pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
        ret=opponent.pbReduceStat(PBStats::DEFENSE,2,true,true,false,attacker)
        return ret ? 0 : -1
      end
    
      def pbAdditionalEffect(attacker,opponent)
        if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,false,false,attacker) &  (opponent.type1=getConst(PBTypes,:STEEL) || opponent.type2=getConst(PBTypes,:STEEL))
          opponent.pbReduceStat(PBStats::DEFENSE,2,true,true,false,attacker)
        end
        return true
      end
    end
     
    Back
    Top