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.

[Resolved]Help with Prexus Beastiary Script

Status
Not open for further replies.
I'm using Prexus' Beastiary Script and I'm having some trouble. The only problem is that when it displays the enemies drop item, it doesn't display the name, but a bunch of strange numbers and letters. Here is the script

Code:
# ------------------------------------------------------------------- #
# PXMod::Beastiary                                                    #
#   By Prexus                                                         #
# Description: Allows you to view enemies in the game and their stats #
# ------------------------------------------------------------------- #

module RPG
  class Enemy
    alias pxmod_r_enemy_initialize initialize
    def initialize
      pxmod_r_enemy_initialize
      @seen = false
    end
    attr_accessor :seen
    def set_seen(yes = false)
      @seen = yes
    end
  end
end

class Game_Enemy < Game_Battler
  alias pxmod_g_enemy_initialize initialize
  def initialize(troop_id, member_index)
    pxmod_g_enemy_initialize(troop_id, member_index)
    enemy = $data_enemies[@enemy_id]
    enemy.set_seen(true)
  end
end

module PXMod
  class Window_BeastList < Window_Selectable
    def initialize
      super(480, 64, 160, 416);
      self.index = 0;
      refresh;
    end
    def enemy
      return @data[self.index];
    end
    def refresh
      if self.contents != nil
        self.contents.dispose;
        self.contents = nil;
      end
      @data = [];
      for i in 1...$data_enemies.size
        if $data_enemies[i].seen
          @data.push($data_enemies[i]);
        else
          @data.push('????');
        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_item(i);
        end
      end
    end
    def draw_item(index)
      item = @data[index];
      x = 4;
      y = index * 32;
      case item
      when RPG::Enemy
        self.contents.draw_text_shadow(x, y, self.contents.width - 8, 32,
          "#{item.id}: #{item.name}", 0);
      else
        self.contents.draw_text_shadow(x, y, self.contents.width - 8, 32, item, 1);
      end
    end
  end
  
  class Window_BeastInfo < Window_Base
    def initialize
      super(0, 64, 480, 416);
      self.contents = Bitmap.new(width - 32, height - 32);
    end
    def refresh(enemy)
      return if enemy == @enemy;
      @enemy = enemy;
      self.contents.clear;
      third_width = (self.contents.width - 8) / 3;
      y_offset = 192;
      if @enemy.is_a?(String);
        rect = Rect.new(0, 0, third_width+8, 32);
        rect2 = Rect.new(1, 1, third_width+6, 30);
        self.contents.fill_rect(rect, Color.new(0, 0, 32, 160));
        self.contents.fill_rect(rect2, Color.new(32, 32, 64, 114));
        rect = Rect.new(0, y_offset, self.contents.width, self.contents.height - 192);
        rect2 = Rect.new(1, y_offset + 1, self.contents.width - 2, self.contents.height - 194);
        self.contents.fill_rect(rect, Color.new(0, 0, 32, 160));
        self.contents.fill_rect(rect2, Color.new(32, 32, 64, 114));
        return
      else
        bitmap = RPG::Cache.battler(@enemy.battler_name, @enemy.battler_hue);
        src_rect = Rect.new(0, 0, bitmap.width/4, bitmap.height/4);
        x = 230;
        self.contents.blt(x, 0, bitmap, src_rect);
        rect = Rect.new(0, 0, third_width+8, 32);
        rect2 = Rect.new(1, 1, third_width+6, 30);
        self.contents.fill_rect(rect, Color.new(0, 0, 32, 160));
        self.contents.fill_rect(rect2, Color.new(32, 32, 64, 114));
        rect = Rect.new(0, y_offset, self.contents.width, self.contents.height - 192);
        rect2 = Rect.new(1, y_offset + 1, self.contents.width - 2, self.contents.height - 194);
        self.contents.fill_rect(rect, Color.new(0, 0, 32, 160));
        self.contents.fill_rect(rect2, Color.new(32, 32, 64, 114));
      end
      self.contents.draw_text_shadow(4, 0, third_width, 32, @enemy.name, 1);
      self.contents.draw_text_shadow(4, y_offset, third_width, 32,
                              "#{$data_system.words.hp}: #{@enemy.maxhp}", 0);
      self.contents.draw_text_shadow(third_width, y_offset, third_width, 32, 
                              "#{$data_system.words.sp}: #{@enemy.maxsp}", 0);
      self.contents.draw_text_shadow(4, y_offset + 32, third_width, 32,
                              "#{$data_system.words.str}: #{@enemy.str}", 0);
      self.contents.draw_text_shadow(4, y_offset + 64, third_width, 32,
                              "#{$data_system.words.dex}: #{@enemy.dex}", 0);
      self.contents.draw_text_shadow(third_width, y_offset + 32, third_width, 32,
                              "#{$data_system.words.agi}: #{@enemy.agi}", 0);
      self.contents.draw_text_shadow(third_width, y_offset + 64, third_width, 32,
                              "#{$data_system.words.int}: #{@enemy.int}", 0);
      self.contents.draw_text_shadow(third_width*2, y_offset + 32, third_width, 32,
                              "EXP: #{@enemy.exp}", 0);
      self.contents.draw_text_shadow(third_width*2, y_offset + 64, third_width, 32,
                              "#{$data_system.words.gold}: #{@enemy.gold}", 0);
      self.contents.draw_text_shadow(4, y_offset + 128, third_width, 32,
                              "#{$data_system.words.atk}: #{@enemy.atk}", 0);
      self.contents.draw_text_shadow(4, y_offset + 160, third_width, 32,
                              "Evasion: #{@enemy.eva}", 0);
      self.contents.draw_text_shadow(third_width, y_offset + 128, third_width, 32,
                              "#{$data_system.words.pdef}: #{@enemy.pdef}", 0);
      self.contents.draw_text_shadow(third_width, y_offset + 160, third_width, 32,
                              "#{$data_system.words.mdef}: #{@enemy.mdef}", 0);
      self.contents.draw_text_shadow(third_width*2, y_offset + 128, third_width, 32,
                              "Item Dropped:", 0);
      if @enemy.item_id > 0
        item_name = $data_items[@enemy.item_id];
      elsif @enemy.weapon_id > 0
        item_name = $data_weapons[@enemy.weapon_id];
      elsif @enemy.armor_id > 0
        item_name = $data_armors[@enemy.armor_id];
      else
        item_name = 'No Treasure';
      end
      self.contents.draw_text_shadow(third_width*2, y_offset + 160, third_width, 32,
                              "#{item_name}", 0);
    end
  end
  
  class Scene_Beastiary
    def main
      @help_window = PXMod::Window_Help.new;
      @help_window.set_text("Press Cancel to return to the Menu.", 1)
      @beast_list = PXMod::Window_BeastList.new;
      @beast_info = PXMod::Window_BeastInfo.new;
      @beast_info.refresh(@beast_list.enemy);
      Graphics.transition;
      loop do
        Graphics.update;
        Input.update;
        update;
        if $scene != self
          break;
        end
      end
      Graphics.freeze;
      @help_window.dispose;
      @beast_list.dispose;
      @beast_info.dispose;
    end
    def update
      @help_window.update;
      @beast_list.update;
      @beast_info.refresh(@beast_list.enemy);
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        $scene = Scene_Menu.new(8)
        return
      end
    end
  end
end

All I need is so that it displays the name of the item that the enemy drops, with it's icon if possible. The most important thing is the name. Thank you to whoever can do this.
 
Wrong forum. This should be in the RGSS support one.

For your problem, look at this bit near the bottom:
Code:
      if @enemy.item_id > 0
        item_name = $data_items[@enemy.item_id];
      elsif @enemy.weapon_id > 0
        item_name = $data_weapons[@enemy.weapon_id];
      elsif @enemy.armor_id > 0
        item_name = $data_armors[@enemy.armor_id];
      else
        item_name = 'No Treasure';
      end
You need to add .name after each of the ]s.
 
This topic has been resolved. If kaze950 or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

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