power up attack by number of targets poisoned

● ARCHIVED · READ-ONLY
Started by Countyoungblood 4 posts View original ↗
  1. So, as stated.. id like to create an attack formula that would check the party the enemy and the user for poison state and increase damage for each.

    Can the formula acess arrays? Itd be fine to tally a variable each time poison was inflicted but id need a way to lower the value when poison is removed or wears off.

    Id prefer to stay in the formula or make small edits to the script rather than adding plugins since the attack formula would only affect performance when the attack is called.
  2. Damage formulae are evaluated ruby code and as such you can add anything there. There might be a faster way of doing it but I don't have access to the code right now so I cannot check it. If I remember correctly you should be able to access enemies using
    Code:
    $game_troop.members
    and battling party members using
    Code:
    $game_party.members #only if used in battle. It is battle_members otherwise

    Then you have to increase a variable for each member having the poison state. I am assuming you didn't change the ID of poison state so I'll use state 2 in my example.

    Code:
    mult = 0; $game_troop.members.each do |e|;  mult += 1 if enemy.state?(2); end; $game_party.members.each do |actor|;  mult += 1 if actor.state?(2); end; your_damage_formula_goes_here * mult

    I am almost 100% sure that this won't fit in your damage formula so you can try this:

    Code:
    m = 0; bm = $game_troop.members + $game_party.members; bm.each do |i|; m+=1 if i.state?(2); end; your_famage_formula_goes_here * m

    I am still not sure if this fits or not but if it doesn't you can give this other one a try

    Code:
    m=0; SceneManager.scene.members.each do |i|; m+=1 if i.state?(2); end; your_famage_formula_goes_here * m

    Theoretically "SceneManager.scene" is Scene_Battle if called inside a battle and "member" is a method of Scene_Battle that returns "$game_party.members + $game_troop.members". I listed these possibilities in what I think being a "safety priority". Since I cannot test it right now you should give it a try.

    If it doesn't work you can just type this in your script:
    Code:
    class Game_Battler < Game_BattlerBase
      def state_scaling(val, id)
        mult = 0
        $game_troop.members.each do |enemy|
          mult += 1 if enemy.state?(id)
        end
        $game_party.members.each do |actor|
          mult += 1 if actor.state?(id)
        end
        return (val * mult)
      end
    end

    Once you do this you can call it in your damage formula using
    Code:
    a.state_scaling(your_damage_formula_goes_here, your_state_id)

    This has the advantage of being usable regardless of the state you are looking for. You can just change the value of "your_state_id" in your damage formula and it scales based on that state.

    EDIT: do not forget that when you write your formula instead of "your_damage_formula" in the code I provided you have to use parenthesis.
    Code:
    a.atk*4 - b.def*2 * mult # this just multiplies enemies defense!
    (a.atk*4 - b.def*2) * mult # this works as intended
  3. This is fantastic. the bit of script opens up a ton of possibilities. thank you for taking the time to put all of this together.

    issue resolved
  4. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.