Posts: 19
Threads: 5
Joined: Jul 2020
Hello good people,
I have been trying to figure out a way to make a skill that "Throws" enemies for a while now, but it looks like I need a hand.
The Skill should work as follows:
1.- You select One Enemy
2.- The selected enemy gets damaged and Stunned from being "thrown"
3.- If there are more enemies, one random additional enemy also gets stunned and damaged (imagine the thrown enemy crashing down into him)
Especially for the last part I have been tinkering with Scene_Battle and Game_Troop without good result. I had found some scripts that target a random number of enemies, or make you target several enemies at the same time. The thing is, I want the player to be able to select One Enemy; the game then needs to randomly select another and do the skill effects.
As far as I know part of the problem is the Scope. The script does not let you have a Scope that targets One Enemy + One Random.
This is where I get stuck.
If anyone knows ways to make this work, please let me know.
Posts: 11,243
Threads: 650
Joined: May 2009
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.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 19
Threads: 5
Joined: Jul 2020
Works like a gem :)
Thank you so much DerVVulfman! I really appreciate it
Posts: 11,243
Threads: 650
Joined: May 2009
Well, when I get the time (meh, look at the RPG Central archive)... I plan to have this feature for all three attack modes.
FYI: The older RPGMaker 2000 and 2003 engines allowed enemies both an attack and a 2xAttack in their Enemy attack definitions... Another REMOVAL of a feature that Enterbrain liked to do (and then return it and say... oooh, new feature).
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 19
Threads: 5
Joined: Jul 2020
Quote:FYI: The older RPGMaker 2000 and 2003 engines allowed enemies both an attack and a 2xAttack in their Enemy attack definitions... Another REMOVAL of a feature that Enterbrain liked to do (and then return it and say... oooh, new feature).
It is a shame they did this. Now we have to add any old-new features manually through scripting or eventing. And if you lack the scripting skills like I do its a pain. To be honest I never touched a RPG maker newer than XP. 2000 and 2003 is a long, long time ago.
About this script though, I found an error when I try to use the skill againt a party of 1 enemy. After the initial hit, it crashes before the second hit, saying "Script Game_Troop TypeError occured. no implicit conversion from nil to integer"
In the Editor it points at enemy = @enemies[enemy_index]
Code: #--------------------------------------------------------------------------
# * Smooth Selection of a Target Enemy
# enemy_index : enemy index
#--------------------------------------------------------------------------
def smooth_target_enemy(enemy_index)
# Get an enemy
enemy = @enemies[enemy_index]
# If an enemy exists
if enemy != nil and enemy.exist?
return enemy
end
# Loop
for enemy in @enemies
# If an enemy exists
if enemy.exist?
return enemy
end
end
end
Posts: 11,243
Threads: 650
Joined: May 2009
(09-30-2024, 03:33 PM)DerVVulfman Wrote: FYI: The older RPGMaker 2000 and 2003 engines allowed enemies both an attack and a 2xAttack in their Enemy attack definitions... Another REMOVAL of a feature that Enterbrain liked to do (and then return it and say... oooh, new feature).
(10-01-2024, 08:18 AM)Bennerdeben Wrote: About this script though, I found an error when I try to use the skill againt a party of 1 enemy. After the initial hit, it crashes before the second hit, saying "Script Game_Troop TypeError occured. no implicit conversion from nil to integer"
I needed to rework a few features. THIS will be ... fun:
Code: module Collateral
SKILLS, ITEMS = {}, {}
# 0 = Identical target(s) as the initial attack
# 1 = One random target separate from initial attack
# 2 = All targets other than those of the initial attack
# 3 = All targets
# Type Chance
# ==== =====-
SKILLS[1] = [ 3, 50 ] # Heal has 50% chance to collateral all
SKILLS[57] = [ 1, 99 ] # Cross Cut has 99% to hit another
SKILLS[58] = [ 2, 99 ] # 2 == all other
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_responce_flag # Collateral responce 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_responce_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_basic_action_result make_basic_action_result
alias collateral_make_skill_action_result make_skill_action_result
alias collateral_make_item_action_result make_item_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_responce_flag = false
@active_battler.collateral_performed = false
#
# Perform the original method
collateral_update_phase4_step2
#
end
#--------------------------------------------------------------------------
# * Make Basic Action Results
#--------------------------------------------------------------------------
def make_basic_action_result
#
=begin
# Only do this if not already performed (no looping)
unless @active_battler.collateral_performed
#
if @active_battler.is_a?(Game_Actor)
#
# Only a melee attack by Actor (no guard/escape)
if @active_battler.current_action.basic == 0
#
# Get the skill ID
id = @active_battler.current_action.skill_id
#
# Generate collateral damage result
collateral_action_result(Collateral::SKILLS, id)
#
end
#
else
#
# Get the skill ID
id = @active_battler.current_action.skill_id
#
# Generate collateral damage result
collateral_action_result(Collateral::SKILLS, id)
#
end
#
end
=end
#
# perform the original method
collateral_make_basic_action_result
#
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
#
# Generate collateral damage result
collateral_action_result(Collateral::SKILLS, id)
#
end
#
# perform the original method
collateral_make_skill_action_result
#
end
#--------------------------------------------------------------------------
# * Make Skill Action Results
#--------------------------------------------------------------------------
def make_item_action_result
#
# Only do this if not already performed (no looping)
unless @active_battler.collateral_performed
#
# Get the item ID
id = @active_battler.current_action.item_id
#
# Generate collateral damage result
collateral_action_result(Collateral::ITEMS, id)
#
end
#
# perform the original method
collateral_make_item_action_result
#
end
#--------------------------------------------------------------------------
# * Make Collateral Action Result
# array_list : configured list of collateral tagged attacks
# id : attack ID
#--------------------------------------------------------------------------
def collateral_action_result(array_list, id)
#
# Exit if not in list
return unless array_list.has_key?(id)
#
# Get values from array
responce = array_list[id][0]
chance = array_list[id][1]
#
# Exit if chance doesn't succeed
roll = rand(100)
return if chance < roll
#
# Set that there will be collateral damage
@active_battler.collateral_flag = true
@active_battler.collateral_responce_flag = responce
#
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
#
# Determine if there WOULD be another target
if @active_battler.collateral_flag == true
@target_battlers = collateral_gather
end
#
# Remove nil entries
@target_battlers.compact!
#
# ONLY if the collateral flag is true and collateral targets exist
if @active_battler.collateral_flag == true && @target_battlers != []
#
# Perform collateral action
collateral_action
#
# Shift to step 3
@phase4_step = 3
# Exit method
return
#
else
#
# Clear flag
@active_battler.collateral_flag = false
#
end
#
# Perform the original method
collateral_update_phase4_step6
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase gather collateral targets)
#--------------------------------------------------------------------------
def collateral_gather
#
# Determine target of collateral based on active battler's action scope
targets_are_enemies = collateral_gather_scope
target_group = collateral_gather_group(targets_are_enemies)
#
# Make temp copy of all previous battlers targeted
old_battlers = @target_battlers
#
# Branch on collateral responce
case @active_battler.collateral_responce_flag
when 0 ; battler_return = collateral_gather_identical(target_group)
when 1 ; battler_return = collateral_gather_other(target_group)
when 2 ; battler_return = collateral_gather_all_other(target_group)
when 3 ; battler_return = collateral_gather_all(target_group)
end
#
return battler_return
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase gather collateral targets : get attack scope)
#--------------------------------------------------------------------------
def collateral_gather_scope
#
# Branch according to each action
case @active_battler.current_action.kind
when 2 ; return (@item.scope == 1 || @item.scope == 2) # Items
when 1 ; return (@skill.scope == 1 || @skill.scope == 2) # Skill
end
#
# Exit method true (assume Basic)
return true
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase gather collateral targets : get target group)
# enemy_targets : if targets are battler's enemies or allies
#--------------------------------------------------------------------------
def collateral_gather_group(enemy_targets=true)
#
# If action battler is actor
if @active_battler.is_a?(Game_Actor)
# group is 'troop' if true, otherwise group is 'party'
group = (enemy_targets) ? $game_troop.enemies : $game_party.actors
else
# group is 'party' if true, otherwise group is 'troop'
group = (enemy_targets) ? $game_party.actors : $game_troop.enemies
end
#
# Return group member list
return group
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase gather collateral targets: all identical)
# group : party or troop member list
#--------------------------------------------------------------------------
def collateral_gather_identical(group)
#
# Set receiving array and get list of prev targets
battler_return = []
old_battlers = @target_battlers
#
for target in group # Cycle through group
if old_battlers.include?(target) # If previously targeted
battler_return.push(target) if target.exist? # Add if valid target
end
end
#
# Exit method with gathered
return battler_return
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase gather collateral targets: random other)
# group : party or troop member list
#--------------------------------------------------------------------------
def collateral_gather_other(group)
#
# Set receiving arrays and get list of prev targets
target_list = []
battler_return = []
old_battlers = @target_battlers
#
for target in group # Cycle through group
next if old_battlers.include?(target) # Skip if it was targeted
target_list.push(target) if target.exist? # Add to list if valid
end
#
id = rand(target_list.size) # Choose target in list
new_target = target_list[id] # Acquire target from ID
battler_return.push(new_target) # Add valid target
#
# Exit method with gathered
return battler_return
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase gather collateral targets: all other targets)
# group : party or troop member list
#--------------------------------------------------------------------------
def collateral_gather_all_other(group)
#
# Set receiving array and get list of prev targets
battler_return = []
old_battlers = @target_battlers
#
for target in group # Cycle through group
next if old_battlers.include?(target) # Skip if it was targeted
battler_return.push(target) if target.exist? # Add if valid target
end
#
# Exit method with gathered
return battler_return
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase gather collateral targets: all targets)
# group : party or troop member list
#--------------------------------------------------------------------------
def collateral_gather_all(group)
#
# Set receiving array
battler_return = []
#
for target in group # Cycle through group
battler_return.push(target) if target.exist? # Add if valid target
end
#
# Exit method with gathered
return battler_return
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase collateral action)
#--------------------------------------------------------------------------
def collateral_action
#
# Set flag showing collateral damage is performed (no looping)
@active_battler.collateral_performed = true
# Clear the old flag
@active_battler.collateral_flag = false
# Refresh status window
@status_window.refresh
#
# Branch according to each action
case @active_battler.current_action.kind
when 0 # basic (and attack)
collateral_action_melee if @active_battler.current_action.basic == 0
when 1 # skill
collateral_action_skill
when 2 # item
collateral_action_item
end
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase collateral action : melee attack)
#--------------------------------------------------------------------------
def collateral_action_melee
#
# Set anaimation ID
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
# Apply normal attack results
for target in @target_battlers
next if target.nil?
target.attack_effect(@active_battler)
end
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase collateral action : skill attack)
#--------------------------------------------------------------------------
def collateral_action_skill
#
# 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
# Apply skill effect
for target in @target_battlers
next if target.nil?
target.skill_effect(@active_battler, @skill)
end
#
end
#--------------------------------------------------------------------------
# * Frame Update (main phase collateral action : item attack)
#--------------------------------------------------------------------------
def collateral_action_item
#
# Display item name on help window
@help_window.set_text(@item.name, 1)
# Set animation ID
@animation1_id = @item.animation1_id
@animation2_id = @item.animation2_id
# Apply item effect
for target in @target_battlers
next if target.nil?
target.item_effect(@item)
end
#
end
end
A serious expansion, isn't it? Now the secondary (or collateral) damage can fall along these lines:
0) - The target(s) hit by the attack get a second attack.
1) - One random target is attacked, one not already struck by the initial attack
2) - All 'others' get attacked collaterally.
3) - Everyone gets hit collaterally, even the initial target(s)
And right now, the entries for each skill (cough) are in the form of [type, chance), so you can set an attack to hit everyone with a 25% chance of the collateral damage effect working.
I haven't tested ITEM use, but items SHOULD work.
And I haven't added all the mechanics for MELEE/BASIC as yet. But this should fall along the options of
1) ACTOR (by database ID) ... which would be odd indeed
2) WEAPON (by database ID) ... could make a sword that can have 2x hits
3) ENEMY (by database ID) ... this WOULD allow for enemies that can have 2x hits (which existed before RMXP)
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 19
Threads: 5
Joined: Jul 2020
I like where this is going!
It works properly now against a party of 1 enemy.
There is one more thing: is there a way to prevent the skill from repeating if the enemy dodges it, or if a certain state is applied to him?
This would probably only be of use for a 'Throw-like' skill, since it would not matter for a skill where you shoot two fireballs or two arrows.
Posts: 11,243
Threads: 650
Joined: May 2009
FUNNY you should ask. As of now, I've worked to change the options:
Code: # SKILLS
# -------------------------------------------
# Type Chance Must Hit Halved
# ==== ====== ======== ======
SKILL[1] = [ 3, 50, true, true ] # Heal all 50% chance at 1/2
SKILL[57] = [ 1, 99, false, true ] # CrossCut hits another halved
SKILL[58] = [ 2, 99, false, false ] # Feint hits all others
TYPE: Type of attack as before
CHANCE: Chance of the attacker actually doing the 'collateral' attack
MUST HIT: A true/false value indicating if the initial attack DOES need to hit in the first place.
HALVED: Whether the collateral damage is half damage(true) or full damage(false)*
* The HALVED option needs you to edit the Game_Battler code to add VERY simple lines of code. If the damage generating values were broken up into smaller sections... it wouldn't be an issue.
In the works. :D
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 19
Threads: 5
Joined: Jul 2020
Great stuff. Im looking forward to the newest patch
Posts: 11,243
Threads: 650
Joined: May 2009
Posted in SCRIPTS. 700+ lines. over 200+ lines for instructions.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
|