• 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] Custom Move Effect

Webjamin

The Alluring Alumni of Alliterating Alliterations
3
Posts
6
Years
  • looking for help with scripting, as I suck at it tremendously. I'm trying to make a move effect that essentially performs an effect like the move "Wish", But instead of healing the Pokemon by half of it's HP, I want it to heal it fully and only heal at the end of the second turn. I have everything else put the way I need it, but I just need the script to paste into the PokeBattle_MoveEffects section of the script editor. Thanks in advance for any help provided!
     
    Last edited:
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    Copy the code for function code 0x0D7 (or whichever function code is defined for Wish) and make the following alteration:
    Code:
    ################################################################################
    # Battler in user's position is healed by its max HP, at the end of the
    # next round.
    ################################################################################
    class PokeBattle_Move_[COLOR=Red]nnn[/COLOR] < PokeBattle_Move [COLOR=Green]# nnn = function code for your move[/COLOR]
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        if attacker.effects[PBEffects::Wish]>0
          @battle.pbDisplay(_INTL("But it failed!"))
          return -1
        end
        pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
        attacker.effects[PBEffects::Wish]=2
        [COLOR=Red]attacker.effects[PBEffects::WishAmount]=attacker.totalhp[/COLOR]
        attacker.effects[PBEffects::WishMaker]=attacker.pokemonIndex
        return 0
      end
    end
    Using this will mean that the move Wish will fail if whoever's using your move uses Wish before HP is recovered and vice versa.
     

    Webjamin

    The Alluring Alumni of Alliterating Alliterations
    3
    Posts
    6
    Years
  • @James Davy
    What If I want the move to work JUST LIKE THAT, but I want it to display the message "\pokemonname\ recieved the blessing" instead of "\pokemonname\'s wish came true".

    another issue is that if I change the move's type to Fairy in the "moves.txt" text file in the PBS folder, the move acts like it works on the first turn, but then nothing happens on the next.

    I appreciate all of your help!
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    @James Davy
    What If I want the move to work JUST LIKE THAT, but I want it to display the message "\pokemonname\ recieved the blessing" instead of "\pokemonname\'s wish came true".
    That won't be hard. Create three new effects in the PBEffects script called Blessing, BlessingAmount and BlessingMaker. Next, initialise these effects in the PokeBattle_Battler script:
    Code:
      def pbInitPermanentEffects
        # These effects are always retained even if a Pokémon is replaced
        @effects[PBEffects::FutureSight]        = 0
        @effects[PBEffects::FutureSightMove]    = 0
        @effects[PBEffects::FutureSightUser]    = -1
        @effects[PBEffects::FutureSightUserPos] = -1
        @effects[PBEffects::HealingWish]        = false
        @effects[PBEffects::LunarDance]         = false
        @effects[PBEffects::Wish]               = 0
        @effects[PBEffects::WishAmount]         = 0
        @effects[PBEffects::WishMaker]          = -1
        [COLOR=Red]@effects[PBEffects::Blessing]           = 0
        @effects[PBEffects::BlessingAmount]     = 0
        @effects[PBEffects::BlessingMaker]      = -1[/COLOR]
      end
    In the PokeBattle_Battle script, copy the code for the healing effect of Wish and make the following alterations:
    Code:
        [COLOR=Green]# Blessing recovery[/COLOR]
        for i in priority
          next if i.isFainted?
         [COLOR=Red] if i.effects[PBEffects::Blessing]>0
            i.effects[PBEffects::Blessing]-=1
            if i.effects[PBEffects::Blessing]==0[/COLOR]
              [COLOR=Red]PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Blessing")[/COLOR]
              [COLOR=Red]hpgain=i.pbRecoverHP(i.effects[PBEffects::BlessingAmount],true)[/COLOR]
              if hpgain>0
                [COLOR=Red]blessingmaker=pbThisEx(i.index,i.effects[PBEffects::BlessingMaker])[/COLOR]
                [COLOR=Red]pbDisplay(_INTL("{1} received the blessing!",blessingmaker))[/COLOR]
              end
            end
          end
        end
    As for the move's effect, make the following alterations to the code I previously posted:
    Code:
    ################################################################################
    # Battler in user's position is healed by its max HP, at the end of the
    # next round.
    ################################################################################
    class PokeBattle_Move_[COLOR=Red]nnn[/COLOR] < PokeBattle_Move [COLOR=Green]# nnn = function code for your move[/COLOR]
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        [COLOR=Red]if attacker.effects[PBEffects::Blessing]>0[/COLOR]
          @battle.pbDisplay(_INTL("But it failed!"))
          return -1
        end
        pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
        [COLOR=Red]attacker.effects[PBEffects::Blessing]=2[/COLOR]
        [COLOR=Red]attacker.effects[PBEffects::BlessingAmount]=attacker.totalhp[/COLOR]
        [COLOR=Red]attacker.effects[PBEffects::BlessingMaker]=attacker.pokemonIndex[/COLOR]
        return 0
      end
    end
    This way, the effects of Wish and your move can both occur without failure.

    Whenever a new move function is created, the AI needs to be updated so it can know what to do with it. In PokeBattle_AI add this line to the script:
    Code:
    class PokeBattle_Battle
    ################################################################################
    # Get a score for each move being considered (trainer-owned Pokémon only).
    # Moves with higher scores are more likely to be chosen.
    ################################################################################
      def pbGetMoveScore(move,attacker,opponent,skill=100)
        skill=PBTrainerAI.minimumSkill if skill<PBTrainerAI.minimumSkill
        score=100
        opponent=attacker.pbOppositeOpposing if !opponent
        opponent=opponent.pbPartner if opponent && opponent.isFainted?
    ##### Alter score depending on the move's function code ########################
        case move.function
    
        [COLOR=Red]when 0xnnn[/COLOR] [COLOR=Green]# function code of your move[/COLOR]
          [COLOR=Red]score-=90 if attacker.effects[PBEffects::Blessing]>0[/COLOR]
     
    Last edited:

    Webjamin

    The Alluring Alumni of Alliterating Alliterations
    3
    Posts
    6
    Years
  • I realized what was wrong with the fairy-type problem. I was missing a line in the "types" text file. As far as @James Davy 's solution is concerned, I will try it out and see if it works. Thanks for all the help!
     
    Back
    Top