[XP] Weapon Training System v1.00

Started by tSwitch, July 19, 2008, 12:31:14 pm

Previous topic - Next topic

tSwitch

July 19, 2008, 12:31:14 pm Last Edit: February 21, 2009, 06:03:50 am by shdwlink1993
Weapon Training System
Authors: NAMKCOR
Version: 1.00
Type: Custom Equipment System
Key Term: Custom Equipment System



Introduction

Think FF2 with this one.  Characters all have 'skill levels' with types of weapons that grant them bonuses with those types of weapons.  They gain experience every time they attack with the weapon, and each weapon skill level gives them bonus skill in determining attack damage, the accuracy, and the critical rate of that weapon type.


Version History


  • v1.00 - Completed System




Planned Future Versions


  • v?.?? possible efficiency upgrades and bug fixes




Features


  • Easy to configure bonus rates
  • Easy to configure experience/level requirement
  • Easy to configure default level values
  • Uses weapon elements to make weapon categories a breeze



Screenshots

N/A for this type of script


Demo

N/A


Script

Spoiler: ShowHide

#=================================================================
#   Weapon Training System                                                     
#---------------------------------------------------------------------------------------------------------------------
#   Created By: NAMKCOR                                                                                                     
#   Created for the Websites: Chaos Project, RPG Maker Resource Kit
#                                                  (www.chaosproject.co.nr; www.rmrk.net)                       
#   If this script is hosted on any other website, then it is stolen, please contact           
#   me at the address given below                                                                                         
#--------------------------------------------------------------------------------------------------------------------
#   If you find any Bugs/Incompatability issues with this script, please contact me at   
#   the following e-mail address: Rockman922@aol.com, and please be descriptive   
#   with your e-mail subject, as I delete spam on sight.                                                                                                             
#--------------------------------------------------------------------------------------------------------------------
#   Function:                                                                                                                             
#    Think FF2 with this one.  Characters all have 'skill levels' with types of weapons that
#    grant them bonuses with those types of weapons.  They gain experience every time
#    they attack with the weapon, and each weapon skill level gives them bonus skill in
#     determining attack damage, the accuracy, and the critical rate of that weapon type
#                                                                         
#    Compatability:                                                                                                                   
#     100% compatability with SDK (some things may conflict I dunno SDK well)
#      80% compatability with exotic CBSes
#      uses own damage calculations that might cause errors in some cases (merge required)
#      0% compatibility with RTAB
#      Unknown as of yet, but high possibility of corrupting old save files
#
#     Instructions:                                                                                                                     
#      Comments and instructions for the individual customizations will be given           
#       right where they are located.  Only real skills needed are reading, typing,             
#       and copy&paste
#--------------------------------------------------------------------------------------------------------------------
#     Version History:
#     1.0 - completed system
#=================================================================
    #how much experience is given per attack
    $WTSexp_rate = 5
   
    #bonus rate formula is weapon level * bonus amount
    $WTSattack_bonus = 10
    $WTSaccuracy_bonus = 10
    $WTScritical_bonus = 10
   
    #==============================================================
    # @exp_levels : how much experience is needed to reach the next level
    #----------------------------------------------------------------------------------------------------------------
    # this array functions quite simply, each element is a level, and the value in that
    # element is the amount of experience needed to reach that level.
    # so an array with values [15, 30, 45] would have 3 levels, level 1 needing 15xp
    # level 2 needing 30xp and level 3 needing 45xp
    #==============================================================
    $WTSexp_levels = [10, 30, 60, 100, 150, 210, 280]
   
    #==============================================================
    # @elements : which elements are used to store weapon types
    #----------------------------------------------------------------------------------------------------------------
    # simply place the indexes of the elements you plan on using in the array below
    # a REMINDER that only the first numerical value of an element will be taken
    # into consideration.  So if you make a weapon with elements 17 and 20, only
    # element 17 will be taken into consideration.
    # ALSO a weapon type -must- be set, or else you will get a range error
    #==============================================================
    $WTSelements = [17, 18, 19, 20]
   


