Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

critical text changing depending of actor id?

tatao

Member

Hi,
I tried to do this with that part in RPG Module:

bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "STUNNING ATTACK", 1)
bitmap.draw_text(+1, -1, 160, 20, "STUNNING ATTACK", 1)
bitmap.draw_text(-1, +1, 160, 20, "STUNNING ATTACK", 1)
bitmap.draw_text(+1, +1, 160, 20, "STUNNING ATTACK", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "STUNNING ATTACK", 1)

and making a if condition,
but i cannot seem to do it properly (no surprise as I'm still pretty bad with anything scripting)

i'd like to do it with a condition like
if battler.id = 1 then
if battler.id = 2 then

but what should i put in the if?
 
I recommend using a hash with a default for the text. Something like this :

Code:
class RPG::Sprite
  Critical_Hit_Text_A = {}
  Critical_Hit_Text.default = 'Critical'
  Critical_Hit_Text_E = {}
  Critical_Hit_Text.default = 'Critical'

# Replace this part in def damage

      if critical
        bitmap.font.size = 20
        bitmap.font.color.set(0, 0, 0)
        if $critical_text_battler.is_a?(Game_Actor)
          text = Critical_Hit_Text_A[$critical_text_battler.id]
        elsif $critical_text_battler.is_a?(Game_Enemy)
          text = Critical_Hit_Text_E[$critical_text_battler.id]
        else
          text = Critical_Hit_Default_Text
        end
        bitmap.draw_text(-1, -1, 160, 20, text, 1)
        bitmap.draw_text(+1, -1, 160, 20, text, 1)
        bitmap.draw_text(-1, +1, 160, 20, text, 1)
        bitmap.draw_text(+1, +1, 160, 20, text, 1)
        bitmap.font.color.set(255, 255, 255)
        bitmap.draw_text(0, 0, 160, 20, text, 1)
      end

Then, add this below your modifications.

Code:
class Sprite_Battler
  alias_method :seph_crittext_sprbltr_update, :update
  def update
    if @battler_visible && @battler.damage_pop
      $critical_text_battler = @battler
    else
      $critical_text_battler = nil
    end
    seph_crittext_sprbltr_update
  end
end

You only need to modify these:

Critical_Hit_Text_A = {}
Critical_Hit_Text.default = 'Critical'
Critical_Hit_Text_E = {}
Critical_Hit_Text.default = 'Critical'
Critical_Hit_Default_Text = 'Critical'

A is for the actors. Just add a key and value pair for whatever actors you want to define. So making actor 1 critical text be 'Ouch!' and actor 2 critical text be 'DANG!', just use:
Code:
  Critical_Hit_Text_A = {1 => 'Ouch!', 2 => 'DANG!'}

The next line is just the default text, for all non-defined actors text.

E is the same, only it's for enemies. That last one is just the default for critical text, if a Enemy or Actor isn't used.

That should work. Let me know if it doesn't.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top