More RMXP Script Tweaks

Discussion in 'RGSS Script Requests' started by TheRiotInside, Mar 7, 2014.

  1. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Hey all, it's me back again with some more little things that RMXP does that irk me. Two things this time!

    1. Skills used repeatedly in battle.

    What it does: It seems that when you use a skill in battle, it shows the skill name at the top of the screen just fine, but if that skill is cast again right afterwards in that turn (ie: two monsters casting the same spell and they both act one after the other) the second cast doesn't display the name at the top like the first. Rather, it just plays the animation and does its thing. This wouldn't be a huge deal, but I have taken a page out of Earthbound's book where enemies will frequently do non-important actions for their turns instead of attack like, "The Slime jiggles around" or, "The Bat files into a wall!" (the latter which damages the bat by a little bit). These are just me setting those phrases to the skill names and flashing the user a few times for an animation. So if two enemies happen to use the same sit-there-doing-nothing skill one after the other, the second one just sits there and flashes with no message.

    What I want it to do: Pretty simple (in theory!). I would like it to display the skill name all the time, no matter if it was just used during the previous action or not.

    2. State effects stacking.

    What it does: States affecting base stats stack on top of each other in ways I don't like. Example, you have 500 HP. You stick on a state that boosts HP to 110%. Now it's 550. On top of that state, another one is added that drops HP to 90%. With the current system, you will end up with 495 HP. The formula in my mind would go something like this:

    Base HP * [state1] * [state2]  -->  500 * 1.1 * 0.9 = 495

    What I want it to do: What I'm looking for is a method where all of the state effects are added together before multiplying them onto the stat, so a +10% and a -10% would give you +0%, or 500 HP. It would look something like this instead:

    Base HP * ( 100 + [state1] + [state2] ) / 100  -->  500 * ( 100 + 10 - 10 ) / 100 = 500

    For proper unit conversions, you would have to do some math with the rates, since a 10% boost is a 110 rate, and a 10% penality is a 90 rate. It'd be something like this:

    Base HP * ( 100 + ([s1] - 100) + ([s2] - 100) ) / 100

    I can do the math, but as far as implementing this into the scripts themselves, it's a bit over my head. Any help on both of these fronts would be greatly appreciated!

    PS: To save you guys entire seconds of searching, it looks like state bonuses are applied to the stats in Game_Battler 1 :)
     
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,932
    Likes Received:
    11,598
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    #1 doesn't really sound right. As far as I know, RMXP displays each skill name as it is used. Have you added or modified any scripts that affect the battles?
     
    #2
  3. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    Hello again! First off, I'll second what Shaz said about #1. I justed tested it on a fresh project and saw the skill displayed twice. But as for #2, this should do the trick.

    Code:
    # Changes to class Game_Battler as requested by TheRiotInside# States now stack such that an 110% increase and 90% decrease cancel out# Code by MobiusXVI# Licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported licenseclass Game_Battler  #--------------------------------------------------------------------------  # * Get Maximum HP  #--------------------------------------------------------------------------  def maxhp    n = [[base_maxhp + @maxhp_plus, 1].max, 999999].min	state_factor = 100    for i in @states      state_factor += ($data_states[i].maxhp_rate - 100.0)    end	n *= state_factor / 100.0    n = [[Integer(n), 1].max, 999999].min    return n  end  #--------------------------------------------------------------------------  # * Get Maximum SP  #--------------------------------------------------------------------------  def maxsp    n = [[base_maxsp + @maxsp_plus, 0].max, 9999].min	state_factor = 100    for i in @states      state_factor += ($data_states[i].maxsp_rate - 100.0)    end	n *= state_factor / 100.0    n = [[Integer(n), 0].max, 9999].min    return n  end  #--------------------------------------------------------------------------  # * Get Strength (STR)  #--------------------------------------------------------------------------  def str    n = [[base_str + @str_plus, 1].max, 999].min	state_factor = 100    for i in @states      state_factor += ($data_states[i].str_rate - 100.0)    end	n *= state_factor / 100.0    n = [[Integer(n), 1].max, 999].min    return n  end  #--------------------------------------------------------------------------  # * Get Dexterity (DEX)  #--------------------------------------------------------------------------  def dex    n = [[base_dex + @dex_plus, 1].max, 999].min	state_factor = 100    for i in @states      state_factor += ($data_states[i].dex_rate - 100.0)    end	n *= state_factor / 100.0    n = [[Integer(n), 1].max, 999].min    return n  end  #--------------------------------------------------------------------------  # * Get Agility (AGI)  #--------------------------------------------------------------------------  def agi    n = [[base_agi + @agi_plus, 1].max, 999].min	state_factor = 100    for i in @states      state_factor += ($data_states[i].agi_rate - 100.0)    end	n *= state_factor / 100.0    n = [[Integer(n), 1].max, 999].min    return n  end  #--------------------------------------------------------------------------  # * Get Intelligence (INT)  #--------------------------------------------------------------------------  def int    n = [[base_int + @int_plus, 1].max, 999].min	state_factor = 100    for i in @states      state_factor += ($data_states[i].int_rate - 100.0)    end	n *= state_factor / 100.0    n = [[Integer(n), 1].max, 999].min    return n  end  #--------------------------------------------------------------------------  # * Get Hit Rate  #--------------------------------------------------------------------------  def hit    n = 100	state_factor = 100    for i in @states      state_factor += ($data_states[i].hit_rate - 100.0)    end	n *= state_factor / 100.0    return Integer(n)  end  #--------------------------------------------------------------------------  # * Get Attack Power  #--------------------------------------------------------------------------  def atk    n = base_atk	state_factor = 100    for i in @states      state_factor += ($data_states[i].atk_rate - 100.0)    end	n *= state_factor / 100.0    return Integer(n)  end  #--------------------------------------------------------------------------  # * Get Physical Defense Power  #--------------------------------------------------------------------------  def pdef    n = base_pdef	state_factor = 100    for i in @states      state_factor += ($data_states[i].pdef_rate - 100.0)    end	n *= state_factor / 100.0    return Integer(n)  end  #--------------------------------------------------------------------------  # * Get Magic Defense Power  #--------------------------------------------------------------------------  def mdef    n = base_mdef	state_factor = 100    for i in @states      state_factor += ($data_states[i].mdef_rate - 100.0)    end	n *= state_factor / 100.0    return Integer(n)  endend 
     
    #3
  4. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Alright, so I made a blank project and started adding each script one at a time to find the culprit. Turns out it was an old HP/SP bar script I've had in there for years. As I am nowhere near the level of scripting to properly troubleshoot something like this, maybe you guys could have a peek and see what could be causing the issue?

    I'd like to get this sorted out while keeping the script if possible, but I'm sure it isn't the only one out there, so it wouldn't be the end of the world. Here's the script:

    # HP/SP gauge animation indication Ver1.03# 07/01/11# Distribution original support URL# http://members.jcom.home.ne.jp/cogwheel/ #==============================================================================# ** Game_Actor#------------------------------------------------------------------------------#  This class handles the actor. It's used within the Game_Actors class#  ($game_actors) and refers to the Game_Party class ($game_party).#============================================================================== class Game_Actor < Game_Battler  def now_exp    return @exp - @exp_list[@level]  end  def next_exp    return (@exp_list[@level+1] > 0 ?      @exp_list[@level+1] - @exp_list[@level] : 0)  endend #==============================================================================# ** Window_Base#------------------------------------------------------------------------------#  This class is for all in-game windows.#============================================================================== class Window_Base < Window  #--------------------------------------------------------------------------  # * Object Initialization  #     x      : window x-coordinate  #     y      : window y-coordinate  #     width  : window width  #     height : window height  #--------------------------------------------------------------------------  alias :initialize_gauge :initialize  def initialize(x, y, width, height)    initialize_gauge(x, y, width, height)    # Initialize HP and SP gauge values    @hp_gauge = {}    @sp_gauge = {}  end  #--------------------------------------------------------------------------  # * Dispose  #--------------------------------------------------------------------------  alias :dispose_gauge :dispose  def dispose    # ƒQ[ƒW‚Ì휠   gauge_delete    # ƒIƒŠƒWƒiƒ‹‚̉ð•úˆ—    dispose_gauge  end  #--------------------------------------------------------------------------  # * Gauge Delete  #--------------------------------------------------------------------------  def gauge_delete    # HP ƒQ[ƒW‚ÌÁ‹Ž    for gauge in @hp_gauge.values      gauge[0].bitmap.dispose      gauge[0].dispose    end    # SP ƒQ[ƒW‚ÌXV    for gauge in @sp_gauge.values      gauge[0].bitmap.dispose      gauge[0].dispose    end    @hp_gauge = {}    @sp_gauge = {}  end  #--------------------------------------------------------------------------  # * Frame Update  #--------------------------------------------------------------------------  alias :update_gauge :update  def update    update_gauge    # HP ƒQ[ƒW‚ÌXV    for gauge in @hp_gauge.values      gauge_refresh(gauge, 0)    end    # SP ƒQ[ƒW‚ÌXV    for gauge in @sp_gauge.values      gauge_refresh(gauge, 1)    end  end  #--------------------------------------------------------------------------  # * Draw HP Gauge  #--------------------------------------------------------------------------  # Modification of the original Draw HP process  alias :draw_actor_hp_hpsp :draw_actor_hp  def draw_actor_hp(actor, x, y, width = 144)    # ‰•`‰æ‚Ìꇠ   if @hp_gauge[actor] == nil      # ƒQ[ƒW‚      height = 10      # FÝ’èBcolor1:ŠO˜gCcolor2:’†˜g      # color3:‹óƒQ[ƒWƒ_[ƒNƒJƒ‰[Ccolor4:‹óƒQ[ƒWƒ‰ƒCƒgƒJƒ‰[      color1 = Color.new(0, 0, 0, 192)      color2 = Color.new(255, 255, 192, 192)      color3 = Color.new(64, 0, 0, 192)      color4 = Color.new(0, 0, 0, 192)      # ‹óƒQ[ƒW‚Ì•`‰æ      @hp_frame = gauge_rect(width, height, color1, color2, color3, color4)      sprite = Sprite.new      sprite.bitmap = Bitmap.new(width, height)      sprite.x = self.x + x + 16      sprite.y = self.y + y + 42 - height      sprite.z = self.z + 1      count = rand(400)      # •Ï”rate‚É Œ»Ý‚ÌHP/MHP‚ð‘ã“ü      if actor.maxhp != 0        rate = ((width - 4) * actor.hp.to_f / actor.maxhp).ceil      else        rate = width - 4      end      # ˆÊ’u“™î•ñ‚Ì‹L‰¯      @hp_gauge[actor] = [sprite, actor, rate, count, x, y - height]      # ƒQ[ƒW•`‰æ      gauge_refresh(@hp_gauge[actor], 0)      # ƒ^[ƒQƒbƒgƒEƒBƒ“ƒhƒE‚Ìê‡A‰Šúó‘Ô‚Í”ñ•\Ž¦      @hp_gauge[actor][0].visible = false if self.is_a?(Window_Target)    end    # •Ï”rate‚É Œ»Ý‚ÌHP/MHP‚ð‘ã“ü    if actor.maxhp != 0      rate = ((width - 4) * actor.hp.to_f / actor.maxhp).ceil    else      rate = width - 4    end    @hp_gauge[actor][2] = rate    # ƒIƒŠƒWƒiƒ‹‚ÌHP•`‰æˆ—‚ðŒÄ‚Ño‚µ    draw_actor_hp_hpsp(actor, x, y, width)  end  #--------------------------------------------------------------------------  # * Draw SP Gauge  #--------------------------------------------------------------------------  # Modification of the original Draw SP process  alias :draw_actor_sp_hpsp :draw_actor_sp  def draw_actor_sp(actor, x, y, width = 144)    # ‰•`‰æ‚Ìꇠ   if @sp_gauge[actor] == nil      # ƒQ[ƒW‚      height = 10      # FÝ’èBcolor1:ŠO˜gCcolor2:’†˜g      # color3:‹óƒQ[ƒWƒ_[ƒNƒJƒ‰[Ccolor4:‹óƒQ[ƒWƒ‰ƒCƒgƒJƒ‰[      color1 = Color.new(0, 0, 0, 192)      color2 = Color.new(255, 255, 192, 192)      color3 = Color.new(0, 64, 64, 192)      color4 = Color.new(0, 0, 0, 192)      # ‹óƒQ[ƒW‚Ì•`‰æ      @sp_frame = gauge_rect(width, height, color1, color2, color3, color4)      sprite = Sprite.new      sprite.bitmap = Bitmap.new(width, height)      sprite.x = self.x + x + 16      sprite.y = self.y + y + 42 - height      sprite.z = self.z + 1      count = rand(400)      # •Ï”rate‚É Œ»Ý‚ÌHP/MHP‚ð‘ã“ü      if actor.maxsp != 0        rate = ((width - 4) * actor.sp.to_f / actor.maxsp).ceil      else        rate = width - 4      end      # ˆÊ’u“™î•ñ‚Ì‹L‰¯      @sp_gauge[actor] = [sprite, actor, rate, count, x, y - height]      # ƒQ[ƒW•`‰æ      gauge_refresh(@sp_gauge[actor], 1)      # ƒ^[ƒQƒbƒgƒEƒBƒ“ƒhƒE‚Ìê‡A‰Šúó‘Ô‚Í”ñ•\Ž¦      @sp_gauge[actor][0].visible = false if self.is_a?(Window_Target)    end    # •Ï”rate‚É Œ»Ý‚ÌHP/MHP‚ð‘ã“ü    if actor.maxsp != 0      rate = ((width - 4) * actor.sp.to_f / actor.maxsp).ceil    else      rate = width - 4    end    @sp_gauge[actor][2] = rate    # ƒIƒŠƒWƒiƒ‹‚ÌHP•`‰æˆ—‚ðŒÄ‚Ño‚µ    draw_actor_sp_hpsp(actor, x, y, width)  end  #--------------------------------------------------------------------------  # * Drawing of gauge  #--------------------------------------------------------------------------  def gauge_rect(width, height, color1, color2, color3, color4)    bitmap = Bitmap.new(width, height)    # ˜g•`‰æ    bitmap.fill_rect(0, 0, width, height, color1)    bitmap.fill_rect(1, 1, width - 2, height - 2, color2)    # ‹óƒQ[ƒW‚Ì•`‰æ    bitmap.gradation_rect(2, 2, width-4, height-4, color3, color4, 1)    return bitmap  end  #--------------------------------------------------------------------------  # œ ŽÀƒQ[ƒW‚ÌXV  #--------------------------------------------------------------------------  def gauge_refresh(gauge, type)    # ƒ^ƒCƒv‚É‚æ‚蕪Šò    case type    when 0 # HPƒQ[ƒW‚Ìꇠ     graphic = RPG::Cache.system("Gauge_HP")      rate = gauge[2] * 100 / (gauge[0].bitmap.width - 4)      point = (rate < 50 ? 8 : 0) + (rate < 25 ? 8 : 0)      frame = @hp_frame    when 1 # SPƒQ[ƒW‚Ìꇠ     graphic = RPG::Cache.system("Gauge_SP")      rate = gauge[2] * 100 / (gauge[0].bitmap.width - 4)      point = (rate < 50 ? 8 : 0) + (rate < 25 ? 8 : 0)      frame = @sp_frame    end    # ƒJƒEƒ“ƒg‚ÌXV    gauge[3] = (gauge[3] - 2) % 400    # ‹óƒQ[ƒW‚Ì‚Ì•`‰æ    gauge[0].bitmap.fill_rect(0, 0, gauge[0].bitmap.width,      gauge[0].bitmap.height, Color.new(0, 0, 0, 0))    gauge[0].bitmap.blt(0, 0, frame, frame.rect)    # ƒQ[ƒW‚Ì’†g‚ð•`‰æ‰Â”\‚Èꇠ   if gauge[2] > 0      # ŽÀƒQ[ƒW‚Ì•`‰æ      gauge[0].bitmap.blt(2, 2, graphic,        Rect.new(gauge[3], point, gauge[2], gauge[0].bitmap.height - 4), 192)      gauge[0].bitmap.fill_rect(3, 3, gauge[2] - 2,        gauge[0].bitmap.height - 6,Color.new(0, 0, 0, 0))      gauge[0].bitmap.blt(3, 3, graphic,        Rect.new(gauge[3]+1,point+1,gauge[2]-2,gauge[0].bitmap.height- 6), 128)    end    # ƒQ[ƒWÀ•W‚ÌXV    gauge[0].x = [self.x - self.ox + gauge[4] + 16, self.x + 16].max    gauge[0].y = [self.y - self.oy + gauge[5] + 42, self.y + 16].max    gauge[0].src_rect = Rect.new([self.ox - gauge[4], 0].max,      [self.oy - gauge[5] - 26, 0].max,      [self.ox + self.width - gauge[4] - 32, gauge[0].bitmap.width].min,      [self.oy + self.height - gauge[5] - 32, gauge[0].bitmap.height].min)    gauge[0].visible = self.visible  end  #--------------------------------------------------------------------------  # Set X-position for gauge  #--------------------------------------------------------------------------  def x=(new_x)    super(new_x)    if @hp_gauge != nil      # HP ƒQ[ƒW‚ÌXV      for gauge in @hp_gauge.values + @sp_gauge.values        gauge[0].x = self.x + gauge[4] + 16      end    end  end  #--------------------------------------------------------------------------  # Set Y-position for gauge  #--------------------------------------------------------------------------  def y=(new_y)    super(new_y)    if @hp_gauge != nil      # HP ƒQ[ƒW‚ÌXV      for gauge in @hp_gauge.values + @sp_gauge.values        gauge[0].y = self.y + gauge[5] + 42      end    end  end  #--------------------------------------------------------------------------  # Set Z-depth for gauge  #--------------------------------------------------------------------------  def z=(new_z)    super(new_z)    if @hp_gauge != nil      # HP ƒQ[ƒW‚ÌXV      for gauge in @hp_gauge.values + @sp_gauge.values        gauge[0].z = self.z + 1      end    end  endend  #==============================================================================# ** Window_Help#------------------------------------------------------------------------------#  This window shows skill and item explanations along with actor status.#============================================================================== class Window_Help < Window_Base  #--------------------------------------------------------------------------  # * Set Text  #  text  : text string displayed in window  #  align : alignment (0..flush left, 1..center, 2..flush right)  #--------------------------------------------------------------------------  alias :gauge_set_text :set_text  def set_text(text, align = 0)    # ƒeƒLƒXƒg‚ƃAƒ‰ƒCƒ“ƒƒ“ƒg‚Ì*‚È‚*‚Æ‚àˆê•û‚ª‘O‰ñ‚ƈá‚Á‚Ä‚¢‚éꇠ   if text != @text or align != @align      # ƒQ[ƒW‚Ì휠     gauge_delete      # ƒIƒŠƒWƒiƒ‹‚̈—      gauge_set_text(text, align)    end  end  #--------------------------------------------------------------------------  # * Set Actor  #     actor : status displaying actor  #--------------------------------------------------------------------------  alias :gauge_set_actor :set_actor  def set_actor(actor)    if actor != @actor      # ƒQ[ƒW‚Ì휠     gauge_delete      # ƒIƒŠƒWƒiƒ‹‚̈—      gauge_set_actor(actor)    end  end  #--------------------------------------------------------------------------  # * Set Enemy  #     enemy : name and status displaying enemy  #--------------------------------------------------------------------------  alias :gauge_set_enemy :set_enemy  def set_enemy(enemy)    # ƒQ[ƒW‚Ì휠   gauge_delete    # ƒIƒŠƒWƒiƒ‹‚̈—    gauge_set_enemy(enemy)  endend  #==============================================================================# ** Spriteset_Battle#------------------------------------------------------------------------------#  This class brings together battle screen sprites. It's used within#  the Scene_Battle class.#============================================================================== class Spriteset_Battle  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  alias :initialize_gauge :initialize  def initialize    initialize_gauge    @viewport2.z = 100  endend #==============================================================================# ** Bitmap#------------------------------------------------------------------------------# New routine added to the Bitmap class. #==============================================================================  class Bitmap#-------------------------------------------------------------------------- # * Rectangle Gradation Indicator#   color1: Start color #   color2: Ending color #   align: 0: On side gradation #          1: Vertically gradation #          2: The gradation (intense concerning slantedly heavily note) #--------------------------------------------------------------------------   def gradation_rect(x, y, width, height, color1, color2, align = 0)    if align == 0      for i in x...x + width        red   = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)        green = color1.green +                (color2.green - color1.green) * (i - x) / (width - 1)        blue  = color1.blue +                (color2.blue - color1.blue) * (i - x) / (width - 1)        alpha = color1.alpha +                (color2.alpha - color1.alpha) * (i - x) / (width - 1)        color = Color.new(red, green, blue, alpha)        fill_rect(i, y, 1, height, color)      end    elsif align == 1      for i in y...y + height        red   = color1.red +                (color2.red - color1.red) * (i - y) / (height - 1)        green = color1.green +                (color2.green - color1.green) * (i - y) / (height - 1)        blue  = color1.blue +                (color2.blue - color1.blue) * (i - y) / (height - 1)        alpha = color1.alpha +                (color2.alpha - color1.alpha) * (i - y) / (height - 1)        color = Color.new(red, green, blue, alpha)        fill_rect(x, i, width, 1, color)      end    elsif align == 2      for i in x...x + width        for j in y...y + height          red   = color1.red + (color2.red - color1.red) *                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2          green = color1.green + (color2.green - color1.green) *                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2          blue  = color1.blue + (color2.blue - color1.blue) *                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2          alpha = color1.alpha + (color2.alpha - color1.alpha) *                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2          color = Color.new(red, green, blue, alpha)          set_pixel(i, j, color)        end      end    elsif align == 3      for i in x...x + width        for j in y...y + height          red   = color1.red + (color2.red - color1.red) *            ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2          green = color1.green + (color2.green - color1.green) *            ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2          blue  = color1.blue + (color2.blue - color1.blue) *            ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2          alpha = color1.alpha + (color2.alpha - color1.alpha) *            ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2          color = Color.new(red, green, blue, alpha)          set_pixel(i, j, color)        end      end    end  endend #==============================================================================# **  Sprite#------------------------------------------------------------------------------#  Class for sprites added to various effect handling used within RPGXP#============================================================================== module RPG  class Sprite < ::Sprite    def damage(value, critical)      dispose_damage      if value.is_a?(Numeric)        damage_string = value.abs.to_s      else        damage_string = value.to_s      end      bitmap = Bitmap.new(160, 48)      bitmap.font.name = "Arial Black"      bitmap.font.size = 32      bitmap.font.color.set(0, 0, 0)      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)      if value.is_a?(Numeric) and value < 0        bitmap.font.color.set(176, 255, 144)      else        bitmap.font.color.set(255, 255, 255)      end      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)      if critical        bitmap.font.size = 20        bitmap.font.color.set(0, 0, 0)        bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)        bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)        bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)        bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)        bitmap.font.color.set(255, 255, 255)        bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)      end      @_damage_sprite = ::Sprite.new      @_damage_sprite.bitmap = bitmap      @_damage_sprite.ox = 80 + self.viewport.ox      @_damage_sprite.oy = 20 + self.viewport.oy      @_damage_sprite.x = self.x + self.viewport.rect.x      @_damage_sprite.y = self.y - self.oy / 2 + self.viewport.rect.y      @_damage_sprite.z = 3000      @_damage_duration = 40    end    def animation(animation, hit)      dispose_animation      @_animation = animation      return if @_animation == nil      @_animation_hit = hit      @_animation_duration = @_animation.frame_max      animation_name = @_animation.animation_name      animation_hue = @_animation.animation_hue      bitmap = RPG::Cache.animation(animation_name, animation_hue)      if @@_reference_count.include?(bitmap)        @@_reference_count[bitmap] += 1      else        @@_reference_count[bitmap] = 1      end      @_animation_sprites = []      if @_animation.position != 3 or not @@_animations.include?(animation)        for i in 0..15          sprite = ::Sprite.new          sprite.bitmap = bitmap          sprite.visible = false          @_animation_sprites.push(sprite)        end        unless @@_animations.include?(animation)          @@_animations.push(animation)        end      end      update_animation    end    def loop_animation(animation)      return if animation == @_loop_animation      dispose_loop_animation      @_loop_animation = animation      return if @_loop_animation == nil      @_loop_animation_index = 0      animation_name = @_loop_animation.animation_name      animation_hue = @_loop_animation.animation_hue      bitmap = RPG::Cache.animation(animation_name, animation_hue)      if @@_reference_count.include?(bitmap)        @@_reference_count[bitmap] += 1      else        @@_reference_count[bitmap] = 1      end      @_loop_animation_sprites = []      for i in 0..15        sprite = ::Sprite.new        sprite.bitmap = bitmap        sprite.visible = false        @_loop_animation_sprites.push(sprite)      end      update_loop_animation    end    def animation_set_sprites(sprites, cell_data, position)      for i in 0..15        sprite = sprites        pattern = cell_data[i, 0]        if sprite == nil or pattern == nil or pattern == -1          sprite.visible = false if sprite != nil          next        end        sprite.visible = true        sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)        if position == 3          if self.viewport != nil            sprite.x = self.viewport.rect.width / 2            sprite.y = self.viewport.rect.height - 160          else            sprite.x = 320            sprite.y = 240          end        else          sprite.x = self.x + self.viewport.rect.x -                      self.ox + self.src_rect.width / 2          sprite.y = self.y + self.viewport.rect.y -                      self.oy + self.src_rect.height / 2          sprite.y -= self.src_rect.height / 4 if position == 0          sprite.y += self.src_rect.height / 4 if position == 2        end        sprite.x += cell_data[i, 1]        sprite.y += cell_data[i, 2]        sprite.z = 2000        sprite.ox = 96        sprite.oy = 96        sprite.zoom_x = cell_data[i, 3] / 100.0        sprite.zoom_y = cell_data[i, 3] / 100.0        sprite.angle = cell_data[i, 4]        sprite.mirror = (cell_data[i, 5] == 1)        sprite.opacity = cell_data[i, 6] * self.opacity / 255.0        sprite.blend_type = cell_data[i, 7]      end    end  endend  #==============================================================================# ** RPG#------------------------------------------------------------------------------# A module containing RPGXP's data structures and more.#============================================================================== module RPG  #============================================================================  # ** Cache  #----------------------------------------------------------------------------  # A module that loads each of RPGXP's graphic formats, creates a Bitmap  # object, and retains it.  #============================================================================  module Cache    def self.system(filename)      self.load_bitmap("Graphics/Pictures/", filename)    end  endend

    Also, it looks like the little HP display tweak for enemies that you made for me, Mobius, is also making something weird happen. My test was one party member fighting two identical enemies. We all know Cross Cut for testing purposes. When using the enemy HP display script, the skill names will pop up fine for both enemies on the first turn, but if I use the same command as last turn (ie: an identical turn happens I guess) then the window showing the enemy's name, state, and HP (the one that shows up when I would select them) shows up instead of the skill name when they cast. Changing up my party member's action fixes this, but if the same actions repeat on the next turn, the enemy info shows up in the window instead of the skill name that they are using. Weird stuff!

    Code:
    class Window_Help < Window_Base  #--------------------------------------------------------------------------  # * Set Enemy  #     enemy : name and status displaying enemy  #     Mobius XVI version - adds HP/SP information (original HP @ 284)  #--------------------------------------------------------------------------  def set_enemy(enemy)      # treat enemy as actor      self.contents.clear      draw_actor_name(enemy, 4, 0)      draw_actor_state(enemy, 140, 0)      draw_actor_hp(enemy, 460, 0)      @actor = nil      self.visible = true  endend 
     
    #4
  5. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    Ok, yea, it looks like the fix I made for you is missing a line. Try this.

    class Window_Help < Window_Base #-------------------------------------------------------------------------- # * Set Enemy # enemy : name and status displaying enemy # Mobius XVI version - adds HP/SP information (original HP @ 284) #-------------------------------------------------------------------------- def set_enemy(enemy) # treat enemy as actor self.contents.clear draw_actor_name(enemy, 4, 0) draw_actor_state(enemy, 140, 0) draw_actor_hp(enemy, 460, 0) @actor = nil @text = nil self.visible = true endend  
    Just off the top of my head, I'd say that might (emphasis on might) fix the other problem too. So give it a shot. If it doesn't, I'll look into it more.
     
    #5
  6. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Okay, that did take care of the second issue thankfully, but the primary issue with the HP/SP bar script still remains. It's kind of scary how that little line could cause such a strange error...scripting is kind of intimidating, haha.
     
    #6
  7. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    Ok just to make sure I'm tracking with you - you're still having the issue where the skill name doesn't display if it's used back-to-back, and the problem is fixed by removing the HP/SP bar script? 
     
    #7
  8. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    You got it. The strange "showing enemy info instead of skill name" issue was with the Enemy HP snippet you made, and that is fixed with that line of code you added. The first issue, where the same skill used consecutively doesn't display after the first time is caused somehow by the HP/SP bar script I posted.

    I did a couple more tests to try and help. I made a slow and fast enemy use the same skill, with my party member acting in between them. If I attack or use the same skill they are using, the name displays only the first time. If I defend, use a different skill, or use an item, both skill names show up (before and after my action). This seems to narrow the issue down to whenever the same text is displayed in the top window twice in a row, since attacking doesn't display a message, while defending/item use does.

    Hope that helps!
     
    #8
  9. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    Yea that helps out a lot actually. So basically the problem with the HP/SP script is identical to the snippet I made for. The script isn't handling the "set_text" method of Window_Help correctly. What you need to do is change lines 14 and 15 below from this:

    class Window_Help < Window_Base #-------------------------------------------------------------------------- # * Set Text # text : text string displayed in window # align : alignment (0..flush left, 1..center, 2..flush right) #-------------------------------------------------------------------------- alias :gauge_set_text :set_text def set_text(text, align = 0) # ƒeƒLƒXƒg‚ƃAƒ‰ƒCƒ“ƒƒ“ƒg‚Ì*‚È‚*‚Æ‚àˆê•û‚ª‘O‰ñ‚ƈá‚Á‚Ä‚¢‚éê‡ if text != @text or align != @align # ƒQ[ƒW‚Ìíœ gauge_delete # ƒIƒŠƒWƒiƒ‹‚̈— gauge_set_text(text, align) end endend 
    to this:

    class Window_Help < Window_Base #-------------------------------------------------------------------------- # * Set Text # text : text string displayed in window # align : alignment (0..flush left, 1..center, 2..flush right) #-------------------------------------------------------------------------- alias :gauge_set_text :set_text def set_text(text, align = 0) # ƒeƒLƒXƒg‚ƃAƒ‰ƒCƒ“ƒƒ“ƒg‚Ì*‚È‚*‚Æ‚àˆê•û‚ª‘O‰ñ‚ƈá‚Á‚Ä‚¢‚éê‡ if text != @text or align != @align # ƒQ[ƒW‚Ìíœ gauge_delete # ƒIƒŠƒWƒiƒ‹‚̈— end gauge_set_text(text, align) endend 
    You can also just take that second bit of code and paste it below the HP/SP Bar script and that'll fix the problem as well.
     
    Last edited by a moderator: Mar 10, 2014
    #9
  10. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Sorry for the huge delay in replying; I've had a rough few weeks. Anyway, it looks like those little tweaks have fixed problem #1 beautifully. Problem #2 still seems to be lingering though. I tried pasting the code as a separate script, and also tried replacing the sections of code in Game_Battler 1, but both seem to have no effect.

    I tried applying the +10% and -10% states separately and at the same time (one skill adding both) and the result was still as follows:

    500 * 110% * 90% = 495

    Instead of:

    500 * (110% + 90%) / 2 = 500

    Looking at your edit, I thought it would have worked, but unfortunately it's not quite there yet.
     
    #10
  11. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    Alright so it took me a little while to figure out what was wrong with #2 mostly because - like you I'm guessing - I was testing the code using various actors' HP. Basically my fix works fine for everything except actors' HP. So yea, I thought it was pretty funny. But anyways on to how to fix it. See actors have their own separate method for determining how states affect their HP because they have a lower cap on the HP than enemies. So I'll you'll have to do is paste the following snippet as well.
     

    Code:
    class Game_Actor  #--------------------------------------------------------------------------  # * Get Maximum HP  #--------------------------------------------------------------------------  def maxhp    n = [[base_maxhp + @maxhp_plus, 1].max, 9999].min    state_factor = 100    for i in @states      state_factor += ($data_states[i].maxhp_rate - 100.0)    end    n *= state_factor / 100.0    n = [[Integer(n), 1].max, 9999].min    return n  endend 
     
    #11
  12. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Aha! I had no idea that they snuck a separate HP calculation into Game_Actor, good find! It looks like that fixes the problem. While working on my game this weekend I've come across a few more small little RMXP annoyances, so there might be some more mutual improvement to look forward to, haha.

    Thanks again!
     
    #12

Share This Page