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.

Getting the actor tags to display in items.

Hey, in my game I have a weapon created by the main character, and I want the weapon's name and description to say so. However, using "\n[1]" doesn't work for item names or their descriptions. Is there any way to do this without scripting?
 
I could, but I want a classic old-school RPG feel to my game, so having name input fields is necessary I feel. I've found a way around the problem, sort of. Using the old "last name" trick, letting players only change the first name.
 

ikos

Member

Hey, you might want to try:

Code:
#==============================================================================
#  Description Replacement Codes
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script basically just allows the use of some basic message codes in
#  item descriptions.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#
#    To use, insert the codes you'd like to use into the description of the
#  item, weapon, armor, or skill. The message codes you can use are:
#
#  General Codes
#    \n[actor_id] - prints name of actor with specified ID
#    \c[class_id] - prints name of class with specified ID
#    \s[state_id] - prints name of state with specified ID
#    \v[variable_id] - prints value of variable with specified ID
#    \e[element_id] - prints name of element with specified ID
#    \vocab[value] - prints vocab for that item type. Suitable values for this
#                  are: level, level_a, hp, hp_a, mp, mp_a, atk, def, spi, 
#                    agi, weapon, armor1, armor2, armor3, armor4, weapon1, 
#                    weapon2, attack, skill, guard, item, equip, status, save,
#                    game_end, fight, escape, new_game, shutdown, to_title,
#                    continue, cancel, gold
#    \p - prints price                         (Items, Weapons, or Armors ONLY)
#    \spd - prints speed stat value                      (Skills or Items ONLY)
#    \dmg - prints damage stat value                     (Skills or Items ONLY)
#    \var - prints variance stat value                   (Skills or Items ONLY)
#    \atkf - prints Attack F stat value                  (Skills or Items ONLY)
#    \spif - prints Spirit F stat value                  (Skills or Items ONLY)
#    \hr - prints hit ratio                            (Skills or Weapons ONLY)
#    \mpc - prints mp cost value                                  (Skills ONLY)
#    \mpr - prints mp rate percentile                              (Items ONLY)
#    \mpv - prints mp value                                        (Items ONLY)
#    \hpr - prints hp rate percentile                              (Items ONLY)
#    \hpv - prints hp value                                        (Items ONLY)
#    \pn - prints paramter name (MaxHP etc...)                     (Items ONLY)
#    \pv - prints parameter points (50, etc...)                    (Items ONLY)
#    \eva - prints evasion                                        (Armors ONLY)
#    \atk - prints Attack                              (Weapons or Armors ONLY)
#    \def - prints Defense                             (Weapons or Armors ONLY)
#    \spi - prints Spirit                              (Weapons or Armors ONLY)
#    \agi - prints Agility                             (Weapons or Armors ONLY) 
#==============================================================================
# ** RPG::BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes: 
#    aliased method - description
#==============================================================================

class RPG::BaseItem
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Description
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_desc_codes_description_extract_8fn3 description
  def description
    # Get duplicate of actual description
    text = modalg_desc_codes_description_extract_8fn3.dup
    # Substitute codes for their actual values
    text.gsub! (/\\n\[(\d+)\]/i) { $game_actors[$1.to_i].name }   # Actor Name
    text.gsub! (/\\c\[(\d+)\]/i) { $data_classes[$1.to_i].name }  # Class Name 
    text.gsub! (/\\s\[(\d+)\]/i) { $data_states[$1.to_i].name }   # State Name
    text.gsub! (/\\v\[(\d+)\]/i) { $game_variables[$1.to_i].to_s }     # Variable
    text.gsub! (/\\e\[(\d+)\]/i) { $data_elements[$1.to_i].name } # Element
    begin
      text.gsub! (/\\vocab\[(\w+)\]/i) {eval ("Vocab.#{$1.to_s}")}# Vocabulary
    rescue
    end
    # Skill or Item ONLY
    if self.is_a? (RPG::UsableItem)
      text.gsub! (/\\spd/i)  { self.speed }                       # Speed
      text.gsub! (/\\dmg/i)  { self.base_damage }                 # Damage
      text.gsub! (/\\var/i)  { self.variance }                    # Variance
      text.gsub! (/\\atkf/i) { self.atk_f }                       # Attack F
      text.gsub! (/\\spif/i) { self.spi_f }                       # Spirit F
    end
    # Skill or Weapon ONLY
    text.gsub! (/\\hr/i) {self.hit} if self.is_a? (RPG::Weapon) || self.is_a? (RPG::Skill)
    # Item ONLY
    if self.is_a? (RPG::Item)
      text.gsub! (/\\hpr/i) { self.hp_recovery_rate }             # HP Percent
      text.gsub! (/\\hpv/i) { self.hp_recovery }                  # HP Value
      text.gsub! (/\\mpr/i) { self.mp_recovery_rate }             # MP Percent
      text.gsub! (/\\mpv/i) { self.mp_recovery }                  # MP Value
      text.gsub! (/\\pv/i)  { self.parameter_points }             # Param. Value
      if text[/\\pn/i]
        vocab = ["Max + #{Vocab.hp}", "Max + #{Vocab.mp}", Vocab.atk, 
                 Vocab.def, Vocab.spi, Vocab.agi]
        text.gsub! (/\\pn/i) { vocab[self.parameter_type] }       # Param. Name
      end
    end
    # Items, Weapons, or Armor ONLY
    unless self.is_a? (RPG::Skill)
      text.gsub! (/\\p/i) { self.price }
      # Armor ONLY
      text.gsub! (/\\eva/i) {self.hit} if self.is_a? (RPG::Armor)
      # Armor or Weapon ONLY
      if self.is_a? (RPG::Armor) || self.is_a? (RPG::Weapon)
        text.gsub! (/\\atk/i) { self.atk }
        text.gsub! (/\\def/i) { self.def }
        text.gsub! (/\\spi/i) { self.spi }
        text.gsub! (/\\agi/i) { self.agi }
      end
    end
    # Return the text with substituted codes
    return text
  end
end
 

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