• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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] Problems with changing types of moves

  • 2
    Posts
    163
    Days
    • Seen Nov 23, 2024
    Hello there,

    I'm currently scripting some new starters with a triple type. To make this more manageable and to make it easier for the player to utilize the STAB bonus I want to make an attack that can change its type to one of the three types of the user, which is most effective against the target.

    I've been trying to use pbBaseType and pbCalcType and took inspiration of the calculations for effectiveness and the script of judgment.
    The script I'm currently at is:
    Code:
    class Battle::Move::TypeDependsOnTargetType < Battle::Move
      def pbBaseType(user,target)
        userTypes = user.pbTypes(true)
        targetTypes = target.pbTypes(true)
        bestType = Normal
        effValue = 0.0
        userTypes.each do |type|
          effectiveness = pbCalcTypeModSingle(type, targetTypes, user, target)
          if effectiveness > effValue
            bestType = type
            effValue = effectiveness
          end
        end
        return bestType
      end
    end

    Some examples of how the attack should work:
    • If Charizard uses it against Heracross it would be flying-type
    • If Charizard uses it against Tinkaton it would be fire-type
    • If Charizard uses it against a Iron Thorns it would be fire-type due to Iron Thorns 4 times resistance against flying
     
    Programming-wise I don't see a problem either but problem here is that the pbBaseType thrown an exception as it only expects one (user) parameter but gets two (user, target).

    So is there a work around on how I can could use to input the target too, or another function that I could use instead of pbBaseType?
     
    Oh, now I see the problem. Your code has several mistakes, but it's not a big deal.
    basically u cant pass a target into pbBaseType or pbCalcType which is only accepted a user. tbh its difficult to achieve yr goal.
    if u really want to be, check pbCalcDamage(# Get the move's type), its still not an ideal way since there are too many things happen in pbUseMove.
    Ruby:
        # Get the move's type
        #===============================================
        if @id == :SURF # change to your condition
          userTypes = user.pbTypes(true)
          targetTypes = target.pbTypes(true)
          bestType = :NORMAL
          effValue = 0.0
          userTypes.each do |type|
            typeMod = pbCalcTypeMod(type, user, target)
            if typeMod > effValue
              bestType = type
              effValue = typeMod
            end
          end
          @calcType = bestType
          target.damageState.typeMod = effValue
        end
        #===============================================
        type = @calcType   # nil is treated as physical
     
    Back
    Top