Recent posts

Pages1 2 3 ... 10
1
RPG Maker Scripts / [XP] System Reputation
Last post by AvilaMn - September 22, 2021, 06:02:44 pm
System Reputation
Authors: AvilaMn
Version: 1.0



Introduction:

This script will allow you to create reputations, with different levels and custom shops.

This work is licenced under BSD Licence 2.0:
QuoteCopyright (c) Bryan Ávila alias "AvilaMn"
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1.  Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.

2.  Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.

3.  Neither the name of the copyright holder nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

You may use this script for both non-commercial and commercial products without limitations as long as you fulfill the conditions presented by the above license. The "complete" way to give credit is to include the license somewhere in your product (e.g. in the credits screen), but a "simple" way is also acceptable. The "simple" way to give credit is as follows:
QuoteSystem Reputation licensed under BSD License 2.0, Copyright (c) Bryan Ávila alias "AvilaMn"

Alternatively, if your font doesn't support diacritic characters, you may use this variant:
QuoteSystem Reputation licensed under BSD License 2.0, Copyright (c) Bryan Ávila alias "AvilaMn"

In general other similar variants are allowed as long as it is clear who the creator is (e.g. "System Reputation created by AvilaMn" is acceptable). But if possible, prefer to use one of the two variants listed above.

If you fail to give credit and/or claim that this work was created by you, this may result in legal action and/or payment of damages even though this work is free of charge to use normally.



Features

  • Window to show the reputation list and navigate arround to see the progress on each reputation.
  • Custom Shop that make discount based on the reputation level.
  • The items with discount will be shown with green color
  • Fully editable, can change the Reputations, Levels, Shops, Itemsets, Weaponsets and Armorsets for the shops.
  • Can cheque in event conditions if a player can access a certain shop.
  • Can Add and Remove exp from the Reputation you want on events with a simple Script Call.



Screenshots

Window Reputation
Spoiler: ShowHide


Window Custom Shop
Spoiler: ShowHide




Demo

System Reputation



Script

Just make a new script above main and paste this code into it.
#==============================================================================
# System_Reputation
# Created by: AvilaMn
#------------------------------------------------------------------------------
# Description:
# This system add the possibility to have different reputations that can be
# increased by events, including a window to check de reputation progress and
# the posibility to create custom shops that change their items values based
# on the reputations levels
#------------------------------------------------------------------------------
# Instructions:
#
# To call the Reputation Menu use this line in a Script call or in you script:
# $scene = Scene_Reputations.new
#
# To Add exp to a certain Reputation use this line in a Script Call:
# add_rep_exp(ID, VALUE) : ID is the Reputation ID and VALUE is the ammount
# of exp you want to add
#
# To Remove exp to a certain Reputation use this line in a Script Call:
# remove_rep_exp(ID, VALUE) : ID is the Reputation ID and VALUE is the ammount
# of exp you want to remove
#
# To check if the player can access a certain Custom Shop use this line in a
# Script section of the Event Conditional:
# can_shop?(ID) : ID is the Shop ID
#
# To call a Custom Shop use this line in a Script Call:
# call_custom_shop(ID) : ID is the Shop ID
#
# The IDs you need to make the diferent calls are in the CONFIGURATION below
#==============================================================================
module REP_CONFIG
  #============================================================================
  # CONFIGURATION :
  # To add a new data just add new lines following the syntax commented in each
  # data Hash, and don't forget to put the , at the end
  #============================================================================
  Reputations = {
  # ID => [NAME, LEVEL, EXP, ACTIVE, ICON]
  0 => ["KINGDOM", 5, 99999, true, "Reputation-01"],
  1 => ["ALIANCE", 1, 0, false, "Reputation-02"],
  2 => ["HORDE", 1, 0, false, "Reputation-03"],
  } 
  Levels = {
  # ID => [NAME, EXP_TO_LVL, %_REDUCED_VALUE]
  0 => ["HATED", -1, -100],
  1 => ["UNKNOWN", 0, 0],
  2 => ["NEUTRAL", 10, 0],
  3 => ["FRIENDLY", 100, 0],
  4 => ["HONORED", 1000, 10],
  5 => ["REVERED", 10000, 25],
  6 => ["EXALTED", 100000, 50],
  }
  Shops = {
  # ID => [REP_ID, LEVEL_ID, ITEMSET_ID, WEAPONSET_ID, ARMORSET_ID]
  0 => [0, 3, 0, 0, 0],
  1 => [2, 2, 0, 0, 0],
  2 => [1, 4, 0, 0, 0],
  }
  ItemSets = {
  # ID => [ITEMS_IDs]
  0 => [1, 2, 3, 4],
  }
  WeaponSets = {
  # ID => [WEAPONS_IDs]
  0 => [2, 5, 8],
  }
  ArmorSets = {
  # ID => [ARMOR_IDs]
  0 => [1, 10, 23],
  }
