Jump to content
Sign in to follow this  
dinhbat3

Yami's MP turned TP Shield & Yanfly's Popups

Recommended Posts

Hey Guys

 

I am using Yami's MP shield along with Yanfly's Ace Battle Engine,

Here is the script I am using

 

 

 

# Manashield
# This will make a manashield state which allow actor takes damage to mana
# instead of health points.
# Usage: use this notetag inside a state <manashield: X, Y%>
# X is damage absorb per mana point.
# Y is damage percentage which can be absorbed.
# Free for all using purposes.
# Credit: Archeia Nessiah for the allowance.

module REGEXP
  module TPSHIELD
    TPSHIELD = /<tpshield:[ ]*(\d+),[ ]*(\d+)[%“]?>/i
  end # TPSHIELD
end # REGEXP

#==============================================================================
# ¡ DataManager
#==============================================================================

module DataManager
    
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_tpshield load_database; end
  def self.load_database
    load_database_tpshield
    initialize_tpshield
  end
  
  #--------------------------------------------------------------------------
  # new method: initialize_manashield
  #--------------------------------------------------------------------------
  def self.initialize_tpshield
    groups = [$data_states]
    groups.each { |group|
      group.each { |obj|
        next if obj.nil?
        obj.initialize_tpshield
      }
    }
  end
  
end # DataManager

#==============================================================================
# ¡ RPG::BaseItem
#==============================================================================

class RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :tpshield

  #--------------------------------------------------------------------------
  # new method: initialize_manashield
  #--------------------------------------------------------------------------
  def initialize_tpshield
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when REGEXP::TPSHIELD::TPSHIELD
        @tpshield = [$1.to_i, [$2.to_i, 100].min]
      end
    }
  end
  
end # RPG::BaseItem

#==============================================================================
# ¡ Game_ActionResult
#==============================================================================

class Game_ActionResult
  
  #--------------------------------------------------------------------------
  # alias method: make_damage
  #--------------------------------------------------------------------------
  alias tpshield_make_damage make_damage
  def make_damage(value, item)
    tpshield_make_damage(value, item)
    #---
    if @battler.tpshield && @battler.tp > 0
      dpt = @battler.tpshield[0]
      percent = @battler.tpshield[1]
      shield = (@hp_damage * percent.to_f) / 100.0
      shield = shield / dpt.to_f
      shield = [shield, @battler.tp.to_f].min
      @hp_damage -= (shield * dpt.to_f).to_i
      @tp_damage += shield.to_i
    end
  end
  
end # Game_ActionResult

#==============================================================================
# ¡ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # new method: manashield
  #--------------------------------------------------------------------------
  
  def tpshield
    mns = nil
    states.each { |state|
      next unless state.tpshield
      mns = state.tpshield
      break
    }
    return mns ? mns : false
  end
  
end # Game_Battler 

 

 

 

The MP deduction popped up and the HP was null.Is there any way to remove the NULL only when the MP Shield state is active? Thanks in advance to anyone that may have some insight on this!

~ Dinhbat

Edited by dinhbat3

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×