Some suggestions from Seph
1) I don't suggest adding \w[n] to the description for weight. For one, you are having to call the set_weight method, which ends up just adding a bunch of new lines of code to go through.
Why not try this:
- class RPG::Item
- # weapon_id => weight
- Weight = {}
- # default weight
- Weight.default = 1
- def weight
- return Weight[@id]
- end
- end
Expand to see the code.
Cuts your 93 lines down pretty quickly. Not as simple as adding the \w in the item description, but a little more efficient.
------------------------------------------------------
2) This code:
- draw_actor_graphic(@actor1, 64, y1)
- draw_actor_graphic(@actor2, 164, y1)
- draw_actor_graphic(@actor3, 264, y1)
- draw_actor_graphic(@actor4, 364, y1)
- draw_actor_name(@actor1, 32, y2)
- draw_actor_name(@actor2, 140, y2)
- draw_actor_name(@actor3, 240, y2)
- draw_actor_name(@actor4, 340, y2)
- self.contents.draw_text(420, 23, 64, 32, $data_system.words.gold)
- self.contents.draw_text(440, 46, 144, 32, $game_party.gold.to_s)
- end
- def reset_actors
- @actor1 = $game_party.actors[0]
- @actor2 = $game_party.actors[1]
- @actor3 = $game_party.actors[2]
- @actor4 = $game_party.actors[3]
-
Expand to see the code.
What happens if there is only 1, 2 or 3 actors in the party?
I also suggest a loop function. Could cut down on some lines:
- class Window_Hud < Window_Base
- def initialize
- super 0, 320, 640, 160
- self.contents = Bitmap.new(width - 32, height - 32)
- self.z = 1
- self.opacity = 160
- self.back_opacity = 120
- refresh
- end
- def refresh
- self.contents.clear
- @actors = $game_party.actors
- y1, y2 = 64, 75
- for i in [email hidden]
- draw_actor_name(@actors[i], 32 + i * 100, y2)
- draw_actor_graphic(@actors[i], 64 + i * 100, y1)
- end
- self.contents.draw_text(420, 23, 64, 32, $data_system.words.gold)
- self.contents.draw_text(440, 46, 144, 32, $game_party.gold.to_s)
- end
- end
Expand to see the code.
------------------------------------------------------
3) This block right here:
- case @cwin.index
- when 0
- $shortcuts[@key] = Scene_Item.new
- when 1
- $shortcuts[@key] = Scene_Status.new
- when 2
- $shortcuts[@key] = Scene_Equip.new
- when 3
- $shortcuts[@key] = Scene_Skill.new
- when 4
- $shortcuts[@key] = Scene_Save.new
- end
Expand to see the code.
You are essentially making new objects and saving them to the $shortcuts variable. I suggest instead setting class name (remove the .new) Then down on your $scene = $shortcuts[0] line, change those to $scene = $shortcuts[0].new. Create the new object then.
I would also suggest adding this little method in Window_Command
- class Window_Command
- def command(index = self.index)
- return @commands[index]
- end
- end
Expand to see the code.
The reason for this is because I have found it better practice to not base command windows based off indexes, but the command itself. This way, you can add other commands without having to change all the index values in your case. So you would have
case @cwin.command
In the end, this makes things easier in the future.
------------------------------------------------------
The only other thing would be to modify Window_Item to not spread the icons by 28, but by the default of 32. This is more a general practice. You could then remove those methods below update_help, that modify the cursor height to 28.
------------------------------------------------------
Finally, I suggest adding a specialized update method in Window_HUD. The purpose of this is to check if the actors change. Just create some some flag variables that hold @character_name, @character_hue and @name of your actors in the refresh method. Then in the update method, compare party size and those instances.
- def refresh
- @actors = $game_party.actors
- @size = @actors.size
- @character_names = @actors.collect {|n| n.character_name}
- @character_hues = @actors.collect {|n| n.character_hue}
- @names = @actors.collect {|n| n.name}
- # ...
-
- def update
- super
- character_names = $game_party.actors.collect {|n| n.character_name}
- character_hues = $game_party.actors.collect {|n| n.character_hue}
- names = $game_party.actors.collect {|n| n.name}
- if @size != @actors.size || character_names != @character_names ||
- character_hues != @character_hues || names != @names
- refresh
- end
Expand to see the code.
Something like that. The same thing is done in Sprite_Character/Sprite_Battler in the update methods if you would like to see another example of this.
------------------------------------------------------
Pretty good script. I like the idea for the shortcuts and the Window_Item modification looks much better than the default one. I don't mean to pick apart your script, just offer guidance, as I see potential in you.
:thumb: