RPG-Maker Quartier

Hier dreht sich alles um die RPG-Maker-Reihe von ASCII/Enterbrain. Der RPG-Maker ist ein Tool, mit dem du dir dein eigenes kleines Rollenspiel erstellen kannst. Du findest hier alles, was du dazu brauchst. Aber natürlich umfasst die Community noch mehr!
Aktuelle Zeit: Di Mär 03, 2020 3:01

Alle Zeiten sind UTC + 1 Stunde



Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast



Ein neues Thema erstellen Auf das Thema antworten  [ 10 Beiträge ] 
Autor Nachricht
Offline
Rotfüchschen
Rotfüchschen
Benutzeravatar
Beiträge: 186
Alter: 29
Wohnort: Delmenhorst
 Betreff des Beitrags: Ruby: Problem mit Icons im Status
BeitragVerfasst: Di Mär 22, 2011 13:24 
Hallo Leute^^

Ich hab da ein kleines Problem, mit einem Script, an dem ich arbeite. Um genauer zu sein ist es nur eine Modifikation von Window_Base. Statt Text bei Statusveränderungen (sprich bei Vergiftung, Paraylse, etc), werden stattdessen Icons angezeigt. Klappt wunderbar, nur wenn mein Charakter vergiftet ist, verschwindet sein Affinitäts-Icon, das ich im Statusbildschirm noch anzeigen wollte. Um ehrlich zu sein, ich habe keine Ahnung woran das liegt. Hat eienr von euch vielleicht eine Idee woran das liegt?

Script:
Code:
  #--------------------------------------------------------------------------
  # * Draw State
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
 def draw_actor_state(actor, x, y, width = 120)
   images = make_battler_state_images(actor)
   for i in 0...images.length
     rect = Rect.new(x + (i * 26), y, self.width - 32, 24)
     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
     self.contents.blt(x + (i * 26), y, images[i], Rect.new(0, 0, 24, 24), 255)
   end
 end
  #--------------------------------------------------------------------------
  # * Draw Affinity
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
   def draw_actor_affi(actor, x, y)
  affi = RPG::Cache.character(actor.character_name+"-a", actor.character_hue)
  fw = 150
  fh = 170
  src_rect = Rect.new(0, 0, fw, fh)
  self.contents.blt(x - fw / 50, y - fh, affi, src_rect)
  end


Und ganz unten in Window_Base:
Code:
 bitmap = RPG::Cache.icon(item.icon_name)
    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, item.name)
  end
  def make_battler_state_images(battler)
   images = []
   for i in battler.states
     images.push(RPG::Cache.icon($data_states[i].name))
   end
   return images
       
 end


Am Rest von Window_Base habe ich nicht herum geschraubt, kann aber auch noch den Rest davon posten, falls erwünscht/benötigt. Vielen Dank schon mal im vorraus^^

_________________
Bild


Nach oben
 Profil  
Mit Zitat antworten  

BeitragVerfasst: Di Mär 22, 2011 17:40 
Aus dem hier gezeigten Code kann ich den Fehler grad nicht erkennen.
Poste mal den Menücode, dann kann ichs selber testen.


Nach oben
  
Mit Zitat antworten  
Offline
Rotfüchschen
Rotfüchschen
Benutzeravatar
Beiträge: 186
Alter: 29
Wohnort: Delmenhorst
BeitragVerfasst: Di Mär 22, 2011 23:07 
Bitte.

