RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

Can it be done?

Started by couldbne1, January 19, 2011, 07:24:41 PM

0 Members and 1 Guest are viewing this topic.

couldbne1

I am useing this script to lvl weapons in my game and it works great for weapons as it is made to now either I am doing something wrong or it is just not set up to work on armor because it seems to do nothing to the armor. My question is can I use this to do the same thing for armor as with the weapons and if so what do I need to change

Exact Script is below
[spoiler]
#===============================================================================
# Leveled Weapons via Actors
# by Deriru
#
# PLEASE GIVE CREDIT IF USED!
#
#-------------------------------------------------------------------------------
# v1.2c: -Added features:
#        --Gain exp ONLY when a switch is turned on.
#        --Allow 0 to be base stat. (by decreasing all weapon stats by 1.)
#
# v1.2b: -Improved aliasing (a bit)
#
# v1.2: -Recoded script for further compatibility. It should be compatible with
#        most item-related scripts.
#
# v1.1: -Added exclusion of level in weapon name.
#       -Fixed two-handed error.
#
# v1.0: -Initial release.
#-------------------------------------------------------------------------------
# What this script does:
# -It creates a weapon system wherein several weapons can be leveled like
#  characters. The weapon can learn skills too, and the weapons stats are based
#  on the actor you have "linked" it to. Basically, the weapon itself is
#  almost an actor.
#-------------------------------------------------------------------------------
# How to use:
# -Create a new actor and configure it. Remember this actor's number since
#  it will be used as a weapon's stats.
# -Put a tag on your preferred like this: <actor_link [actornumber]>
#  eg. <actor_link 3>
#      3 is Bennett's number, therefore making Bennett's stats the specified
#      weapon's stats.
# -To exclude the level from the weapon's name, add the tag <no_lvname>
#-------------------------------------------------------------------------------
# Notes:
# -You don't have to worry about linking a weapon to an actor because the actor
#  is cloned within the weapon. The actor 'inside' the weapon is cloned from
#  the original one, meaning how it gains exp is separate from the actor in the
#  database.
# -The Event Action: Change EXP will not affect your weapons.
# -If BASE_0 is on, the base stat of the weapons will be subtracted by 1.
#-------------------------------------------------------------------------------
# Setup Options:
# GAIN_EXP_VIA_SWITCH: true/false
# -Sets if exp can only be gained via switch.
# GAME_SWITCH = number
# -Number of switch the script would check.
# BASE_0 = true/false
# -If base stat 0 is allowed. (see notes for details)
#-------------------------------------------------------------------------------
# Setup Start!
#-------------------------------------------------------------------------------
module Deriru
  module LvWpVA
    GAIN_EXP_VIA_SWITCH = false
    GAME_SWITCH = 100
    BASE_0 = true
  end
end
#-------------------------------------------------------------------------------
# Setup End!
# DO NOT TOUCH THE PARTS BELOW IF YOU DON'T KNOW WHAT YOU'RE DOING!
#===============================================================================

#===============================================================================
# RPG::Weapon [All are new methods]
#===============================================================================
module RPG
  class Weapon < BaseItem
   
    attr_accessor :actor
    attr_accessor :has_link
   
    def get_exp(int,bool)
      @actor.gain_exp(int,bool)
      get_actorlink
    end
   
    def lv
      return @actor.level
    end

    def get_actorlink
     
      if @actor == nil
        actorno = @note.scan(/<actor_link ([\w]*)>/i)
        unless actorno[0] == nil
          @actor = Marshal.load(Marshal.dump($game_actors[actorno[0][0].to_i]))
          @actor.name = @name
          @orig_name = @name
        end
      end
      unless @actor == nil
        @has_link = true
        @actor.strip_equipment
        @lv = @actor.level
        @name = @note.include?("<no_lvname>") ? "LV#{@lv} " + @orig_name : @orig_name
        @atk = Deriru::LvWpVA::BASE_0 ? @actor.base_atk - 1 : @actor.base_atk
        @def = Deriru::LvWpVA::BASE_0 ? @actor.base_def - 1 : @actor.base_def
        @agi = Deriru::LvWpVA::BASE_0 ? @actor.base_agi - 1 : @actor.base_agi
        @spi = Deriru::LvWpVA::BASE_0 ? @actor.base_spi - 1 : @actor.base_spi
      end
    end
  end
