if SDK.state("Caldaron's Battle")
class ABS
attr_accessor :actor
attr_accessor :enemies
attr_accessor :events
attr_accessor :event_triggers
attr_accessor :active
attr_accessor :actor_battle
attr_accessor :e_animations
attr_accessor :p_animations
attr_accessor :portrait
def initialize
@portrait = false
@p_animations = false
@p_animations = false
@actor = $game_party.actors[0]
@actor_battle = false
@enemies = {}
@events = {} # Hash of Dead Events
@event_triggers = {} # Hash of the Triggers of Dead Events
$game_player.move_speed = 3
end
def setup_enemies(events)
@enemies = {}
for event in events.values
settings = SDK.event_comment_input(event, 5, 'ABS Enemy')
next unless settings
enemy_setup = settings[0].to_s.split
behaviour_setup = settings[1].to_s.split
range_setup = settings[2].to_s.split
coward_setup = settings[3].to_s.split
trigger_setup = settings[4].to_s.split
id = enemy_setup[0].to_i
troop = enemy_setup[1]
immortal = eval(enemy_setup[2]) # true/false
alignment = behaviour_setup[0].to_i
# 0 = attack none
# 1 = attack evil
# 2 = attack player and good
# 3 = attack player
# 4 = attack player and evil
# 5 = attack good
# 6 = attack all
reaction = behaviour_setup[1].to_i
# 0 = attack none
# 1 = attack attacker
# 2 = attack attacker and evil
# 3 = attack attacker and good
# 4 = attack all
allied = eval(behaviour_setup[2])
find_range = range_setup[0].to_i
attack_range = range_setup[1].to_f
help = eval(coward_setup[0]) # calls troop for help (true/false)
run = coward_setup[1].to_i # runs away when hp is run %
trigger_type = trigger_setup[0]
trigger = trigger_setup[1]
for enemy in $data_enemies
next unless enemy
if id == enemy.id
@enemies[event.id] = ABS::Enemy.new(enemy.id)
@enemies[event.id].event_id = event.id
@enemies[event.id].troop = "ABS #{event.id}"
@enemies[event.id].troop = troop.upcase unless troop == nil
@enemies[event.id].find_range = find_range
@enemies[event.id].attack_range = attack_range
@enemies[event.id].help = help
@enemies[event.id].run = run/100.00
@enemies[event.id].alignment = alignment
@enemies[event.id].allied = allied
@enemies[event.id].reaction = reaction
@enemies[event.id].immortal = immortal
@enemies[event.id].trigger_type = trigger_type
@enemies[event.id].trigger = trigger
@agi = @enemies[event.id].agi/$game_party.actors[0].agi
if @agi < 0.75
@agi = 1
elsif @agi < 1
@agi = 2
elsif @agi < 1.25
@agi = 3
elsif @agi < 1.5
@agi = 4
else
@agi = 5
end
event.move_speed = @agi
break
end
end
end
end
def update
update_actor if @actor_battle
for enemy in @enemies.values
update_enemy(enemy)
end
update_status
update_hud
end
def update_actor
@actor = $game_party.actors[0]
@actor.abs.chill
end
def update_enemy(enemy)
enemy.find_alignment
if enemy.engaged
enemy.guarding = false # Resets guarding
enemy.chill if enemy.cooldown != 0 # Decrease cooldown
if enemy.cooldown == 0
enemy.reset if enemy.check_ai # Reset timers
enemy.cooldown /= 2 if enemy.guarding
end
enemy.path_find # Pathfind to the player
end
if enemy.dead?
for sprite in $scene.spriteset.character_sprites
sprite.animation($data_animations[3],true) if sprite.character == $game_map.events[enemy.event_id]
end
collect_spoils(enemy) if enemy.attackers.include?($ABS.actor)
remove(enemy)# Remove enemy based on its triggers
end
end
#----------------------------------------------------------------------
def update_status
if @actor.dead?
$game_temp.gameover = true # End game if dead.
end
end
#----------------------------------------------------------------------
def update_hud
#hud shit goes here
end
#----------------------------------------------------------------------
# * ABS Functions
#----------------------------------------------------------------------
# Handles anything regarding the ABS best done outside of other classes
#----------------------------------------------------------------------
def collect_spoils(enemy)
exp = enemy.exp # Set to the enemy's EXP amount
exp = Integer(exp/enemy.attackers.size * 1.00)
gold = enemy.gold # Set to the enemy's GOLD amount
gold = Integer(gold/enemy.attackers.size * 1.00)
if rand(100) < enemy.treasure_prob # Random Probability of SPOIL
if enemy.item_id > 0 # If its an ITEM
treasure = $data_items[enemy.item_id]
end
if enemy.weapon_id > 0 # If its a WEAPON
treasure = $data_weapons[enemy.weapon_id]
end
if enemy.armor_id > 0 # If its an ARMOR
treasure = $data_armors[enemy.armor_id]
end
end
@actor.exp += exp unless @actor.cant_get_exp? # Add Appropriate EXP
$game_party.gain_gold(gold) # Add Appropriate GOLD
case treasure
when RPG::Item
$game_party.gain_item(treasure.id, 1) # Add ITEM
when RPG::Weapon
$game_party.gain_weapon(treasure.id, 1) # Add WEAPON
when RPG::Armor
$game_party.gain_armor(treasure.id, 1) # Add ARMOR
end
end
#----------------------------------------------------------------------
def remove(enemy)
for attacker in @enemies.values
attacker.attackers.delete(enemy)
end
@enemies.delete(enemy.event_id) # Remove dead enemy from hash
case enemy.trigger_type.upcase
when 'LOCAL' # If trigger is a local switch
case enemy.trigger.upcase
when 'A','B','C','D' # If the trigger is a valid trigger
event = $game_map.events[enemy.event_id]
key = [event.map_id, event.id, enemy.trigger.upcase]
$game_self_switches[key] = true
@events[event.id] = event
@event_triggers[event.id] = enemy.trigger.upcase
event.refresh
return
end
when 'SELF' # If trigger is a local switch
case enemy.trigger.upcase
when 'A','B','C','D' # If the trigger is a valid trigger
event = $game_map.events[enemy.event_id]
key = [event.map_id, event.id, enemy.trigger.upcase]
$game_self_switches[key] = true
@events[event.id] = event
@event_triggers[event.id] = enemy.trigger_type.upcase
event.refresh
return
end
when 'SWITCH' # If the trigger is a switch
if enemy.trigger.to_i > 0 # If the trigger is a valid switch
$game_switches[enemy.trigger.to_i] = true
event.refresh
return
end
when 'CHEST'
event = $game_map.events[enemy.event_id]
key = [event.map_id, event.id, 'A']
$game_self_switches[key] = true
@events[event.id] = event
@event_triggers[event.id] = enemy.trigger_type.upcase
event.refresh
return
end
# Else just remove the event lickity split.
$game_map.events[enemy.event_id].character_name = ''
$game_map.events[enemy.event_id].erase
end
#----------------------------------------------------------------------
# * Calculation Functions
#----------------------------------------------------------------------
# Handles range and direction checks
#----------------------------------------------------------------------
def check_range(element, object, range = 0)
element = $game_map.events[element.event_id] if element.is_a?(ABS::Enemy)
object = $game_map.events[object.event_id] if object.is_a?(ABS::Enemy)
x = (object.x - element.x)
y = (object.y - element.y)
if (x*x+y*y) <= (range * range)
return true
end
return false
end
#----------------------------------------------------------------------
def find_range(element, object)
element = $game_map.events[element.event_id] if element.is_a?(ABS::Enemy)
object = $game_map.events[object.event_id] if object.is_a?(ABS::Enemy)
x = (object.x - element.x) * (object.x - element.x)
y = (object.y - element.y) * (object.y - element.y)
return (x + y)
end
#----------------------------------------------------------------------
def check_facing(element, object, magic = 0)
return true if element == object
element = $game_map.events[element.event_id] if element.is_a?(ABS::Enemy)
object = $game_map.events[object.event_id] if object.is_a?(ABS::Enemy)
case magic
when 2, 4
return true
when 1, 3
if element.direction == 2
return true if object.y >= element.y
end
if element.direction == 4
return true if object.x <= element.x
end
if element.direction == 6
return true if object.x >= element.x
end
if element.direction == 8
return true if object.y <= element.y
end
when 0
if element.direction == 2
return true if object.y > element.y
end
if element.direction == 4
return true if object.x < element.x
end
if element.direction == 6
return true if object.x > element.x
end
if element.direction == 8
return true if object.y < element.y
end
end
return false
end
#----------------------------------------------------------------------
# * ABS Animation Engine Functions
#----------------------------------------------------------------------
# Handles animating map sprites for a wide variety of uses
#----------------------------------------------------------------------
def animate(object, animation_name, position, wait = 8, frames = 0, repeat = 0)
if object != nil
object.animate(animation_name, position, frames, wait, repeat)
end
end
end
class Game_Battler
def skill_can_use?(skill_id)
if $data_skills[skill_id].sp_cost > self.sp and self.maxsp > 0
return false
end
if dead?
return false
end
if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
return false
end
occasion = $data_skills[skill_id].occasion
if $scene.is_a?(Scene_Map)
return (occasion == 0 or occasion == 1)
else
return (occasion == 0 or occasion == 2)
end
end
end
#-----------------------------------------------------------------------------#
# â–º Game_Event
#-----------------------------------------------------------------------------#
class Game_Event
attr_reader :page
attr_reader :map_id
def name
return @event.name
end
end
#-----------------------------------------------------------------------------#
# â–º Game_Map
#-----------------------------------------------------------------------------#
class Game_Map
alias prexus_abs_g_map_setup setup
def setup(map_id)
prexus_abs_g_map_setup(map_id)
$ABS = ABS.new if !$ABS
$ABS.setup_enemies(@events)
end
end
#-----------------------------------------------------------------------------#
# â–º Spriteset_Map
#-----------------------------------------------------------------------------#
class Spriteset_Map
attr_accessor :character_sprites
attr_accessor :viewport4
alias prex_abs_sset_map_init_viewports init_viewports
def init_viewports
prex_abs_sset_map_init_viewports
@viewport4 = Viewport.new(0, 0, 640, 480)
@viewport4.z = 6000
end
alias prex_abs_sset_map_update update
def update
prex_abs_sset_map_update
@viewport4.update
end
end
#-----------------------------------------------------------------------------#
# â–º Window_Skill
#-----------------------------------------------------------------------------#
class Window_Skill < Window_Selectable
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
if $ABS.actor.abs.hot_key.include?(skill.id)
self.contents.font.color = Color.new(0, 225, 0, 255)
else
self.contents.font.color = normal_color
end
else
if $ABS.actor.abs.hot_key.include?(skill.id)
self.contents.font.color = Color.new(0, 225, 0, 160)
else
self.contents.font.color = disabled_color
end
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
end
end
#-----------------------------------------------------------------------------#
# â–º Interpreter
#-----------------------------------------------------------------------------#
class Interpreter
def event
return $game_map.events[@event_id]
end
end
#-----------------------------------------------------------------------------#
# â–º Scene_Title
#-----------------------------------------------------------------------------#
class Scene_Title
alias prexus_abs_s_title_main_database main_database
def main_database
prexus_abs_s_title_main_database
$ABS = nil
$data_skills.each {|s| s.set_range if s}
$data_weapons.each {|s| s.set_range if s}
for i in 1...$data_animations.size
i = $data_animations.frames
for j in 0...i.size
for k in 0...i[j].cell_max
i[j].cell_data[k, 1] /= 3
i[j].cell_data[k, 2] /= 3
i[j].cell_data[k, 3] /= 3
end
end
end
end
end
module RPG
class Animation
class Frame
attr_accessor :cell_data
end
end
end
#-----------------------------------------------------------------------------#
# â–º Scene_Map
#-----------------------------------------------------------------------------#
class Scene_Map
attr_accessor :spriteset
alias prexus_abs_s_map_update update
def update
if Input.trigger?(Input::ALT)
$ABS.actor_battle = $ABS.actor_battle == true ? false : true
end
$ABS.update
if !$ABS.actor.abs.acted and !$game_party.actors[0].guarding? and $ABS.actor_battle
$ABS.actor.abs.attack if Input.trigger?(Input::C)
$ABS.actor.abs.cast($ABS.actor.abs.hot_key[0]) if Input.trigger?(Input::X)
$ABS.actor.abs.cast($ABS.actor.abs.hot_key[1]) if Input.trigger?(Input::Y)
$ABS.actor.abs.cast($ABS.actor.abs.hot_key[2]) if Input.trigger?(Input::Z)
elsif !$ABS.actor_battle
if $ABS.actor.abs.hot_key[0]
skill1 = $data_skills[$ABS.actor.abs.hot_key[0]]
$ABS.actor.abs.cast($ABS.actor.abs.hot_key[0]) if Input.trigger?(Input::X) and [3, 4, 7].include?(skill1.scope) and (skill1.power < 1 or skill1.minus_state_set.size > 0)
end
if $ABS.actor.abs.hot_key[1]
skill2 = $data_skills[$ABS.actor.abs.hot_key[1]]
$ABS.actor.abs.cast($ABS.actor.abs.hot_key[1]) if Input.trigger?(Input::Y) and [3, 4, 7].include?(skill2.scope) and (skill2.power < 1 or skill2.minus_state_set.size > 0)
end
if $ABS.actor.abs.hot_key[2]
skill3 = $data_skills[$ABS.actor.abs.hot_key[2]]
$ABS.actor.abs.cast($ABS.actor.abs.hot_key[2]) if Input.trigger?(Input::Z) and [3, 4, 7].include?(skill3.scope) and (skill3.power < 1 or skill3.minus_state_set.size > 0)
end
end
prexus_abs_s_map_update
end
alias prex_abs_s_map_transfer_player transfer_player
def transfer_player
for i in 0..$game_map.events.size
event = $ABS.events
trigger = $ABS.event_triggers
next unless event and trigger
next if trigger.upcase == 'SELF'
if ['A', 'B', 'C', 'D'].include?(trigger.upcase)
key = [event.map_id, event.id, trigger]
$game_self_switches[key] = false
$ABS.events.delete(event)
$ABS.event_triggers.delete(trigger)
next
end
if trigger.upcase == 'CHEST'
key = [event.map_id, event.id, 'A']
$game_self_switches[key] = false
key = [event.map_id, event.id, 'B']
$game_self_switches[key] = false
key = [event.map_id, event.id, 'C']
$game_self_switches[key] = false
key = [event.map_id, event.id, 'D']
$game_self_switches[key] = false
$ABS.events.delete(event)
$ABS.event_triggers.delete(trigger)
next
end
end
prex_abs_s_map_transfer_player
end
end
#-----------------------------------------------------------------------------#
# â–º Scene_Skill
#-----------------------------------------------------------------------------#
class Scene_Skill
alias prexus_abs_s_skill_update update
def update
if Input.trigger?(Input::X)
skill = @skill_window.skill
unless $ABS.actor.abs.hot_key[0] or
$ABS.actor.abs.hot_key.include?(skill.id)
$ABS.actor.abs.hot_key[0] = skill.id
$game_system.se_play($data_system.decision_se)
end
@skill_window.refresh
return
end
if Input.trigger?(Input::Y)
skill = @skill_window.skill
unless $ABS.actor.abs.hot_key[1] or
$ABS.actor.abs.hot_key.include?(skill.id)
$ABS.actor.abs.hot_key[1] = skill.id
$game_system.se_play($data_system.decision_se)
end
@skill_window.refresh
return
end
if Input.trigger?(Input::Z)
skill = @skill_window.skill
unless $ABS.actor.abs.hot_key[2] or
$ABS.actor.abs.hot_key.include?(skill.id)
$ABS.actor.abs.hot_key[2] = skill.id
$game_system.se_play($data_system.decision_se)
end
@skill_window.refresh
return
end
prexus_abs_s_skill_update
end
end
#-----------------------------------------------------------------------------#
# â–º Scene_Save
#-----------------------------------------------------------------------------#
class Scene_Save < Scene_File
alias prex_abs_s_save_write_data write_data
def write_data(file)
prex_abs_s_save_write_data(file)
Marshal.dump($ABS, file)
end
end
#-----------------------------------------------------------------------------#
# â–º Scene_Load
#-----------------------------------------------------------------------------#
class Scene_Load < Scene_File
alias prex_abs_s_load_read_data read_data
def read_data(file)
prex_abs_s_load_read_data(file)
$ABS = Marshal.load(file)
end
end
#-----------------------------------------------------------------------------#
# â–º RPG::Sprite
#-----------------------------------------------------------------------------#
module RPG
class Sprite < ::Sprite
def damage(value, critical)
dispose_damage
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = $fontface
bitmap.font.size = 18
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(0, 96, 0)
elsif value.is_a?(Numeric) and value > 0
bitmap.font.color.set(96, 0, 0)
else
bitmap.font.color.set(0, 0, 96)
end
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(0, 255, 0)
elsif value.is_a?(Numeric) and value > 0
bitmap.font.color.set(255, 0, 0)
else
bitmap.font.color.set(0, 0, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.color.set(96, 96, 0)
bitmap.draw_text(-1, -1, 160, 20, "Nice!", 1)
bitmap.draw_text(+1, -1, 160, 20, "Nice!", 1)
bitmap.draw_text(-1, +1, 160, 20, "Nice!", 1)
bitmap.draw_text(+1, +1, 160, 20, "Nice!", 1)
bitmap.font.color.set(255, 255, 0)
bitmap.draw_text(0, 0, 160, 20, "Nice!", 1)
end
@_damage_sprite = ::Sprite.new($scene.spriteset.viewport4)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = x
@_damage_sprite.y = y - oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end
#-----------------------------------------------------------------------------#
# â–º RPG::Skill
#-----------------------------------------------------------------------------#
module RPG
class Skill
attr_accessor :range
attr_accessor :slip_damage
#--------------------------------------------------------------------
# * Instructions:
# Add new spells and their ranges by adding these lines:
# when "SpellName"
# @range = valueforrange
#--------------------------------------------------------------------
# For Example:
# when "Cross Cut"
# @range = 2
#--------------------------------------------------------------------
def set_range
@range = 1
case self.id
# Add New Lines Here:
when 57
@range = 40
when 1, 4, 7, 25, 28, 45
@range = 6
when 3, 5, 27, 30, 46
@range = 4
when 61
@range = 2
end
end
end
#--------------------------------------------------------------------
class Weapon
attr_accessor :range
def set_range
@range = 1
case self.id
when 4..8
@range = Math.sqrt(2)
when 1
@range = 6
when 2
@range = 4
when 3
@range = 6
end
end
end
end
class Game_Player < Game_Character
#--------------------------------------------------------------------
alias caldaron_abs_game_player_update_action_trigger update_action_trigger
#--------------------------------------------------------------------
def update_action_trigger
caldaron_abs_game_player_update_action_trigger unless $ABS.actor_battle
end
=begin
#--------------------------------------------------------------------
alias caldaron_abs_game_player_trigger_touch check_event_trigger_touch
#--------------------------------------------------------------------
def
end
check_event_trigger_touch(x, y)
caldaron_abs_game_player_trigger_touch(x, y) unless $ABS.actor_battle
end
#--------------------------------------------------------------------
end
class Game_Event < Game_Character
#--------------------------------------------------------------------
alias caldaron_abs_game_event_trigger_touch check_event_trigger_touch
#--------------------------------------------------------------------
def check_event_trigger_touch(x, y)
caldaron_abs_game_event_trigger_touch(x, y) unless $ABS.actor_battle
end
#--------------------------------------------------------------------
=end
end