• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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] Weakness/Resistance multiplier

  • 32
    Posts
    9
    Years
    • Seen May 6, 2020
    I imagine this is a really easy fix, but I can't seem to find it.
    Where can I change the weakness and resistance multipliers? I want to switch them to 3/2 and 2/3, respectively.

    Critical hits are also on my radar, but I think I did find this.
     
    Yeah. So these things are usually called "typemod" in the code, and weirdly are counted in ⅛s. i.e. typemod=1 is ⅛×, =2 is ¼×, =16 is 2×, etc.

    Lots of code looks at the actual number inside typemod, so you can't just start using different numbers—you're going to have to find the point in the code where it applies the typemod (e.g. something along the lines of "multiplier *= typemod/8") and convert into your new multipliers instead.
     
    Oof.
    But can I assume that tediously ctrl+f-ing my way around to find all of the instances of typemod and adjusting them by hand will get me there?

    Annoyingly, 2/3s can't be expressed easily as a multiple of eighths. If it accepts "typemod=16/3" though that will work
     
    Oof.
    But can I assume that tediously ctrl+f-ing my way around to find all of the instances of typemod and adjusting them by hand will get me there?

    Annoyingly, 2/3s can't be expressed easily as a multiple of eighths. If it accepts "typemod=16/3" though that will work

    My thinking is that instead of doing that, you try and find only the final uses of typemod that happen during computing the actual damage number and remap those from eighths space into your own space.

    i.e. going from something like:
    Code:
    damage = (damage * (typemod/8.0) * multiplier).floor

    To something like:
    Code:
    typemod_ = {2: ???, 4: 2.0/3.0, 8: 1.0, 16: 3.0/2.0, 32: ???}
    damage = (damage * typemod_[typemod] * multiplier).floor

    You'll need to decide what to use for cases 2 (i.e. ¼×) and 32 (i.e. 4×), but I don't think any of the other possible numbers ever come up. Also it's important to use "x.0" instead of just "x" because Ruby inherited some stupid rules about division where 2/3=0 and 3/2=1 (it truncates towards 0).
     
    Back
    Top