Code:
#==============================================================================
# ** 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
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super()
    @windowskin_name = $game_system.windowskin_name
    self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    self.x = x
    self.y = y
    self.width = width
    self.height = height
    self.z = 100
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    # Dispose if window contents bit map is set
    if self.contents != nil
      self.contents.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # * Get Text Color
  #     n : text color number (0-7)
  #--------------------------------------------------------------------------
  def text_color(n)
    case n
    when 0
      return Color.new(255, 255, 255, 255)
    when 1
      return Color.new(128, 128, 255, 255)
    when 2
      return Color.new(255, 128, 128, 255)
    when 3
      return Color.new(128, 255, 128, 255)
    when 4
      return Color.new(128, 255, 255, 255)
    when 5
      return Color.new(255, 128, 255, 255)
    when 6
      return Color.new(255, 255, 128, 255)
    when 7
      return Color.new(192, 192, 192, 255)
    else
      normal_color
    end
  end
  #--------------------------------------------------------------------------
  # * Get Normal Text Color
  #--------------------------------------------------------------------------
  def normal_color
    return Color.new(255, 255, 255, 255)
  end
  #--------------------------------------------------------------------------
  # * Get Disabled Text Color
  #--------------------------------------------------------------------------
  def disabled_color
    return Color.new(255, 255, 255, 128)
  end
  #--------------------------------------------------------------------------
  # * Get System Text Color
  #--------------------------------------------------------------------------
  def system_color
    return Color.new(192, 224, 255, 255)
  end
  #--------------------------------------------------------------------------
  # * Get Crisis Text Color
  #--------------------------------------------------------------------------
  def crisis_color
    return Color.new(255, 255, 64, 255)
  end
  #--------------------------------------------------------------------------
  # * Get Knockout Text Color
  #--------------------------------------------------------------------------
  def knockout_color
    return Color.new(255, 64, 0)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # Reset if windowskin was changed
    if $game_system.windowskin_name != @windowskin_name
      @windowskin_name = $game_system.windowskin_name
      self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_graphic(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
  #--------------------------------------------------------------------------
  # * Draw Name
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_name(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 120, 32, actor.name)
  end
  #--------------------------------------------------------------------------
  # * Draw Class
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_class(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 236, 32, actor.class_name)
  end
  #--------------------------------------------------------------------------
  # * Draw Level
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_level(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, "Lv")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Make State Text String for Drawing
  #     actor       : actor
  #     width       : draw spot width
  #     need_normal : Whether or not [normal] is needed (true / false)
  #--------------------------------------------------------------------------
  def make_battler_state_text(battler, width, need_normal)
    # Get width of brackets
    brackets_width = self.contents.text_size("[]").width
    # Make text string for state names
    text = ""
    for i in battler.states
      if $data_states[i].rating >= 1
        if text == ""
          text = $data_states[i].name
        else
          new_text = text + "/" + $data_states[i].name
          text_width = self.contents.text_size(new_text).width
          if text_width > width - brackets_width
            break
          end
          text = new_text
        end
      end
    end
    # If text string for state names is empty, make it [normal]
    if text == ""
      if need_normal
        text = "[Normal]"
      end
    else
      # Attach brackets
      text = "[" + text + "]"
    end
    # Return completed text string
    return text
  end
  #--------------------------------------------------------------------------
  # * Draw State
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
 def draw_actor_state(actor, x, y, width = 120)
   images = make_battler_state_images(actor)
   for i in 0...images.length
     rect = Rect.new(x + (i * 26), y, self.width - 32, 24)
     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
     self.contents.blt(x + (i * 26), y, images[i], Rect.new(0, 0, 24, 24), 255)
   end
 end
  #--------------------------------------------------------------------------
  # * Draw Affinity
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
   def draw_actor_affi(actor, x, y)
  affi = RPG::Cache.character(actor.character_name+"-a", actor.character_hue)
  fw = 150
  fh = 170
  src_rect = Rect.new(0, 0, fw, fh)
  self.contents.blt(x - fw / 50, y - fh, affi, src_rect)
  end
  #--------------------------------------------------------------------------
  # * Draw EXP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_exp(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 24, 32, "Exp")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 14, y, 40, 32, actor.exp_s, 2)
    self.contents.draw_text(x + 40, y, 50, 32, "/", 1)
    self.contents.draw_text(x + 70, y, 20, 32, actor.next_exp_s)
  end
  #--------------------------------------------------------------------------
  # * Draw HP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 144)
    # Draw "HP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 28
      hp_x = x + width - 68
      flag = false
    end
    # Draw HP
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x - 30, y, 48, 32, actor.hp.to_s, 2)
    # Draw MaxHP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 18, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 30, y, 48, 32, actor.maxhp.to_s)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw SP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width = 144)
    # Draw "SP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    # Draw SP
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x - 30, y, 48, 32, actor.sp.to_s, 2)
    # Draw MaxSP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 18, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 30, y, 48, 32, actor.maxsp.to_s)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Parameter
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6)
  #--------------------------------------------------------------------------
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = $data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = $data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = $data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = $data_system.words.str
      parameter_value = actor.str
    when 4
      parameter_name = $data_system.words.dex
      parameter_value = actor.dex
    when 5
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 6
      parameter_name = $data_system.words.int
      parameter_value = actor.int
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 60, y, 36, 32, parameter_value.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Item Name
  #     item : item
  #     x    : draw spot x-coordinate
  #     y    : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y)
    if item == nil
      return
    end
   
    bitmap = RPG::Cache.icon(item.icon_name)
    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, item.name)
  end
  def make_battler_state_images(battler)
   images = []
   for i in battler.states
     images.push(RPG::Cache.icon($data_states[i].name))
   end
   return images
       
 end

end

_________________
Bild


Nach oben
 Profil  
Mit Zitat antworten  

BeitragVerfasst: Mi Mär 23, 2011 3:22 
Ich wollte auch den Menü-Code haben, weil es ziemlich sicher an einem Positionierungsfehler liegt.


Nach oben
  
Mit Zitat antworten  
Offline
Rotfüchschen
Rotfüchschen
Benutzeravatar
Beiträge: 186
Alter: 29
Wohnort: Delmenhorst
BeitragVerfasst: Mi Mär 23, 2011 12:44 
Achso, mein Fehler, sorry.

