• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!

Changing Type Effectiveness with Item

SammyBoy

Rookie
Member
Joined
Dec 27, 2020
Posts
5
Hello! Working in Essentials 21.1 with the Hotfix. Light PBS and code edits to project, but nothing related to my question.

I'm currently working on giving a Pokémon the attack bonus and resistances of another type without the weaknesses, and have it in the form of a species-specific item. The attack bonuses are fairly straightforward because of many type boosting items already in the code, but I am currently trying to give Toxicroak the resistances (and immunity) of a Dark type when holding the "Croak Cloak."

Ruby:
Expand Collapse Copy
Battle::ItemEffects::DamageCalcFromTarget.add(:CROAKCLOAK,
  proc { |item, user, target, move, mults, power, type|
    if !target.isSpecies?(:TOXICROAK)
      next if move.calcType != :PSYCHIC
        next 0
      next if move.calcType != :DARK
        mults[:defense_multiplier] *= 1.5
      next if move.calcType != :GHOST
        mults[:defense_multiplier] *= 1.5
    end
  }
)

None of the above resistances are working, but the game loads up just fine.

Anyone have any ideas of what to do here? Is this an instance where I need to define a new function code in the ItemEffects (potentially by pulling from AbilityEffects), or am I making a dumb mistake?

Thanks in advance!
 

Penelope

Trainer
Member
Joined
Sep 15, 2023
Posts
90
yeah, you made a dumb mistake, but it doesnt matter.
if i understand correctly, you want a pokemon with the item has a "fake type"(only gains stab and resistance when calc dmg), yeah?
check pbCalcTypeMod.
 

SammyBoy

Rookie
Member
Joined
Dec 27, 2020
Posts
5
yeah, you made a dumb mistake, but it doesnt matter.
if i understand correctly, you want a pokemon with the item has a "fake type"(only gains stab and resistance when calc dmg), yeah?
check pbCalcTypeMod.
That's what I've been looking for thank you! Yes you understand correctly. I've placed it in with the rest of that code after the Grounded Flying-type susceptibility. I ran that through and it works correctly with resistances, but the immunity still seems to not be working as expected. Instead of being completely immune it just comes back with not very effective. Any idea what's up with that? Is it because Toxicroak is 4* weak to Psychic?

Ruby:
Expand Collapse Copy
 # Toxicroak's Croak Cloak (Dark STAB and Resistances/Immunity)
    if target.hasActiveItem?(:TOTEMTOXICROAK) && target.isSpecies?(:TOXICROAK)
        defType == :PSYCHIC
      ret = Effectiveness::INEFFECTIVE_MULTIPLIER
        defType == :GHOST
        defType == :DARK
      ret = Effectiveness::NOT_VERY_EFFECTIVE_MULTIPLIER
    end
 

SammyBoy

Rookie
Member
Joined
Dec 27, 2020
Posts
5
That's what I've been looking for thank you! Yes you understand correctly. I've placed it in with the rest of that code after the Grounded Flying-type susceptibility. I ran that through and it works correctly with resistances, but the immunity still seems to not be working as expected. Instead of being completely immune it just comes back with not very effective. Any idea what's up with that? Is it because Toxicroak is 4* weak to Psychic?

Ruby:
Expand Collapse Copy
 # Toxicroak's Croak Cloak (Dark STAB and Resistances/Immunity)
    if target.hasActiveItem?(:TOTEMTOXICROAK) && target.isSpecies?(:TOXICROAK)
        defType == :PSYCHIC
      ret = Effectiveness::INEFFECTIVE_MULTIPLIER
        defType == :GHOST
        defType == :DARK
      ret = Effectiveness::NOT_VERY_EFFECTIVE_MULTIPLIER
    end
Scratch that nonsense, I got it! Thanks again for the help, Penelope!

Code below for anyone curious:
Ruby:
Expand Collapse Copy
# Toxicroak's Croak Cloak (Dark STAB and Resistances/Immunity)
    if target.hasActiveItem?(:TOTEMTOXICROAK) && target.isSpecies?(:TOXICROAK)
      ret = Effectiveness::INEFFECTIVE_MULTIPLIER
      return ret if moveType == :PSYCHIC 
      ret = Effectiveness::NOT_VERY_EFFECTIVE_MULTIPLIER
      return ret if moveType == :DARK
      return ret if moveType == :GHOST
    end
 

Penelope

Trainer
Member
Joined
Sep 15, 2023
Posts
90
Ruby:
Expand Collapse Copy
    # STAB
    if type && (user.pbHasType?(type) || type == :DARK && user.hasActiveItem?(:TOTEMTOXICROAK))
      if user.hasActiveAbility?(:ADAPTABILITY)
        multipliers[:final_damage_multiplier] *= 2
      else
        multipliers[:final_damage_multiplier] *= 1.5
      end
    end

Code:
Expand Collapse Copy
  def pbCalcTypeMod(moveType, user, target)
    ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
    return ret if !moveType
    return ret if moveType == :GROUND && target.pbHasType?(:FLYING) && target.hasActiveItem?(:IRONBALL)
    # Get effectivenesses
    if moveType == :SHADOW
      if target.shadowPokemon?
        ret = Effectiveness::NOT_VERY_EFFECTIVE_MULTIPLIER
      else
        ret = Effectiveness::SUPER_EFFECTIVE_MULTIPLIER
      end
    else
      def_types = target.pbTypes(true).clone
      def_types << :DARK if target.hasActiveItem?(:TOTEMTOXICROAK)
      def_types.each do |type|
        ret *= pbCalcTypeModSingle(moveType, type, user, target)
      end
      ret *= 2 if target.effects[PBEffects::TarShot] && moveType == :FIRE
    end
    return ret
  end
 
 
 
    elsif Effectiveness.super_effective_type?(moveType, defType)
      # Delta Stream's weather
      if target.effectiveWeather == :StrongWinds && defType == :FLYING
        ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
      end
      if target.hasActiveItem?(:TOTEMTOXICROAK) && defType == :DARK
        ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
      end
    end

it should work, havent tested it.
 
Back
Top