• 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] Weakness/Resistance multiplier

32
Posts
8
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.
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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.
     
    32
    Posts
    8
    Years
    • Seen May 6, 2020
    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
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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