• 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] Having trouble adding a new move to essentials

286
Posts
5
Years
    • Seen yesterday
    So I'm trying to add a new move called Dragon Fleet into my game. I wanted it to work like Beat Up, dealing slightly more damage, but only add hits for the user and all Dragon-types in the user's party. In the PokeBattle_MoveEffects script, I copied the code for Beat Up and tried to change it so it would only register for Dragon-types, but it didn't work differently than Beat Up.
    ---------------------------------------------------------------------------
    Here is the code that I changed from Beat Up in order to implement Dragon Fleet:
    class PokeBattle_Move_179 < PokeBattle_Move
    def pbIsMultiHit
    return true
    end

    def pbNumHits(attacker)
    return @participants.length
    end

    def pbOnStartUse(attacker)
    [email protected](attacker.index)
    @participants=[]
    for i in 0...party.length
    if attacker.pokemonIndex==i
    @participants.push(i)
    elsif party && !party.egg? && party.hp>0 && party.status==0 && party.pbHasType?(:DRAGON)
    @participants.push(i)
    end
    end
    if @participants.length==0
    @battle.pbDisplay(_INTL("But it failed!"))
    return false
    end
    return true
    end

    def pbBaseDamage(basedmg,attacker,opponent)
    [email protected](attacker.index)
    atk=party[@participants[0]].baseStats[1]
    @participants[0]=nil; @participants.compact!
    return 5+(atk/7)
    end
    end

    Here is the original code for Beat Up:

    class PokeBattle_Move_0C1 < PokeBattle_Move
    def pbIsMultiHit
    return true
    end

    def pbNumHits(attacker)
    return @participants.length
    end

    def pbOnStartUse(attacker)
    [email protected](attacker.index)
    @participants=[]
    for i in 0...party.length
    if attacker.pokemonIndex==i
    @participants.push(i)
    elsif party && !party.egg? && party.hp>0 && party.status==0
    @participants.push(i)
    end
    end
    if @participants.length==0
    @battle.pbDisplay(_INTL("But it failed!"))
    return false
    end
    return true
    end

    def pbBaseDamage(basedmg,attacker,opponent)
    [email protected](attacker.index)
    atk=party[@participants[0]].baseStats[1]
    @participants[0]=nil; @participants.compact!
    return 5+(atk/10)
    end
    end
    ---------------------------------------------------------------------------
    I know that the method for ".hasType?" was called because there was no error, it just always returned true. When I tried to see what would happen if I put an "!" in front of it to negate the statement, the attack only hit once (based on just the user). Accessing a type works if it is the user or the opponent, but it doesn't seem to work properly here. Thanks if anyone is able to help me.
     

    Poq

    144
    Posts
    6
    Years
    • Seen Aug 28, 2021
    In your code example, you used .pbHasType? Try charging it to just .hasType? I'm pretty sure the method you're calling is the ove that checks if the player has a pokémon of that type on the team. And, based on your scenario that would always return true.

    (Note: there is a method "pbHasType?" Which checks an individual pokémon's type, but it is defined in the PokeBattle_Battler class, so it doesn't really work on the party - only on pokémon in battle).
     
    Back
    Top