I have been trying to make a Luck attribute for my game. I would like to have the attribute tied to the Actors, Weapons & Armors. I seem to be having success with creating it for the Actors, but not so sure about the Weapons & Armors. I attempted to alias the Modules for Weapon and Armor to include the stat, but I'm not sure if it applied.
Here is basically what I am trying to do:
When you call Scene_Equip, I modified what information is passed to set_new_parameters.
def refresh
# Set item window to visible
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
# Get currently equipped item
item1 = @right_window.item
# Set current item window to @item_window
case @right_window.index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
# If right window is active
if @right_window.active
# Erase parameters for after equipment change
@left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil, nil)
end
# If item window is active
if @item_window.active
# Get currently selected item
item2 = @item_window.item
# Change equipment
last_hp = @actor.hp
last_sp = @actor.sp
@actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
# Get parameters for after equipment change
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
new_str = @actor.str
new_dex = @actor.dex
new_agi = @actor.agi
new_int = @actor.int
new_eva = @actor.eva
new_luck = @actor.luck
# Return equipment
@actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
@actor.hp = last_hp
@actor.sp = last_sp
# Draw in left window
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, new_luck)
end
end
Now in the EquipLeft window, I modified it to show all the stats (not just the two are three that were default) and to show increases or decreases in each attribute through color changes to the stats, depending on the weapon/armor in the @item_window.
#==============================================================================
# ** Window_EquipLeft
#------------------------------------------------------------------------------
# This window displays actor parameter changes on the equipment screen.
#==============================================================================
class Window_EquipLeft < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 64, 272, 192)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
if @new_atk != nil
self.contents.font.color = text_color(0)
self.contents.draw_text(4,32,80,32,"ATK")
if @new_atk > @actor.atk
self.contents.font.color = text_color(6)
elsif @new_atk < @actor.atk
self.contents.font.color = text_color(2)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(30,32,80,32, @new_atk.to_s, 2)
else
self.contents.font.color = text_color(0)
self.contents.draw_text(4,32,80,32,"ATK")
self.contents.draw_text(30,32,80,32,@actor.atk.to_s,2)
end
if @new_pdef != nil
self.contents.font.color = text_color(0)
self.contents.draw_text(4,64,80,32,"PDEF")
if @new_pdef > @actor.pdef
self.contents.font.color = text_color(6)
elsif @new_pdef < @actor.pdef
self.contents.font.color = text_color(2)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(30,64,80,32,@new_pdef.to_s,2)
else
self.contents.font.color = text_color(0)
self.contents.draw_text(4,64,80,32,"PDEF")
self.contents.draw_text(30,64,80,32,@actor.pdef.to_s,2)
end
if @new_mdef != nil
self.contents.font.color = text_color(0)
self.contents.draw_text(4,96,80,32,"MDEF")
if @new_mdef > @actor.mdef
self.contents.font.color = text_color(6)
elsif @new_mdef < @actor.mdef
self.contents.font.color = text_color(2)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(30,96,80,32,@new_mdef.to_s,2)
else
self.contents.font.color = text_color(0)
self.contents.draw_text(4,96,80,32,"MDEF")
self.contents.draw_text(30,96,80,32,@actor.mdef.to_s,2)
end
if @new_str != nil
self.contents.font.color = text_color(0)
self.contents.draw_text(134,0,80,32,"STR")
if @new_str > @actor.str
self.contents.font.color = text_color(6)
elsif @new_str < @actor.str
self.contents.font.color = text_color(2)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(160,0,80,32,@new_str.to_s,2)
else
self.contents.font.color = text_color(0)
self.contents.draw_text(134,0,80,32,"STR")
self.contents.draw_text(160,0,80,32,@actor.str.to_s,2)
end
if @new_dex != nil
self.contents.font.color = text_color(0)
self.contents.draw_text(134,32,80,32,"DEX")
if @new_dex > @actor.dex
self.contents.font.color = text_color(6)
elsif @new_dex < @actor.dex
self.contents.font.color = text_color(2)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(160,32,80,32,@new_dex.to_s,2)
else
self.contents.font.color = text_color(0)
self.contents.draw_text(134,32,80,32,"DEX")
self.contents.draw_text(160,32,80,32,@actor.dex.to_s,2)
end
if @new_agi != nil
self.contents.font.color = text_color(0)
self.contents.draw_text(134,64,80,32,"AGI")
if @new_agi > @actor.agi
self.contents.font.color = text_color(6)
elsif @new_agi < @actor.agi
self.contents.font.color = text_color(2)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(160,64,80,32,@new_agi.to_s,2)
else
self.contents.font.color = text_color(0)
self.contents.draw_text(134,64,80,32,"AGI")
self.contents.draw_text(160,64,80,32,@actor.agi.to_s,2)
end
if @new_int != nil
self.contents.font.color = text_color(0)
self.contents.draw_text(134,96,80,32,"INT")
if @new_int > @actor.int
self.contents.font.color = text_color(6)
elsif @new_int < @actor.int
self.contents.font.color = text_color(2)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(160,96,80,32,@new_int.to_s,2)
else
self.contents.font.color = text_color(0)
self.contents.draw_text(134,96,80,32,"INT")
self.contents.draw_text(160,96,80,32,@actor.int.to_s,2)
end
if @new_eva != nil
self.contents.font.color = text_color(0)
self.contents.draw_text(134,128,80,32,"EVA")
if @new_eva > @actor.eva
self.contents.font.color = text_color(6)
elsif @new_eva < @actor.eva
self.contents.font.color = text_color(2)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(160,128,80,32,@new_eva.to_s,2)
else
self.contents.font.color = text_color(0)
self.contents.draw_text(134,128,80,32,"EVA")
self.contents.draw_text(160,128,80,32,@actor.eva.to_s,2)
end
if @new_luck != nil
self.contents.font.color = text_color(0)
self.contents.draw_text(4,128,80,32,"LUCK")
if @new_luck > @actor.luck
self.contents.font.color = text_color(6)
elsif @new_luck < @actor.luck
self.contents.font.color = text_color(2)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(30,128,80,32,@new_luck.to_s,2)
else
self.contents.font.color = text_color(0)
self.contents.draw_text(4,128,80,32,"LUCK")
draw_actor_luck(@actor,-10,128)
end
end
#--------------------------------------------------------------------------
# * Set parameters after changing equipment
# new_atk : attack power after changing equipment
# new_pdef : physical defense after changing equipment
# new_mdef : magic defense after changing equipment
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, new_luck)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef or @new_str != new_str or @new_dex != new_dex or @new_agi != new_agi or @new_int != new_int or @new_eva != new_eva or @new_luck != new_luck
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
@new_str = new_str
@new_dex = new_dex
@new_agi = new_agi
@new_int = new_int
@new_eva = new_eva
@new_luck = new_luck
refresh
end
end
end
So basically, I would like to figure out how to set it up so that the Luck attribute completely mimics all the other attributes (e.g. str, mdef, eva, etc...).
I have been trying to make a Luck attribute for my game. I would like to have the attribute tied to the Actors, Weapons & Armors. I seem to be having success with creating it for the Actors, but not so sure about the Weapons & Armors. I attempted to alias the Modules for Weapon and Armor to include the stat, but I'm not sure if it applied.
Here is basically what I am trying to do:
When you call Scene_Equip, I modified what information is passed to set_new_parameters.
def refresh # Set item window to visible @item_window1.visible = (@right_window.index == 0) @item_window2.visible = (@right_window.index == 1) @item_window3.visible = (@right_window.index == 2) @item_window4.visible = (@right_window.index == 3) @item_window5.visible = (@right_window.index == 4) # Get currently equipped item item1 = @right_window.item # Set current item window to @item_window case @right_window.index when 0 @item_window = @item_window1 when 1 @item_window = @item_window2 when 2 @item_window = @item_window3 when 3 @item_window = @item_window4 when 4 @item_window = @item_window5 end # If right window is active if @right_window.active # Erase parameters for after equipment change @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil, nil) end # If item window is active if @item_window.active # Get currently selected item item2 = @item_window.item # Change equipment last_hp = @actor.hp last_sp = @actor.sp @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id) # Get parameters for after equipment change new_atk = @actor.atk new_pdef = @actor.pdef new_mdef = @actor.mdef new_str = @actor.str new_dex = @actor.dex new_agi = @actor.agi new_int = @actor.int new_eva = @actor.eva new_luck = @actor.luck # Return equipment @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id) @actor.hp = last_hp @actor.sp = last_sp # Draw in left window @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, new_luck) end endNow in the EquipLeft window, I modified it to show all the stats (not just the two are three that were default) and to show increases or decreases in each attribute through color changes to the stats, depending on the weapon/armor in the @item_window.
#============================================================================== # ** Window_EquipLeft #------------------------------------------------------------------------------ # This window displays actor parameter changes on the equipment screen. #============================================================================== class Window_EquipLeft < Window_Base #-------------------------------------------------------------------------- # * Object Initialization # actor : actor #-------------------------------------------------------------------------- def initialize(actor) super(0, 64, 272, 192) self.contents = Bitmap.new(width - 32, height - 32) @actor = actor refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear draw_actor_name(@actor, 4, 0) if @new_atk != nil self.contents.font.color = text_color(0) self.contents.draw_text(4,32,80,32,"ATK") if @new_atk > @actor.atk self.contents.font.color = text_color(6) elsif @new_atk < @actor.atk self.contents.font.color = text_color(2) else self.contents.font.color = text_color(0) end self.contents.draw_text(30,32,80,32, @new_atk.to_s, 2) else self.contents.font.color = text_color(0) self.contents.draw_text(4,32,80,32,"ATK") self.contents.draw_text(30,32,80,32,@actor.atk.to_s,2) end if @new_pdef != nil self.contents.font.color = text_color(0) self.contents.draw_text(4,64,80,32,"PDEF") if @new_pdef > @actor.pdef self.contents.font.color = text_color(6) elsif @new_pdef < @actor.pdef self.contents.font.color = text_color(2) else self.contents.font.color = text_color(0) end self.contents.draw_text(30,64,80,32,@new_pdef.to_s,2) else self.contents.font.color = text_color(0) self.contents.draw_text(4,64,80,32,"PDEF") self.contents.draw_text(30,64,80,32,@actor.pdef.to_s,2) end if @new_mdef != nil self.contents.font.color = text_color(0) self.contents.draw_text(4,96,80,32,"MDEF") if @new_mdef > @actor.mdef self.contents.font.color = text_color(6) elsif @new_mdef < @actor.mdef self.contents.font.color = text_color(2) else self.contents.font.color = text_color(0) end self.contents.draw_text(30,96,80,32,@new_mdef.to_s,2) else self.contents.font.color = text_color(0) self.contents.draw_text(4,96,80,32,"MDEF") self.contents.draw_text(30,96,80,32,@actor.mdef.to_s,2) end if @new_str != nil self.contents.font.color = text_color(0) self.contents.draw_text(134,0,80,32,"STR") if @new_str > @actor.str self.contents.font.color = text_color(6) elsif @new_str < @actor.str self.contents.font.color = text_color(2) else self.contents.font.color = text_color(0) end self.contents.draw_text(160,0,80,32,@new_str.to_s,2) else self.contents.font.color = text_color(0) self.contents.draw_text(134,0,80,32,"STR") self.contents.draw_text(160,0,80,32,@actor.str.to_s,2) end if @new_dex != nil self.contents.font.color = text_color(0) self.contents.draw_text(134,32,80,32,"DEX") if @new_dex > @actor.dex self.contents.font.color = text_color(6) elsif @new_dex < @actor.dex self.contents.font.color = text_color(2) else self.contents.font.color = text_color(0) end self.contents.draw_text(160,32,80,32,@new_dex.to_s,2) else self.contents.font.color = text_color(0) self.contents.draw_text(134,32,80,32,"DEX") self.contents.draw_text(160,32,80,32,@actor.dex.to_s,2) end if @new_agi != nil self.contents.font.color = text_color(0) self.contents.draw_text(134,64,80,32,"AGI") if @new_agi > @actor.agi self.contents.font.color = text_color(6) elsif @new_agi < @actor.agi self.contents.font.color = text_color(2) else self.contents.font.color = text_color(0) end self.contents.draw_text(160,64,80,32,@new_agi.to_s,2) else self.contents.font.color = text_color(0) self.contents.draw_text(134,64,80,32,"AGI") self.contents.draw_text(160,64,80,32,@actor.agi.to_s,2) end if @new_int != nil self.contents.font.color = text_color(0) self.contents.draw_text(134,96,80,32,"INT") if @new_int > @actor.int self.contents.font.color = text_color(6) elsif @new_int < @actor.int self.contents.font.color = text_color(2) else self.contents.font.color = text_color(0) end self.contents.draw_text(160,96,80,32,@new_int.to_s,2) else self.contents.font.color = text_color(0) self.contents.draw_text(134,96,80,32,"INT") self.contents.draw_text(160,96,80,32,@actor.int.to_s,2) end if @new_eva != nil self.contents.font.color = text_color(0) self.contents.draw_text(134,128,80,32,"EVA") if @new_eva > @actor.eva self.contents.font.color = text_color(6) elsif @new_eva < @actor.eva self.contents.font.color = text_color(2) else self.contents.font.color = text_color(0) end self.contents.draw_text(160,128,80,32,@new_eva.to_s,2) else self.contents.font.color = text_color(0) self.contents.draw_text(134,128,80,32,"EVA") self.contents.draw_text(160,128,80,32,@actor.eva.to_s,2) end if @new_luck != nil self.contents.font.color = text_color(0) self.contents.draw_text(4,128,80,32,"LUCK") if @new_luck > @actor.luck self.contents.font.color = text_color(6) elsif @new_luck < @actor.luck self.contents.font.color = text_color(2) else self.contents.font.color = text_color(0) end self.contents.draw_text(30,128,80,32,@new_luck.to_s,2) else self.contents.font.color = text_color(0) self.contents.draw_text(4,128,80,32,"LUCK") draw_actor_luck(@actor,-10,128) end end #-------------------------------------------------------------------------- # * Set parameters after changing equipment # new_atk : attack power after changing equipment # new_pdef : physical defense after changing equipment # new_mdef : magic defense after changing equipment #-------------------------------------------------------------------------- def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, new_luck) if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef or @new_str != new_str or @new_dex != new_dex or @new_agi != new_agi or @new_int != new_int or @new_eva != new_eva or @new_luck != new_luck @new_atk = new_atk @new_pdef = new_pdef @new_mdef = new_mdef @new_str = new_str @new_dex = new_dex @new_agi = new_agi @new_int = new_int @new_eva = new_eva @new_luck = new_luck refresh end end endSo basically, I would like to figure out how to set it up so that the Luck attribute completely mimics all the other attributes (e.g. str, mdef, eva, etc...).
Thanks to anyone that can help!
Share this post
Link to post
Share on other sites