end
#============================================================================
# GAME PARTY - DON'T TOUCH
#============================================================================
class Game_Party
  # Variables
  attr_accessor :reputations
  attr_accessor :rep_levels
  attr_accessor :rep_shops
  attr_accessor :rep_itemsets
  attr_accessor :rep_weaponsets
  attr_accessor :rep_armorsets
  # Aliasing
  alias rep_initialize initialize
  #Initialize Game_Party
  def initialize
    # Para acceder o modificar la variable
    #$game_party.reputations[rep_id][index] = value
    @reputations = REP_CONFIG::Reputations
    @rep_levels = REP_CONFIG::Levels
    @rep_shops = REP_CONFIG::Shops
    @rep_itemsets = REP_CONFIG::ItemSets
    @rep_weaponsets = REP_CONFIG::WeaponSets
    @rep_armorsets = REP_CONFIG::ArmorSets
    # Initialize old Game_Party
    rep_initialize
  end
end
#============================================================================
# WINDOW BASE - DON'T TOUCH
#============================================================================
class Window_Base
  def hated_color
    return Color.new(255, 36, 36, 255)
  end
  def neutral_color
    return Color.new(250, 250, 36, 255)
  end
  def friendly_color
    return Color.new(36, 255, 36, 255)
  end
end
#============================================================================
# SYSTEM REPUTATION - DON'T TOUCH
#============================================================================
class System_Reputation
  #============================================================================
  # GET :
  #============================================================================
  # Reputation Name
  def name(rep_id)
    reputation = $game_party.reputations[rep_id]
    name = reputation[0]
    return name
  end
  # Reputation Level
  def lvl(rep_id)
    reputation = $game_party.reputations[rep_id]
    lvl = reputation[1] 
    return lvl
  end
  # Reputation EXP
  def exp(rep_id)
    reputation = $game_party.reputations[rep_id]
    exp = reputation[2]
    return exp
  end
  # Reputation active
  def active?(rep_id)
    reputation = $game_party.reputations[rep_id]
    active = reputation[3]
    return active
  end
  # Reputation Icon
  def icon(rep_id)
    reputation = $game_party.reputations[rep_id]
    icon = reputation[4]
    return icon
  end
  # Reputation Shop IDs (Array of IDs)
  def shop_ids(rep_id)
    shops = $game_party.rep_shops
    id = []
    for i in 1..shops
      index = 0
      if shops[i][0] == rep_id
        id[index] = shop[i][0]
      end
      index += 1
    end
    return id
  end
  #----------------------------------------------------------------------------
  # Level Name
  def lvl_name(lvl_id)
    level = $game_party.rep_levels[lvl_id]
    name = level[0]
    return name
  end
  # Level Base Exp
  def lvl_base_exp(lvl_id)
    level = $game_party.rep_levels[lvl_id]
    base_exp = level[1]
    return base_exp
  end
  # Level Reduce Price Value Percentage
  def reduced_value(lvl_id)
    level = $game_party.rep_levels[lvl_id]
    percentage = level[2]
    return percentage
  end
  #----------------------------------------------------------------------------
  # Shop Reputation
  def shop_rep(shop_id)
    shop = $game_party.rep_shops[shop_id]
    rep = shop[0]
    return rep
  end
  # Shop Level Needed
  def shop_lvl_needed(shop_id)
    shop = $game_party.rep_shops[shop_id]
    lvl = shop[1]
    return lvl
  end
  # Shop Item Set (Array)
  def shop_itemset(shop_id)
    shop = $game_party.rep_shops[shop_id]
    id = shop[2]
    itemset = $game_party.rep_itemsets[id]
    return itemset
  end
  # Shop Weapon Set (Array)
  def shop_weaponset(shop_id)
    shop = $game_party.rep_shops[shop_id]
    id = shop[3]
    weaponset = $game_party.rep_weaponsets[id]
    return weaponset
  end
  # Shop Armor Set (Array)
  def shop_armorset(shop_id)
    shop = $game_party.rep_shops[shop_id]
    id = shop[4]
    armorset = $game_party.rep_armorsets[id]
    return armorset
  end
  #============================================================================
  # CHECKS :
  #============================================================================
  def rep_id?(string)
    reputations = $game_party.reputations
    rep_ids = reputations.keys
    id = nil
    for i in rep_ids
      id = i
      exist = exist?(id)
      if exist == true
        rep_name = name(id)
        if rep_name == string
          return id
        end
      end 
    end
  end
  # Reputation exists
  def exist?(rep_id)
    exist = $game_party.reputations.include?(rep_id)
    return exist
  end
  # EXP to Level UP
  def to_lvl?(rep_id)
    exist = exist?(rep_id)
    if exist == true
      current_exp = exp(rep_id)
      current_lvl = lvl(rep_id)
      max_lvl = max_lvl?
      if current_lvl >= max_lvl
        next_lvl = current_lvl
      else
        next_lvl = current_lvl + 1
      end
      needed_exp = lvl_base_exp(next_lvl)
      to_lvl = needed_exp - current_exp
      return to_lvl
    else
      return nil
    end   
  end
  # Max Level
  def max_lvl?
    levels = $game_party.rep_levels.keys
    temp = 0
    for i in levels
      if temp < i
        temp = i
      end
    end
    max_lvl = temp
    return max_lvl
  end
  # Is Max Level
  def is_max_lvl?(rep_id)
    exist = exist?(rep_id)
    if exist == true
      lvl = lvl(rep_id)
      max_lvl = max_lvl?
      if lvl == max_lvl
        return true
      else
        return false
      end
    else
      return false
    end
  end
  # Can Shop
  def can_shop?(shop_id)
    rep_id = shop_rep(shop_id)
    shop_lvl = shop_lvl_needed(shop_id)
    rep_lvl = lvl(rep_id)
    if rep_lvl >= shop_lvl
      return true
    end
    return false
  end
  # Positive or Negative
  def pos_or_neg(value)
    if value > 0 && value != nil
      return true
    else
      return false
    end
  end
  #============================================================================
  # SET :
  #============================================================================
  # Level Manager
  def lvl_manager(rep_id)
    exist = exist?(rep_id)
    if exist == true
      levels = $game_party.rep_levels.keys
      levels = levels.sort
      current_exp = exp(rep_id)
      max_lvl = max_lvl?
      max_exp = lvl_base_exp(max_lvl)
      lvl = 0
      if current_exp == max_exp
        lvl = max_lvl
      else
        for i in levels
          lvl_exp = lvl_base_exp(i)
          if current_exp >= lvl_exp
              lvl = i
          end       
        end
      end
      $game_party.reputations[rep_id][1] = lvl     
    end
  end
  # Set Shop Goods
  def shop_goods(shop_id)
    shop_goods = []
    itemset = shop_itemset(shop_id)
    weaponset = shop_weaponset(shop_id)
    armorset = shop_armorset(shop_id)
    array = []
    for id in itemset
      array = [0, id]
      shop_goods.push(array)
    end
    for id in weaponset
      array = [1, id]
      shop_goods.push(array)
    end
    for id in armorset
      array = [2, id]
      shop_goods.push(array)
    end
    return shop_goods
  end
  # Recalculates de Item Price
  def recalculate_price(shop_id, price)
    sys_rep = System_Reputation.new
    rep_id = sys_rep.shop_rep(shop_id)
    min_lvl = sys_rep.shop_lvl_needed(shop_id)
    rep_lvl = sys_rep.lvl(rep_id)
    percentage = sys_rep.reduced_value(rep_lvl)
    if rep_lvl >= min_lvl
      value = (percentage * price) / 100
      price -= value
      return price
    end
    return price
  end
