[RMVXACE] COMBAT FORMULA CHECKING MULTIPLE STATUS AILMENTS.

Posts

Pages: 1
Erynden
Gamers don't die, they respawn.
1702
I'm looking to make a skill do damage based on the number of status ailments that has been inflicted upon an enemy. To an enemy without any status ailments, the skill will do it's normal damage. However, with an enemy inflicted with 1 status ailment, the damage will increase by 25%, and an enemy with (2) status ailments the damage will increase by 50%, and so on.
You can get the number of states applied to a battler via
battler.states.count

So if you want to use that in an attack algorithm you could do this for example:
(2 * a.atk - b.def) * (b.states.count * 0.25 + 1)

This will increase the base damage (the bit on the left, replace with your own damage algorithm) by 25% for each state the target has on it. This will use all states so there'll have to be a way to filter only status ailments and this doesn't count debuffs either (because I don't remember where they're stored and can't check right now)
Erynden
Gamers don't die, they respawn.
1702
Thanks, GreadRedSpirit. You've been a big help. ^.^

Um, one more thing. Is there a way to see how much damage a particular skill will do in the skill's description before using or would the person have to wait and see how much damage the skill will do once used? So that in the description, after a.atk-b.def has been calculated, you'll know how much damage the skill will do before using it.
I slapped this together:
class Window_Help < Window_Base
  
  attr_reader :user, :target
  
  def user=(value)
    @user = value
    recalculate_evaluation
  end
  
  def target=(value)
    @target = value
    recalculate_evaluation
  end
  
  def recalculate_evaluation
    # If we don't have a set item to evaluate or a user or the item isn't
    # a usable item (and therefore nothing to evaluate) then we're done
    return if @set_item.nil? or @user.nil? or not @set_item.is_a? RPG::UsableItem
    
    damage = 0
    
    # If the skill is for all of a type then we don't need the target
    if @set_item.for_all? or @set_item.for_random?
      targets = @set_item.for_opponent? ? $game_troop.alive_members : 
                                          $game_party.alive_members
      damage = (targets.inject(0.0) { |sum, target| sum + target.calculate_damage_value(@user, @set_item) } / targets.size).to_i
    elsif @set_item.for_one? and not @target.nil?
      damage = @target.calculate_damage_value(@user, @set_item).to_i
    end
    
    if damage != 0
      value_text = damage > 0 ? "Damage: " : "Heal: "
      set_text("#{@set_item.description} #{value_text}#{damage.abs}")
    end    
  end
  
  # When set_item is called remember the item passed so we can (potentially)
  # evaluate it. Once the item is set see if we can evaluate it
  alias :set_item_action_preview :set_item unless $@
  def set_item(item)
    @set_item = item
    set_item_action_preview(item)
    recalculate_evaluation
  end
  
end

class Scene_Battle < Scene_Base

  # On updates if the select enemy or actor windows are available pass the
  # target to the help window
  alias :update_basic_action_preview :update_basic unless $@
  def update_basic
    update_basic_action_preview 
    # See what selection window is open (if any) and pass the targets along
    @help_window.target = @enemy_window.enemy if @enemy_window.active and @help_window.target != @enemy_window.enemy 
    @help_window.target = @actor_window.actor if @actor_window.active and @help_window.target != @actor_window.actor 
  end
  
  alias :start_actor_command_selection_action_preview :start_actor_command_selection unless $@
  def start_actor_command_selection
    # Set the user reference for the help item
    @help_window.user = BattleManager.actor
    # Now call the original method
    start_actor_command_selection_action_preview
  end
end

class Window_BattleActor < Window_BattleStatus
  
  def actor
    $game_party.battle_members[@index]
  end
  
end

class Game_Battler < Game_BattlerBase

  def calculate_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    #value = apply_critical(value) if @result.critical
    #value = apply_variance(value, item.damage.variance)
    #value = apply_guard(value)
    return value
  end
  
end


It'll append the expected damage or healing of a skill to the end of its description. If its a single target it'll be the highlighted target. If it targets a group it gets the average. Demo project here, start a test fight against the slime and bat with Eric at level 15+ and his first three skills will show what the script does.
Pages: 1