• 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] Wondering how to add some abilities (and if it is possible)

5
Posts
7
Years
    • Seen May 30, 2023
    So I am wondering how I could get these abilities to work in essentials, and I am pretty lost. These ideally should only activate when a damaging attack is used and not when a status move is used.

    Flinching-Increases flinch chance for every attack by 30%

    Burning-Increases burn chance for every attack by 30%

    Confusing-Increases confuse chance for every attack by 30%

    (And variations on the burning ability for some other statuses but I figure those are pretty much the same kind of scripting as the Burning ability)
     
    188
    Posts
    9
    Years
    • Seen May 16, 2024
    What you seem to be asking is how to implement abilities that have a random chance of causing certain status conditions to occur when a damaging attack is used. For these sorts of abilities, add this code to the end of def pbOnDamageLost(damage,attacker,opponent) to get a 30% chance of these abilities triggering:
    Code:
        if attacker.hasWorkingAbility([COLOR=Green]:NAMEOFABILITY[COLOR=Black]) && @battle.pbRandom(10)<3
          [COLOR=Green]# check to see if opponent can get the status condition
          # apply the status condition if true
    [COLOR=Black]    end
    [/COLOR]
    [/COLOR][/COLOR][/COLOR]
     
    84
    Posts
    10
    Years
    • Seen Jun 11, 2022
    What you seem to be asking is how to implement abilities that have a random chance of causing certain status conditions to occur when a damaging attack is used. For these sorts of abilities, add this code to the end of def pbOnDamageLost(damage,attacker,opponent) to get a 30% chance of these abilities triggering:
    Code:
        if attacker.hasWorkingAbility([COLOR=Green]:NAMEOFABILITY[COLOR=Black]) && @battle.pbRandom(10)<3
          [COLOR=Green]# check to see if opponent can get the status condition
          # apply the status condition if true
    [COLOR=Black]    end
    [/COLOR]
    [/COLOR][/COLOR][/COLOR]

    My concern about this method (and correct me if I'm wrong): it looks like the way you've written it causes the game to initiate a kind of 'check' to see if the move successfully adds the secondary effect separate of any other check.

    For most moves this would be fine, but say I'm holding a king's rock (which adds 10% flinch chance), because of the way the code is structured the bonuses wouldn't have an additive effect. Instead of being 40% flinch chance (10% from KR + 30% from ability), it would be 37% flinch chance (Check 1 (ability): 3/10 chance of flinch = 30%, Check 2 (KR): 7/10 chance of not having flinched already TIMES 1/10 chance of flinch =7%, 30+7=37% flinch chance).

    I think it's best where possible to make this kind of thing as intuitive as possible, which would be 30+10=40. I know though that this is much easier said than done though - and I don't have the coding ability yet to write this myself.
     
    220
    Posts
    14
    Years
    • Seen Nov 29, 2021
    My concern about this method (and correct me if I'm wrong): it looks like the way you've written it causes the game to initiate a kind of 'check' to see if the move successfully adds the secondary effect separate of any other check.

    For most moves this would be fine, but say I'm holding a king's rock (which adds 10% flinch chance), because of the way the code is structured the bonuses wouldn't have an additive effect. Instead of being 40% flinch chance (10% from KR + 30% from ability), it would be 37% flinch chance (Check 1 (ability): 3/10 chance of flinch = 30%, Check 2 (KR): 7/10 chance of not having flinched already TIMES 1/10 chance of flinch =7%, 30+7=37% flinch chance).

    I think it's best where possible to make this kind of thing as intuitive as possible, which would be 30+10=40. I know though that this is much easier said than done though - and I don't have the coding ability yet to write this myself.
    While that is true, there is already a precedent re:Rings Kock and flinch moves.
     
    5
    Posts
    7
    Years
    • Seen May 30, 2023
    What you seem to be asking is how to implement abilities that have a random chance of causing certain status conditions to occur when a damaging attack is used. For these sorts of abilities, add this code to the end of def pbOnDamageLost(damage,attacker,opponent) to get a 30% chance of these abilities triggering:
    Code:
        if attacker.hasWorkingAbility([COLOR=Green]:NAMEOFABILITY[COLOR=Black]) && @battle.pbRandom(10)<3
          [COLOR=Green]# check to see if opponent can get the status condition
          # apply the status condition if true
    [COLOR=Black]    end
    [/COLOR]
    [/COLOR][/COLOR][/COLOR]
    Thank you for your advice, but I could not get it to work under the pbOnDamageLost(damage,attacker,opponent). I eventually figured out how to get to work under def pbEffectsOnDealingDamage(move,user,target,damage) in PokeBattle_Battler. I added this code under the if damage>0 section, underneath if !target.damagestate.substitute :
    Code:
            if user.hasWorkingAbility(:BURNING,true) && @battle.pbRandom(10)<3 &&
               target.pbCanBurn?(nil,false)
              PBDebug.log("[Ability triggered] #{user.pbThis}'s Burning")
              target.pbBurn(user,_INTL("{1}'s {2} burned {3}!",user.pbThis,
                 PBAbilities.getName(user.ability),target.pbThis(true)))
            end
    Again, thank you for your help, and if anyone feels like using this code, be my guest.
     
    Back
    Top