A Skill that throws enemies?
#6
(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...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }


Messages In This Thread
A Skill that throws enemies? - by Bennerdeben - 09-28-2024, 08:42 AM
RE: A Skill that throws enemies? - by DerVVulfman - 09-29-2024, 09:49 PM
RE: A Skill that throws enemies? - by Bennerdeben - 09-30-2024, 09:10 AM
RE: A Skill that throws enemies? - by DerVVulfman - 09-30-2024, 03:33 PM
RE: A Skill that throws enemies? - by Bennerdeben - 10-01-2024, 08:18 AM
RE: A Skill that throws enemies? - by DerVVulfman - 10-01-2024, 08:19 PM
RE: A Skill that throws enemies? - by Bennerdeben - 10-02-2024, 12:49 PM
RE: A Skill that throws enemies? - by DerVVulfman - 10-03-2024, 04:15 AM
RE: A Skill that throws enemies? - by Bennerdeben - 10-03-2024, 09:02 AM
RE: A Skill that throws enemies? - by DerVVulfman - 10-08-2024, 02:15 PM
RE: A Skill that throws enemies? - by Bennerdeben - 10-08-2024, 05:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Plugin or Script help with Item menu, SKill menu, and Equip menu JayRay 2 60 Yesterday, 03:09 AM
Last Post: JayRay
   Actors & enemies without Morale Bennerdeben 4 2,199 07-15-2023, 06:21 PM
Last Post: Bennerdeben
   [RMXP] Showing skill gained by leveling up on battle result FrQise 12 12,641 05-07-2021, 02:05 PM
Last Post: FrQise
   Skill Cooldown script Fenriswolf 11 16,429 12-10-2019, 11:10 AM
Last Post: Fenriswolf
   Scan skill should show states Tumen 5 9,208 05-02-2017, 03:33 AM
Last Post: DerVVulfman
   Dervvulfman's Skill Tree (Micko's) Passive Skill Malfunction! reiji1337 6 9,764 04-28-2017, 03:27 AM
Last Post: reiji1337
   RMXP SKill animations too bright (overlaying the battle screen) Starmage 4 10,151 06-13-2016, 03:41 AM
Last Post: Starmage
   Lycan abs - Making enemies flee on sight ChickenFetus 1 4,411 06-07-2016, 04:39 AM
Last Post: DerVVulfman
   Atoa ACBS HP Regen Skill Lightness 11 14,087 03-11-2016, 10:43 PM
Last Post: Lightness
   Inserting MOG Chain Commands in a particular Skill ID iceflux 6 12,820 08-27-2015, 06:33 PM
Last Post: iceflux



Users browsing this thread: 4 Guest(s)