end
#============================================================================
# WINDOW REP TITLE : Add
#============================================================================
class Window_Rep_Title < Window_Base
  def initialize
    super(40, 40, 560, 60)
    @title = "REPUTATIONS"
    draw_rep_title(@title, 180, 0)
  end
  def draw_rep_title(title, x, y)
    if title == nil
      return
    end
    bitmap = RPG::Cache.icon("Reputation-00")
    self.contents = Bitmap.new(self.width - 32, self.height - 32)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 28, y, 212, 32, title)
  end
end
#============================================================================
# WINDOW REP DESCRIPTION : Add
#============================================================================
class Window_Rep_Description < Window_Base
  def initialize
    super(40, 380, 560, 60)
    draw_lvl_description(rep_array = nil)
  end
  def draw_lvl_description(rep_array)
    x = 0
    y = 0
    rep_id = 0
    lvl = 1
    exp = 0
    to_lvl = 0
    max_lvl = 1
    lvl_name = "ERROR"
    if rep_array != nil
      reputation = System_Reputation.new
      rep_id = rep_array[0]
      lvl = reputation.lvl(rep_id)
      exp = reputation.exp(rep_id)
      to_lvl = reputation.to_lvl?(rep_id)
      lvl_name = reputation.lvl_name(lvl)
      max_lvl = reputation.max_lvl?
    end
    self.contents = Bitmap.new(self.width - 32, self.height - 32)
    case lvl
    when 0
      self.contents.font.color = hated_color
    when 1
      self.contents.font.color = neutral_color
    when 2
      self.contents.font.color = neutral_color
    end
    if lvl > 2
      self.contents.font.color = friendly_color
    end
    self.contents.draw_text(x, y, 140, 32, lvl_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 144, y, 140, 32, "EXP : " + exp.to_s)
    if lvl == max_lvl
      self.contents.draw_text(x + 284, y, 212, 32, "MAX LEVEL")
    else
      self.contents.draw_text(x + 284, y, 212, 32, "TO NEXT LEVEL: " + to_lvl.to_s)
    end
  end
