• 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?".
  • 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] Trying to learn about field effect scripting

20
Posts
3
Years
    • Seen Jan 30, 2024
    So I've been practicing field effects using the Pokemon Reborn script as a base.

    My question is how to add a second type to the attack depending on the field. (E.j: Smog doing POISON and FIRE damage on Burning Field)

    I add this code in PokeBattle_Move, before the ´Move acurracy check´

    Code:
     def pbTypeModMessages(type,attacker,opponent)
        return 8 if type<0
        typemod=pbTypeModifier(type,attacker,opponent)
        if typemod==0
          @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
        else
          return 0 if pbTypeImmunityByAbility(type,attacker,opponent)
        end
        return typemod
        # Field Effect type changes go here
        
        typemod=FieldTypeChange(attacker,opponent,typemod,false)
        if typemod==0
          if @function==0x111
            return 1
          else            
            @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
            if (@function==0xC9 || @function==0xCA || @function==0xCB || @function==0xCC || @function==0xCD || @function==0xCE)
              @battle.scene.pbUnVanishSprite(attacker)
            end        
          end      
        end
        return typemod
      end
      
      #Add type to attack
      def FieldTypeChange(attacker,opponent,typemod,absorbtion=false)
        case $fieldeffectsbg
          when 4 # Burning Field
            if (id == PBMoves::SMACKDOWN || id == PBMoves::SMOG ||
             id == PBMoves::CLEARSMOG || id == PBMoves::THOUSANDARROWS)
              typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.25).ceil
              typemod=typemod3
              typeChange=PBTypes::FIRE
            end
          end
      end


    The script does not seem to run as it is not broken or applied.
    I ask if anyone knows where I should check to make it work, or at least know if what i am doing is fine.
     
    286
    Posts
    5
    Years
    • Seen May 15, 2024
    So I've been practicing field effects using the Pokemon Reborn script as a base.

    My question is how to add a second type to the attack depending on the field. (E.j: Smog doing POISON and FIRE damage on Burning Field)

    I add this code in PokeBattle_Move, before the ´Move acurracy check´

    Code:
     def pbTypeModMessages(type,attacker,opponent)
        return 8 if type<0
        typemod=pbTypeModifier(type,attacker,opponent)
        if typemod==0
          @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
        else
          return 0 if pbTypeImmunityByAbility(type,attacker,opponent)
        end
        return typemod
        # Field Effect type changes go here
        
        typemod=FieldTypeChange(attacker,opponent,typemod,false)
        if typemod==0
          if @function==0x111
            return 1
          else            
            @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
            if (@function==0xC9 || @function==0xCA || @function==0xCB || @function==0xCC || @function==0xCD || @function==0xCE)
              @battle.scene.pbUnVanishSprite(attacker)
            end        
          end      
        end
        return typemod
      end
      
      #Add type to attack
      def FieldTypeChange(attacker,opponent,typemod,absorbtion=false)
        case $fieldeffectsbg
          when 4 # Burning Field
            if (id == PBMoves::SMACKDOWN || id == PBMoves::SMOG ||
             id == PBMoves::CLEARSMOG || id == PBMoves::THOUSANDARROWS)
              typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.25).ceil
              typemod=typemod3
              typeChange=PBTypes::FIRE
            end
          end
      end


    The script does not seem to run as it is not broken or applied.
    I ask if anyone knows where I should check to make it work, or at least know if what i am doing is fine.

    Are you in v17? If you're in v18, I wouldn't recommend using Reborn as a base considering it's v15 and there's a big difference between those.

    However, if you're in v17 or v16 I may be able to help here (the help I can provide is for v17, but v16 shouldn't be too different). (Note that the code here has a bunch of custom stuff from my game in terms of the specific field interactions, but you can obviously ignore those parts.)

    Here's what my code looks like for "pbTypeModMessages":
    Spoiler:

    And "FieldTypeChange":
    Spoiler:

    I'm not sure what you mean by "I add this code in PokeBattle_Move, before the ´Move acurracy check´". I couldn't find any instance of "Move accuracy check" (or the misspelling you gave) in default Essentials or my code with field effects. If you're talking about where you're adding the definition for these methods, "pbTypeModMessages" already exists, and "FieldTypeChange" should go right after that (though I don't think the order of the definitions matter very much).

    Let me know if you need any more help or if any of this doesn't make sense.

    EDIT: Also note that pbUnVanishSprite (and pbVanishSprite) do not exist in Essentials v17 or later (not even sure if they originally existed in earlier versions), so make sure to get rid of those calls.
     
    Last edited:
    20
    Posts
    3
    Years
    • Seen Jan 30, 2024
    It worked!
    I am using a version of v17 patched with small additions of skills from generation VI

    Comparing it with your code, apart from removing pbUnVanishSprite, I think my mistake was also in defining typemod2 = nil and typemod3 = nil outside def pbTypeModMessages.
     
    Back
    Top