end

#===============================================================================
# Game_Party
#===============================================================================
class Game_Party < Game_Unit
 
  #-----------------------------------------------------------------------------
  # Initialize [Aliased]
  #-----------------------------------------------------------------------------
  alias deriru_ea_init initialize unless $@
  def initialize
    deriru_ea_init
    @cust_weapons = []
  end
 
  #-----------------------------------------------------------------------------
  # Items [Aliased]
  #-----------------------------------------------------------------------------
  alias deriru_ea_itms items  unless $@
  def items
    result = deriru_ea_itms
    for i in @cust_weapons
      result.push(i)
    end
    return result
  end
 
  #-----------------------------------------------------------------------------
  # Item number [Aliased]
  #-----------------------------------------------------------------------------
  alias deriru_ea_item_num item_number unless $@
  def item_number(item)
    return 1 if item.is_a?(RPG::Weapon) && item.has_link
    return deriru_ea_item_num(item)
  end
 
  #-----------------------------------------------------------------------------
  # Gain Item [Aliased]
  #-----------------------------------------------------------------------------
  alias deriru_ea_gainitem gain_item unless $@
  def gain_item(item, n, include_equip = false)
    if item.is_a?(RPG::Weapon)
      item.get_actorlink
      if item.has_link
        n.times do
          @cust_weapons.push(item)
        end
      else
        deriru_ea_gainitem(item, n, include_equip)
      end
    else
      deriru_ea_gainitem(item, n, include_equip)
    end
  end
 
  #-----------------------------------------------------------------------------
  # Lose Item [Aliased]
  #-----------------------------------------------------------------------------
  alias deriru_ea_loseitem lose_item unless $@
  def lose_item(item,n, include_equip = false)
    if item.is_a?(RPG::Weapon) && item.has_link
      @cust_weapons.delete_at(@cust_weapons.index(item))
    else
     deriru_ea_loseitem(item, n, include_equip)
    end
  end
 
end


#===============================================================================
# Game_Actor
#===============================================================================
class Game_Actor < Game_Battler
 
  attr_accessor :weapon1
  attr_accessor :weapon2

  def strip_equipment
    @weapon1 = @weapon2 = nil
    @armor1_id = @armor2_id = @armor3_id = @armor4_id = 0
  end
 
  #-----------------------------------------------------------------------------
  # Setup [Aliased]
  #-----------------------------------------------------------------------------
  alias deriru_ea_setup setup unless $@
  def setup(actor_id)
    deriru_ea_setup(actor_id)
    @weapon1 = @weapon_id == 0 ? nil : $data_weapons[@weapon_id].clone
    @weapon2 = two_swords_style ? armor1_id == 0 ? nil : $data_weapons[armor1_id].clone : nil
    for w in weapons
      w.get_actorlink if w.is_a?(RPG::Weapon)
    end
  end
 
  #-----------------------------------------------------------------------------
  # Weapons [Overwritten]
  #-----------------------------------------------------------------------------
  def weapons
    result = [@weapon1]
    if two_swords_style
      result.push(@weapon2)
    end
    return result
  end
 
  #-----------------------------------------------------------------------------
  # Skill Can Use? [Overwritten]
  #-----------------------------------------------------------------------------
  def skill_can_use?(skill)
    used_by_weapon = false
    for w in weapons
      if w.is_a?(RPG::Weapon) && w.actor != nil
        used_by_weapon = true if w.actor.skill_learn?(skill)
      end
    end
    return false unless skill_learn?(skill) || used_by_weapon
    return super
  end
 
  #-----------------------------------------------------------------------------
  # Change Equip [Aliased] (Copied from xBrokenSin's Dark Cloud Weapons Script)
  #-----------------------------------------------------------------------------
  alias deriru_ea_chgequip change_equip unless $@
  def change_equip(equip_type, item, test = false, two_hand = false)
    if equip_type == 0
      last_item = equips[equip_type]
      unless test
        $game_party.gain_item(last_item, 1)
        $game_party.lose_item(item, 1)
      end
      @weapon_id = item.nil? ? 0 : item.id
      @weapon1 = item
      unless two_hands_legal?
        change_equip(1, nil, test, true)
      end
    elsif equip_type == 1 and two_hand
      last_item = equips[equip_type]
      unless test
        $game_party.gain_item(last_item, 1)
        $game_party.lose_item(item, 1)
      end
      @armor1_id = item.nil? ? 0 : item.id
      @weapon2 = item
      unless two_hands_legal?
        change_equip(0, nil, test, true)
      end
    else
      deriru_ea_chgequip(equip_type, item, test)
    end
  end

  #-----------------------------------------------------------------------------
  # Discard [Aliased] (Copied from xBrokenSin's Dark Cloud Weapons Script)
  #-----------------------------------------------------------------------------
  alias deriru_ea_discequip discard_equip unless $@
  def discard_equip(item)
    if item.is_a?(RPG::Weapon)
      if @weapon1 == item
        @weapon1 = nil
        @weapon_id = 0
      elsif two_swords_style and @weapon_2 == item
        @weapon2 = nil
        @armor1_id = 0
      end
    else
      deriru_ea_discequip(item)
    end
  end
 
  #-----------------------------------------------------------------------------
  # Change Exp [Aliased]
  #-----------------------------------------------------------------------------
  alias deriru_ea_gainexp gain_exp unless $@
  def gain_exp(exp,show)
    deriru_ea_gainexp(exp,show)
    if Deriru::LvWpVA::GAIN_EXP_VIA_SWITCH
      if $game_switches[Deriru::LvWpVA::GAME_SWITCH]
        for w in weapons
          w.get_exp(exp,show) if w.is_a?(RPG::Weapon) && w.actor != nil
        end
      end
    else
      for w in weapons
        w.get_exp(exp,show) if w.is_a?(RPG::Weapon) && w.actor != nil
      end
    end
  end

 
 