end
#============================================================================
# WINDOW REP LIST : Add
#============================================================================
class Window_Rep_List < Window_Selectable
  def initialize
    super(40, 100, 560, 280)
    @column_max = 2
    refresh
    self.index = 0
  end
  def rep
    return @data[self.index]
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end   
    # Add reputations to data
    @data = []
    temp = []
    reputations = $game_party.reputations   
    for i in 0...reputations.keys.size
      reputation = $game_party.reputations[i]
      if reputation != nil && reputation[3] == true
        temp = [i, reputation]
        @data.push(temp)
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_rep_name(i)
      end
    end
  end
  def draw_rep_name(index)
    sys_rep = System_Reputation.new
    rep = @data[index]
    rep_id = rep[0]
    rep_name = sys_rep.name(rep_id)
    lvl = sys_rep.lvl(rep_id)
    if @data.empty? == true
      rep_name = "Don't have reputations"
    end
    x = 4 + index % 2 * (248 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(sys_rep.icon(rep_id))
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 255)
    case lvl
    when 0
      self.contents.font.color = hated_color
    when 1
      self.contents.font.color = neutral_color
    when 2
      self.contents.font.color = neutral_color
    end
    if lvl > 2
      self.contents.font.color = friendly_color
    end
    self.contents.draw_text(x + 28, y, 212, 32, rep_name, 0)
  end
  def update_help
    @help_window.draw_lvl_description(self.rep == nil ? nil : self.rep)
  end
end
#============================================================================
# SCENE REPUTATIONS :
#============================================================================
class Scene_Reputations
  def start
    @spriteset = Spriteset_Map.new
    @window_rep_title = Window_Rep_Title.new
    @window_rep_list = Window_Rep_List.new
    @window_rep_description = Window_Rep_Description.new
    @window_rep_list.help_window = @window_rep_description
  end
  def main
    start
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @spriteset.dispose
    @window_rep_title.dispose
    @window_rep_list.dispose
    @window_rep_description.dispose
  end
  def update
    @window_rep_list.update
    @window_rep_description.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
  end
