• 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?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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.

Changing type based on enemy attack type

  • 2
    Posts
    10
    Years
    • Seen Aug 2, 2023
    Hello! I'm attempting to change the Multitype ability so that it acts the same as the anime/movies. I know for someone who has little to no experience with ruby that this is probably going to be a huge headache, but I was hoping someone here might be able to point me in the right direction. For reference I'm using Essentials v15.1.

    The general idea is that as long as the player has the corresponding plate, Arceus will change to a type that gives 1/2 or 0 damage, eg., if the attack is psychic and you own the dread plate Arceus will change it's type to dark before damage is calculated and then return to normal type after damage is calculated. The form (sprite) change seems very simple to do, but the tough part for me is figuring out how to change the type and then where to place the new lines so that it operates properly before and after the damage calculation.

    So far I'm looking at the script for the Color Change ability. It seems like this is the closest ability to what I'm trying to do. The biggest differences are that it needs to change to a different type based on the attack's type, not to the attack's type itself, and it needs to initiate before the damage is calculated, not after. I'm foreseeing lots of if/else statements for each possible type and presence of plates, but I think most of it should be extremely repetitive.

    # Color Change
    movetype=thismove.pbType(thismove.type,user,target)
    if target.hasWorkingAbility(:COLORCHANGE) && totaldamage>0 &&
    !PBTypes.isPseudoType?(type) && !target.pbHasType?(movetype)
    target.type1=movetype
    target.type2=movetype
    @battle.pbDisplay(_INTL("{1}'s {2} made it the {3} type!",target.pbThis,
    PBAbilities.getName(target.ability),PBTypes.getName(movetype)))
    PBDebug.log("[#{target.pbThis}'s Color Change made it #{PBTypes.getName(movetype)}-type]")
    end

    So far I'm imagining something like this for before the damage is calculated:

    # Multitype
    movetype=thismove.pbType(thismove.type,user,target)
    if target.hasWorkingAbility(:MULTITYPE) && !PBTypes.isPseudoType?(type)
    if movetype=PSYCHIC && $PokemonBag.pbQuantity(:DREADPLATE)>0
    target.type1=DARK
    target.type2=DARK
    self.form=17
    transformed=true
    elseif movetype=PSYCHIC && $PokemonBag.pbQuantity(:IRONPLATE)>0
    target.type1=STEEL
    target.type2=STEEL
    self.form=8
    transformed=true
    elseif movetype=PSYCHIC && $PokemonBag.pbQuantity(:MINDPLATE)>0
    target.type1=PSYCHIC
    target.type2=PSYCHIC
    self.form=14
    transformed=true
    elseif movetype=NORMAL && $PokemonBag.pbQuantity(:SPOOKYPLATE)>0
    target.type1=GHOST
    target.type2=GHOST
    self.form=7
    transformed=true
    # This pattern continues for all type and plate combinations
    @battle.pbDisplay(_INTL("{1}'s {2} made it the {3} type!",target.pbThis,
    PBAbilities.getName(target.ability),PBTypes.getName(movetype)))
    PBDebug.log("[#{target.pbThis}'s Multitype made it #{PBTypes.getName(movetype)}-type]")
    end

    As you can see I'm very lost. Any advice is greatly appreciated!
     
    Here's a quick update. I got the type change to work, but to my surprise I can't get the form change to do anything. I thought that would be the easy part.

    I placed these lines within the def pbSuccessCheck section (line 1981) of PokeBattle_Battler. It looks like the issue is all form changes in battle (like Cherrim) must begin with the def pbCheckForm but I can't do that when it's already within pbSuccessCheck. Anyone have any ideas?

    This is what I last tried:

    # Multitype
    if target.hasWorkingAbility(:MULTITYPE) && !PBTypes.isPseudoType?(type)
    if movetype=getConst(PBTypes,:NORMAL) || 0 && $PokemonBag.pbQuantity(:SPOOKYPLATE)>0
    target.type1=(getConst(PBTypes,:GHOST) || type1)
    target.type2=(getConst(PBTypes,:GHOST) || type2)
    if target.form!=5
    target.form=5
    transformed=true
    pbUpdate(true)
    end
    #...all other attack type and plate combinations
    @battle.pbDisplay(_INTL("{1}'s {2} made it the {3} type!",target.pbThis,
    PBAbilities.getName(target.ability),PBTypes.getName(movetype)))
    PBDebug.log("[#{target.pbThis}'s Multitype made it #{PBTypes.getName(movetype)}-type]")
    end
     
    The problem is that Arceus's form is locked to its item. In order to get the form to change, you'll have to remove these lines of code from Arceus's section in the Pokemon_MultipleForms script:

    Code:
    "getForm"=>proc{|pokemon|
       next 1  if isConst?(pokemon.item,PBItems,:FISTPLATE)
       next 2  if isConst?(pokemon.item,PBItems,:SKYPLATE)
       next 3  if isConst?(pokemon.item,PBItems,:TOXICPLATE)
       next 4  if isConst?(pokemon.item,PBItems,:EARTHPLATE)
       next 5  if isConst?(pokemon.item,PBItems,:STONEPLATE)
       next 6  if isConst?(pokemon.item,PBItems,:INSECTPLATE)
       next 7  if isConst?(pokemon.item,PBItems,:SPOOKYPLATE)
       next 8  if isConst?(pokemon.item,PBItems,:IRONPLATE)
       next 10 if isConst?(pokemon.item,PBItems,:FLAMEPLATE)
       next 11 if isConst?(pokemon.item,PBItems,:SPLASHPLATE)
       next 12 if isConst?(pokemon.item,PBItems,:MEADOWPLATE)
       next 13 if isConst?(pokemon.item,PBItems,:ZAPPLATE)
       next 14 if isConst?(pokemon.item,PBItems,:MINDPLATE)
       next 15 if isConst?(pokemon.item,PBItems,:ICICLEPLATE)
       next 16 if isConst?(pokemon.item,PBItems,:DRACOPLATE)
       next 17 if isConst?(pokemon.item,PBItems,:DREADPLATE)
       next 18 if isConst?(pokemon.item,PBItems,:PIXIEPLATE)
       next 0
    },

    In the base Essentials code, the ability Multitype doesn't actually do anything (except make Arceus immune to certain ability-changing effects). Everything is done merely by being an Arceus.
     
    Back
    Top