Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Magic Weapon Add-on, Automatic weapon skills
Kread-EX
post Feb 16 2010, 03:55 AM
Post #1


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Magic Weapon Add-on


At leongon's request, I post this script here. It's a very simple and small add-on which allows to perform a certain skill in place of a normal attack when a certain weapon is equipped.

Create a new script section (must be under Scene_Battle) and paste this little code:

CODE
#==============================================================================
# Simple Magic Weapons Script
#------------------------------------------------------------------------------
# Author: Kread-EX
#==============================================================================

#The constant below is the only thing you need to configure.

#The first number is the ID of the weapon. The second, the ID of the skill.
#The third is the probability (should be 0-100).

MAGIC_WEAPONS = {1 => [59, 75], 2 => [60, 50]}
#In this example, the first weapon in the database has 75% chance of casting Fire, and the second 50% of casting Fire 2.

# If GTBS not detected
unless defined?(Scene_Battle_TBS)

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # Changes to execute_action
  #--------------------------------------------------------------------------
  alias_method :krx_mw_execute_action, :execute_action
  def execute_action
    if @active_battler.is_a?(Game_Actor) && MAGIC_WEAPONS.keys.include?(@active_battler.weapon_id) &&
     @active_battler.action.attack? && (rand(101) >= (100 - MAGIC_WEAPONS[@active_battler.weapon_id][1]))
     @active_battler.action.set_skill(MAGIC_WEAPONS[@active_battler.weapon_id][0])
   end
   krx_mw_execute_action
  end
end

# Support for GTBS
else
  
#==============================================================================
# Scene_Battle_TBS
#==============================================================================

class Scene_Battle_TBS < Scene_Base
  #----------------------------------------------------------------------------
  # Determine if Magic Weapon is active
  #----------------------------------------------------------------------------
  #----------------------------------------------------------------------------
  # Process Actions (Attack/Skill/Item)
  #----------------------------------------------------------------------------
  alias_method :krx_mw_gtbs_phase_9, :tbs_phase_9
  def tbs_phase_9
    if @active_battler.is_a?(Game_Actor) && MAGIC_WEAPONS.keys.include?(@active_battler.weapon_id) &&
      (rand(101) >= (100 - MAGIC_WEAPONS[@active_battler.weapon_id][1])) &&
      @active_battler.current_action.kind == 0 && @active_battler.current_action.basic == 0
      @active_battler.current_action.kind = 1
      @active_battler.current_action.skill_id = MAGIC_WEAPONS[@active_battler.weapon_id][0]
      @animation2 = $data_skills[@active_battler.current_action.skill_id].animation_id
    end
    krx_mw_gtbs_phase_9
  end
end

end


Side notes: -Compatible with Tankentai SBS.
-Compatible with GubiD's TBS.
-Unless when using GubiD's TBS, the MP are consumed when the skill is cast. If you don't want it, you'll have to create another skill with 0 MP cost.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   



Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 22nd May 2013 - 03:22 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker