05-11-2019, 02:45 AM
I've encountered a very bizarre issue with this script. It's a fixed version of Wecoc's battle scope script. It adds more scope options to both items and skills. It's part of his collection that brings features from VX/ACE to XP.
The original bug was that it caused skills or items that revive more than one actor to not work at all. That got fixed but now the new bug it's that causes all the offensive skills aligned with the first element on System (Fire by default) to revive all the dead enemies on battle.
I wasn't able to replicate the glitch on a new project, meaning it must also have something to do with one of the dozen or so scripts on my game. What a pain in the neck.
The original bug was that it caused skills or items that revive more than one actor to not work at all. That got fixed but now the new bug it's that causes all the offensive skills aligned with the first element on System (Fire by default) to revive all the dead enemies on battle.
Code:
#==============================================================================
# [XP] VX Ace Wecoc Features (ACE_WF) VERSION 1.1
#------------------------------------------------------------------------------
# AC : #024
# Name : BATTLE_SCOPE
# Requires : -
# Incompat : -
# Author : Wecoc
#==============================================================================
# Description
#------------------------------------------------------------------------------
# Adds new 'random' scope options to items and skills.
#
# 0: none
# 1: one enemy
# 2: all enemies
# 3: one ally
# 4: all allies
# 5: 1 ally--HP 0
# 6: all allies--HP 0
# 7: the user
#
# 8: 1 random enemy
# 9: 2 random enemies
# 10: 3 random enemies
# 11: 4 random enemies
# 12: 5 random enemies
# 13: 6 random enemies
# 14: 7 random enemies
#
# 15: 1 random ally
# 16: 2 random allies
# 17: 3 random allies
# 18: 4 random allies
# 19: 5 random allies
# 20: 6 random allies
# 21: 7 random allies
#
# 22: 1 random ally--HP 0
# 23: 2 random allies--HP 0
# 24: 3 random allies--HP 0
# 25: 4 random allies--HP 0
# 26: 5 random allies--HP 0
# 27: 6 random allies--HP 0
# 28: 7 random allies--HP 0
#
# - How to call it
# $data_items[id].scope = n
# $data_skills[id].scope = n
#==============================================================================
module ACE_WF
BATTLE_SCOPE = true
end
module RPG
class Item
def to_enemy?
return [1, 2, 8, 9, 10, 11, 12, 13, 14].include?(@scope)
end
def to_ally?
return (to_live_ally? or to_dead_ally?)
end
def to_live_ally?
return [3, 4, 15, 16, 17, 18, 19, 20, 21].include?(@scope)
end
def to_dead_ally?
return [5, 6, 22, 23, 24, 25, 26, 27, 28].include?(@scope)
end
def to_user?
return @scope == 7
end
def to_singular?
return [1, 3, 5, 7, 8, 15, 22].include?(@scope)
end
def to_multiple?
return (not to_singular?)
end
def to_random?
return @scope > 7
end
end
end
module RPG
class Skill
def to_enemy?
return [1, 2, 8, 9, 10, 11, 12, 13, 14].include?(@scope)
end
def to_ally?
return (to_live_ally? or to_dead_ally?)
end
def to_live_ally?
return [3, 4, 15, 16, 17, 18, 19, 20, 21].include?(@scope)
end
def to_dead_ally?
return [5, 6, 22, 23, 24, 25, 26, 27, 28].include?(@scope)
end
def to_user?
return @scope == 7
end
def to_singular?
return [1, 3, 5, 7, 8, 15, 22].include?(@scope)
end
def to_multiple?
return (not to_singular?)
end
def to_random?
return @scope > 7
end
end
end
class Scene_Battle
def set_target_battlers(scope)
live_actors = $game_party.actors.select {|x| x.exist? }
dead_actors = $game_party.actors.select {|x| x && x.hp0?}
live_enemies = $game_troop.enemies.select {|x| x.exist? }
dead_enemies = $game_troop.enemies.select {|x| x && x.hp0?}
# If battler performing action is enemy
if @active_battler.is_a?(Game_Enemy)
case scope
when 1 # single enemy
index = @active_battler.current_action.target_index
@target_battlers.push($game_party.smooth_target_actor(index))
when 2, 11..14 # all enemies
for actor in live_actors + dead_actors # Bugfix
@target_battlers.push(actor)
end
when 3 # single ally
index = @active_battler.current_action.target_index
@target_battlers.push($game_troop.smooth_target_enemy(index))
when 4 # all allies
for enemy in live_enemies + dead_enemies # Bugfix
@target_battlers.push(enemy)
end
when 5 # single ally (HP 0)
index = @active_battler.current_action.target_index
enemy = $game_troop.enemies[index]
if enemy != nil and enemy.hp0?
@target_battlers.push(enemy)
end
when 6 # all allies (HP 0)
for enemy in dead_enemies
@target_battlers.push(enemy)
end
when 7 # user
@target_battlers.push(@active_battler)
when 8 # 1 random enemy
@target_battlers.push(live_actors[rand(live_actors.size)])
when 9 # 2 random enemies
if live_actors.size <= 2
for actor in live_actors
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_actors.size
rand_array.push(rand(live_actors.size))
end
rand_array.uniq!
if rand_array.size >= 2
break
end
end
@target_battlers.push(live_actors[rand_array[0]])
@target_battlers.push(live_actors[rand_array[1]])
end
when 10 # 3 random enemies
if live_actors.size <= 3
for actor in live_actors
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_actors.size
rand_array.push(rand(live_actors.size))
end
rand_array.uniq!
if rand_array.size >= 3
break
end
end
@target_battlers.push(live_actors[rand_array[0]])
@target_battlers.push(live_actors[rand_array[1]])
@target_battlers.push(live_actors[rand_array[2]])
end
when 15 # 1 random ally
@target_battlers.push(live_enemies[rand(live_enemies.size)])
when 16 # 2 random allies
if live_enemies.size <= 2
for enemy in live_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 2
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
end
when 17 # 3 random allies
if live_enemies.size <= 3
for enemy in live_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 3
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
end
when 18 # 4 random allies
if live_enemies.size <= 4
for enemy in live_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 4
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
@target_battlers.push(live_enemies[rand_array[3]])
end
when 19 # 5 random allies
if live_enemies.size <= 5
for enemy in live_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 5
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
@target_battlers.push(live_enemies[rand_array[3]])
@target_battlers.push(live_enemies[rand_array[4]])
end
when 20 # 6 random allies
if live_enemies.size <= 6
for enemy in live_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 6
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
@target_battlers.push(live_enemies[rand_array[3]])
@target_battlers.push(live_enemies[rand_array[4]])
@target_battlers.push(live_enemies[rand_array[5]])
end
when 21 # 7 random allies
if live_enemies.size <= 7
for enemy in live_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 7
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
@target_battlers.push(live_enemies[rand_array[3]])
@target_battlers.push(live_enemies[rand_array[4]])
@target_battlers.push(live_enemies[rand_array[5]])
@target_battlers.push(live_enemies[rand_array[6]])
end
when 22 # 1 random ally --HP=0
@target_battlers.push(dead_enemies[rand(live_enemies.size)])
when 23 # 2 random allies --HP=0
if dead_enemies.size <= 2
for enemy in dead_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...dead_enemies.size
rand_array.push(rand(dead_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 2
break
end
end
@target_battlers.push(dead_enemies[rand_array[0]])
@target_battlers.push(dead_enemies[rand_array[1]])
end
when 24 # 3 random allies --HP=0
if dead_enemies.size <= 3
for enemy in dead_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...dead_enemies.size
rand_array.push(rand(dead_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 3
break
end
end
@target_battlers.push(dead_enemies[rand_array[0]])
@target_battlers.push(dead_enemies[rand_array[1]])
@target_battlers.push(dead_enemies[rand_array[2]])
end
when 25 # 4 random allies --HP=0
if dead_enemies.size <= 4
for enemy in dead_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...dead_enemies.size
rand_array.push(rand(dead_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 4
break
end
end
@target_battlers.push(dead_enemies[rand_array[0]])
@target_battlers.push(dead_enemies[rand_array[1]])
@target_battlers.push(dead_enemies[rand_array[2]])
@target_battlers.push(dead_enemies[rand_array[3]])
end
when 26 # 5 random allies --HP=0
if dead_enemies.size <= 5
for enemy in dead_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...dead_enemies.size
rand_array.push(rand(dead_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 5
break
end
end
@target_battlers.push(dead_enemies[rand_array[0]])
@target_battlers.push(dead_enemies[rand_array[1]])
@target_battlers.push(dead_enemies[rand_array[2]])
@target_battlers.push(dead_enemies[rand_array[3]])
@target_battlers.push(dead_enemies[rand_array[4]])
end
when 27 # 6 random allies --HP=0
if dead_enemies.size <= 6
for enemy in dead_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...dead_enemies.size
rand_array.push(rand(dead_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 6
break
end
end
@target_battlers.push(dead_enemies[rand_array[0]])
@target_battlers.push(dead_enemies[rand_array[1]])
@target_battlers.push(dead_enemies[rand_array[2]])
@target_battlers.push(dead_enemies[rand_array[3]])
@target_battlers.push(dead_enemies[rand_array[4]])
@target_battlers.push(dead_enemies[rand_array[5]])
end
when 28 # 7 random allies --HP=0
if dead_enemies.size <= 7
for enemy in dead_enemies
@target_battlers.push(enemy)
end
else
rand_array = []
loop do
for i in 0...dead_enemies.size
rand_array.push(rand(dead_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 7
break
end
end
@target_battlers.push(dead_enemies[rand_array[0]])
@target_battlers.push(dead_enemies[rand_array[1]])
@target_battlers.push(dead_enemies[rand_array[2]])
@target_battlers.push(dead_enemies[rand_array[3]])
@target_battlers.push(dead_enemies[rand_array[4]])
@target_battlers.push(dead_enemies[rand_array[5]])
@target_battlers.push(dead_enemies[rand_array[6]])
end
end
end
# If battler performing action is actor
if @active_battler.is_a?(Game_Actor)
case scope
when 1 # single enemy
index = @active_battler.current_action.target_index
@target_battlers.push($game_troop.smooth_target_enemy(index))
when 2 # all enemies
for enemy in live_enemies + dead_enemies # Bugfix
@target_battlers.push(enemy)
end
when 3 # single ally
index = @active_battler.current_action.target_index
@target_battlers.push($game_party.smooth_target_actor(index))
when 4, 18..21 # all allies
for actor in live_actors + dead_actors # Bugfix
@target_battlers.push(actor)
end
when 5 # single ally (HP 0)
index = @active_battler.current_action.target_index
actor = $game_party.actors[index]
if actor != nil and actor.hp0?
@target_battlers.push(actor)
end
when 6, 25..28 # all allies (HP 0)
for actor in dead_actors
@target_battlers.push(actor)
end
when 7 # user
@target_battlers.push(@active_battler)
when 8 # 1 random enemy
@target_battlers.push(live_enemies[rand(live_enemies.size)])
when 9 # 2 random enemies
if live_enemies.size <= 2
for actor in live_enemies
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 2
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
end
when 10 # 3 random enemies
if live_enemies.size <= 3
for actor in live_enemies
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 3
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
end
when 11 # 4 random enemies
if live_enemies.size <= 4
for actor in live_enemies
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 4
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
@target_battlers.push(live_enemies[rand_array[3]])
end
when 12 # 5 random enemies
if live_enemies.size <= 5
for actor in live_enemies
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 5
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
@target_battlers.push(live_enemies[rand_array[3]])
@target_battlers.push(live_enemies[rand_array[4]])
end
when 13 # 6 random enemies
if live_enemies.size <= 6
for actor in live_enemies
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 6
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
@target_battlers.push(live_enemies[rand_array[3]])
@target_battlers.push(live_enemies[rand_array[4]])
@target_battlers.push(live_enemies[rand_array[5]])
end
when 14 # 7 random enemies
if live_enemies.size <= 7
for actor in live_enemies
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_enemies.size
rand_array.push(rand(live_enemies.size))
end
rand_array.uniq!
if rand_array.size >= 7
break
end
end
@target_battlers.push(live_enemies[rand_array[0]])
@target_battlers.push(live_enemies[rand_array[1]])
@target_battlers.push(live_enemies[rand_array[2]])
@target_battlers.push(live_enemies[rand_array[3]])
@target_battlers.push(live_enemies[rand_array[4]])
@target_battlers.push(live_enemies[rand_array[5]])
@target_battlers.push(live_enemies[rand_array[6]])
end
when 15 # 1 random ally
@target_battlers.push(live_actors[rand(live_actors.size)])
when 16 # 2 random allies
if live_actors.size <= 2
for actor in live_actors
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_actors.size
rand_array.push(rand(live_actors.size))
end
rand_array.uniq!
if rand_array.size >= 2
break
end
end
@target_battlers.push(live_actors[rand_array[0]])
@target_battlers.push(live_actors[rand_array[1]])
end
when 17 # 3 random allies
if live_actors.size <= 3
for actor in live_actors
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...live_actors.size
rand_array.push(rand(live_actors.size))
end
rand_array.uniq!
if rand_array.size >= 3
break
end
end
@target_battlers.push(live_actors[rand_array[0]])
@target_battlers.push(live_actors[rand_array[1]])
@target_battlers.push(live_actors[rand_array[2]])
end
when 22 # 1 random ally --HP = 0
@target_battlers.push(dead_actors[rand(dead_actors.size)])
when 23 # 2 random allies --HP = 0
if dead_actors.size <= 2
for actor in dead_actors
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...dead_actors.size
rand_array.push(rand(dead_actors.size))
end
rand_array.uniq!
if rand_array.size >= 2
break
end
end
@target_battlers.push(dead_actors[rand_array[0]])
@target_battlers.push(dead_actors[rand_array[1]])
end
when 24 # 3 random allies --HP = 0
if dead_actors.size <= 3
for actor in dead_actors
@target_battlers.push(actor)
end
else
rand_array = []
loop do
for i in 0...dead_actors.size
rand_array.push(rand(dead_actors.size))
end
rand_array.uniq!
if rand_array.size >= 3
break
end
end
@target_battlers.push(dead_actors[rand_array[0]])
@target_battlers.push(dead_actors[rand_array[1]])
@target_battlers.push(dead_actors[rand_array[2]])
end
end
end
end
end
I wasn't able to replicate the glitch on a new project, meaning it must also have something to do with one of the dozen or so scripts on my game. What a pain in the neck.