09-29-2024, 09:49 PM
(This post was last modified: 09-29-2024, 09:52 PM by DerVVulfman.)
(09-28-2024, 08:42 AM)Bennerdeben Wrote: If anyone knows ways to make this work, please let me know.
I kinda came up with ... something. I call it "Collateral Damage"
Essentially, if a skill hits a target, one (or more depending on skill) also get hit.
Code:
module Collateral
SKILLS = {}
SKILLS[57] = false
SKILLS[58] = true
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# This class deals with battlers. It's used as a superclass for the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias collateral_init initialize
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :collateral_flag # Collateral damage flag
attr_accessor :collateral_qty_flag # Collateral quantity flag
attr_accessor :collateral_performed # Collateral prevent looping
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Perform the original method
collateral_init
# New flags in play
@collateral_flag = false
@collateral_qty_flag = false
collateral_performed = false
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias collateral_update_phase4_step2 update_phase4_step2
alias collateral_make_skill_action_result make_skill_action_result
alias collateral_update_phase4_step3 update_phase4_step3
alias collateral_update_phase4_step6 update_phase4_step6
#--------------------------------------------------------------------------
# * Frame Update (main phase step 2 : start action)
#--------------------------------------------------------------------------
def update_phase4_step2
#
# Clear new flags battler at each one's action start
@active_battler.collateral_flag = false
@active_battler.collateral_qty_flag = false
@active_battler.collateral_performed = false
#
# Perform the original method
collateral_update_phase4_step2
#
end
#--------------------------------------------------------------------------
# * Make Skill Action Results
#--------------------------------------------------------------------------
def make_skill_action_result
#
# Only do this if not already performed (no looping)
unless @active_battler.collateral_performed
# Get the skill ID
id = @active_battler.current_action.skill_id
#
# IF we did define a collateral skill)
if Collateral::SKILLS.has_key?(id)
# Set that there will be collateral damage
@active_battler.collateral_flag = true
# IF flag set to true, random number up to all party can be hit
if Collateral::SKILLS[id] == true
@active_battler.collateral_qty_flag = true
end
end
#
end
# perform the original method
collateral_make_skill_action_result
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 3 : animation for action performer)
#--------------------------------------------------------------------------
def update_phase4_step3
#
# Just skip the attacker animatics if we are performing a loop
if @active_battler.collateral_performed == true
@phase4_step = 4
return
end
#
# Perform the original method
collateral_update_phase4_step3
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 6 : refresh)
#--------------------------------------------------------------------------
def update_phase4_step6
#
# ONLY if the collateral flag is true
if @active_battler.collateral_flag == true
#
# Set flag showing collateral damage is performed (no looping)
@active_battler.collateral_performed = true
# Clear the old flag
@active_battler.collateral_flag = false
# If we have All targets hit
if @active_battler.collateral_qty_flag == true
#
# Make temp copy of all battlers targeted
old_battlers = @target_battlers
# Clear targets
@target_battlers = []
# Push all not-hit targets (whether actor or enemy targets)
if @active_battler.is_a?(Game_Actor)
for enemy in $game_troop.enemies
next if old_battlers.include?(enemy)
@target_battlers.push(enemy) if enemy.exist?
end
else
for actor in $game_party.actors
next if old_battlers.include?(actor)
@target_battlers.push(actor) if actor.exist?
end
end
#
# Otherwise, ONE random person hit
else
# Get our already hit target
old_index = @active_battler.current_action.target_index
# Clear a temp list
target_list = []
# Branch on actor or enemy and populate with IDs
if @active_battler.is_a?(Game_Actor)
for i in 0...$game_troop.enemies.size
next if i == old_index
target_list.push(i)
end
else
for i in 0...$game_party.actors.size
next if i == old_index
target_list.push(i)
end
end
#
# Randomly select an enemy
target_id = rand(target_list.size-1)
# And make it the new target
@active_battler.current_action.target_index = target_list[target_id]
#
end
#
# 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)
# Apply skill effect
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
# Shift to step 3
@phase4_step = 3
# Exit method
return
#
end
#
# Perform the original method
collateral_update_phase4_step6
#
end
end
The way THIS works...
It sees if a defined skill hits others.. collteral. It then does the skill on the target. THEN... it loops back and hits all the others AFTERWARDs. Gives it a bit of a BAM! then a followed-up BOOM! effect on everyone else. :D
When it DOES perform the original BAM! on the first target, that's when worked to select another target. I bypassed the scopes method which ... does no good here. And whether you randomly hit all party members or just one other party member, I worked to ensure the principle first enemy hit was not part of the group hit afterwards. AKA... you can't accidentally hit the same target twice with this attack.
Oh, but be warned... tied to skills, it should let enemies do the same to YOU!
As to a stun effect, well... that could merely be a state change you apply to the skill itself.