#------------------------------------------------------------------------------#
=begin
"FFIX Style" Throw Script
by The_Sarah
(v1.2.1)
-- --
~~~ REQUIREMENTS ~~~
None
-- --
~~~ HOW TO USE ~~~
Step 1) Create a "Throw" skill in your Database like you normally would.
Step 2) In the Editable Region below, change the number 219 to the number
of your Throw skill's id in the Database.
Step 3) For any character you want to be able to use the Throw skill, simply
add a notetag saying "<Throw>" (without the speechmarks).
- Add this <Throw> notetag in the relevant character's Note Box (in
the Game Actors section of the Database).
Step 4) For any items, weapons or armour in your inventory that you would
like to be throwable:
i) You must write a Notetag in their Note Box sections in the Database.
ii) A FULL LIST of the notetags you can write, as well as information
on what they each do, can be found below.
iii) This list is found under the "~ NOTETAGS KEY ~" section of this
script intro (just below FEATURES).
Step 5) Enjoy the script!
Maybe leave a like on my RPG Maker Forum Thread page? :P
-- --
~~~ FEATURES ~~~
With this script, you can make any number of characters (who are Game Actors)
in your game able to use the "Throw" skill.
The Throw skill is a skill that (by default) is found underneath any chosen
character's SKILL command and above that character's GUARD command when in
battle.
This skill will open a unique Throwable Item Window.
- This window will then show the player a list of any Items, Weapons or
Armour that they have in their inventory that you (the game maker) have
decided are throwable in your game.
The player can then pick from this list and throw the object at an enemy.
The object thrown will decrease in the party's inventory by 1.
Any damage a thrown object does is calculated on whatever you wrote in
your "Throw" skill's damage formula (in the Database), as well as whatever
Notetag you have assigned to the Item/Weapon/Armour thrown.
-- --
~~~ NOTETAGS KEY ~~~
The following section is a list of every Notetag you can put into the Note
Box of an Item, Weapon or Armour in the game's Database to make them
throwable.
The list also includes information on what each Notetag does to the damage
of your Throw skill.
Please note, each variant on the Notetag applies a different effect to
YOUR existing Throw skill's Damage Formula.
So make sure to have already created a Throw Skill in the Database as well :)
________________________________________________________________________________
Notetag Effect | Notetag Effect
<throwheal> = Throws for 1x healing | <throwhalf> = Throws for half damage
<throwdmg0> = Throws for 0 damage | <throwdmg> = Throws for 1x damage
<throwdmg1> = Throws for 1x damage | <throwdmg2> = Throws for 2x damage
<throwdmg3> = Throws for 3x damage | <throwdmg4> = Throws for 4x damage
<throwdmg5> = Throws for 5x damage | <throwdmg6> = Throws for 6x damage
<throwdmg7> = Throws for 7x damage | <throwdmg8> = Throws for 8x damage
<throwdmg9> = Throws for 9x damage | <throwdmg10> = Throws for 10x damage
<throwdmg11> = Throws for 11x damage | <throwdmg12> = Throws for 12x damage
<throwdmg13> = Throws for 13x damage | <throwdmg14> = Throws for 14x damage
<throwdmg15> = Throws for 15x damage | <throwdmg16> = Throws for 16x damage
<throwdmg17> = Throws for 17x damage | <throwdmg18> = Throws for 18x damage
<throwdmg19> = Throws for 19x damage | <throwdmg20> = Throws for 20x damage
<throwdmg21> = Throws for 21x damage | <throwdmg22> = Throws for 22x damage
<throwdmg23> = Throws for 23x damage | <throwdmg24> = Throws for 24x damage
<throwdmg25> = Throws for 25x damage | <throwdmg50> = Throws for 50x damage
<throwdmg75> = Throws for 75x damage | <throwdmg100> = Throws for 100x damage
<throwdmg250> = Throws for 250x damage| <throwdmg500> = Throws for 500x damage
<throwdmg750> = Throws for 750x damage|
<throwdmg1000> = Throws for 1000x damage
<throwdmg2500> = Throws for 2500x damage
<throwdmg5000> = Throws for 5000x damage
<throwdmg7500> = Throws for 7500x damage
<throwdmg10000> = Throws for 10000x damage
________________________________________________________________________________
-- --
~~~ TERMS OF USE ~~~
If you share a game with this script in it (freely OR commercially), you
MUST credit me in the game.
Ideally like this: "Throw Script by The_Sarah"
Or like this if you edited the script: "Original Throw Script by The_Sarah"
Other than that, this script is free to download and use or edit in any
game or project (free or commercial).
-- --
~~~ REQUESTS ~~~
If you would like me to add more damage variants via additional notetags,
please request so in the RPG Maker Forum Thread I made to originally host
this Script.
I will reply to all requests when I have the time (which shouldn't be too
long to be honest) and do my best to accomodate them.
-- --
~~~ BUGS ~~~
No current known issues.
-- --
~~~ SPECIAL THANKS ~~~
* The_Sarah (aka me) for being awesome and making this script :O
* TheoAllen (RPG Maker Forum user) for initially helping me with
figuring out the make_damage_value method.
* Kyonides (RPG Maker Forum user) for helping with Module Instance
variables and Regex.
* A-Moonless-Night (RPG Maker Forum user) for Aliasing help as well as
helping me to finally understand how to grab specific parts within a
Regex string.
* LockeZ Ninja Throw (Script) for helping me figure out how to decrease
items when thrown.
-- --
~~~ OUTRO ~~~
And that's it!
This is my second ever public script (and definitely the biggest public one
I've made so far) and as a result it has many areas I'm sure can be cleaned
up (looking at you "include?").
But the community on the RPG Maker Forum has been mostly friendly so far, so
I'm happy to allow anyone who wants to look at it and give me tips to do so
(if they feel so kind).
Have wonderful lives everyone.
Be kind to eachother.
Don't be ____ist or ___phobic towards others, remember we're all human!
Let's make wonderful games together!
- The_Sarah
=end
#------------------------------------------------------------------------------#
#=begin
module TheSarahThrow
#=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~#
# ~~~~----# - EDITABLE REGION - #----~~~~ #
# IMPORTANT #
# Change the number in this section to the number of your Throw skill in the
# Database (default 185):
THROW_SKILL_ID = 185 # Your Throw skill ID
# ~~# - END OF EDITABLE REGION - #~~ #
#=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~#
end # End of TheSarahThrow module
#------------------------------------------------------------------------------#
# The Script #
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
# Game Classes #
#==============================================================================
# * Exisiting Class
# ** Game_Action
#------------------------------------------------------------------------------
# This class handles battle actions. This class is used within the
# Game_Battler class.
#==============================================================================
class Game_Action
#--------------------------------------------------------------------------
# * New Method
# ** Set Throw action
#--------------------------------------------------------------------------
def set_throw_action
if BattleManager.actor.thrown_item != 0
set_skill(subject.throw_skill_id)
self
else
next_action
end
end
end # End of Game_Action class
#==============================================================================
# * Existing Class
# ** Game_BattlerBase
#------------------------------------------------------------------------------
# This base class handles battlers. It mainly contains methods for calculating
# parameters. It is used as a super class of the Game_Battler class.
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# * New Method
# ** Set Throw Skill ID
#--------------------------------------------------------------------------
def throw_skill_id
return TheSarahThrow::THROW_SKILL_ID
end
end # End of Game_BattlerBase class
#==============================================================================
# * Existing Class
# ** Game_Battler
#------------------------------------------------------------------------------
# A battler class with methods for sprites and actions added. This class
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# * Existing Method
# ** Calculate Damage (aliased)
#--------------------------------------------------------------------------
alias thesarah_throwscript_gamebattler_makedmgval make_damage_value
def make_damage_value(user, item)
if item.id == TheSarahThrow::THROW_SKILL_ID && user.is_a?(Game_Actor) && user.has_throw
return thesarah_custom_damage_method(user, item)
end
thesarah_throwscript_gamebattler_makedmgval(user, item)
end
#--------------------------------------------------------------------------
# * New Method
# ** Calculate Damage when Throw is used
#--------------------------------------------------------------------------
def thesarah_custom_damage_method(user, item)
value = item.damage.eval(user, self, $game_variables)
case user.thrown_item_notetag
when /<throwdmg\s*(\d+)>/i
value *= $1.to_i
end
if user.thrown_item_category == "Nothing to throw"
value *= 0
Audio.se_play("Audio/SE/Miss", 80, 100)
end
value *= 0.5 if user.thrown_item_notetag[/throwhalf/i]
value *= -1 if user.thrown_item_notetag[/throwheal/i]
user.reset_thrown_item()
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 # End of Game_Battler class
#==============================================================================
# * Existing Class
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :has_throw # Checks if Actor has Throw command
attr_accessor :thrown_item # Checks Thrown Item ID
attr_accessor :thrown_item_notetag # Checks Thrown Item Notetag
attr_accessor :thrown_item_category # Checks Thrown Item Type/Category
#--------------------------------------------------------------------------
# * New Method
# ** Reset Thrown Item
#--------------------------------------------------------------------------
def reset_thrown_item
@thrown_item = 0
@thrown_item_notetag = ""
@thrown_item_category = ""
end
#--------------------------------------------------------------------------
# * Existing Method
# ** Setup (aliased)
#--------------------------------------------------------------------------
alias thesarah_throwscript_gameactor_setup setup
def setup(actor_id)
thesarah_throwscript_gameactor_setup(actor_id) # Calls original Method
@has_throw = true if actor.note[/<Throw>/i]; # p(actor.note)
end
#--------------------------------------------------------------------------
# * Existing Method (from Game_Battler)
# ** Use Skill/Item (aliased)
#--------------------------------------------------------------------------
alias thesarah_throwscript_gameactor_useitem use_item
def use_item(item)
case @thrown_item_category
when "Armour"
if $game_party.has_item?($data_armors[@thrown_item])
$game_party.lose_item($data_armors[@thrown_item], 1)
else
@thrown_item_category = "Nothing to throw"
end
when "Weapon"
if $game_party.has_item?($data_weapons[@thrown_item])
$game_party.lose_item($data_weapons[@thrown_item], 1)
else
@thrown_item_category = "Nothing to throw"
end
when "Item"
if $game_party.has_item?($data_items[@thrown_item])
$game_party.lose_item($data_items[@thrown_item], 1)
else
@thrown_item_category = "Nothing to throw"
end
end
thesarah_throwscript_gameactor_useitem(item) # calls original method
end
end # End of Game_Actor class
#------------------------------------------------------------------------------#
# Window Classes #
#==============================================================================
# * Existing Class
# ** Window_ActorCommand
#------------------------------------------------------------------------------
# This window is for selecting an actor's action on the battle screen.
#==============================================================================
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# * Existing Method
# ** Create Command List (aliased)
#--------------------------------------------------------------------------
alias thesarah_throwscript_winactorcmd_makecmdlist make_command_list
def make_command_list
return unless @actor
if BattleManager.actor.has_throw == true
return thesarah_throwadded_make_command_list
end
thesarah_throwscript_winactorcmd_makecmdlist
end
#--------------------------------------------------------------------------
# * New Method | To change skill order, edit where the
# ** Create Command List with [Throw] | "add_throw_command" goes below.
#--------------------------------------------------------------------------
def thesarah_throwadded_make_command_list
return unless @actor
add_attack_command
add_skill_commands
add_throw_command
add_guard_command
add_item_command
end
#--------------------------------------------------------------------------
# * New Method
# ** Add defined Throw Command to List
#--------------------------------------------------------------------------
def add_throw_command
add_command("Throw", :throw)
end
end # End of Window_ActorCommand class
#==============================================================================
# * New Class
# ** Window_BattleEnemy_Throw (alternate version of Window_BattleEnemy)
#------------------------------------------------------------------------------
# Window for selecting the enemy who is the action target on the battle
# screen (after selecting item to throw).
#==============================================================================
class Window_BattleEnemy_Throw < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(info_viewport)
super(0, info_viewport.rect.y, window_width, fitting_height(4))
refresh
self.visible = false
@info_viewport = info_viewport
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
Graphics.width - 128
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 2
end
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
def item_max
$game_troop.alive_members.size
end
#--------------------------------------------------------------------------
# * Get Enemy Object
#--------------------------------------------------------------------------
def enemy
$game_troop.alive_members[@index]
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
change_color(normal_color)
name = $game_troop.alive_members[index].name
draw_text(item_rect_for_text(index), name)
end
#--------------------------------------------------------------------------
# * Show Window
#--------------------------------------------------------------------------
def show
if @info_viewport
width_remain = Graphics.width - width
self.x = width_remain
@info_viewport.rect.width = width_remain
select(0)
end
super
end
#--------------------------------------------------------------------------
# * Hide Window
#--------------------------------------------------------------------------
def hide
@info_viewport.rect.width = Graphics.width if @info_viewport
super
end
end # End of Window_BattleEnemy_Throw class
#==============================================================================
# * New Class
# ** Window_ThrowItem (alternate version of Window_BattleItem)
#------------------------------------------------------------------------------
# This class is for selecting items to use in the "Throw Item" Window.
#==============================================================================
class Window_ThrowItem < Window_ItemList
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(help_window, info_viewport)
y = help_window.height
super(0, y, Graphics.width, info_viewport.rect.y - y)
self.visible = false
@help_window = help_window
@info_viewport = info_viewport
end
#--------------------------------------------------------------------------
# * Include in Item List?
# Note to Refractors - You wouldn't believe what this used to look like.
#--------------------------------------------------------------------------
def include?(item)
return true if item.is_a?(RPG::Item) && item.note[/<throwheal>/i]
return true if item.is_a?(RPG::Item) && item.note[/<throwhalf>/i]
return true if item.is_a?(RPG::Item) && item.note[/throwdmg/i]
return true if item.is_a?(RPG::Weapon) && item.note[/<throwheal>/i]
return true if item.is_a?(RPG::Weapon) && item.note[/<throwhalf>/i]
return true if item.is_a?(RPG::Weapon) && item.note[/throwdmg/i]
return true if item.is_a?(RPG::Armor) && item.note[/<throwheal>/i]
return true if item.is_a?(RPG::Armor) && item.note[/<throwhalf>/i]
return true if item.is_a?(RPG::Armor) && item.note[/throwdmg/i]
end
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
def enable?(item)
true
end
#--------------------------------------------------------------------------
# * Show Window
#--------------------------------------------------------------------------
def show
select_last
@help_window.show
super
end
#--------------------------------------------------------------------------
# * Hide Window
#--------------------------------------------------------------------------
def hide
@help_window.hide
super
end
end # End of Window_ThrowItem class
#------------------------------------------------------------------------------#
# Scene Classes #
#==============================================================================
# * Existing Class
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
# Basically it manages what happens in a battle.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Existing Method
# ** Create All Windows (aliased)
#--------------------------------------------------------------------------
alias thesarah_throwscript_scenebattle_createallwinds create_all_windows
def create_all_windows
thesarah_throwscript_scenebattle_createallwinds
create_throwitem_window
create_enemy_throw_window
end
#--------------------------------------------------------------------------
# * Existing Method
# ** Create Actor Commands Window (aliased)
#--------------------------------------------------------------------------
alias thesarah_throwscript_scenebattle_createactorcmdwin create_actor_command_window
def create_actor_command_window
thesarah_throwscript_scenebattle_createactorcmdwin
@actor_command_window.set_handler(:throw, method(:command_throwitem))
end
#--------------------------------------------------------------------------
# * New Method
# ** [Throw Item] Command
#--------------------------------------------------------------------------
def command_throwitem
@throwitem_window.refresh
@throwitem_window.show.activate
end
#--------------------------------------------------------------------------
# * New Method
# ** Create Throw Item Window
#--------------------------------------------------------------------------
def create_throwitem_window
@throwitem_window = Window_ThrowItem.new(@help_window, @info_viewport)
@throwitem_window.set_handler(:ok, method(:on_throwitem_ok))
@throwitem_window.set_handler(:cancel, method(:on_throwitem_cancel))
end
#--------------------------------------------------------------------------
# * New Method
# ** Throw Item [OK]
#--------------------------------------------------------------------------
def on_throwitem_ok
@throwitem = @throwitem_window.item
if @throwitem == nil
@throwitem_window.hide
Audio.se_play("Audio/SE/Buzzer1", 80, 100)
@actor_command_window.activate
else
BattleManager.actor.input.set_item(@throwitem.id)
BattleManager.actor.thrown_item = @throwitem.id
BattleManager.actor.thrown_item_notetag = @throwitem.note
if @throwitem.is_a?(RPG::Armor)
BattleManager.actor.thrown_item_category = "Armour"
elsif @throwitem.is_a?(RPG::Weapon)
BattleManager.actor.thrown_item_category = "Weapon"
elsif @throwitem.is_a?(RPG::Item)
BattleManager.actor.thrown_item_category = "Item"
end
@throwitem_window.hide
select_throw_enemy_selection
end
$game_party.last_item.object = @throwitem
end
#--------------------------------------------------------------------------
# * New Method
# ** Throw Item [Cancel]
#--------------------------------------------------------------------------
def on_throwitem_cancel
@throwitem_window.hide
@actor_command_window.activate
end
#--------------------------------------------------------------------------
# * New Method
# ** Create Enemy Throw Window
#--------------------------------------------------------------------------
def create_enemy_throw_window
@enemy_window_throw = Window_BattleEnemy_Throw.new(@info_viewport)
@enemy_window_throw.set_handler(:ok, method(:on_enemy_throw_ok))
@enemy_window_throw.set_handler(:cancel, method(:on_enemy_throw_cancel))
end
#--------------------------------------------------------------------------
# * New Method
# ** Start Throw Enemy Selection
#--------------------------------------------------------------------------
def select_throw_enemy_selection
@enemy_window_throw.refresh
@enemy_window_throw.show.activate
end
#--------------------------------------------------------------------------
# * New Method
# ** Enemy [OK] (after picking an item to throw)
#--------------------------------------------------------------------------
def on_enemy_throw_ok
BattleManager.actor.input.target_index = @enemy_window_throw.enemy.index
@skill_window.hide
@item_window.hide
@enemy_window_throw.hide
@throwitem_window.hide
BattleManager.actor.input.set_throw_action
next_command
end
#--------------------------------------------------------------------------
# * New Method
# ** Enemy [Cancel] (after picking an item to throw)
#--------------------------------------------------------------------------
def on_enemy_throw_cancel
@enemy_window_throw.hide
BattleManager.actor.reset_thrown_item
case @actor_command_window.current_symbol
when :throw
@throwitem_window.show.activate
end
end
#--------------------------------------------------------------------------
# * Existing Method
# ** Actor [OK] (aliased)
#--------------------------------------------------------------------------
alias thesarah_throwscript_scenebattle_onactorok on_actor_ok
def on_actor_ok
thesarah_throwscript_scenebattle_onactorok
@throwitem_window.hide
end
#--------------------------------------------------------------------------
# * Existing Method
# ** Actor [Cancel] (aliased)
#--------------------------------------------------------------------------
alias thesarah_throwscript_scenebattle_onactorcancel on_actor_cancel
def on_actor_cancel
thesarah_throwscript_scenebattle_onactorcancel
case @actor_command_window.current_symbol
when :throwitem
@throwitem_window.show.activate
end
end
end # End of Scene_Battle class
#------------------------------------------------------------------------------#
# End of Script #
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
#=end