#============================================================================
# * Mr.Mo's SBABS
#============================================================================
# Mr.Mo "Muhammet Sivri"
# Version 1.0
# 09.16.06
# Thanks to Near Fantastica's methods;
# - In Range?, Get Range, In Direction?, enemy_dead?, treasure
# - Class Game_Range(highly modified for convinience)
# - Scene_Skill(main, update_shk)
# Most were modified by me to my style and to increase performance and
# cleaner code.
#
# Give Credit to Near Fantastica as well, those methods saved me time and helped.
#
#============================================================================
# Intoduction
#============================================================================
# I wasnt happy with the current version of Near's ABS, and he wasn't going to
# update it anymore. So instead I made an ABS.
# Detailed Tutorial on the ABS and HUD modification tutorials added.
#============================================================================
# Explanation
#============================================================================
#--Skill Casting :
# If the skill is not ranged and its suppose to attack one enemy, it will attack
# the closest enemy.
# If the skill scope is more then 1 enemy, it can be ranged. It will just attack
# the enemies in that range.
# The skill animations can be assigned in the Constants section
# The default skill animation suffix is _cast. If you want a skill to have the
# default animation(_casT) just don't do anything for it :)
#--Enemy AI :
# 0 = Dummy - Will not attack but can be attacked
# 1 = See Range - Will attack only if it can see an enemy
# 2 = Hear Range - WIll attack only if it can hear an enemy
# 3 = Hear or See Range - Will attack if it can see or hear enemy
# 4 = Ally Under Attack - Will attack if its ally is under attack and if it can
# see or hear the enemy
# 5 = 1,2,3,4,6 - Will attack if either has happened.
# 6 = Attack if Atacked - Will attack only if attacked.
#
#--Comment List :
# To add a comment, click on the event command list, in the first tab, you should
# see the [ Comment... ] button. It should look similar to this.
#
# V = value
#
# Comment: ABS - Required for recognizing enemies.
# Comment: ID V - Enemy ID from the database.
# Comment: Behavior V - Refer to Enemy AI.
# Comment: Sight V - See range the enemy can hear.
# Comment: Sound V - Sound range the enemy can hear.
# Comment: Aggressiveness V - How fast will the enemy attack.
# Comment: Speed V - How fast will the enemy move when in battle
# Comment: Frequency V - What rate will the enemy move when in battle
# Comment: Trigger V - Refer to Triggers.
# Comment: Respawn V - Respawn Time. If 0, then don't respawn
# Comment: Personality [V] - 1. Able to Attack.
# 2. Stay at distance from hostile.
# 3. Run when dying.
# 4. Do not move.
# 5. Do not turn.
#
# Example:
#
# Comment: ABS
# Comment: ID 1
# Comment: Behavior 1
# Comment: Sight 5
# Comment: Sound 5
# Comment: Aggressiveness 1
# Comment: Speed 4
# Comment: Frequency 4
# Comment: Trigger 0
# Comment: Respawn 0
# Comment: Personality [1,2,4]
#
#--Triggers :
# Trigger 0 - Will erase the event.
# Trigger 1 2 - Will turn on a switch with the ID of 2.
# Trigger 2 5 9 - Will change the Varaible's value with the ID of 5 to 9. If 9 is
# set to 0, the the Variable 5 will be added 1.
# Trigger 3 1 - Will change the local switch of the enemy to 1("A").
# 1 = A
# 2 = B
# 3 = C
# 4 = D
#
#--Startegy Usage :
# You can make an event a dummy, it can still be attacked, but it won't retaliate.
# This is usefull for practices, or teacing the player how to fight. It can also
# be used for NPC's.
#
#--Default Animations
# charactername_melee - melee attacks
# charactername_cast - skills
#============================================================================
#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log("Mr.Mo's ABS", "Mr.Mo", 1, "09.16.06")
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.enabled?("Mr.Mo's ABS") == true
#--------------------------------------------------------------------------
# * Constants - MAKE YOUR EDITS HERE
#--------------------------------------------------------------------------
CAN_DASH = true #Can the player Dash?
CAN_SNEAK = true #Can the player sneak?
#--------------------------------------------------------------------------
ATTACK_KEY = Input::Letters["S"]
#--------------------------------------------------------------------------
# Can the player defend?
CAN_DEFEND = true
# Defend key.
DEFEND_KEY = Input::Letters["D"]
# Defend Animation that will be played if the player animation is turned on.
DEFEND_ANIMATION = "_defend"
# Defend Mash
DEFEND_MASH = 3
# How much percantage should the damge decrease by when
DEFEND_DAMAGE_PERCENT = 50
#--------------------------------------------------------------------------
# Do not change the '=> 0', part.
# To Add more just make a new line; there are 10 examples :P
# Besides Numberkeys, you can use;
# Input::Letters["LETTER"] Make sure the letter is in CAPS.
# Input::Numberpad[number]
# Input::Fkeys[number]
# For more keys look in to the Input Script
SKILL_KEYS = {Input::Numberkeys[2] => 0,
Input::Numberkeys[3] => 0,
Input::Numberkeys[4] => 0,
Input::Numberkeys[5] => 0,
Input::Numberkeys[6] => 0,
Input::Numberkeys[7] => 0,
Input::Numberkeys[8] => 0,
Input::Numberkeys[9] => 0,
Input::Letters["A"] => 0,
}
# You can use a skill key for item key as well, but I used some other keys here
# as well.
ITEM_KEYS = {Input::Numberkeys[0] => 0,
Input::Numberkeys[1] => 0,
Input::Letters["B"] => 0,
}
# NOTE: IF you don't plan to use item or skill hot keys just deleted inside { }.
#--------------------------------------------------------------------------
SNEAK_KEY = Input::Letters["Z"]
DASH_KEY = Input::Letters["X"]
#--------------------------------------------------------------------------
# Make the following nil if you don't want to use any. For example, if I don't
# want to use the HEAL_ALLY_KEY;
# HEAL_ALLY_KEY = nil
#
# When pressed this key the allies will follow you. If in battle they will follow
# 5 seconds and if still in battle they will go back to attack. So you better run :p.
FOLLOW_KEY = Input::Letters["J"]
# I wouldn't use this, it doesn't work will in places where there are alot of obstacles.
# It searches for an enemy 16 tiles away and goes to attack it.
DESTROY_KEY = Input::Letters["K"]
# The party stays behind. Good for securing areas just incase more mosnters come.
STAY_KEY = Input::Letters["L"]
# Changes party leader.
PARTY_FORWARD_KEY = Input::Letters["N"]
# Changes party leader.
PARTY_BACKWARD_KEY = Input::Letters["M"]
# Makes an ally heal an hurt member if the ally has a heal skill.
HEAL_ALLY_KEY = Input::Letters["B"]
#--------------------------------------------------------------------------
# Add Dash and Sneak animation_suffix here.
DASH_ANIMATION = "_dash"
SNEAK_ANIMATION = "_sneak"
# Change characterset when dash or sneak?
DASH_SHO_AN = false
SNEAK_SHO_AN = false
#--------------------------------------------------------------------------
# You do not need to add the animation suffixes if you don't want the player
# to animate when attacking.
#--------------------------------------------------------------------------
#Ranged Weapons
RANGE_WEAPONS = {}
# RANGE_WEAPONS[Weapon_ID] = [Character Set Name, Move Speed, Animation, Ammo, Range,
# Mash Time(in seconds), Kick Back(in tiles),Animation Suffix]
# Leave kickback 0 if you don't want kick back effect.
RANGE_WEAPONS[17] = ["Arrow", 6, 4, 35, 15, 3, 0, "_bow"]
RANGE_WEAPONS[18] = ["Arrow", 6, 4, 35, 15, 4, 0]
RANGE_WEAPONS[33] = ["Ammo", 6, 4, 34, 10, 4, 0]
RANGE_WEAPONS[22] = ["Ammo", 15, 4, 0, 12, 0, 1]
#--------------------------------------------------------------------------
#Ranged Skills
RANGE_SKILLS = {}
# RANGE_SKILLS[Skill_ID] = [Range, Move Speed, Character Set Name, Mash Time(in seconds), Kick Back(in tiles)]
RANGE_SKILLS[7] = [10, 5, "Magic Balls", 3, 1]
RANGE_SKILLS[35] = [10, 5, "Magic Balls", 3, 0]
RANGE_SKILLS[15] = [10, 5, "", 3, 1]
RANGE_SKILLS[81] = [15, 6, "Arrow", 3, 0]
#--------------------------------------------------------------------------
#Ranged Explosives
RANGE_EXPLODE = {}
# RANGE_EXPLODE[Skill_ID] = [Range, Move Speed, Character Set Name, Explosive Range, Mash Time(in seconds), Kick Back(in tiles)]
RANGE_EXPLODE[8] = [10, 6, "183-Rock02", 5, 3, 2]
#--------------------------------------------------------------------------
# Since Melee weapons aren't listed I made this for customazation of melee weapons.
MELEE_CUSTOM = {}
# if left blank the default mash time will be MASH_TIME(below)
# No need to use the animation suffix if you don't plan to animate the player's character set.
# MELEE_CUSTOM[Weapon_ID] = [Mash Time(in seconds), Kick Back(in tiles), animation suffix]
MELEE_CUSTOM[1] = [3, 0, "_melee"]
MELEE_CUSTOM[2] = [10, 1]
#--------------------------------------------------------------------------
# Since some skills won't be listed(i.e non-ranged) I made this for customazation of melee weapons.
SKILL_CUSTOM = {}
# if left blank the default mash time will be MASH_TIME(below)
# No need to use the animation suffix if you don't plan to animate the player's character set.
# SKILL_CUSTOM[Skill_ID] = [Mash Time(in seconds), Kick Back(in tiles), animation suffix]
SKILL_CUSTOM[1] = [3, 0]
SKILL_CUSTOM[7] = [3, 0]
SKILL_CUSTOM[8] = [3, 0, "_cast"]
#--------------------------------------------------------------------------
#Game over once the player is dead?
GAME_OVER_DEAD = true
#--------------------------------------------------------------------------
#Mash Time
#Determines the cool down period between attacks of the player, in seconds.
MASH_TIME = 3
#--------------------------------------------------------------------------
#Should it display damage?
DISPLAY_DAMAGE = true
#--------------------------------------------------------------------------
#Hotkey should say
HOTKEY_SAY = "Assigned to key!"
#--------------------------------------------------------------------------
#Terrain Tag
PASS_TAG = 1
#--------------------------------------------------------------------------
ANIMATE_PLAYER = false
ANIMATE_ENEMY = false
#--------------------------------------------------------------------------
DASH_SPEED = 5
SNEAK_SPEED = 3
#--------------------------------------------------------------------------
#Max frames the player can run or sneak
DASH_MAX = 100
SNEAK_MAX = 100
#--------------------------------------------------------------------------
#Should the states be gone after a while?
STATES_UPDATE = true
#If true
STATES = {}
#STATES[STATE_ID] = [DURATION in FRAMES, 0]
#if Duration is 0 the state will stay there until healed(item, skill).
#10 frames = 1 sec
STATES[1] = 0 #Until Healed
STATES[2] = 200 #20 seconds
STATES[3] = 200 #20 seconds
STATES[4] = 200 #20 seconds
STATES[5] = 200 #20 seconds
STATES[6] = 200 #20 seconds
STATES[7] = 200 #20 seconds
STATES[8] = 200 #20 seconds
STATES[9] = 200 #20 seconds
STATES[10] = 200 #20 seconds
STATES[17] = 200 #20 seconds
STATES[18] = 200 #20 seconds
STATES[19] = 200 #20 seconds
#--------------------------------------------------------------------------
# Allow state effects?
STATE_EFFECTS = true
# Assign the ID of states to each variable. Each effect is described. You can
# add more then one id to each to get the effect you want.
STUN_EFFECT = [2] # No movement/atk/skill, and can't use items.
DAZZLE_EFFECT = [4] # Makes the screen bright.
MUTE_EFFECT = [5] # Can't use skill.
CONFUSE_EFFECT = [6] # Controls randomly don't work.
SLEEP_EFFECT = [7] # Can't move until you get hit.
PARALAYZE_EFFECT = [8] # Move slowly, cant attack or use skills.
CLUMSY_EFFECT = [9,10] # Can't run or sneak.
DELAY_EFFECT = [11] # Walk slow, can't run.
BLIND_EFFECT = [17] # Make screen darker.
SPEED_UP = [18] # Can run without depleting the bar.
LIGHT_FEET =[19] # Can sneak without depleting the bar.
#--------------------------------------------------------------------------
#Display Level UP?
DISPLAY_LEVELUP = true
#Level Up Music, leave "" if no music
LEVELUP_MUSIC = ""
#--------------------------------------------------------------------------
#Fade dead?
FADE_DEAD = true
#--------------------------------------------------------------------------
#How many actors do you want to have in your party?
MAX_ACTORS = 8
#--------------------------------------------------------------------------
ANIMATION_DIVIDE = 2
#--------------------------------------------------------------------------
DAMAGE_FONT_NAME = "Arial Black"
#--------------------------------------------------------------------------
DAMAGE_FONT_SIZE = 22
#--------------------------------------------------------------------------
# To change the color you need to adjust the numbers below.
# The numbers reperesnt 3 colors, red, greend and blue. All you have to do is
# just change the numbers.
# Color.new(RED,GREEN,BLUE)
DAMAGE_FONT_COLOR = Color.new(0,0,0)
#--------------------------------------------------------------------------
# If the party has a revive item, than the player will revive after death.
REVIVE = true
# Death(Knockout) state Id
DEATH_STATE_ID = 1
#--------------------------------------------------------------------------
DISPALY_COMMAND_ICONS = true
#--------------------------------------------------------------------------
# Wall Tag. Determines the walls so the event's can't see through them.
WALL_TAG = 2
#--------------------------------------------------------------------------
# Item Drop Display, if true, display.
ITEM_DROP = true
#--------------------------------------------------------------------------
# After the Item is dropped, how long(in frames 1/10th of a second) should the
# item stay there?
Item_Duration_Time = 300
#--------------------------------------------------------------------------
# Items Weapons Armors and Gold Display
# This is the default item display. If there is no character_set set for specific
# item and Item_Drop is true, then this character set will be used.
DEFAULT_ITEM_DISPLAY = 'Item_Display'
DEFAULT_WEAPON_DISPLAY = 'Item_Display'
DEFAULT_ARMOR_DISPLAY = 'Item_Display'
# Gold Display
GOLD_DISPLAY = 'Gold_Display'
# Items
ITEMS_DISPLAY = {}
# Item ID = 'Character_Set Name'
ITEMS_DISPLAY[1] = 'Item_Display'
ITEMS_DISPLAY[2] = 'Item_Display'
# Weapons
WEAPONS_DISPLAY = {}
# Item ID = 'Character_Set Name'
WEAPONS_DISPLAY[1] = 'Item_Display'
WEAPONS_DISPLAY[2] = 'Item_Display'
# Armor
ARMORS_DISPLAY = {}
# Item ID = 'Character_Set Name'
ARMORS_DISPLAY[1] = 'Item_Display'
ARMORS_DISPLAY[2] = 'Item_Display'
#--------------------------------------------------------------------------
# Display Items and EXP. recieved?
DISPLAY_INFO = true
#--------------------------------------------------------------------------
# If true, the monsters out of the screen will not be updated, there for will
# not move or attack.
UPDATE_ONLY_INSCREEN = false
#--------------------------------------------------------------------------
# The attack time for monsters will be calculated by: BASE_AGGRESSIVE * monster_aggressive
# The higher here the slower. I reccomend using 5 as base if you are making
# Turrets or alike. If you make this lower, the monsters will be faster, so you'll
# have to change monster aggressivenes(in event) a bit higher. I reccomend testing
# with different settings because it sucks to go back and edit each monster...
BASE_AGGRESSIVE = 5
#--------------------------------------------------------------------------
# * Class Mo ABS - DO NOT EDIT BELOW, if you don't know what you are doing :)
#--------------------------------------------------------------------------
class MrMo_ABS
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :active #The ABS Active Boolean
attr_accessor :enemies #Enemy List
attr_accessor :can_dash #Player Dash Boolean
attr_accessor :can_sneak #Player Sneak Boolean
attr_accessor :can_update_states # Can Update States
attr_accessor :attack_key #Attack Key
attr_accessor :skill_keys #Skill Keys
attr_accessor :item_keys #Item Keys
attr_accessor :range
attr_accessor :damage_display
attr_accessor :dash_max
attr_accessor :dash_min
attr_accessor :sneak_max
attr_accessor :sneak_min
attr_accessor :item_duration_time
attr_accessor :treasures
attr_accessor :revive
attr_accessor :display_sprite
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(con=true)
#ABS Active Boolean
@active = con
#ABS Enemy Variables
@enemies = {}
#Dash
@can_dash = CAN_DASH
#Sneak
@can_sneak = CAN_SNEAK
#States
@can_update_states = STATES_UPDATE
#Attack Key
@attack_key = ATTACK_KEY
#Skill Keys
@skill_keys = SKILL_KEYS
#Item Keys
@item_keys = ITEM_KEYS
#Button Mash
@button_mash = 0
#Ranged Skills and Weapons
@range = []
#Display Demage true:false
@damage_display = DISPLAY_DAMAGE
#Game Over?
@game_over = GAME_OVER_DEAD
#Player Animated?
@player_ani = ANIMATE_PLAYER
#Enemy Animated?
@enemy_ani = ANIMATE_ENEMY
# Dashing
@dashing = false
@dash_max = DASH_MAX
@dash_min = @dash_max
@dash_speed = DASH_SPEED
# Sneaking
@sneaking = false
@sneak_max = SNEAK_MAX
@sneak_min = @sneak_max
@sneak_speed = SNEAK_SPEED
#Treasures
@treasures = []
# Old Speed
@old_speed = 4
#PvP - N+ Only
@pvp_active = true
# Item Duration Time
@item_duration_time = Item_Duration_Time
# Movement
@move_check = 0
@player_moved = false
# Revive
@revive = {}
@revive["Map"] = nil
@revive["x"] = nil
@revive["y"] = nil
@revive["Direction"] = nil
# Display Sprite
if DISPLAY_INFO
@display_sprite = Sprite.new
@display_sprite.x += 5
@display_sprite.y += 150
@display_sprite.z = 999999
@display_sprite.bitmap = Bitmap.new(100,100)
@display_y = 0
@number_of_display = 0
end
end
#--------------------------------------------------------------------------
# * Range Weapons
#--------------------------------------------------------------------------
def RANGE_WEAPONS
return RANGE_WEAPONS
end
#--------------------------------------------------------------------------
# * Range Skills
#--------------------------------------------------------------------------
def RANGE_SKILLS
return RANGE_SKILLS
end
#--------------------------------------------------------------------------
# * Range Explode
#--------------------------------------------------------------------------
def RANGE_EXPLODE
return RANGE_EXPLODE
end
#--------------------------------------------------------------------------
# * Hotkey
#--------------------------------------------------------------------------
def HOTKEY_SAY
return HOTKEY_SAY
end
#--------------------------------------------------------------------------
# * Pass Tag
#--------------------------------------------------------------------------
def PASS_TAG
return PASS_TAG
end
#--------------------------------------------------------------------------
# * Max Actors
#--------------------------------------------------------------------------
def MAX_ACTORS
return MAX_ACTORS
end
#--------------------------------------------------------------------------
# * Animation Divide
#--------------------------------------------------------------------------
def ANIMATION_DIVIDE
return ANIMATION_DIVIDE
end
#--------------------------------------------------------------------------
# * Damage Font Size
#--------------------------------------------------------------------------
def DAMAGE_FONT_SIZE
return DAMAGE_FONT_SIZE
end
#--------------------------------------------------------------------------
# * Damage Font Color
#--------------------------------------------------------------------------
def DAMAGE_FONT_COLOR
return DAMAGE_FONT_COLOR
end
#--------------------------------------------------------------------------
# * Damage Font NAme
#--------------------------------------------------------------------------
def DAMAGE_FONT_NAME
return DAMAGE_FONT_NAME
end
#--------------------------------------------------------------------------
# * REVIVE
#--------------------------------------------------------------------------
def REVIVE
return REVIVE
end
#--------------------------------------------------------------------------
# * DEATH_STATE_ID
#--------------------------------------------------------------------------
def DEATH_STATE_ID
return DEATH_STATE_ID
end
#--------------------------------------------------------------------------
# * Display Command Icons
#--------------------------------------------------------------------------
def DISPALY_COMMAND_ICONS
return DISPALY_COMMAND_ICONS
end
#--------------------------------------------------------------------------
# * Defend Damage Percentage
#--------------------------------------------------------------------------
def DEFEND_DAMAGE_PERCENT
return DEFEND_DAMAGE_PERCENT
end
#--------------------------------------------------------------------------
# * Wall Tag
#--------------------------------------------------------------------------
def WALL_TAG
return WALL_TAG
end
#--------------------------------------------------------------------------
# * Item
#--------------------------------------------------------------------------
def ITEMS_DISPLAY
return ITEMS_DISPLAY
end
#--------------------------------------------------------------------------
# * Weapon
#--------------------------------------------------------------------------
def WEAPONS_DISPLAY
return WEAPONS_DISPLAY
end
#--------------------------------------------------------------------------
# * Armor
#--------------------------------------------------------------------------
def ARMORS_DISPLAY
return ARMORS_DISPLAY
end
#--------------------------------------------------------------------------
# * Hide
#--------------------------------------------------------------------------
def hide_allies
for ally in $game_allies
next if ally.nil?
ally.hide
end
end
#--------------------------------------------------------------------------
# * Show
#--------------------------------------------------------------------------
def show_allies
for ally in $game_allies
next if ally.nil?
ally.show
end
end
#--------------------------------------------------------------------------
# * ABS Refresh(Event, List, Characterset Name
#--------------------------------------------------------------------------
def refresh(event, list, character_name)
@get_hate = true
#Delete the event from the list
@enemies.delete(event.id)
#Skip the event if its invisible or doesn't contain a list
return if character_name == "" or list == nil
#Get the parameters
parameters = SDK.event_comment_input(event, 10, "ABS")
#Skip if the paramete is NIL
return if parameters.nil?
#Get Enemy ID
id = parameters[0].split
#Get Enemy
enemy = $data_enemies[id[1].to_i]
#Skip If Enemy is NIL
return if enemy == nil
@enemies[event.id] = ABS_Enemy.new(enemy.id)
#Set Event ID
@enemies[event.id].event_id = event.id
#Get Event
@enemies[event.id].event = event
#Set Behavior
behavior = parameters[1].split
@enemies[event.id].behavior = behavior[1].to_i
#Set See Range
see_range = parameters[2].split
@enemies[event.id].see_range = see_range[1].to_i
#Set Hear Range
hear_range = parameters[3].split
@enemies[event.id].hear_range = hear_range[1].to_i
#Set Aggresiveness
aggressiveness = parameters[4].split
@enemies[event.id].aggressiveness = aggressiveness[1].to_i
#Set Speed
speed = parameters[5].split
@enemies[event.id].speed = speed[1].to_i
#Set Frequency
freq = parameters[6].split
@enemies[event.id].frequency = freq[1].to_i
#Set Trigger
trigger = parameters[7].split
@enemies[event.id].trigger= [trigger[1].to_i, trigger[2].to_i, trigger[3].to_i]
#Respawn
if parameters[8] != nil
respawn = parameters[8].split
@enemies[event.id].respawn = respawn[1].to_i * 10
end
#Personality
if parameters[9] != nil
per = parameters[9].split
@enemies[event.id].personality = eval(per[1])
end
end
#--------------------------------------------------------------------------
# * Update(Frame)
#--------------------------------------------------------------------------
def update
#Update Player
update_player if @active
#Update Dash
update_dash if @can_dash
#Update Sneak
update_sneak if @can_sneak
#Update States
update_states if @can_update_states
#Update Allies
for ally in $game_allies
next if ally.nil?
ally.update
end
#Update Ranged
for range in @range
next if range.nil?
range.update
end
#Update Treasure
for treasure in @treasures
next if treasure.nil?
treasure.update
end
# Display Sprite
if DISPLAY_INFO and (@display_sprite.nil? or @display_sprite.disposed?)
@display_sprite = Sprite.new
@display_sprite.x += 5
@display_sprite.y += 150
@display_sprite.z = 999999
@display_sprite.bitmap = Bitmap.new(200,200)
@display_sprite.bitmap.font.color = Color.new(0,0,0,255)
@display_sprite.bitmap.font.size = 18
@display_sprite.src_rect.set(0, 0, 200, 200)
@display_y = 0
@number_of_display = 0
end
# Update Display
if DISPLAY_INFO and @display_y > 0
@number_of_display += 1
if @number_of_display > 100
@display_sprite.bitmap.clear
@number_of_display = 0
@display_y = 0
@display_sprite.oy = 0
@display_sprite.src_rect.set(0, 0, 200, 200)
end
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
@display_sprite.dispose if !@display_sprite.nil? and !@display_sprite.disposed?
for ally in $game_allies
next if ally.nil?
ally.command_sprite.dispose
end
end
#--------------------------------------------------------------------------
# * Revive Actor
#--------------------------------------------------------------------------
def revive_actor
items = []
# Get the item that revives
for i in $game_party.items.keys
next if $game_party.items[i] == 0 or $game_party.items[i] == nil
item = $data_items[i]
next if !item.minus_state_set.include?(DEATH_STATE_ID) or item.scope < 3
items.push(i)
end
# If list is empty
if items == [] or items == nil or !REVIVE
$game_temp.gameover = @game_over if $game_party.all_dead?
else
i = rand(items.size)
item = $data_items[items[i]]
# If effect scope is an ally
if item.scope >= 3
# Apply item use effects to target actor
target = @actor
used = target.item_effect(item)
# If an item was used
if used
#Show animation on player
$game_player.animation_id = item.animation1_id
# Play item use SE
$game_system.se_play(item.menu_se)
# If consumable; Decrease used items by 1
$game_party.lose_item(item.id, 1) if item.consumable
# If all party members are dead; Switch to game over screen
return game_over(true) if $game_party.all_dead?
# If common event ID is valid; Common event call reservation
return $game_temp.common_event_id = item.common_event_id if item.common_event_id > 0
# If effect scope is other than an ally
end
else
# If command event ID is valid
if item.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = item.common_event_id
# Play item use SE
$game_system.se_play(item.menu_se)
# If consumable; Decrease used items by 1
$game_party.lose_item(item.id, 1) if item.consumable
end
end
end
end
#--------------------------------------------------------------------------
# * Update States(Frame)
#--------------------------------------------------------------------------
def update_states
# For Player
for actor in $game_party.actors
next if actor == nil
for id in actor.states
next if !STATES.has_key?(id)
state = STATES[id]
next if state == 0
add_state_effect(id,actor.ally) if actor.state_time == 0
actor.state_time += 1
if actor.state_time >= state
actor.remove_state(id)
actor.state_time = 0
remove_state_effects(id,actor.ally)
return
end
update_states_effects(id,actor.ally)
end
if actor.hp > 0 and actor.slip_damage? and Graphics.frame_count % (40) == 0 and !$game_player.moving?
actor.hp -= [actor.maxhp / 100, 1].max
if actor.hp == 0
$game_system.se_play($data_system.actor_collapse_se)
if $game_party.all_dead?
revive_actor
else
$game_party.move_forward if $game_party.actors[0] == actor
end
end
$game_screen.start_flash(Color.new(255,0,0,128), 4)
end
end
end
#--------------------------------------------------------------------------
# * Add State Effect(State, ID)
#--------------------------------------------------------------------------
def add_state_effect(id,player)
if STATE_EFFECTS
if DAZZLE_EFFECT.include?(id)
$game_screen.start_tone_change(Tone.new(200, 200, 130, 0), 20)
elsif BLIND_EFFECT.include?(id)
$game_screen.start_tone_change(Tone.new(-200,-200,-200, 0), 50)
elsif STUN_EFFECT.include?(id)
player.movable = false
elsif SLEEP_EFFECT.include?(id)
player.movable = false
elsif PARALAYZE_EFFECT.include?(id)
if @sneaking or @dashing
player.move_speed = player.old_speed
@sneaking = false
@dashing = false
end
player.old_speed = player.move_speed
elsif DELAY_EFFECT.include?(id)
if @sneaking or @dashing
player.move_speed = player.old_speed
@sneaking = false
@dashing = false
end
player.old_speed = player.move_speed
end
end
end
#--------------------------------------------------------------------------
# * Update State Effect(ID, Player)
#--------------------------------------------------------------------------
def update_states_effects(id,player)
return if !STATE_EFFECTS
if PARALAYZE_EFFECT.include?(id)
player.move_speed = 1
elsif DELAY_EFFECT.include?(id)
player.move_speed = 2
elsif SPEED_UP.include?(id)
@dash_min = @dash_max
elsif LIGHT_FEET.include?(id)
@sneak_min = @sneak_max
end
end
#--------------------------------------------------------------------------
# * Removve State Effect(id , Player)
#--------------------------------------------------------------------------
def remove_state_effects(id,player)
return if !STATE_EFFECTS
if STUN_EFFECT.include?(id)
player.movable = true
elsif DAZZLE_EFFECT.include?(id)
$game_screen.start_tone_change(Tone.new(0, 0, 0, 0), 50)
elsif BLIND_EFFECT.include?(id)
$game_screen.start_tone_change(Tone.new(0, 0, 0, 0), 50)
elsif SLEEP_EFFECT.include?(id)
player.movable = true
elsif PARALAYZE_EFFECT.include?(id)
player.move_speed = player.old_speed
elsif DELAY_EFFECT.include?(id)
player.move_speed = player.old_speed
end
end
#--------------------------------------------------------------------------
# * Update Respawn(enemy)
#--------------------------------------------------------------------------
def update_respawn(enemy)
event = enemy.event
return if enemy.respawn == 0 or event.erased == false
enemy.respawn -= 1
if enemy.respawn == 0
event.moveto(event.event.x,event.event.y)
event.erased = false
event.refresh
for ally in $game_allies
next if ally == nil or ally.dead?
ally.button_mash = 30
end
end
end
#--------------------------------------------------------------------------
# * Update Enemy AI(Frame)
#--------------------------------------------------------------------------
def update_enemy(event)
# Enemy
enemy = @enemies[event.id]
return if enemy.nil? or !@active
if enemy.dead?
return update_respawn(enemy)
end
#Update Enemy State
update_enemy_state(enemy)
#Skip if not on screen
return if UPDATE_ONLY_INSCREEN and !in_screen?(enemy.event)
enemy.go_to == [] if (enemy.go_to != [] and enemy.go_to[0] == enemy.event.x and enemy.go_to[1] == enemy.event.y) or enemy.in_battle
enemy.event.move_pos(enemy.go_to) if !enemy.in_battle and enemy.go_to != [] and !enemy.event.moving?
return if !enemy.in_battle and !update_enemy_ai(enemy)
update_enemy_battle(enemy) if enemy.in_battle and enemy.behavior != 0
end
#--------------------------------------------------------------------------
# * Update Enemy State(Enemy)
#--------------------------------------------------------------------------
def update_enemy_state(enemy)
for id in enemy.states
next if !STATES.has_key?(id)
state = STATES[id]
next if state == 0
enemy.state_time += 1
if enemy.state_time >= state
enemy.remove_state(id)
enemy.state_time = 0
return
end
end
if enemy.hp > 0 and enemy.slip_damage? and Graphics.frame_count % (40) == 0
enemy.hp -= [enemy.maxhp / 100, 1].max
if enemy.hp <= 0
enemy_dead?(enemy,nil)
end
end
end
#--------------------------------------------------------------------------
# * Update Enemy Battle(Enemy)
#--------------------------------------------------------------------------
def update_enemy_battle(enemy)
#If the enemy can't see it's enemy, skip the enemy
if !in_range?(enemy.event, enemy.attacking.event, enemy.see_range) and
!in_range?(enemy.event, enemy.attacking.event, enemy.hear_range)
enemy.go_to = [enemy.attacking.event.x,enemy.attacking.event.y]
#Restore movement
restore_movement(enemy)
#Take it out off battle
enemy.in_battle = false
enemy.attacking = nil
return
elsif enemy.attacking == nil or enemy.attacking.actor.dead?
# Restore movement
restore_movement(enemy)
# Take it out off battle
enemy.in_battle = false
enemy.attacking = nil
return
end
#Update the enemy attack or follow
update_enemy_attack(enemy,enemy.attacking) if Graphics.frame_count % (enemy.aggressiveness * BASE_AGGRESSIVE) == 0
#Skip this if the attack killed the enemy
return if enemy == nil or enemy.attacking == nil or enemy.event.moving?
# Ranged
if enemy.personality.include?(2)
enemy.event.move_away(enemy.attacking.event) if in_range?(enemy.event, enemy.attacking.event, 2)
return enemy.event.turn_to(enemy.attacking.event) if !enemy.personality.include?(5)
end
# Run
if enemy.personality.include?(3)
if in_range?(enemy.event, enemy.attacking.event, 4) and enemy.low_hp?
return enemy.event.move_away(enemy.attacking.event)
elsif enemy.low_hp?
return
end
end
enemy.event.move_to(enemy.attacking.event) if !in_range?(enemy.event, enemy.attacking.event, 1) and !enemy.personality.include?(4) and !enemy.personality.include?(2)
enemy.event.turn_to(enemy.attacking.event) if !in_direction?(enemy.event, enemy.attacking.event) and in_range?(enemy.event, enemy.attacking.event, 1) and !enemy.personality.include?(5)
end
#--------------------------------------------------------------------------
# * Update Enemy AI(Enemy)
#--------------------------------------------------------------------------
def update_enemy_ai(enemy)
#Get the enemy behavior
b = enemy.behavior
return true if b == 0 # Dummy
#Next enemy if this enemy can't see the player
return true if b == 1 and !can_enemy_see(enemy)
#Next enemy if this enemy can't hear the player
return true if b == 2 and !can_enemy_hear(enemy)
#Next enemy if this enemy can't see or hear the player
return true if b == 3 and !can_enemy_see(enemy) and !can_enemy_hear(enemy)
#Next if its not
return true if b == 4 and !enemy_ally_in_battle?(enemy)
#Next enemy if this enemy can't see or hear the player
return true if b == 5 and !can_enemy_see(enemy) and !can_enemy_hear(enemy) and !enemy_ally_in_battle?(enemy)
#Next enemy if this enemy can't see or hear the player
return true if b == 6 # Attack if attacked
#Return false
return false
end
#--------------------------------------------------------------------------
# * Obstocle Check
#--------------------------------------------------------------------------
def obstocle_check(subject,object)
# Check Wall
range = get_range(subject,object)
dir = subject.direction
case dir
when 2 # Down
for i in 0..range
return false if !$game_map.passable?(subject.x,subject.y+i,dir) and $game_map.terrain_tag(subject.x,subject.y+i) != PASS_TAG
end
when 4 # Left
for i in 0..range
return false if !$game_map.passable?(subject.x-i,subject.y,dir) and $game_map.terrain_tag(subject.x-i,subject.y) != PASS_TAG
end
when 6 # Right
for i in 0..range
return false if !$game_map.passable?(subject.x+i,subject.y,dir) and $game_map.terrain_tag(subject.x+i,subject.y) != PASS_TAG
end
when 8 # Up
for i in 0..range
return false if !$game_map.passable?(subject.x,subject.y-i,dir) and $game_map.terrain_tag(subject.x,subject.y-i) != PASS_TAG
end
end
return true
end
#--------------------------------------------------------------------------
# * Update Enemy Attack(Enemy)
#--------------------------------------------------------------------------
def update_enemy_attack(e,actor)
#Return if the enemy can't attack
return if e.actions == nil or e.actions == []
#Get all actions
for action in e.actions
#Next if enemy can't attack
next if enemy_pre_attack(e, action)
#Get the current action kind
case action.kind
when 0 # Basic
#Get the action
case action.basic
when 0 #Attack
next if !in_range?(e.event, actor.event, 1) or !in_direction?(e.event, actor.event)
#Attack it's enemy
a = actor.actor
a.effect_attack(e)
#Animate the enemy
e.event.animation_id = e.animation1_id
animate(e.event, "_melee") if @enemy_ani
#Show Animation
hit_enemy(actor,e) if a.damage != "Miss" and a.damage != 0
#Check if enemy's enemy is dead
return if enemy_dead?(a,e)
#Make enemy
a = actor if a.is_a?(Game_Actor)
return if a.attacking == e and a.in_battle
#Set the new target for the enemy
a.attacking = e
#Setup movement
setup_movement(e)
#The enemy is now in battle
a.in_battle = true
return
when 1..3 #Nothing
return
end
when 1..2 #Skill
#Get the skill
skill = $data_skills[action.skill_id]
#Return if the skill is NIL
return if skill == nil
id = skill.id
#Activate Common Event
if skill.common_event_id > 0
# Common event call reservation
$game_temp.common_event_id = skill.common_event_id
end
#Get the skill scope
case skill.scope
when 1 # One Enemy
next if !in_direction?(e.event, actor.event)
next if !e.can_use_skill?(skill)
#Animate the enemy
if RANGE_SKILLS.has_key?(skill.id)
return e.event.move_to(actor.event) if !obstocle_check(e.event,actor.event)
@range.push(Game_Ranged_Skill.new(e.event, e, skill))
e.sp -= skill.sp_cost
e.event.animation_id = skill.animation1_id
animate(e.event, "_cast") if @enemy_ani
return
end
e.event.animation_id = skill.animation1_id
animate(e.event, "_cast") if @enemy_ani
# Add Player and Allies
enemies = []
enemies.push($game_player)
for ally in $game_allies
next if ally == nil
enemies.push(ally)
end
#Order them from closest to the farthest
enemies.sort! {|a,b|
get_range(e.event,a.event) - get_range(e.event,b.event)}
#Attack the closest one
enemies[0].actor.effect_skill(e, skill)
#Take off SP
e.sp -= skill.sp_cost
#Show Animetion on enemy
hit_enemy(enemies[0], e, skill.animation2_id) if enemies[0].actor.damage != "Miss" and enemies[0].actor.damage != 0
#Return if enemy is dead
return if enemy_dead?(enemies[0].actor,e)
return
when 3..4, 7 # User
next if e.hp > skill.power.abs
#Animate the enemy
e.event.animation_id = skill.animation1_id
animate(e.event, "_cast") if @enemy_ani
e.effect_skill(e, skill)
e.sp -= skill.sp_cost
e.event.animation_id = skill.animation2_id
return
end
return
end
end
end
#--------------------------------------------------------------------------
# * Update Player
#--------------------------------------------------------------------------
def update_player
#If the actor is dead
$game_party.move_forward if $game_party.actors[0].dead?
#Keep the current party leader updated
@actor = $game_party.actors[0]
# Check for command keys
party_command_keys
#Update click time
@button_mash -= 1 if @button_mash > 0
return if @button_mash > 0
# Check Defend
if CAN_DEFEND
# Check Defend key
if Input.trigger?(DEFEND_KEY)
player_defend
else
@actor.guarding = false
end
end
#Check Ranged attack
if Input.trigger?(@attack_key)
#Check State Effect
if STATE_EFFECTS
for id in $game_party.actors[0].states
return if STUN_EFFECT.include?(id) or PARALAYZE_EFFECT.include?(id)
end
end
return player_range if RANGE_WEAPONS.has_key?(@actor.weapon_id)
return player_melee
end
return if @enemies == {}
#Check for Skill attacks
for key in @actor.skill_keys.keys
next if @actor.skill_keys[key] == nil or @actor.skill_keys[key] == 0
next if !Input.trigger?(key)
if STATE_EFFECTS
for i in $game_party.actors[0].states
return if STUN_EFFECT.include?(i) or PARALAYZE_EFFECT.include?(i) or MUTE_EFFECT.include?(i)
end
end
id = @actor.skill_keys[key]
if RANGE_EXPLODE.has_key?(id)
return player_explode(id)
else
return player_skill(id)
end
end
#Check Item
check_item
end
#--------------------------------------------------------------------------
# * Player Defend
#--------------------------------------------------------------------------
def player_defend
@actor.guarding = true
@mash_time = DEFEND_MASH
return if $game_player.animating_e
animate($game_player, DEFEND_ANIMATION.to_s) if @player_ani
end
#--------------------------------------------------------------------------
# * Party Command Keys
#--------------------------------------------------------------------------
def party_command_keys
if FOLLOW_KEY != nil and Input.trigger?(FOLLOW_KEY)
for ally in $game_allies
next if ally == nil or ally.map_id != $game_map.map_id
ally.follow
end
elsif DESTROY_KEY != nil and Input.trigger?(DESTROY_KEY)
for ally in $game_allies
next if ally == nil or ally.map_id != $game_map.map_id
ally.destroy
end
elsif STAY_KEY != nil and Input.trigger?(STAY_KEY)
for ally in $game_allies
next if ally == nil or ally.map_id != $game_map.map_id
ally.stay
end
elsif HEAL_ALLY_KEY != nil and Input.trigger?(HEAL_ALLY_KEY)
for ally in $game_allies
next if ally == nil or ally.map_id != $game_map.map_id
ally.heal = true
end
elsif PARTY_FORWARD_KEY != nil and Input.trigger?(PARTY_FORWARD_KEY)
$game_party.move_forward
elsif PARTY_BACKWARD_KEY != nil and Input.trigger?(PARTY_BACKWARD_KEY)
$game_party.move_backward
end
end