RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Weapons by Ranks by Uresk (RMVX to RMVXA Script conversion/enhancement)

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 83

In my game, I'm planning for a system where the base damage an actor does with a weapon, further altered by skill formulae, is dependent on his skill (out of 100) with the weapon he has equipped (e.g., value = a.atk * weapskill/50), and where a percentage of each battle's EXP is put towards advancing the actor's weapon rank.

Finding no such script for RMVXA, I came upon a script called "Weapons by Ranks" for RMVX:
http://www.rpgrevolution.com/forums/?showtopic=17705
(which requires TagNote(2.0):
http://www.rpgrevolution.com/forums/index.php?showtopic=10804)

Using my rudimentary knowledge of RGSS2/3, I managed to translate/alter enough of it get it to a half-working state, mainly altering things like how RGSS3 handles windows and scenes and changing some terminology here and there. I noticed, however, that the script makes up for features that are now existing in RMVXA that didn't in RMVX, like weapon types and finding terms in notetags. Also, the original script's use of rank titles (e.g., "Rookie", "Master") weren't really what I was going for; trying to have ranks instead of "0", "1", "2" and so-on is kind of impractical. I'm still kind of hung up on how to give the weapon rank its own EXP, as well; that part of the script didn't translate too well.

In short, I would like the script, being inefficient and outdated but still having the functionality that I need, instead of having its own Weapon Types, to access and display the database's "Weapon Types", (thereby not needing to read anything in weapon notetags) as well as have removed the "rank titles" in favor of a straight "out of 100" rank system.

Here is the script I'm using right now, which works right up until the end-of-battle scene where EXP is given, then displaying an error of: "Script 'Weapon By Ranks' line121: TypeError occurred. no implicit conversion from nil to integer."
Code: [Select]
################################################################################
#  Script: Weapons by ranks                                                   
#  Version: 1.2                                                             
#  Author: uresk (AKA 332211)                                                 
#  Requires: Tagnote 2.0+ (by Queex)                                         
################################################################################
#                                                                             
# Customize: RANKS                                                           
# RANKS = [lowest to highest]                                               
# RANKS = ["None","Rookie","Master"]                                     
#                                                                           
# Customize: $exp_ranks                                                       
# $exp_ranks = [0, exp needed for rank 1, exp for rank 2...]                 
# $exp_ranks = [0,100,5000,10000]                                             
#                                                                             
# Customize: EXP_rate                                                         
# regular experience multiplier:                                           
# Ex: You kill Rat and win 13 exp, exp for ranks will be 13 * EXP_rate       
# EXP_rate = number                                                           
#                                                                             
# Customize: $weapon_skills                                                   
# names of your skills in weapons; must be one word                           
# $weapon_skills = ["Swords","Bows","Staffs"]                                 
#                                                                             
# Change_Damage = true                                                       
# True: the actor's rank will afect regular attack damage                     
# False: nothing happens                                                     
#                                                                             
# Damage_multiplier = [0.75, 1, 1.25]                                         
# Ex: If Ralph is a rookie using swords damage will be reduced to 3/4.       
# Ex_2: If ralph is a Master damage will be multiplied by 5/4                 
#                                                                             
# Change_crit = true                                                         
# True: the actor's rank will afect regular critical chance                   
# False: nothing happens                                                     
#                                                                             
# Added_crit = [0, 2, 4]                                                     
# Ex: If Ralph's a rookie no bonus critical but if he is a master           
# the chance for critical will go up by 4%                                   
#                                                                             
# Critical_Adjustment = 3                                                     
# Critical damage multiplier                                                 
# Critical damage = damage * Critical_Adjustment                             
#                                                                             
# Customize: Class_Limit                                                     
# True: a hero can only equip weapons assigned for his class                 
# False: a hero can equip every weapon, regardless of his class               
#                                                                             
################################################################################
#                                                                             
# Database                                                                   
# In the notes field of a weapon write down <mastery Swords> or <mastery Bows>
# to determine weapon 'type' and <rank None>,<rank Rookie> to choose the rank
# needed to equip that weapon.                                               
#                                                                             
################################################################################
#==============================================================================#
#  ** Begin Configuration                                                           
#==============================================================================#
module Vocab
  Rank_Up = "%s is a %s using %s." #message for when rank goes up
  #%s - actor name; new rank; rank type
  Show_in_Menu = false #true: rankings can be show in the Menu
                      #false: rankings are not shown in the menu
                      #and must be called with '$scene = Scene_weapon_by_ranks.new'
  Menu_Ranks = "Rankings" #word that shows up in the menu
end
module Ranks
  RANKS = ["0","1","2","3","4","5","6","7","8","9","10"]  #ranks from lowest to highest1
  $exp_ranks = [0,10,25,45,70,100,135,175,220,270]              #defines experience
                                      #needed for each rank
  EXP_rate = 1                        #experience multiplier
  $weapon_skills = ["Unarmed","Sword1H", "Sword2H", "Hammer1H", "Hammer2H", "Axe1H", "Axe2H", ]
  Unarmed_tag_id = 0                      #"unarmed name positon
  Change_Damage = true                #the actor's rank will afect regular attack damage
  Damage_multiplier = [1,1.05,1.1,1.15,1.2,1.25,1.3,1.35,1.4,1.45,1.5]   #damage multiplier
  Change_crit = false                  #the actor's rank will afect regular critical chance
  Added_crit = [0, 2, 4]              #critical chance = regular critical + Added_critical
  Critical_Adjustment = 2             #critical damage multiplier
  Class_Limit = false  #if true: can only equip weapons checked in the class
                      #Equippable Weapons list.
                      #false: can equip every weapon, only depending on the rank
end
#==============================================================================#
#  ** End Configuration                                                            #
#  unless you know what you're doing, don't change the script from here on!
#==============================================================================#
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
 
  include TAGNOTE                           #include TagNote
  include Ranks                             #get custom defenitions
 
  attr_accessor :weapon_skill_rank          #set object
    alias initialize_with_ranks initialize    #reset actor initialize def
  def initialize(actor_id)
    initialize_with_ranks(actor_id)         #do regular initialize
    @weapon_skill_rank = []                 #clear weapon_skill_rank
    for i in 0...$weapon_skills.size do     #sets starting rank
      @weapon_skill_rank[i] = RANKS[0]      #as the 1st Rank
    end
    @ws_exp = []                            #clear ws_exp
  end
 
    alias gain_w_exp gain_exp                 #redefining gain_exp
 
  def gain_exp(exp)
    gain_w_exp(exp)                   # do regular exp_gain
    if @weapon_id != 0                # if weilding a weapon
        ws = get_tag($data_weapons[@weapon_id].note,"mastery")
        @ws_i = $weapon_skills.index(ws)      #turn weapon type into index
    else
      @ws_i = Unarmed_tag_id
    end
    if @ws_exp[@ws_i] != nil             
      then $exp_temp = @ws_exp[@ws_i] + exp * EXP_rate #calcs experience
    else                                  #if it's the first time
      $exp_temp.to_i                      #calcs experience
      $exp_temp = exp * EXP_rate
    end
    @ws_exp.delete_at(@ws_i)              #deletes old experience
    @ws_exp.insert @ws_i,$exp_temp        #replaces with new experience value
    rank_index = RANKS.index(@weapon_skill_rank[@ws_i]) #weapon rank --> rank index
    for i in 1...$exp_ranks.size do # compares experience with exp need to the next rank
      if $exp_ranks[i] <= $exp_temp # if exp needed < current exp
        if rank_index >= i     # and the rank index is not lower
          then next              # goes to the next rank
        else @weapon_skill_rank[@ws_i] = RANKS[i] #else assigns new rank
        end
        ws = $weapon_skills[Unarmed_tag_id] if ws == nil
        text = sprintf(Vocab::Rank_Up,actor.name,RANKS[i],ws) #prints
        $game_message.texts.push('\.' + text)           #rank up message
      end
    end
  end
   
end
class Game_Battler
 
  include TAGNOTE
  include Ranks
 
  alias wbr_make_damage_value make_damage_value
   
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables) 
    if user.is_a?(Game_Actor)
      @actor = user
      if @actor.equips[0] != nil
        if has_tag?(@actor.equips[0].note,"mastery")
          mastery = get_tag(user.equips[0].note,"mastery")
          mastery_index = $weapon_skills.index(mastery)
          actor_rank = @actor.weapon_skill_rank[mastery_index]
          rank_index = RANKS.index(actor_rank)
        end
      else
        rank_index = Unarmed_tag_id
      end
    value *= Damage_multiplier[rank_index]     
     end
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end
end
class Scene_weapon_by_ranks < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_background
    @actor = $game_party.members[@actor_index]
    @status_window = Window_Ranks.new(@actor)
    @status_window.set_handler(:cancel,   method(:return_scene))
    @status_window.set_handler(:pagedown, method(:next_actor))
    @status_window.set_handler(:pageup,   method(:prev_actor))
  end
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  def on_actor_change
    @status_window.actor = @actor
    @status_window.activate
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_background
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Return to Original Screen
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def on_actor_change
    @status_window.actor = @actor
    @status_window.activate
  end
  #--------------------------------------------------------------------------
  # * Next Actor
  #--------------------------------------------------------------------------
 
