• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Custom move that doubles in power if a sound move was used the previous turn

I expect lastMoveUsed works the same, except that some moves are exempt from being set as the lastMoveUsedSketch.

Which bit do you think works out which move was last used?

Would it be something like

Code:
class PokeBattle_Move_D07 < PokeBattle_Move
  def pbBaseDamage(basedmg,attacker,opponent)
    return basedmg*2 if isConst?(PBMoveData.new(attacker.lastMoveUsed).isSoundBased?)
    return basedmg
  end
end

Doing that still returns an undefined method error for 'isSoundBased?'
 
Would it be something like

Code:
class PokeBattle_Move_D07 < PokeBattle_Move
  def pbBaseDamage(basedmg,attacker,opponent)
    return basedmg*2 if isConst?(PBMoveData.new(attacker.lastMoveUsed).isSoundBased?)
    return basedmg
  end
end

Doing that still returns an undefined method error for 'isSoundBased?'

Hm, maybe isSoundBased? is only on PBMove not PBMoveData?
 
Hm, maybe isSoundBased? is only on PBMove not PBMoveData?

I tried changing it to just PBMove, and it still returns an error.

I'm wondering if I should use part of mimic's code:

Code:
isConst?(PBMoveData.new(opponent.lastMoveUsed).type,PBTypes,:SHADOW)

But I'm not sure how I'd replace the type part with isSoundBased?
 
I tried changing it to just PBMove, and it still returns an error.

Well, yes. AFAIK you can't just create a PBMove from an ID. But you might be able to create a PBMove from a PBMoveData? (I think if you search the code for FromMoveData you might find something, but I don't remember exactly what it was called)

I'm wondering if I should use part of mimic's code:

Code:
isConst?(PBMoveData.new(opponent.lastMoveUsed).type,PBTypes,:SHADOW)

But I'm not sure how I'd replace the type part with isSoundBased?
Have a look at the definition of PBMoveData and of isSoundBased? and see how they work. I assume the latter checks for a particular flag on the former?
 
Have a look at the definition of PBMoveData and of isSoundBased? and see how they work. I assume the latter checks for a particular flag on the former?[/QUOTE]

isSoundBased? just returns
Code:
(@flags&0x400)!=0 # flag k: Is sound-based move

and I don't see a def for PBMoveData, but I do see

Code:
class PBMoveData
  attr_reader :function,:basedamage,:type,:accuracy
  attr_reader :totalpp,:addlEffect,:target,:priority
  attr_reader :flags
  attr_reader :category

So I'm not really sure where to go from here
 
So PBMoveData has flags. And isSoundBased? looks at @flags. Maybe (PBMoveData.new(opponent.lastMoveUsed).flags&0x400)!=0?
 
Well, yes. AFAIK you can't just create a PBMove from an ID. But you might be able to create a PBMove from a PBMoveData? (I think if you search the code for FromMoveData you might find something, but I don't remember exactly what it was called)


Have a look at the definition of PBMoveData and of isSoundBased? and see how they work. I assume the latter checks for a particular flag on the former?

Hello again, I still haven't been able to make any progress on the move, it still either returns an error or deals damage without the effect working.
 
So PBMoveData has flags. And isSoundBased? looks at @flags. Maybe (PBMoveData.new(opponent.lastMoveUsed).flags&0x400)!=0?

I think this worked!

Code:
################################################################################
# Doubles in power if a sound move was used the previous turn (feedback loop)
################################################################################
class PokeBattle_Move_D07 < PokeBattle_Move
  def pbBaseDamage(basedmg,attacker,opponent)
    return basedmg*2 if (PBMoveData.new(attacker.lastMoveUsed).flags&0x400)!=0
    return basedmg
  end
end
 
Back
Top