• 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] Would like help creating an ability to apply damage and stuff later

20
Posts
11
Years
    • Seen Sep 11, 2022
    Hello everybody. I'd like to find out how I'd go about coding an ability that stores whats supposed to happen to a Pokemon (damage, stat changes, status effects) and applies it later (at the end of the turn or if possible at the end of the next turn).
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    Hello everybody. I'd like to find out how I'd go about coding an ability that stores whats supposed to happen to a Pokemon (damage, stat changes, status effects) and applies it later (at the end of the turn or if possible at the end of the next turn).

    Ok, this sounds very difficult, because I assume you're going to change a loooot of things.
    If you're new to coding, then it's probably not the first thing you should try to code.

    My idea is:
    1. Create a new PBEffect for a battler. This PBEffect will store a copy of your Pokémon.
    2. When initialising a battler, create a "Dummy" copy of the battler if it has the required ability. Otherwise, set this value to nil.
      There is a function that does that (pbInitDummyPokemon), check how Future Sight works. Or, if the Dummy is too "dummy", I think there is a function pbCreateBattler that can be adapted for your purposes.
    3. Look for the generic functions that apply effects / damage / stat changes to a Pokémon. The functions I'm thinking of are: pbReduceHP / pbRecoverHP / pbInflictStatus / pbRaiseStatStageBasic / pbLowerStatStageBasic. You will need to modify them so that the changes apply to the Dummy if it exists, or to the Pokémon if it doesn't exist.
      Nota Bene: I suggest you don't edit the functions themselves. Copy/paste them in a new script (all together) so that you can debug/fix them easily. Ruby allows you to rewrite code, so if you have two versions of a function, it will consider the last one. It's the step where I advise you to be careful.
    4. You wil have to make a specific function for the end of the turn, to transfer to the actual Pokémon any change that occurred to the Dummy.

    If you need more details, do ask.
     
    1,408
    Posts
    10
    Years
    • Seen today
    I've had this idea for an Ability before as a signature Ability for the Slowpoke family. They need a turn to realize that they got hit the previous turn lol. I never bothered to make it though because it's just one of those things that are really complicated implement. My advice would be to simplify the Ability's effects. For instance, just have the Ability trigger on direct damage taken. Keeping track of effects, statuses, indirect damage, etc. will be a huge undertaking.

    But if the Ability just triggers when the user is hit, then you can *probably* just copy something like Disguise to negate damage taken, but save the damage that WOULD have been taken to an effect, along with the current turncount as an array, like [PBEffects::DelayedDamage] = [damage, turncount]. And then at the end of each turn, there's a check to see if any Pokemon on the field have your Ability, as well as if [PBEffects::DelayedDamage] isn't empty, and if it isn't it matches the saved [turncount] with the current turncount. If the current turncount is higher (aka, a turn has passed), then it applies the saved [damage] to the Pokemon.

    I'm totally spit balling here though, it's probably not that easy.
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    I've had this idea for an Ability before as a signature Ability for the Slowpoke family. They need a turn to realize that they got hit the previous turn lol. I never bothered to make it though because it's just one of those things that are really complicated implement. My advice would be to simplify the Ability's effects. For instance, just have the Ability trigger on direct damage taken. Keeping track of effects, statuses, indirect damage, etc. will be a huge undertaking.

    But if the Ability just triggers when the user is hit, then you can *probably* just copy something like Disguise to negate damage taken, but save the damage that WOULD have been taken to an effect, along with the current turncount as an array, like [PBEffects::DelayedDamage] = [damage, turncount]. And then at the end of each turn, there's a check to see if any Pokemon on the field have your Ability, as well as if [PBEffects::DelayedDamage] isn't empty, and if it isn't it matches the saved [turncount] with the current turncount. If the current turncount is higher (aka, a turn has passed), then it applies the saved [damage] to the Pokemon.

    I'm totally spit balling here though, it's probably not that easy.

    Well actually this is a way simpler, more generic version of what I was suggesting ^^
    I don't think the OP wanted to delay each effect like Leech Seed or Aqua Ring (which would require a LOT of changes). Also I think your PBEffect idea is perfectly adaptable to status and stat stages.

    This simpler version requires the same script edits that I suggested though.
     
    20
    Posts
    11
    Years
    • Seen Sep 11, 2022
    Yeah I realized after StCooler's first post that I didn't have the energy nor desire to implement it the way I originally intended. So I'll probably look into taking the easier route eventually. Thanks for the feedback. I greatly appreciate it!!!
     
    Back
    Top