class Game_Actor < Game_Battler

  attr_accessor  :WTSweapon_experience
  attr_accessor  :WTSweapon_levels
 
  alias WTS_setup_after setup
  def setup(actor_id)
    WTS_setup_after(actor_id)
    #==============================================================
    # @WTSweapon_experience
    #----------------------------------------------------------------------------------------------------------------
    # by modifying the case-when, adding whens for every actor, you are able to
    # set what amount of experience with a given weapon type teh character has
    # at the start of your game.  That way a swordsman could be good with swords
    # or a sniper with rifles etc...
    #----------------------------------------------------------------------------------------------------------------
    # default: @WTSweapon_experience = [0,0,0,0]
    #                @WTSweapon_levels = [0,0,0,0]
    # template when [actor_id] then
    #                             @WTSweapon_experience = [0,0,0,...]
    #                             @WTSweapon_levels = [0,0,0,...]
    #                 end
    # !!! WARNING !!! be sure to add an element to these arrays for every weapon
    # element type used, or you may encounter bugs later on; and try to line up
    # weapon levels with the appropriate amount of experience, or when it
    # auto-corrects, it will appear very buggy
    #==============================================================
    case actor_id
      when 1 then
        @WTSweapon_experience = [0,0,0,0]
        @WTSweapon_levels = [0,0,0,0]
      when 2 then
        @WTSweapon_experience = [0,0,0,0]
        @WTSweapon_levels = [0,0,0,0]
      end
    end
   
    #===================================================================
    # DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
    #===================================================================
   
    def attack_bonus
      @temp_element = $data_weapons[self.weapon_id].element_set
      for i in 0...@temp_element.size
          for j in 0...$WTSelements.size
            if $WTSelements[j] == @temp_element[i]
              return $WTSattack_bonus * @WTSweapon_levels[j]
            end
          end
        end
      end
     
      def accuracy_bonus
      @temp_element = $data_weapons[self.weapon_id].element_set
      for i in 0...@temp_element.size
          for j in 0...$WTSelements.size
            if $WTSelements[j] == @temp_element[i]
              return $WTSaccuracy_bonus * @WTSweapon_levels[j]
            end
          end
        end
      end
     
      def critical_bonus
      @temp_element = $data_weapons[self.weapon_id].element_set
      for i in 0...@temp_element.size
          for j in 0...$WTSelements.size
            if $WTSelements[j] == @temp_element[i]
              return $WTScritical_bonus * @WTSweapon_levels[j]
            end
          end
        end
      end
  end

class Scene_Battle
 
  alias make_basic_action_result_first make_basic_action_result
  def make_basic_action_result
    make_basic_action_result_first
    if !$game_troop.enemies.include?(@active_battler)
      @temp_element = $data_weapons[@active_battler.weapon_id].element_set
      if @active_battler.current_action.basic == 0
        for i in 0...@temp_element.size
          for j in 0...$WTSelements.size
            if $WTSelements[j] == @temp_element[i]
              @active_battler.WTSweapon_experience[j] += $WTSexp_rate
              if $WTSexp_levels[@active_battler.WTSweapon_levels[j]] != nil
                while @active_battler.WTSweapon_experience[j] >=
                  $WTSexp_levels[@active_battler.WTSweapon_levels[j]]
                  @active_battler.WTSweapon_levels[j] += 1
                end
              end
            end
          end
        end
      end
    end
  end
 
end