end

#===============================================================================
# Window_Skill
#===============================================================================
class Window_Skill < Window_Selectable
 
  #-----------------------------------------------------------------------------
  # Refresh [Overwritten]
  #-----------------------------------------------------------------------------
  def refresh
    @data = []
    for skill in @actor.skills
      @data.push(skill)
      if skill.id == @actor.last_skill_id
        self.index = @data.size - 1
      end
    end
    for w in @actor.weapons
      if w.is_a?(RPG::Weapon) && w.actor != nil
        @data += w.actor.skills
      end
    end
    @data = @data.uniq
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
 
end

#===============================================================================
# Scene_Equip
#===============================================================================
 
class Scene_Equip < Scene_Base
  #-----------------------------------------------------------------------------
  # * Update Status Window (Copied from xBrokenSin's Dark Cloud Weapons Script)
  #-----------------------------------------------------------------------------
  alias deriru_ea_updstwin update_status_window unless $@
  def update_status_window
    if not @item_window.nil? and @item_window.active
      if @equip_window.index == 1 and @actor.two_swords_style
        temp_actor = @actor.clone
        temp_actor.change_equip(@equip_window.index,@item_window.item,true,true)
        new_atk = temp_actor.atk
        new_def = temp_actor.def
        new_spi = temp_actor.spi
        new_agi = temp_actor.agi
        @status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi)
        @status_window.update
        return
      end
    end
    deriru_ea_updstwin
  end
  #-----------------------------------------------------------------------------
  # * Update Item Selection (Copied from xBrokenSin's Dark Cloud Weapons Script)
  #-----------------------------------------------------------------------------
  alias deriru_ea_upditmsel update_item_selection unless $@
  def update_item_selection
    if Input.trigger?(Input::C)
      if @equip_window.index == 1 and @actor.two_swords_style
        Sound.play_equip
        @actor.change_equip(@equip_window.index, @item_window.item, false, true)
        @equip_window.active = true
        @item_window.active = false
        @item_window.index = -1
        @equip_window.refresh
        for item_window in @item_windows
          item_window.refresh
        end
        return
      end
    end
    deriru_ea_upditmsel
  end
end

[/spoiler]

Gracie

Seems like its just for weapons bro!


Grafikal

use /code tags :|

i'll edit them in for you now