Code:
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Status < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 740, 580)
    self.contents = Bitmap.new(width - 16, height - 16)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
       
     draw_actor_graphic(@actor, 58, 103)
    draw_actor_affi(@actor, 350, 200 )
    draw_actor_name(@actor, x + 45, y + 97)
    draw_actor_class(@actor, 110, 30)
    draw_actor_level(@actor, 110, 60)
    draw_actor_state(@actor, 190, 30)
    draw_actor_hp(@actor, 220, 60, 172)
    draw_actor_sp(@actor, 220, 90, 172)
    draw_actor_parameter(@actor, 485, 38, 0)
    draw_actor_parameter(@actor, 485, 68, 4)
    draw_actor_parameter(@actor, 485, 100, 2)
    draw_actor_parameter(@actor, 20, 190, 3)
    draw_actor_parameter(@actor, 20, 278, 1)
    draw_actor_parameter(@actor, 20, 250, 5)
    draw_actor_parameter(@actor, 20, 220, 6)
    draw_actor_exp(@actor, 110, 90)
   
   # draw_actor_parameter(@actor, 455, 38, 0)
    #draw_actor_parameter(@actor, 20, 190, 3)
   
    draw_item_name($data_weapons[@actor.weapon_id], 270, 190)
    draw_item_name($data_armors[@actor.armor1_id], 270, 220)
    draw_item_name($data_armors[@actor.armor2_id], 270, 275)
    draw_item_name($data_armors[@actor.armor3_id], 270, 250)
    draw_item_name($data_armors[@actor.armor4_id], 320, 410)
  end
  def dummy
    self.contents.font.color = system_color
    self.contents.draw_text(320, 0, 96, 32, $data_system.words.weapon)
    self.contents.draw_text(320, 176, 96, 32, $data_system.words.armor1)
    self.contents.draw_text(320, 240, 96, 32, $data_system.words.armor2)
    self.contents.draw_text(320, 304, 96, 32, $data_system.words.armor3)
    self.contents.draw_text(320, 368, 96, 32, $data_system.words.armor4)
    draw_item_name($data_weapons[@actor.weapon_id], 320, 50)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 24, 208)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 24, 272)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 24, 336)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 24, 400)
  end
end


Und zur sicherheit noch Scene_Status:

Code:
#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
#  This class performs status screen processing.
#==============================================================================

class Scene_Status
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make status window
    @status_window = Window_Status.new(@actor)
    @status_window.back_opacity = 0
   
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
      @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
       
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(3)
      return
    end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different status screen
      $scene = Scene_Status.new(@actor_index)
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different status screen
      $scene = Scene_Status.new(@actor_index)
      return
    end
  end
end

_________________
Bild


Nach oben
 Profil  
Mit Zitat antworten  

BeitragVerfasst: Mi Mär 23, 2011 18:54 
Abgesehen davon, dass die Positionierung einiger Elemente etwas ungünstig ist, was aber deine Sache ist, kann ich keinen Fehler erkennen.
Alle Test-Grafiken werden korrekt angezeigt.
Ich könnte das noch mit den Originalgrafiken testen, aber da würde ich sicher auch nichts finden.
Wenn es aber weder an Window_Base noch am Window_Status liegt, woran dann?

Die Initialisierungsgröße vom Status-Fenster ist aber ziemlich daneben. Ist das Absicht?


Nach oben
  
Mit Zitat antworten  
Offline
Rotfüchschen
Rotfüchschen
Benutzeravatar
Beiträge: 186
Alter: 29
Wohnort: Delmenhorst
BeitragVerfasst: Do Mär 24, 2011 10:16 
Danke fürs durchsehen^^

Bei der Initialisierungsgröße hab ich mir eigentlich nichts gedacht, der Status ist noch im Aufbau, einiges wird sich noch ändern.
Bis jetzt sieht es so aus:

Bild

_________________
Bild


Nach oben
 Profil  
Mit Zitat antworten  

BeitragVerfasst: Do Mär 24, 2011 16:30 
Na, vielleicht findest du den Fehler noch selbst. Manchmal brauch man nur etwas Zeit um von seiner eingefahrenen Schiene zu kommen und das Ganze von einer anderen Seite zu sehen.

Ok, mit dem Hintergrundbild sieht das schon besser aus, als im Standard-Fenster^^
Du hättest sogar genug platz, die Attributsnamen auszuschreiben.
Und warum gibt es eine P.Ver, wenn es keine M.Ver gibt?


Nach oben
  
Mit Zitat antworten  
Offline
Rotfüchschen
Rotfüchschen
Benutzeravatar
Beiträge: 186
Alter: 29
Wohnort: Delmenhorst
BeitragVerfasst: Do Mär 24, 2011 18:28 
Ich war mir nicht ganz sicher wofür die einzelnen Werte stehen, es schien mir, als ob es Stärke und Verteidigung zweimal gibt. Deshalb sind ATK, Vert und RES oben in der Ecke und nicht bei den anderen Werten, weil die scheinbar von auch von der Ausrüstung mit abhängen und weil ich nicht zweimal einen Wert namens "Vert" wollte, wurde der eine zur P.Ver.

_________________
Bild


Nach oben
 Profil  
Mit Zitat antworten  

BeitragVerfasst: Do Mär 24, 2011 23:17 
Vom Angreifer aus gesehen sind die Werte so:

Schaden = (self.ATK - other.PDef / 2) * (self.STR + 20) / 20

Treffer = 100 - ((8 * other.Agi / self.Dex) + oter.eva) in %

MDef gilt analog bei Magieangriffen.


Nach oben
  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 10 Beiträge ] 

Alle Zeiten sind UTC + 1 Stunde


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de