class Game_Battler
 
  alias attack_effect_old attack_effect
  def attack_effect(attacker)
    self.critical = false
    if !$game_troop.enemies.include?(attacker)
    hit_result = (rand(100) < (attacker.hit + attacker.accuracy_bonus))
    if hit_result == true
      atk = [(attacker.atk + attacker.attack_bonus) - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      if self.damage > 0
        if rand(100) < 4 * (attacker.dex + attacker.critical_bonus) / self.agi
          self.damage *= 2
          self.critical = true
        end
        if self.guarding?
          self.damage /= 2
        end
      end
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    if hit_result == true
      remove_states_shock
      self.hp -= self.damage
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    else
      self.damage = "Miss"
      self.critical = false
    end
    return true
    end
    attack_effect_old(attacker)
  end
end



Instructions

Comments and instructions for the individual customizations will be given right where they are located.  Only real skills needed are reading, typing, and copy&paste.


Compatibility

incompatible with RTAB, trying to figure out a merge or something


Credits and Thanks


  • created by NAMKCOR
  • FF2 for inspiring the system
  • Zeriab and Falcon for bits of help in IRC



Author's Notes

If you find any Bugs/Incompatability issues with this script, please contact me at the following e-mail addresses: Rockman922@aol.com and rockmanamkcor@yahoo.com, and please be descriptive with your e-mail subject, as I delete spam on sight.

This is my first foray back into scripting for a while, I'm glad it finally worked, and I hope y'all like it \o/

Created for the Websites: Chaos Project, RPG Maker Resource Kit
(www.chaos-project.com ; www.rmrk.net)                     
If this script is hosted on any other website, then it is stolen, please contact me at either of the locations given

If you use this script in your game, please link me to the topic
I love to see what my work is used for

do NOT use this script in a commercial game unless you get my permission first


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

Blizzard

Update CP's link in "Restrictions". BTW, want me to add that to Tons?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

tSwitch

yeah, I'll update the link in a few

not unless you can figure out why it hates RTAB so much.
I tried changing the battle settings to fit with it, and it gave me a spriting error that I couldn't tackle.

would need to add the variables to module NAMKCOR as well.


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

Blizzard

Alright, when you update it, I'll add it to Tons and make it compatible with RTAB.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Punn

Yay! With Tons, everything is easy to use!

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Kagutsuchi

I'd really want to add this script to my game ^^ But it sort of don't work with the blizz abs (at least I think so..) So I can't wait till it gets added to tons =D

Blizzard

NAMK, if you move the stuff from Scene_Battle#make_basic_action_result to Game_Battler#attack_effect and it will work with Blizz-ABS. BTW, didn't you want to update it so I can add it to Tons? xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

tSwitch

I haven't had a chance to do much scripting lately, or much RM related at all since the GIAW4 competition.  I've been just swamped with schoolwork and other things.

I don't even remember what I was going to update.

I'll look it over and see what I can do when I get the time.


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

Jragyn

Surely there has been some sort of update that backwards rockman has been hiding from us all, right?
I like Tons.
I like it when things work nicely together.
Therefore, I will be happier when this gets updated...
but did this become a forgotten cause?
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

scoace13

is there some kind of update for this that will show the weapon's level in the equip screen.
scoace13, Eventman extrodnaire...so anybody seen any good movies recently <br />...whys is this here..........random fate...same reason im here...

Seox

NAMKCOR, this would be PERFECT if it weren't for the fact that it ignores all other weapon elements. Do you have any idea why? I've tried looking at it, but can't discern why it would skip the other elements entirely. You mention it briefly in the comment. The worst part is the fact that I have another script which animates those with a "gun element", so that they shoot. Because your script makes the game ignore other elements, they effectively ignore the gun element. Meaning that my battlers run up and bayonet their targets.

XD

Please help me out - thank you for your time, and *powers up* for an awesome script!

... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

tSwitch

Quote from: scoace13 on June 12, 2009, 07:12:22 am
is there some kind of update for this that will show the weapon's level in the equip screen.


you'd need a cms for that, not an update for my script.

Quote from: Seox on June 16, 2009, 06:23:23 pm
NAMKCOR, this would be PERFECT if it weren't for the fact that it ignores all other weapon elements. Do you have any idea why? I've tried looking at it, but can't discern why it would skip the other elements entirely. You mention it briefly in the comment. The worst part is the fact that I have another script which animates those with a "gun element", so that they shoot. Because your script makes the game ignore other elements, they effectively ignore the gun element. Meaning that my battlers run up and bayonet their targets.

XD

Please help me out - thank you for your time, and *powers up* for an awesome script!


that is -weeeeeeeeeeeeeeeeeeeeeird-
it shouldn't interfere with elements at all, all it does is read the ones that are declared as weapon elements when determining experience...

I'm not sure what to tell you..
what's your script order, I guess?


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

Seox

Quote from: NAMKCOR on June 16, 2009, 11:34:07 pm
Quote from: scoace13 on June 12, 2009, 07:12:22 am
is there some kind of update for this that will show the weapon's level in the equip screen.


you'd need a cms for that, not an update for my script.

Quote from: Seox on June 16, 2009, 06:23:23 pm
NAMKCOR, this would be PERFECT if it weren't for the fact that it ignores all other weapon elements. Do you have any idea why? I've tried looking at it, but can't discern why it would skip the other elements entirely. You mention it briefly in the comment. The worst part is the fact that I have another script which animates those with a "gun element", so that they shoot. Because your script makes the game ignore other elements, they effectively ignore the gun element. Meaning that my battlers run up and bayonet their targets.

XD

Please help me out - thank you for your time, and *powers up* for an awesome script!


that is -weeeeeeeeeeeeeeeeeeeeeird-
it shouldn't interfere with elements at all, all it does is read the ones that are declared as weapon elements when determining experience...

I'm not sure what to tell you..
what's your script order, I guess?



I'm not sure if it ignores ALL other elements, but it DOES ignore this script:

#==============================================================================
# Add-On: Guns 1.1
# by Kylock
#------------------------------------------------------------------------------
# This Add-On allows you to use additional animations for guns.
# To use this script, verify if your guns have the attribute with the same
# ID as GUN_ELEMENT in the weapon's tab of your database.
#==============================================================================

module N01
   # $game_actors.animation_id
  # Element for the weapon/skill that has the Gun Animation
  GUN_ELEMENT = 27
  ANIM = []
  # Attack Animation
         ranged_anime = {
         "GUNSHOT" => ["sound", "se",  100, 100, '357_magnum'],}

           
         ANIME.merge!(ranged_anime)
=begin
         "OBJ_ANIM_WEIGHT"
=end
         # Action Sequence
  RANGED_ATTACK_ACTION = {
    "GUN_ATTACK" => ["JUMP_AWAY","WPN_SWING_V","30", "OBJ_ANIM_WEAPON", "WPN_SWING_V",
        "12","WPN_SWING_VL","OBJ_ANIM_L","One Wpn Only",
        "16","Can Collapse","JUMP_TO","COORD_RESET"],}
  ACTION.merge!(RANGED_ATTACK_ACTION)
end

module RPG
  #------------------------------------------------------------------------------
  class Weapon
    alias kylock_guns_base_action base_action
    def base_action
      # If the "Gun" attribute is marked on the weapon's element,
      # the new attack sequence is used
      if $data_weapons[@id].element_set.include?(N01::GUN_ELEMENT)
        return "GUN_ATTACK"
      end
      kylock_guns_base_action
    end
  end
  #------------------------------------------------------------------------------
  class Skill
    alias kylock_sguns_base_action base_action
    def base_action
      # If the "Gun" attribute is marked on the weapon's element,
      # the new attack sequence is used
      if $data_skills[@id].element_set.include?(N01::GUN_ELEMENT)
        return "GUN_ATTACK"
      end
      kylock_sguns_base_action
    end
  end
end


Which is what defines what a "gun" type weapon is.

In your script, you mention this:

#==============================================================
    # @elements : which elements are used to store weapon types
    #----------------------------------------------------------------------------------------------------------------
    # simply place the indexes of the elements you plan on using in the array below
    # a REMINDER that only the first numerical value of an element will be taken
    # into consideration.  So if you make a weapon with elements 17 and 20, only
    # element 17 will be taken into consideration.
    # ALSO a weapon type -must- be set, or else you will get a range error
    #==============================================================
    $WTSelements = [17, 18, 19, 20, 38]
   


What I understood from that was that if any other element came before the weapon level one, it would-

Ok, wait, i understand that. It means that a weapon can't be two different types.

Ok, I pretty much have tankentai sideview CBS, and all of its addons, then a few non-battle type scripts, my custom damage script, my piercing script (Magic defense VS piercing = %of damage taken total), then weapon lvs, then main.

Does that help, or do you need anything more specific?
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

scoace13

is it possible to add the need variables during scene equip so that it shows weapon level after the weapon is equipped. if so where would one add these varibles and just checking but it is these  variables right: @WTSweapon_experience
                     @WTSweapon_levels

thx in advance
scoace13, Eventman extrodnaire...so anybody seen any good movies recently <br />...whys is this here..........random fate...same reason im here...

Blizzard

NAMK, just check what I did in Skill Separation System in Tons for the elements.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Seox

Ok, for some reason, NAM, I figured it out. If the element assigned to GUN ELEMENT is not the first element on the weapon (IE before any other element that is also on the weapon), then they bayonet the guy. Point being, my bad, and it works.

Bad news is that, although it's a BAD *** script, and would be PERFECT for my game, my custom damage system also defines hitresult(or similar, can't remember offhand.) Permission to attempt an edit, and tips?

Please and thank you.
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

tSwitch

hrm...

the reason it overwrites the damage thing is because of where I put the experience calculation.  you could easily merge the two scripts, I think.

just back everything up before you try, just in case.


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

Seox

Quote from: NAMKCOR on June 17, 2009, 05:22:45 pm
hrm...

the reason it overwrites the damage thing is because of where I put the experience calculation.  you could easily merge the two scripts, I think.

just back everything up before you try, just in case.


I'll probably try doing it as soon as I can finish my sidearm script edits. It shouldn't be TOO hard. D'you think I should try to alias the two?

I knew you'd HAVE to define hitresult, it just sucks that they BOTH do. I don't think I'll have a problem with them, though.

Yeah, I prolly should back them up. I usually back things up before I edit them. Good habit to get into.
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

rpgmakerfanhaha

When I attack with a character with no weapon equipped,it gives me an error on line 126.Does it need an element like the weapon too?Or must a player have a weapon in their hand?