Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Weapon Leveling Script Help

Ok, Ima newbie scripter and I've been playing around trying to get this script to work, anyway heres the code since Im kinda lazy. :O

Add this as a new script.

Code:
class Ultimate_Weapons
  
  attr_accessor :weapon_level
  attr_accessor :current_exp
  attr_accessor :max_exp
  attr_accessor :max_level
  attr_accessor :enemy_id
  
  def initialize
    @current_exp = 0  
    @weapon_level = 1
    troop = $data_troops[@troop_id]
    @enemy_id = troop.members[@member_index].enemy_id
    $ultimate_weps = Ultimate_Weapons.new
  end
 
#===================================================================
#-Weapon Leveling
#===================================================================
  

  def get_weapon
    return $game_actors[1].weapon_id
  end
  
  def monster_exp(enemy_id)
    case @enemy_id
    when 1
      return 25
    end
  end    
  
  def weapon_level_stats
    case @weapon_level
    when 1
      @max_exp = 100
    when 2
      @max_exp = 200
    when 3
      @max_exp = 300
    when 4
      @max_exp = 400
    end
  end
  
  def next_level?
    p "Current Exp: " + @current_exp.to_s + "Max Exp: " + @max_exp.to_s
    if $weapon_exp >= @max_exp
     @weapon_level += 1
   end
   if @weapon_level == 5
     @max_level = true
   else
     @max_level = true
   end
 end
end

Add this to Game_Enemy

Code:
  #--------------------------------------------------------------------------
  # - Acquisition of weapon experience
  #--------------------------------------------------------------------------
  def weapon_exp
    return 25 #25 is for test purposes
  end

Add this to Scene_Battle where it does things at the end of the battle.

Code:
bonus_weapon_exp = 0
bonus_weapon_exp += enemy.weapon_exp
actor2 = $game_enemy.weapon_exp
#-------------------------------------------------------------------------
#- Adds the weapon experience
#-------------------------------------------------------------------------
        actor2 += bonus_weapon_exp
#-------------------------------------------------------------------------
#- End adding the weapon experience
#-------------------------------------------------------------------------

Anyway, when you do a battle it all goes good until you end the battle.

Scene_Battle 2 - Line 73 - No Method Error
Undefined method 'weapon_exp' for nil:NilClass
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top