end

class Window_Ranks < Window_Selectable
  include TAGNOTE #includes tagnote
  include Ranks
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 544, 416)
    @actor = actor
    refresh
    activate
  end

  def refresh
    self.contents.clear
    draw_actor_name(@actor, 4, 0)
    draw_actor_face(@actor, 8, 32)
    draw_actor_level(@actor, 8, 136)
    draw_weapons(8, 160)
    draw_weapon_skills(222, 40)
  end
 
  #--------------------------------------------------------------------------
  # * Draw Weapon(s)
  #     x : Draw spot X coordinate
  #     y : Draw spot Y coordinate
  #--------------------------------------------------------------------------
  def draw_weapons(x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y + 24, 120, 24, "Weapon:")
      draw_item_name(@actor.equips[0], x, y + 24 * 2)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y + 24 * 3, 120, 24, "Type:")
    self.contents.font.color = normal_color
    if @actor.equips[0] != nil
      if has_tag?(@actor.equips[0].note,"mastery") == true
        @skill = get_tag(@actor.equips[0].note,"mastery")
      end
    else
      @skill = $weapon_skills[Unarmed_tag_id]
    end
    self.contents.draw_text( x, y + 24 * 4, 120, 24, @skill)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y + 24 * 5, 120, 24, "Rank:")
    self.contents.font.color = normal_color
    if @actor.equips[0] != nil
      then if has_tag?(@actor.equips[0].note,"rank") == true
           then rank = get_tag(@actor.equips[0].note,"rank")
           self.contents.draw_text( x, y + 24 * 6, 120, 24, rank)
         end
    end
  end

  #--------------------------------------------------------------------------
  # * Draw Weapon Skills
  #     x : Draw spot X coordinate
  #     y : Draw spot Y coordinate
  #--------------------------------------------------------------------------
