Skip to content

Required Code: actions_helper.rb

spiritlake edited this page Mar 7, 2022 · 2 revisions

Passing Spell Rolls Properly and Checking FS3 Attacks vs Shields

In plugins\fs3combat\helpers\actions_helper.rb

In def self.determine_attack_margin:

Replace

   def self.determine_attack_margin(combatant, target, mod = 0, called_shot = nil, mount_hit = false)

with

   def self.determine_attack_margin(combatant, target, mod = 0, called_shot = nil, mount_hit = false, result = nil)

Replace

   attack_roll = FS3Combat.roll_attack(combatant, target, mod - combatant.recoil)

with

   result ? attack_roll = result : attack_roll = FS3Combat.roll_attack(combatant, target, mod - combatant.recoil)

Replace

  combatant.log "Attack Margin: mod=#{mod} called=#{called_shot} " +
  " attack=#{attack_roll} defense=#{defense_roll} hit=#{hit} cover=#{stopped_by_cover} result=#{message}"

with

   stopped_by_shield = Magic.determine_margin_with_shield(target, combatant, weapon, attack_roll, defense_roll)
   if stopped_by_shield
     hit = stopped_by_shield[:hit]
     message = stopped_by_shield[:message]
   end

  combatant.log "Attack Margin: mod=#{mod} called=#{called_shot} " +
  " attack=#{attack_roll} defense=#{defense_roll} hit=#{hit} cover=#{stopped_by_cover} shield=#{stopped_by_shield } result=#{message}"

In def self.resolve_attack

Replace

total_damage_mod = hit_mod + melee_damage_mod + attack_luck_mod - defense_luck_mod - armor
target.log "Damage modifiers: attack_luck=#{attack_luck_mod} hit=#{hit_mod} melee=#{melee_damage_mod} defense_luck=#{defense_luck_mod} armor=#{armor} total=#{total_damage_mod}"

with

  damage_type = Magic.magic_damage_type(weapon)
  Magic.find_best_shield(target, damage_type) ? shield_mods = Magic.shield_mods(target, damage_type) : shield_mods = 0
  Magic.find_best_shield(target, damage_type) ? messages = [Magic.shield_failed_msgs(target, attack_name, weapon)] : messages = []

  total_damage_mod = hit_mod + melee_damage_mod + attack_luck_mod - defense_luck_mod - armor + shield_mods
  target.log "Damage modifiers: attack_luck=#{attack_luck_mod} hit=#{hit_mod} melee=#{melee_damage_mod} defense_luck=#{defense_luck_mod} armor=#{armor} shield_mods=#{shield_mods} total=#{total_damage_mod}"
Clone this wiki locally