end
#============================================================================
# INTERPRETER : Adds to the class
#============================================================================
class Interpreter
    # Reputation Gain EXP
  def add_rep_exp(rep_id, value=0)
    sys_rep = System_Reputation.new
    exist = sys_rep.exist?(rep_id)
    if exist == true
      current_exp = sys_rep.exp(rep_id)
      is_positive = sys_rep.pos_or_neg(value)
      if is_positive == true
        new_exp = current_exp + value
        max_lvl = sys_rep.max_lvl?
        max_exp = sys_rep.lvl_base_exp(max_lvl)
        if new_exp > max_exp
          $game_party.reputations[rep_id][2] = max_exp
          sys_rep.lvl_manager(rep_id)
        else
          $game_party.reputations[rep_id][2] = new_exp
          sys_rep.lvl_manager(rep_id)
        end
        active = sys_rep.active?(rep_id)
        if active == false
          $game_party.reputations[rep_id][3] = true
        end
      end
    end
  end
  # Reputation Reduce EXP
  def remove_rep_exp(rep_id, value=0)
    sys_rep = System_Reputation.new
    exist = sys_rep.exist?(rep_id)
    if exist == true
      current_exp = sys_rep.exp(rep_id)
      is_positive = sys_rep.pos_or_neg(value)
      if is_positive == true
        new_exp = current_exp - value
        $game_party.reputations[rep_id][2] = new_exp
        sys_rep.lvl_manager(rep_id)
        active = sys_rep.active?(rep_id)
        if active == false
          $game_party.reputations[rep_id][3] = true
        end
      end
    end
  end
  # Can Shop
  def can_shop?(shop_id)
    sys_rep = System_Reputation.new
    rep_id = sys_rep.shop_rep(shop_id)
    shop_lvl = sys_rep.shop_lvl_needed(shop_id)
    rep_lvl = sys_rep.lvl(rep_id)
    if rep_lvl >= shop_lvl
      return true
    end
    return false
  end
  # Call Custom Shop (shop_id)
  def call_custom_shop(shop_id)
    sys_rep = System_Reputation.new
    $game_temp.shop_goods = sys_rep.shop_goods(shop_id)
    $scene = Scene_Shop.new(shop_id)
  end
end
#============================================================================
# SCENE SHOP : Edit
#============================================================================
class Scene_Shop
  def initialize(shop_id = nil)
    @shop_id = shop_id
    main
  end
  def main
    @help_window = Window_Help.new
    @command_window = Window_ShopCommand.new
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    @buy_window = Window_ShopBuy.new($game_temp.shop_goods, @shop_id)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    @sell_window = Window_ShopSell.new
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window
    @number_window = Window_ShopNumber.new
    @number_window.active = false
    @number_window.visible = false
    @status_window = Window_ShopStatus.new
    @status_window.visible = false
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @sell_window.dispose
    @number_window.dispose
    @status_window.dispose
  end
  def update_buy
    @status_window.item = @buy_window.item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @shop_id != nil
        sys_rep = System_Reputation.new
        new_price = sys_rep.recalculate_price(@shop_id, @item.price)
        if @item == nil or new_price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      else
        if @item == nil or @item.price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      end
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
      end
      if number == 99
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      if @shop_id != nil
        max = new_price == 0 ? 99 : $game_party.gold / new_price
        max = [max, 99 - number].min
        @buy_window.active = false
        @buy_window.visible = false
        @number_window.set(@item, max, new_price)
      else
        max = @item.price == 0 ? 99 : $game_party.gold / @item.price
        max = [max, 99 - number].min
        @buy_window.active = false
        @buy_window.visible = false
        @number_window.set(@item, max, @item.price)
      end
      @number_window.active = true
      @number_window.visible = true
    end
  end