def draw_weapon_skills(x, y)
    for i in 0...$weapon_skills.size do
      if $weapon_skills[i] == @skill                    #goes through weapon types
        then self.contents.font.color = system_color    #if matches the current weapon type
        else self.contents.font.color = normal_color    #has a different color
      end
       
      self.contents.draw_text( x, y, 200, 2 * 24 * (i + 1), $weapon_skills[i])                   #draws weapon types
      self.contents.draw_text( x + 200, y, 50, 2 * 24 * (i + 1), @actor.weapon_skill_rank[i])   #draws weapon ranks
    end
  end
end

Thanks! Any help is appreciated!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I like the idea, and I think I will take this request. However, I don't think I would want to convert the VX script, just because there are features in the VXA database that one could use (like setting the damage formula inside the box for it in weapons, or, as you mentioned, the database weapon types). Still, I will allow for the options that you request.

Also, it might be a little while before I can get around to it, but hopefully I can find some time this weekend.

Do you have anything in mind for a scene that shows the actor's ranks? Ie. would you want them somewhere in the Actor's Status, or maybe you would just want it to show up in the help window for all weapons of the same type, or etc. If you don't have any specific design in mind, I will just try and think of a logical place to put the data.
« Last Edit: September 12, 2012, 11:32:16 PM by modern algebra »

**
Rep: +0/-0Level 83
Thank you very much, Modern Algebra!

As far as a scene that shows the actor's ranks, I'm thinking that, because I'm using Yanfly's Ace Equipment engine as well as Dekita's Perfect Status Screen script, a new main menu item would be easiest to implement. This selection would then display a simple window listing the actor's name, currently-equipped weapon and weapon type rank, followed by a list of weapon types with rank. No bars, graphics, etc. Simple.

Yanfly's Ace Equipment Engine:
http://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/ace-equip-engine/

Dekita's Perfect Status Screen:
http://forums.rpgmakerweb.com/index.php?/topic/4017-perfect-status-screen/

Once again, I appreciate it!


*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I haven't forgotten about you, but haven't found time to do any work on this yet. I will try to get to work on it soon.

**
Rep: +0/-0Level 83
Hey, no problem! I'm just glad to have your help!