Advertiser Content

Custom Feature Question Custom move

Started by FiniteChaos September 30th, 2018 2:26 AM
  • 336 views
  • 1 replies
Seen October 17th, 2018
Posted September 30th, 2018
1 posts
1.2 Years
I'm just now diving into the technical side of my fan game.. I'm very green when it comes to programming, but decided to give it a shot on my own, digging through function codes for several hours (with little success) before seeking help. :frown:

I'm trying to make a move that functions similarly to Soak, but turns the opponent to the Normal type instead of the water type, and also deals damage before changing the type.
Getting it to change to the Normal type was easy enough, but while fiddling with the code I could only get the move to either deal damage or convert the opponent's type--never both. If someone would help explain to me how I could edit the code to make that happen (and maybe a quick explanation on how it works), I'd greatly appreciate it! :smile:

Allan5829

Seen 4 Weeks Ago
Posted May 31st, 2019
9 posts
1.6 Years
Go to your scripts and find the pokebattle_moveeffects and find soak or your new move. I'm going using soak as a reference. This is what I have for soak

class PokeBattle_Move_061 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)
      @battle.pbDisplay(_INTL("But it failed!"))  
      return -1
    end
return -1 if pbTypeImmunityByAbility(pbType(@type,attacker,opponent),attacker,opponent)
    if isConst?(attacker.ability,PBAbilities,:MULTITYPE) || 
      isConst?(attacker.ability,PBAbilities,:RKSSYSTEM)
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    if opponent.type1==getConst(PBTypes,:WATER) &&
       opponent.type2==getConst(PBTypes,:WATER) &&
       (opponent.effects[PBEffects::Type3]<0 ||
       opponent.effects[PBEffects::Type3]==getConst(PBTypes,:WATER))
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    opponent.type1=getConst(PBTypes,:WATER)
    opponent.type2=getConst(PBTypes,:WATER)
    opponent.effects[PBEffects::Type3]=-1
    typename=PBTypes.getName(getConst(PBTypes,:WATER))
    @battle.pbDisplay(_INTL("{1} transformed into the {2} type!",opponent.pbThis,typename))
    return 0
  end
end
When I saw your post the first move that came to mind was spectral thief because it has an effect then does damage. I found this line of code- return super(attacker,opponent,hitnum,alltargets,showanimation)
I then checked with some status effects for moves that do damage and have a chance to cause a status condition and saw this line- return super(attacker,opponent,hitnum,alltargets,showanimation) if pbIsDamaging?
That line of code should be the one that does damage so to have it go before the soak effect I would put it like this

class PokeBattle_Move_061 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    return super(attacker,opponent,hitnum,alltargets,showanimation) if pbIsDamaging?
    if opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)
      @battle.pbDisplay(_INTL("But it failed!"))  
      return -1
    end
I haven't tested this but I think this should work. Make sure the return super starts at the same row as the ifs it should be 2 tab clicks. Hope this helps!
Advertiser Content