Modern Algebra's Additional Skill Effects
Version: 1.0
Author: modern algebra
Date: August 27, 2007
Version History
- Version 1.0: Original Script. Skill Effects include Chain Skill, Distribution, and Dispersion.
Planned Future Versions
- Version 1.1: Allow setting of the percentage by which chain and dispersion skills decrease with each hit
- Version 2.0: Add some special Item Effects, as well as a few new skills
Description
This script allows the game maker to give non-standard effects to skills and items. Specifically, it adds these skill effects:
- Chain Effect: The skill hits all enemies in a random order, with the power of the skill decreasing by 10% with each successive hit.
- Dispersion: The skill jumps to each random target ten times, decreasing in power by 10% with each jump. It randomly selects ten targets, and each enemy in the troop can be selected more than once or not at all
[li]Distribution: This skill distributes the power of the skill through all targets. Thus, if a skill which would normally do 600 damage has 3 targets, it would do 200 damage to each. If 2, 300 to each, and so on. Perfect for easy balancing of skills that target all enemies
[/li][/list]
Features
- New and interesting effects to add a diverse scope to your attacks
- Very easy to set up
Instructions
For each effect, merely place the IDs of the skills which you want to have this effect into the array which corresponds to the effect. See the script for more details.
Script
#==============================================================================
# Additional Skill Effects
# Version: 1.0
# Author: modern algebra
# Date: August 27, 2007
#------------------------------------------------------------------------------
# * List of Skill Effects
# Chain Effect: This 'chains' the skill. It will hit all potential targets,
# it's effectiveness reduced by 10% after every hit. So, if there are
# 4 enemies, it will do 100% on the first, 90% on the second, 80% on
# the third, and 70% on the fourth target.
# Dispersion Effect: It hits 10 random targets, it's effectiveness
# decreases by 10% with every hit
# Distribution Effect: This distributes power equally between each target.
# It does damage to all targets, but how much damage it does to each
# depends on how many enemies there are. In other words, if there is
# one enemy, the skill devotes all it's power to that enemy (100%). If
# there are two enemies, 50% is done on each. If three, 33%.
#------------------------------------------------------------------------------
# Instructions:
# For each skill effect, merely input into the array the IDs of all the skills
# you want to have that skill effect. See below in the Editable Region
#==============================================================================
#==============================================================================
# ** Data MA Skills
#------------------------------------------------------------------------------
# Data class storing, for each effect, the skill IDs of all skills which
# access that effect
#==============================================================================
class Data_MA_Skills
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :chain_effect
attr_reader :dispersion
attr_reader :distribution
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
#------------------------------------------------------------------------
# * Editable Region
#------------------------------------------------------------------------
# Set up all the abilities you want to have effects by placing the ID of
# the skill into the corresponding array. For instance, if you wanted
# skills 1 and 2 and 22 to have the chain effect, then place it like
# this:
# @chain_effect = [1, 2, 22]
#
# Do the same for each skill effect
#-------------------------------------------------------------------------
@chain_effect = []
@dispersion = []
@distribution = []
#------------------------------------------------------------------------
# * END Editable Region
#------------------------------------------------------------------------
end
#--------------------------------------------------------------------------
# * MA Skill?
# skill_id: The ID of the skill to be tested
#--------------------------------------------------------------------------
def ma_skill? (skill_id)
return @chain_effect.include? (skill_id) || @dispersion.include? (skill_id) || @distribution.include? (skill_id)
end
end
#==============================================================================
# ** Scene_Title (MA Skill Effects Modification)
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================
class Scene_Title
alias ma_skills_modification main
def main
ma_skills_modification
$data_ma_skills = Data_MA_Skills.new
end
end
#==============================================================================
# ** Scene_Battle (MA Skill Effects Modification)
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Set Targeted Battler for Skill or Item
# scope : effect scope for skill or item
#--------------------------------------------------------------------------
# Aliased to set up the targets for additional skills
#--------------------------------------------------------------------------
alias ma_new_targets set_target_battlers
def set_target_battlers(scope)
skill_id = @active_battler.current_action.skill_id
if $data_ma_skills.chain_effect.include? (skill_id) || $data_ma_skills.distribution.include? (skill_id)
ma_new_targets (scope)
# If battler performing action is enemy
if @active_battler.is_a?(Game_Enemy)
if scope >= 3
# Get number of impossible targets
untargets = 0
for enemy in $game_troop.enemies
unless enemy.exist?
untargets += 1
end
end
# While there are enemies not targeted
while @target_battlers.size != $game_troop.enemies.size - untargets
# Choose a random target
random_target = rand($game_troop.enemies.size)
enemy = $game_troop.enemies (random_target)
# If not already a target
if not @target_battlers.include?(enemy) && enemy.exist?
# Add to target battlers
@target_battlers.push (enemy)
end
end
else
# Get number of impossible targets
untargets = 0
for actor in $game_party.actors
unless actor.exist?
untargets += 1
end
end
while @target_battlers.size != $game_party.actors.size - untargets
random_target = rand($game_party.actors.size)
actor = $game_party.actors[random_target]
if not @target_battlers.include?(actor) && actor.exist?
# Add to target battlers
@target_battlers.push (actor)
end
end
end
elsif @active_battler.is_a?(Game_Actor)
if scope >= 3
# Get number of impossible targets
untargets = 0
for actor in $game_party.actors
unless actor.exist?
untargets += 1
end
end
while @target_battlers.size != $game_party.actors.size - untargets
random_target = rand($game_party.actors.size)
actor = $game_party.actors[random_target]
if not @target_battlers.include?(actor) && actor.exist?
# Add to target battlers
@target_battlers.push (actor)
end
end
else
# Get number of impossible targets
untargets = 0
for enemy in $game_troop.enemies
unless enemy.exist?
untargets += 1
end
end
# While there are existing enemies un-targetes
while @target_battlers.size != $game_troop.enemies.size - untargets
# Choose a random target
random_target = rand($game_troop.enemies.size)
enemy = $game_troop.enemies (random_target)
# If not already a target
if not @target_battlers.include?(enemy) && enemy.exist?
# Add to target battlers
@target_battlers.push (enemy)
end
end
end
end
return
elsif $data_ma_skills.dispersion.include? (skill_id)
# If battler performing action is enemy
if @active_battler.is_a?(Game_Enemy)
if scope < 3
for i in 0...10
loop do
actor_id = rand($game_party.actors.size)
actor = $game_party.actors[actor_id]
if actor.exist? # If actor is a valid target
break
end
end
# Add actor to @target_Battlers
@target_battlers.push(actor)
end
else
for i in 0...10
loop do
enemy_id = rand($game_troop.enemies.size)
enemy = $game_troop.enemies[enemy_id]
if enemy.exist? # If enemy is a valid target
break
end
end
# Add enemy to @target_Battlers
@target_battlers.push(enemy)
end
end
elsif @active_battler.is_a?(Game_Actor)
if scope < 3
for i in 0...10
loop do
enemy_id = rand($game_troop.enemies.size)
enemy = $game_troop.enemies[enemy_id]
if enemy.exist? # If enemy is a valid target
break
end
end
# Add enemy to @target_Battlers
@target_battlers.push(enemy)
end
else
for i in 0...10
loop do
actor_id = rand($game_party.actors.size)
actor = $game_party.actors[actor_id]
if actor.exist? # If actor is a valid target
break
end
end
# Add actor to @target_Battlers
@target_battlers.push(actor)
end
end
end
return
end
ma_new_targets (scope)
end
#--------------------------------------------------------------------------
# * Make Skill Action Result
#--------------------------------------------------------------------------
# Aliases to add in new skill effects
#--------------------------------------------------------------------------
alias ma_skill_results make_skill_action_result
def make_skill_action_result
# Get skill
@skill = $data_skills[@active_battler.current_action.skill_id]
if $data_ma_skills.ma_skill? (@skill.id) # If it is an MA Skill
if $data_ma_skills.distribution.include? (@skill.id) # If Distribution Skill
# Save the Skill Power in an array
orig_skill_stats = [@skill.power, @skill.atk_f, @skill.pdef_f, @skill.mdef_f]
set_target_battlers (@skill.scope)
# Modify the stats to accomodate for the amount of enemies
@skill.power /= @target_battlers.size
@skill.atk_f /= @target_battlers.size
@skill.pdef_f /= @target_battlers.size
@skill.mdef_f /= @target_battlers.size
# Reset @target_battlers so that there is no overlap
@target_battlers = []
ma_skill_results
# Restore the skill stats
@skill.power = orig_skill_stats[0]
@skill.atk_f = orig_skill_stats[1]
@skill.pdef_f = orig_skill_stats[2]
@skill.mdef_f = orig_skill_stats[3]
return
end
# If not a forcing action
unless @active_battler.current_action.forcing
# If unable to use due to SP running out
unless @active_battler.skill_can_use?(@skill.id)
# Clear battler being forced into action
$game_temp.forcing_battler = nil
# Shift to step 1
@phase4_step = 1
return
end
end
# Save the Skill Power in an array
@orig_skill_stats = [@skill.power, @skill.atk_f, @skill.pdef_f, @skill.mdef_f]
# Use up SP
@active_battler.sp -= @skill.sp_cost
# Refresh status window
@status_window.refresh
# Show skill name on help window
@help_window.set_text(@skill.name, 1)
# Set animation ID
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
# Set command event ID
@common_event_id = @skill.common_event_id
# Set target battlers
set_target_battlers(@skill.scope)
# Animation for action performer (if ID is 0, then white flash)
if @animation1_id == 0
@active_battler.white_flash = true
else
@active_battler.animation_id = @animation1_id
@active_battler.animation_hit = true
end
# Apply skill effect
@phase4_step = 7
else
ma_skill_results
end
end
#--------------------------------------------------------------------------
# * Update Phase4
#--------------------------------------------------------------------------
# Aliases to add a step for the new skills.
#--------------------------------------------------------------------------
alias ma_update_new_skills update_phase4
def update_phase4
ma_update_new_skills
if @phase4_step == 7
ma_skills_update
end
end
#--------------------------------------------------------------------------
# * MA Skills Update
#--------------------------------------------------------------------------
# A new method to handle multiple instances of the same skill, with the
# necessary reductions to power.
#--------------------------------------------------------------------------
def ma_skills_update
target = @target_battlers.shift
if target != nil
if not target.exist?
return
end
# Skill Effects
target.skill_effect (@active_battler, @skill)
# Animation for target
target.animation_id = @animation2_id
target.animation_hit = (target.damage != "Miss")
if target.damage != nil
target.damage_pop = true
end
@wait_count = 8
# Reduce the skill stats
@skill.power -= (@orig_skill_stats[0]*0.1).to_i
@skill.atk_f -= (@orig_skill_stats[1]*0.1).to_i
@skill.pdef_f -= (@orig_skill_stats[2]*0.1).to_i
@skill.mdef_f -= (@orig_skill_stats[3]*0.1).to_i
# Refresh status window
@status_window.refresh
else
# Restore the skill stats
@skill.power = @orig_skill_stats[0]
@skill.atk_f = @orig_skill_stats[1]
@skill.pdef_f = @orig_skill_stats[2]
@skill.mdef_f = @orig_skill_stats[3]
# Hide help window
@help_window.visible = false
# Go to next battle phase
@phase4_step = 6
end
end
end
#==============================================================================
# ** Scene_Menu (MA Skill Effect modifications)
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Skill
#--------------------------------------------------------------------------
# * Frame Update (when target window is active)
#--------------------------------------------------------------------------
alias ma_skill_effects_mod update_target
def update_target
# If the skill is not an MA Skill Effect or if the B Button is being pressed
unless $data_ma_skills.ma_skill? (@skill.id) && Input.trigger? (Input::B) == false
# Run the original method
ma_skill_effects_mod
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If unable to use because SP ran out
unless @actor.skill_can_use?(@skill.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Save the Skill Power in an array
@orig_skill_stats = [@skill.power, @skill.atk_f, @skill.pdef_f, @skill.mdef_f]
# Initialize targets variable
@target_battlers = []
# If Chain Effect Skill
if $data_ma_skills.chain_effect.include? (@skill.id)
# While there are actors not targeted
while @target_battlers.size != $game_party.actors.size
random_target = rand($game_party.actors.size)
actor = $game_party.actors[random_target]
if not @target_battlers.include?(actor) && actor.exist?
# Add to target battlers
@target_battlers.push (actor)
end
end
# If Dispersion Skill
elsif $data_ma_skills.dispersion.include? (@skill.id)
for i in 0...10
loop do
actor_id = rand($game_party.actors.size)
actor = $game_party.actors[actor_id]
if actor.exist? # If actor is a valid target
break
end
end
# Add actor to @target_Battlers
@target_battlers.push(actor)
end
# If Distribution Skill
elsif $data_ma_skills.distribution.include? (@skill.id)
# Modify the stats to accomodate for the amount of enemies
@skill.power /= $game_party.actors.size
@skill.atk_f /= $game_party.actors.size
@skill.pdef_f /= $game_party.actors.size
@skill.mdef_f /= $game_party.actors.size
ma_skill_effects_mod
# Restore the skill stats
@skill.power = @orig_skill_stats[0]
@skill.atk_f = @orig_skill_stats[1]
@skill.pdef_f = @orig_skill_stats[2]
@skill.mdef_f = @orig_skill_stats[3]
return
end
perform_ma_skill_reduction
end
end
def perform_ma_skill_reduction
# For all targets
used = false
for target in @target_battlers
used |= target.skill_effect (@actor, @skill)
# Reduce the Skill Stats
@skill.power -= (@orig_skill_stats[0]*0.1).to_i
@skill.atk_f -= (@orig_skill_stats[1]*0.1).to_i
@skill.pdef_f -= (@orig_skill_stats[2]*0.1).to_i
@skill.mdef_f -= (@orig_skill_stats[3]*0.1).to_i
end
# If skill was used
if used
# Play skill use SE
$game_system.se_play(@skill.menu_se)
# Use up SP
@actor.sp -= @skill.sp_cost
# Remake each window content
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# If entire party is dead
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If command event ID is valid
if @skill.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @skill.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If skill wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
# Restore the skill stats
@skill.power = @orig_skill_stats[0]
@skill.atk_f = @orig_skill_stats[1]
@skill.pdef_f = @orig_skill_stats[2]
@skill.mdef_f = @orig_skill_stats[3]
return
end
end
Credit
Thanks
- Jin_Axl, for the request for the chain skills
Support
Will provide bug fixes and, if anyone can think of easy improvements to the script that I find beneficial, I will edit. I will also provide compatibility support. Further, if anybody has any cool ideas for a new type of skill effect, suggest it and if I like the idea it may come out with the next version. Also suggest Item Effects, since I plan to integrate item effects into this script as well.
Known Compatibility Issues
None known for sure, however the script does assume things both about Scene_Skill and Scene_Battle, so it will likely not work with any scripts that modify either of those default scripts in a major way, unless they do not change the expected output of various methods within the two.
Author's Notes
I wrote this script a long time ago and only recently got back my computer. For that reason I am not even sure if the script is fully completed. If you notice any weird things, then please notify me so that I can correct them.