end
#============================================================================
# WINDOW SHOPBUY : Edit
#============================================================================
class Window_ShopBuy
  def initialize(shop_goods, shop_id = nil)
    super(0, 128, 368, 352)
    @shop_goods = shop_goods
    @shop_id = shop_id
    refresh
    self.index = 0
  end
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if @shop_id != nil
      sys_rep = System_Reputation.new
      new_price = sys_rep.recalculate_price(@shop_id, item.price)
      if new_price <= $game_party.gold and number < 99
        self.contents.font.color = friendly_color
      else
        self.contents.font.color = disabled_color
      end
      x = 4
      y = index * 32
      rect = Rect.new(x, y, self.width - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
      self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
      self.contents.draw_text(x + 240, y, 88, 32, new_price.to_s, 2)
    else
      if item.price <= $game_party.gold and number < 99
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
      x = 4
      y = index * 32
      rect = Rect.new(x, y, self.width - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
      self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
      self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
    end
  end
end



Instructions

Inside the script in the first comment.



Credits and Thanks

  • AvilaMn
  • Jaiden for support
  • kk20 for support
  • And all that helps me on the discord server

Author Notes

If you find any bugs, please report them here:
http://forum.chaos-project.com

Enjoy it  :-*
2
General Discussion / Re: [RESOLVED][XP]Problem with...
Last post by KK20 - August 26, 2021, 11:41:10 am
When that zero is a float, yes.
3
General Discussion / Re: [RESOLVED][XP]Problem with...
Last post by Blizzard - August 26, 2021, 04:59:48 am
Hm, are you sure dividing by 0 is smart?
4
Tutorial Database / Re: [XP] RMXPAce -- Using the ...
Last post by KK20 - August 21, 2021, 12:44:15 am
Doesn't have to specifically be the steam version, could just be v1.05 in general that does that.
5
Tutorial Database / Re: [XP] RMXPAce -- Using the ...
Last post by kikiki - August 20, 2021, 07:50:54 pm
Hi all! Long time lurker, first time poster.

Has anyone been able to download the 2.34 / latest files from Dropbox? No matter what I try (cleaning caches, trying other browsers etc) I'm unable to download the files.

If anyone has any tips or can offer a mirror dl I'd very much appreciate it! Just got back into rmxp and these updates would be stellar.

Edit: finally got the files to download on mobile.

Now I just get a generic error when I try to playtest a blank / new project:

"The specified procedure could not be found"

There's nothing after that. :/

Edit 2: Even though I'm not using the Steam version, the new DLL keeps being overwritten by the old one after saving, so that seems to be the problem. Instead of using the patcher / launcher method, I went into my program files and replaced the original DLL the engine uses to replace the project ones with. Now it saves with the XP Ace DLL every time.
6
New Projects / Re: Creas
Last post by Ti-Max - August 20, 2021, 02:46:04 pm
Hi guys, I just publish my game "Creas" on the "Steam" and "Itch.io" platforms

https://store.steampowered.com/app/1530040/Creas/

https://ti-max02.itch.io/creas

Feel free to share and give your feedback.

Thank you.
7
General Discussion / Re: CSS Question
Last post by KK20 - August 20, 2021, 01:28:02 am
The absolute closest you can get with just CSS and a textarea alone is to add
white-space: break-spaces;
word-break: break-all;
You will still have one remaining bit of jankiness: when you get close to the right edge and try to add a space after a letter (knowing it will go to the next line), that letter will also move down along with the whitespace character.
8
General Discussion / CSS Question
Last post by Heretic86 - August 18, 2021, 11:06:02 pm
I need to make a Text Area behave like a DOS prompt

Basically so it wraps and spaces are placed like they are in a DOS / CMD window...

This might display a little better...

9
General Discussion / Re: [XP] Problem with error Nu...
Last post by Barabian - August 18, 2021, 07:05:39 am
Thank you for your time. I used this fix and now the error has changed to this:

divided by 0
[0182]ATAN2 FIX:6:in `/'
[0182]ATAN2 FIX:6:in `atan2'
[0165]Sprite Shadow:254:in `update'
...


Edit:
After changing x and y to flat it seems to work fine. Thank you.

module Math
  class << self
    alias fix_atan2_domain_error atan2
    def atan2(y, x)
      if y == 0.0 && x == 0.0
        if 1/x.to_f > 0 # x is 0.0
          return y
        else      # x is -0.0
          return 1/y.to_f > 0 ? Math::PI : -Math::PI
        end
      end
      fix_atan2_domain_error(y, x)
    end
  end
end
10
General Discussion / Re: [XP] Problem with error Nu...
Last post by KK20 - August 18, 2021, 01:01:15 am
It looks like in Ruby 1.9.2, they added domain_errors to the method:
static VALUE
math_atan2(VALUE obj, VALUE y, VALUE x)
{
    double dx, dy;
    Need_Float2(y, x);
    dx = RFLOAT_VALUE(x);
    dy = RFLOAT_VALUE(y);
    if (dx == 0.0 && dy == 0.0) domain_error("atan2");
    if (isinf(dx) && isinf(dy)) domain_error("atan2");
    return DBL2NUM(atan2(dy, dx));
}
https://apidock.com/ruby/v1_9_2_180/Math/atan2/class

From what we can infer from this, @deltax and @deltay are either both (positive or negative) 0.0 or Infinity. I believe it's most likely the former. It's kinda weird why they did this too because in later versions of Ruby they removed it.

What we can do is alias the method so that we can bring it back to how it should behave for this particular case:
module Math
  class << self
    alias fix_atan2_domain_error atan2
    def atan2(y, x)
      if y == 0.0 && x == 0.0
        if 1/x > 0 # x is 0.0
          return y
        else      # x is -0.0
          return 1/y > 0 ? Math::PI : -Math::PI
        end
      end
      fix_atan2_domain_error(y, x)
    end
  end
end
Pages1 2 3 ... 10