[resolved]2 handed weapons

Started by ozoke, November 17, 2008, 08:41:00 pm

Previous topic - Next topic

ozoke

November 17, 2008, 08:41:00 pm Last Edit: November 18, 2008, 07:55:06 am by ozoke
heya guys,

im trying my hand at scripting and i decided to try and make or edit a script that prevents me wearing a sheild if im using a certain weapon, so for example, i have a player that can use all types of melee weapons but when he using a 1 handed wep he can equip a sheild, but when he is using a 2 handed wep he cant.

i thought that an edit to window_equipright was the way to do it and this is what i done.
#==============================================================================
# ** Window_EquipRight
#------------------------------------------------------------------------------
#  This window displays items the actor is currently equipped with on the
#  equipment screen.
#==============================================================================
HANDED_NAME = "2h"
  $data_system = load_data("Data/System.rxdata")
$h_element_id = $data_system.elements.index(HANDED_NAME)

class Window_EquipRight < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(272, 64, 368, 192)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Item Acquisition
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if $data_weapons[@actor.weapon_id].element_set.include?($h_element_id)
    self.contents.clear
    @data = []
    @data.push($data_weapons[@actor.weapon_id])
    @data.push($data_armors[@actor.armor2_id])
    @data.push($data_armors[@actor.armor3_id])
    @data.push($data_armors[@actor.armor4_id])
    @item_max = @data.size
    self.contents.font.color = system_color
    self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
    self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
    self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
    self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4)
    draw_item_name(@data[0], 92, 32 * 0)
    draw_item_name(@data[2], 92, 32 * 2)
    draw_item_name(@data[3], 92, 32 * 3)
    draw_item_name(@data[4], 92, 32 * 4)
    end
  else if
    self.contents.clear
    @data = []
    @data.push($data_weapons[@actor.weapon_id])
    @data.push($data_armors[@actor.armor1_id])
    @data.push($data_armors[@actor.armor2_id])
    @data.push($data_armors[@actor.armor3_id])
    @data.push($data_armors[@actor.armor4_id])
    @item_max = @data.size
    self.contents.font.color = system_color
    self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
    self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1)
    self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
    self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
    self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4)
    draw_item_name(@data[0], 92, 32 * 0)
    draw_item_name(@data[1], 92, 32 * 1)
    draw_item_name(@data[2], 92, 32 * 2)
    draw_item_name(@data[3], 92, 32 * 3)
    draw_item_name(@data[4], 92, 32 * 4)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end


but it dont work and i get this error after unequiping a weapon,
Spoiler: ShowHide


My thinking was that if added a dummy element to '2handed' weapons i could get the window to not show the sheild eqiup option.
im probably just doing this all wrong.

im using RMXP, with Blizz ABS 1.99 and tons of addons 6.71
any advice and help is appreciated.

thanks

Aqua

Instead of
HANDED_NAME = "2h"
  $data_system = load_data("Data/System.rxdata")
$h_element_id = $data_system.elements.index(HANDED_NAME)


Use
$h_element_id = ID_NUMBER_OF_THE_ELEMENT_OF_2H


I think this should work... since
 if $data_weapons[@actor.weapon_id].element_set.include?($h_element_id)

requires that $h_element_id is a numeric value.

ozoke

ok i changed the code and added a bit more to make the items and names line up properly but i can still equip a sheild. id assume that i would have to change scene_equip and disable the item window for sheilds, il play around with that and see what i can get.

thanks aqua

Aqua

Hmmm actually... I think the part that deals with /actually/ equipping the items is in Scene_Equip in the refresh method

Spoiler: ShowHide
  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)
    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
      # 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)
    end
  end


You'd need to concentrate on two parts:

Spoiler: ShowHide
    @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)


and

Spoiler: ShowHide
    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


Or... you could get an advanced equipment script that allows for this.  Gimme a moment and I'll search for you.

ozoke

yeah i changed those parts and now i cant equip the sheild with two handed weapons but when it updates the new equipment it updates in the wrong slot.

if theres already scripts like this it would save me alot of time and trial and error.

thanks again aqua

Aqua

Hmm... I can't seem to find one that I remember is compatible with Blizz-ABS...

Here is a very bulk package about equipments... but I'm not completely sure if it works with Blizz-ABS...

winkio

I'll make it for you if you don't find it.

ozoke

November 17, 2008, 10:32:22 pm #7 Last Edit: November 17, 2008, 10:36:20 pm by ozoke
thanks aqua, ill try it out now with blizz abs.

and thanks winkio if i cant get this working i would really aprreciate that.

edit
this is working fine so far, just did a few tests with just the two handed weapon, i was alos looking to add extra armour slots so i will use this one.

thanks for your help aqua