• 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] New Abilities and Script Explanation

8
Posts
2
Years
    • Seen Jan 30, 2023
    I'm trying to add three new abilities and potentially at the same time get some Ruby to reverse engineer ;) So if someone could explain the way they scripted these abilities, or maybe explain to me how to build them myself in an "explain it to me like I'm five" kind of way, either works. Also any resources or tips on learning the language would be appreciated, I've never coded before.
    • Crooked King (This Pokemon's contact moves have a chance to poison the target, regardless of their typing. If this Pokemon is attacking a poisoned target, it will move before them
    • Gallant Soldier (When the user enters the field, if there is an enemy Dark, Poison, or Dragon type on the field, this Pokemon's Attack and Speed are raised
    • Violent Rage (Klikkong ability) : If this Pokemon takes passive damage of any kind, its attack goes up 1 stage. This Pokemon is not affected by the secondary effects of statuses (ignores Burn Atk reduction and Paralysis Spd drop)
     
    1,682
    Posts
    8
    Years
    • Seen yesterday
    So v18 and v19 both use a new battle system, which includes BattleHandlers for abilities (and items) that all trigger at the same time overall in the turn phase or have similar triggering circumstances, like all effects when dealing damage, or on losing enough HP. Stuff like that.

    The easiest way to make new effects, like always, is looking at abilities (or even items sometimes) that do what you want already.

    Crooked King is a blend of Poison Touch's UserAbilityOnHit and a PriorityChangeAbility (there aren't any that do exactly what you want though, since that trigger doesn't know who it's attacking, just the attacker and the move they were going to use.) We can cheat a little on the latter part, by sneaking through the choices on the battle object through the battler object. battler.battle.choices[battler.index][3] is the target index selected, though In single battles, it's always -1, so the target depends on the move's target, and even in larger battle sizes, the target index might not be what you expect, so some experimentation would be needed.

    Gallant Soldier would use an AbilityOnSwitchIn, and it'd need to loop over battle.eachOtherSideBattler(battler.index), checking for the types of these opposing pokemon. While there isn't really an ability in this category that does something similar, Download, Forewarn, Anticipation, and Intimidate all use this method to loop over. You'd need a variable called like found = false and then inside check if the type is one of them, set found to true and break out. Then if found is true, do the ability splash, and raise the two stats. This is probably the easiest to make of the three, and a good one to start with.

    Violent Rage is a bit more complicated because it has effects that aren't covered by a BattleHandler. Almost all passive damage sources call takesIndirectDamage? to see if they can actually deal damage (the remainder are the weathers, sandstorm and hail, which have their own methods, just below the indirect damage definition). If you don't care about passive damage specifically, and can do any type of damage, there's AbilityOnHPDroppedBelowHalf, but that's when HP drops below half. For the other half, ignoring the effects, the ignore burn atk drop is like Guts and you'll find that in Move_Usage_Calculations (you can change the !user.hasActiveAbility?(:GUTS) to !user.hasActiveAbility?([:GUTS,:VIOLENTRAGE]) to copy the guts effect for this one bit). The ignore paralysis speed drop is like Quick Feet, and you'll find that in def pbSpeed in PokeBattle_Battler.

    Since you want to learn Ruby, I do have to suggest some Ruby tutorials.
    https://reliccastle.com/resources/209/
    https://reliccastle.com/resources/53/
    https://www.tutorialspoint.com/ruby/

    Quick tip, CTRL + SHIFT + F lets you search all script sections at the same time, which is great for finding the definitions of effects, or just to see how a method is used or the variables it expects.

    Best of luck, and feel free to ask for help!
     
    Back
    Top