Bienvenue visiteur !
|
Statistiques
Liste des membres
Contact
Mentions légales
274 connectés actuellement
30732931 visiteurs depuis l'ouverture
2910 visiteurs aujourd'hui
Partenaires
Tous nos partenaires
Devenir partenaire
|
Messages postés par Benjaminatorus Nombre de messages référencés sur Oniromancie (non supprimés): 1 Aller à la page: 1
Posté dans Scripts - AMS Ultimate |
benjaminatorus -
posté le 29/11/2011 à 23:17:36. (1 messages postés) |
| Spoiler (cliquez pour afficher) Bonjour bonsoir, je suis nouveau dans le making, et j'essaye de toucher un petit peu aux scripts depuis peu et même si je ne comprends pas tout j'arrive parfois à comprendre certaines lignes. Enfin bref, je te remercie déjà, Zeus, pour ce magnifique script.
Et je me demandais si il y avait un moyen de le rendre compatible avec le script ABS 4.5 de Mr.Mo qui permet de jouer en A-RPG.
Apparement, lorsque j'utilise les 2, bien que le jeu se lance et que j'ai accés au menu dans le jeu, il semble que je ne puisse plus déplacer le héros avec les touches directionnelles et je n'arrive pas à savoir pourquoi.
Merci d'avance si vous avez une solution.
Voici le script :
# * Mr.Mo's ABS
#============================================================================
# Mr.Mo "Muhammet Sivri"
# Version 4.5
# 01/04/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
#
#--Enemy Explanation :
# Hate Points - The enemy will randomly give out hate points to all of it's enemies.
# Later, it's enemies will be ordered from most to least hate points.
#
# Hate Groups - The enemy will attack hate groups, meaning other enemies.
# The hate group enemies aren't considered allies.
# The player's hate id is 0.
# Do not use the event ID, use the Monster ID, you can find it
# in the Database, Enemies Tab.
#
# Closest Enemy - The enemy will attack the closest enemy, if met the right AI
# conditions. Hate points are no longer needed, if this BOOLEAN
# is true.
#
#
#--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: ClosestEnemy V - Refer to Enemy explantion
# Comment: HateGroup [V] - Refer to Enemy explantion
# 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
#
# Example:
#
# Comment: ABS
# Comment: ID 1
# Comment: Behavior 1
# Comment: Sight 5
# Comment: Sound 5
# Comment: ClosestEnemy true
# Comment: HateGroup [0]
# Comment: Aggressiveness 1
# Comment: Speed 4
# Comment: Frequency 4
# Comment: Trigger 0
# Comment: Respawn 0
#
#--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 :
# The ABS can be used to setup wars and make fights between NPCs. Imagination is
# the limit.
# The events do not need to attack the player. Just remove the 0 from the hate
# group list.
#
# 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.
#
# Make allias for the player. Remove the 0 from the hate group list and add all
# the monsters(their enemy IDs, database) on the map. The allias won't follow the player or anything
# but they would attack other monsters giving the effect of allince.
#
# Monster Pit Fights can also be made.
#
#--Default Animations
# charactername_melee - melee attacks
# charactername_cast - skills
#============================================================================
#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log("Mr.Mo's ABS", "Mr.Mo", 4.5, "01/04/06")
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.state("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"]
#--------------------------------------------------------------------------
# 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:keys[number]
# For more keys look in to the Input Script
SKILL_KEYS = {Input::Numberkeys[0] => 0,
Input::Numberkeys[1] => 0,
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"]
#--------------------------------------------------------------------------
# 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", 5, 4, 35, 10, 3, 1, "_bow"]
RANGE_WEAPONS[18] = ["Arrow", 5, 4, 35, 10, 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]
#--------------------------------------------------------------------------
#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]
MELEE_CUSTOM[49] = [5, 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
# When the leader dies and there are alive members, change party leader?
NEXT_LEADER = 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 = "Assigner à la touche"
#--------------------------------------------------------------------------
#Terrain Tag
PASS_TAG = 1
#--------------------------------------------------------------------------
ANIMATE_PLAYER = true
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 = "004-Victory04"
#--------------------------------------------------------------------------
#Fade dead?
FADE_DEAD = true
#--------------------------------------------------------------------------
#Can Hurt Allies
CAN_HURT_ALLY = true
#--------------------------------------------------------------------------
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,255)
#--------------------------------------------------------------------------
# If the party has a revive item, than the player will revive after death.
REVIVE = true
# Death(Knockout) state Id
DEATH_STATE_ID = 1
#--------------------------------------------------------------------------
# * Class Mo ABS - DO NOT EDIT BELOW, if you don't know what you are doing
#--------------------------------------------------------------------------
class MrMo_ABS
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :enemies #Enemy List
attr_accessor :can_dash #Player Dash Boolean
attr_accessor :can_sneak #Player Sneak Boolean
attr_accessor :can_update_states # Update States
attr_accessor :attack_key #Attack Key
attr_accessor kill_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 neak_max
attr_accessor neak_min
attr_accessor :active
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
#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
#Get Hate
@get_hate = true
# 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
# Old Speed
@old_speed = 4
# PvP - N+ Only
@pvp_active = true
# ABS Active
@active = true
end
#--------------------------------------------------------------------------
# * Range Weapons
#--------------------------------------------------------------------------
def RANGE_WEAPONS
return RANGE_WEAPONS
end
#--------------------------------------------------------------------------
# * Damage Font Size
#--------------------------------------------------------------------------
def DAMAGE_FONT_SIZE
return DAMAGE_FONT_SIZE
end
#--------------------------------------------------------------------------
# * Damage Font Name
#--------------------------------------------------------------------------
def DAMAGE_FONT_NAME
return DAMAGE_FONT_NAME
end
#--------------------------------------------------------------------------
# * Damage Font Color
#--------------------------------------------------------------------------
def DAMAGE_FONT_COLOR
return DAMAGE_FONT_COLOR
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
#--------------------------------------------------------------------------
# * Animation Divide
#--------------------------------------------------------------------------
def ANIMATION_DIVIDE
return ANIMATION_DIVIDE
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, 11, "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 Closest Enemy Boolean
closest_enemy = parameters[4].split
@enemies[event.id].closest_enemy = eval(closest_enemy[1])
#Set Hate Group
hate_group = parameters[5].split
@enemies[event.id].hate_group = eval(hate_group[1])
#Set Aggresiveness
aggressiveness = parameters[6].split
@enemies[event.id].aggressiveness = aggressiveness[1].to_i
#Set Speed
speed = parameters[7].split
@enemies[event.id].temp_speed = speed[1].to_i
#Set Frequency
freq = parameters[8].split
@enemies[event.id].temp_frequency = freq[1].to_i
#Set Trigger
trigger = parameters[9].split
@enemies[event.id].trigger= [trigger[1].to_i, trigger[2].to_i, trigger[3].to_i]
#Respawn
if parameters[10] != nil
respawn = parameters[10].split
@enemies[event.id].respawn = respawn[1].to_i * 10
end
end
#--------------------------------------------------------------------------
# * Make Hate Points(Enemy)
#--------------------------------------------------------------------------
def make_hate_points(e)
#Get all the enemies of the enemy
e.hate_points[$game_player.event_id] = rand(999)
for id in e.hate_group
#See if the ID in the Hate group is in the enemy ID
for enemy in @enemies.values
#Skip NIL values
next if enemy == nil
if enemy.enemy_id == id
#Insert in to the list if the enemy is in hate group
e.hate_points[enemy.event_id] = rand(999)
end
end
end
end
#--------------------------------------------------------------------------
# * Update(Frame)
#--------------------------------------------------------------------------
def update
#Update Player
update_player if @active
#Update Enemy AI
update_enemy if @enemies != {} and @active
#Update Dash
update_dash if @can_dash
#Update Sneak
update_sneak if @can_sneak
#Update States
update_states if @can_update_states
#Update Ranged
for range in @range
next if range == nil
range.update
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 == 0 or $game_party.items == nil
item = $data_items
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
else
i = rand(items.size)
item = $data_items[items]
# 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 $scene = Scene_Gameover.new 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
actor = $game_party.actors[0]
for id in $game_party.actors[0].states
next if !STATES.has_key?(id)
state = STATES[id]
next if state == 0
add_state_effect(state,id) if actor.state_time == 0
actor.state_time += 1
if actor.state_time >= state
$game_party.actors[0].remove_state(id)
actor.state_time = 0
remove_state_effects(id)
return
end
update_states_effects(id)
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 NEXT_LEADER and !$game_party.all_dead?
move_forward
else
revive_actor
end
end
$game_screen.start_flash(Color.new(255,0,0,128), 4)
end
end
#--------------------------------------------------------------------------
# * Add State Effect(State, ID)
#--------------------------------------------------------------------------
def add_state_effect(state,id)
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)
$game_player.movable = false
elsif SLEEP_EFFECT.include?(id)
$game_player.movable = false
elsif PARALAYZE_EFFECT.include?(id)
if @sneaking or @dashing
$game_player.move_speed = @old_speed
@sneaking = false
@dashing = false
end
@old_speed = $game_player.move_speed
elsif DELAY_EFFECT.include?(id)
if @sneaking or @dashing
$game_player.move_speed = @old_speed
@sneaking = false
@dashing = false
end
@old_speed = $game_player.move_speed
end
end
end
#--------------------------------------------------------------------------
# * Update State Effect(State, ID)
#--------------------------------------------------------------------------
def update_states_effects(id)
return if !STATE_EFFECTS
if PARALAYZE_EFFECT.include?(id)
$game_player.move_speed = 1
elsif DELAY_EFFECT.include?(id)
$game_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(State, ID)
#--------------------------------------------------------------------------
def remove_state_effects(id)
return if !STATE_EFFECTS
if STUN_EFFECT.include?(id)
$game_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)
$game_player.movable = true
elsif PARALAYZE_EFFECT.include?(id)
$game_player.move_speed = @old_speed
elsif DELAY_EFFECT.include?(id)
$game_player.move_speed = @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
end
end
#--------------------------------------------------------------------------
# * Update Enemy AI(Frame)
#--------------------------------------------------------------------------
def update_enemy
#Get all the enemies on the list
for enemy in @enemies.values
#Skip NIL values
next if enemy == nil
if enemy.dead?
update_respawn(enemy)
next
end
#Update Enemy State
update_enemy_state(enemy)
#Skip if not on screen
next if !in_screen?(enemy.event)
#Make Hate Points
make_hate_points(enemy) if @get_hate
next if !enemy.in_battle and !update_enemy_ai(enemy)
update_enemy_battle(enemy) if enemy.in_battle and enemy.behavior != 0
end
@get_hate = false
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)) or
(enemy.attacking == nil or enemy.attacking.actor.dead? or !enemy.hate_group.include?(enemy.attacking.enemy_id))
# 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 * 30) == 0
# Skip this if the attack killed the enemy
return if enemy == nil or enemy.attacking == nil or enemy.event.moving?
enemy.event.move_to(enemy.attacking.event) if !in_range?(enemy.event, enemy.attacking.event, 1)
enemy.event.turn_to(enemy.attacking.event) if !in_direction?(enemy.event, enemy.attacking.event) and in_range?(enemy.event, enemy.attacking.event, 1)
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)
#Return false
return false
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 == [] or e == nil
#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 if actor.is_a?(ABS_Enemy)
a = $game_party.actors[0] if !actor.is_a?(ABS_Enemy)
a.attack_effect(e)
#Animate the enemy
e.event.animation_id = e.animation1_id
animate(e.event, e.event.character_name+"_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
return if !a.is_a?(ABS_Enemy)
return if a.attacking == e and a.in_battle
#Set the new target for the enemy
a.attacking = e
#The enemy is now in battle
a.in_battle = true
#Setup movement
setup_movement(e)
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
#Get the skill scope
case skill.scope
when 1 # One Enemy
return if Graphics.frame_count % (e.aggressiveness * 30) != 0
next if !in_direction?(e.event, actor.event)
next if !e.can_use_skill?(skill)
#Animate the enemy
e.event.animation_id = skill.animation1_id
animate(e.event, e.event.character_name+"_cast") if @enemy_ani
if RANGE_SKILLS.has_key?(skill.id)
@range.push(Game_Ranged_Skill.new(e.event, e, skill))
e.sp -= skill.sp_cost
return
end
#If the skill is not ranged
enemies = []
#Get all enemies
for enemy in @enemies.values
next if enemy == nil or enemy == e
next if !e.hate_group.include?(enemy.enemy_id)
enemies.push(enemy)
end
enemies.push($game_player) if e.hate_group.include?(0)
#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 if enemies[0].is_a?(Game_Player)
return if enemies[0].attacking == e and enemies[0].in_battle
#If its alive, put it in battle
enemies[0].in_battle = true
#Make it attack the player
enemies[0].attacking = e
#Setup movement
setup_movement(e)
return
when 3..4, 7 # User
return if Graphics.frame_count % (e.aggressiveness * 100) != 0
next if e.hp > skill.power.abs
#Animate the enemy
e.event.animation_id = skill.animation1_id
animate(e.event, e.event.character_name+"_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
#Keep the current party leader updated
@actor = $game_party.actors[0]
#Update click time
@button_mash -= 1 if @button_mash > 0
return if @button_mash > 0
#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 @skill_keys.keys
next if @skill_keys[key] == nil or @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 = @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
#--------------------------------------------------------------------------
# * Check Item
#--------------------------------------------------------------------------
def check_item
#Check for item usage
for key in @item_keys.keys
next if @item_keys[key] == nil or @item_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)
end
end
item = $data_items[@item_keys[key]]
return $game_system.se_play($data_system.buzzer_se) if !$game_party.item_can_use?(item.id)
# If items are used up; Play buzzer SE
return $game_system.se_play($data_system.buzzer_se) if $game_party.item_number(item.id) == 0
# If effect scope is an ally
if item.scope >= 3
# Apply item use effects to target actor
target = $game_party.actors[0]
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 $scene = Scene_Gameover.new 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
#--------------------------------------------------------------------------
# * Player Ranged Attack
#--------------------------------------------------------------------------
def player_range
#Get the weapon
w = RANGE_WEAPONS[@actor.weapon_id]
#Return if the ammo isn't there
return if w[3] != 0 and $game_party.item_number(w[3]) == 0
$game_player.animation_id = $data_weapons[@actor.weapon_id].animation1_id
#Add mash time
@button_mash = (w[5] == nil ? MASH_TIME*10 : w[5]*10)
#Delete an ammo
$game_party.lose_item(w[3], 1) if w[3] != 0
#Make the attack
@range.push(Game_Ranged_Weapon.new($game_player, @actor, @actor.weapon_id))
#Animate
return if w[7] == nil
animate($game_player, $game_player.character_name+w[7].to_s) if @player_ani
return
end
#--------------------------------------------------------------------------
# * Player Melee Attack
#--------------------------------------------------------------------------
def player_melee
return if $data_weapons[@actor.weapon_id] == nil
#Get all enemies
for e in @enemies.values
#Skip NIL values or dead enemies
next if e == nil or e.dead?
#Skip the enemy if its not close by or not facing
next if !in_direction?($game_player, e.event) or !in_range?($game_player, e.event, 1)
# Skip if the enemy is an ally and can't hurt allies.
next if !CAN_HURT_ALLY and e.hate_group.include?(0)
# Show Weapon Aniamtion
$game_player.animation_id = $data_weapons[@actor.weapon_id].animation1_id
#Add mash time
m = MELEE_CUSTOM[@actor.weapon_id]
if m != nil and m[0] != nil
@button_mash = m[0]*10
else
@button_mash = MASH_TIME*10
end
#Attack the enemy
e.attack_effect(@actor)
#Get Animation
a = $data_weapons[@actor.weapon_id].animation2_id
#Hit enemy if the attack succeeds
hit_enemy(e, @actor, a) if e.damage != "Miss" and e.damage != 0
#Jump
jump(e.event, $game_player, MELEE_CUSTOM[@actor.weapon_id][1]) if MELEE_CUSTOM[@actor.weapon_id] != nil and e.damage != "Miss" and e.damage != 0
#Animate the player
if MELEE_CUSTOM[@actor.weapon_id] != nil and MELEE_CUSTOM[@actor.weapon_id][2] == nil
animate($game_player, $game_player.character_name+"_melee") if @player_ani
elsif MELEE_CUSTOM[@actor.weapon_id] != nil
m = MELEE_CUSTOM[@actor.weapon_id][2]
animate($game_player, $game_player.character_name+m.to_s) if @player_ani
end
#Return if the enemy is dead
return if enemy_dead?(e,@actor)
return if !e.hate_group.include?(0)
#Set the new target for the enemy
e.attacking = $game_player
#The enemy is now in battle
e.in_battle = true
#Setup movement
setup_movement(e)
end
end
#--------------------------------------------------------------------------
# * Player Skill Attack
#--------------------------------------------------------------------------
def player_skill(id)
@actor = $game_party.actors[0]
#Get Skill
skill = $data_skills[id]
#Return if the skill doesn't exist
return if skill == nil
#Return if the actor doesn't have the skill
return if !@actor.skills.include?(skill.id)
#Return if the actor can't use the skill
return if !@actor.can_use_skill?(skill)
# Show Animation
$game_player.animation_id = skill.animation1_id
#Animate
if SKILL_CUSTOM.has_key?(id)
l = SKILL_CUSTOM[id]
animate($game_player, $game_player.character_name+l[2].to_s) if @player_ani
else
animate($game_player, $game_player.character_name+"_cast") if @player_ani
end
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 #Enemy
#If the skill is ranged
if RANGE_SKILLS.has_key?(skill.id)
#Add to range
@range.push(Game_Ranged_Skill.new($game_player, @actor, skill))
#Take off SP
@actor.sp -= skill.sp_cost
w = RANGE_SKILLS[id]
#Add mash time
@button_mash = (w[3] == nil ? MASH_TIME*10 : w[3]*10)
return
end
if SKILL_CUSTOM[id] != nil
@button_mash = (SKILL_CUSTOM[id] == nil ? MASH_TIME*10 : SKILL_CUSTOM[id] != nil and SKILL_CUSTOM[id][0] != nil ? SKILL_CUSTOM[id][0]*10 : MASH_TIME*10)
else
@button_mash = MASH_TIME*10
end
#If the skill is not ranged
enemies = []
#Get all enemies
for enemy in @enemies.values
next if enemy == nil
next if !enemy.hate_group.include?(0) and !CAN_HURT_ALLY
enemies.push(enemy)
end
e = $game_player
#Order them from closest to the farthest
enemies.sort! {|a,b|
get_range(e.event,a.event) - get_range(e.event,b.event) }
# Return if enemies = nil
return if enemies[0] == nil
# Attack the closest one
enemies[0].effect_skill(@actor, skill)
#Take off SP
@actor.sp -= skill.sp_cost
#Show Animetion on enemy
hit_enemy(enemies[0], @actor, skill.animation2_id) if enemies[0].damage != "Miss" and enemies[0].damage != 0
e = enemies[0]
jump(e.event, $game_player, SKILL_CUSTOM[id][1]) if SKILL_CUSTOM[id] != nil and e.damage != "Miss" and e.damage != 0
#Return if enemy is dead
return if enemy_dead?(enemies[0],@actor)
return if !enemy.hate_group.include?(0)
#If its alive, put it in battle
enemies[0].in_battle = true
#Make it attack the player
enemies[0].attacking = $game_player
#Setup movement
setup_movement(enemies[0])
return
when 2 #All Emenies
#Play the animation on player
$game_player.animation_id = skill.animation2_id
#Take off SP
@actor.sp -= skill.sp_cost
id = skill.id
#If the skill is ranged
if RANGE_SKILLS.has_key?(skill.id)
enemies = get_all_range($game_player, RANGE_SKILLS[skill.id][0])
w = RANGE_SKILLS[id]
#Add mash time
@button_mash = (w[3] == nil ? MASH_TIME*10 : w[3]*10)
else
if SKILL_CUSTOM[id] != nil
@button_mash = (SKILL_CUSTOM[id] == nil ? MASH_TIME*10 : SKILL_CUSTOM[id] != nil and SKILL_CUSTOM[id][0] != nil ? SKILL_CUSTOM[id][0]*10 : MASH_TIME*10)
else
@button_mash = MASH_TIME*10
end
enemies = @enemies
end
#Get all enemies
for e in enemies.values
#Skip NIL values
next if e== nil
# Skip if the enemy is an ally and can't hurt allies.
next if !CAN_HURT_ALLY and e.hate_group.include?(0)
#Attack enemy
e.effect_skill(@actor, skill)
#Show Animetion on enemy
hit_enemy(e, @actor, 0) if e.damage != "Miss" and e.damage != 0
jump(e.event, $game_player, SKILL_CUSTOM[id][1]) if SKILL_CUSTOM[id] != nil and e.damage != "Miss" and e.damage != 0
#Skip this enemy if its dead
next if enemy_dead?(e,@actor)
next if !e.hate_group.include?(0)
#If its alive, put it in battle
e.in_battle = true
#Make it attack the player
e.attacking = $game_player
#Setup movement
setup_movement(e)
end
return
when 3..4, 7 #User
if SKILL_CUSTOM[id] != nil
@button_mash = (SKILL_CUSTOM[id] == nil ? MASH_TIME*10 : SKILL_CUSTOM[id] != nil and SKILL_CUSTOM[id][0] != nil ? SKILL_CUSTOM[id][0]*10 : MASH_TIME*10)
else
@button_mash = MASH_TIME*10
end
#Use the skill on the player
@actor.effect_skill(@actor, skill)
#Take off SP
@actor.sp -= skill.sp_cost
#Play animation
$game_player.animation_id = skill.animation2_id
return
end
end
#--------------------------------------------------------------------------
# * Player Explode Attack
#--------------------------------------------------------------------------
def player_explode(id)
#Get Skill
skill = $data_skills[id]
#Return if the skill doesn't exist
return if skill == nil
#Return if the actor doesn't have the skill
return if !@actor.skills.include?(skill.id)
#Return if the actor can't use the skill
return if !@actor.can_use_skill?(skill)
w = RANGE_EXPLODE[skill.id]
# Show Animation
$game_player.animation_id = skill.animation1_id
#Add mash time
@button_mash = (w[4] == nil ? MASH_TIME*10 : w[4]*10)
#Animate
if SKILL_CUSTOM.has_key?(id)
l = SKILL_CUSTOM[id]
animate($game_player, $game_player.character_name+l[2].to_s) if @player_ani
else
animate($game_player, $game_player.character_name+"_cast") if @player_ani
end
#Add to range
@range.push(Game_Ranged_Explode.new($game_player, @actor, skill))
#Take off SP
@actor.sp -= skill.sp_cost
return
end
#--------------------------------------------------------------------------
# * Enemy Dead?(Enemy) or (Player)
#--------------------------------------------------------------------------
def enemy_dead?(e,a)
#Return a new method if e is an actor
return player_dead?(e,a) if e.is_a?(Game_Actor)
#Return false if enemy dead
return false if !e.dead?
enemy = e
treasure(enemy) if a != nil and a.is_a?(Game_Actor)
a.attacking = nil if a != nil and !a.is_a?(Game_Actor)
a.in_battle = false if a != nil and !a.is_a?(Game_Actor)
id = enemy.event_id
#Remove from list
@enemies.delete(id) if @enemies[id].respawn == 0
event = enemy.event
case enemy.trigger[0]
when 0
event.fade = true if FADE_DEAD
if !FADE_DEAD
event.character_name = ""
event.erase
end
when 1
event.fade = true if FADE_DEAD
print "EVENT " + event.id.to_s + "Trigger Not Set Right ~!" if enemy.trigger[1] == 0
$game_switches[enemy.trigger[1]] = true
$game_map.need_refresh = true
when 2
event.fade = true if FADE_DEAD
print "EVENT " + event.id.to_s + "Trigger Not Set Right ~!" if enemy.trigger[1] == 0
if enemy.trigger[2] == 0
$game_variables[enemy.trigger[1]] += 1
$game_map.need_refresh = true
else
$game_variables[enemy.trigger[1]] = enemy.trigger[2]
$game_map.need_refresh = true
end
when 3
event.fade = true if FADE_DEAD
value = "A" if enemy.trigger[1] == 1
value = "B" if enemy.trigger[1] == 2
value = "C" if enemy.trigger[1] == 3
value = "D" if enemy.trigger[1] == 4
print "EVENT " + event.id.to_s + "Trigger Not Set Right ~!" if value == 0
key = [$game_map.map_id, event.id, value]
$game_self_switches[key] = true
$game_map.need_refresh = true
end
#Return true if the e is dead
return true
end
#--------------------------------------------------------------------------
# * Player Dead(Player,Enemy)
#--------------------------------------------------------------------------
def player_dead?(a,e)
#Check State Effect
if STATE_EFFECTS
for id in $game_party.actors[0].states
$game_player.movable = true if SLEEP_EFFECT.include?(id)
$game_party.actors[0].states.delete(id) if SLEEP_EFFECT.include?(id)
end
end
#return if the player is not dead
return false if !a.dead?
# If the player is dead;
e.in_battle = false if e != nil and !e.is_a?(Game_Actor)
e.attacking = nil if e != nil and !e.is_a?(Game_Actor)
# Game Over?
if NEXT_LEADER and !$game_party.all_dead?
move_forward
else
revive_actor
end
return true
end
#--------------------------------------------------------------------------
# * Move Forward
#--------------------------------------------------------------------------
def move_forward
# Return if party size is 1
return if $game_party.actors.size == 1
# Record current actor.
actor = $game_party.actors[0]
# Remove actor
$game_party.actors.delete(actor)
$game_party.actors.compact
# Check if everyone except leader is dead
if $game_party.all_dead?
$game_party.actors.insert(0,actor)
return
end
$game_player.end_animate
# Insert leader to last place
$game_party.actors.push(actor)
# Loop members until alive
for a in $game_party.actors
next if a == nil
if a.dead?
$game_party.actors.delete(a)
$game_party.actors.push(a)
else
break
end
end
# Refreshe game player
$game_player.refresh
end
#--------------------------------------------------------------------------
# * Treasure(Enemy)
#--------------------------------------------------------------------------
def treasure(enemy)
exp = 0
gold = 0
treasures = []
unless enemy.hidden
exp += enemy.exp
gold += enemy.gold
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
end
end
treasures = treasures[0..5]
for i in 0...$game_party.actors.size
actor = $game_party.actors
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
actor.hp = actor.maxhp
actor.sp = actor.maxsp
#Show LEvel Up if need to
actor.damage = "~Level Up~" if DISPLAY_LEVELUP
Audio.me_play("Audio/ME/" + LEVELUP_MUSIC.to_s, 100, 100) if LEVELUP_MUSIC != ""
end
end
end
$game_party.gain_gold(gold)
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
when RPG::Armor
$game_party.gain_armor(item.id, 1)
end
end
end
#--------------------------------------------------------------------------
# * Hit Enemy(Enemy) or (Player)
#--------------------------------------------------------------------------
def hit_enemy(e,a,animation=nil)
return if animation == 0
# Animate player
animate(e,e.character_name+"_hit") if e.is_a?(Game_Player) and @player_ani
# Animate Enemy
animate(e.event, e.event.character_name+"_hit") if e.is_a?(ABS_Enemy) and @enemy_ani
if animation == nil
e.event.animation_id = a.animation2_id
else
e.event.animation_id = animation
end
end
#--------------------------------------------------------------------------
# * Jump
#--------------------------------------------------------------------------
def jump(object,attacker,plus)
return if plus == nil
n_plus = plus-(plus*2)
d = attacker.direction
# Calculate new pos
new_x = (d == 6 ? plus : d == 4 ? n_plus : 0)
new_y = (d == 2 ? plus : d == 8 ? n_plus : 0)
# Jump
object.jump_nt(new_x,new_y)
end
#--------------------------------------------------------------------------
# * Enemy Pre-Attack(Enemy,Actions) - Checks action conditions to see if the
# enemy can attack.
#--------------------------------------------------------------------------
def enemy_pre_attack(enemy, actions)
return true if enemy.hp * 100.0 / enemy.maxhp > actions.condition_hp
return true if $game_party.max_level < actions.condition_level
switch_id = actions.condition_switch_id
return true if actions.condition_switch_id > 0 and $game_switches[switch_id] == false
n = rand(11)
return true if actions.rating < n
return false
end
#--------------------------------------------------------------------------
# * Can Enemy See(Enemy)
#--------------------------------------------------------------------------
def can_enemy_see(e)
#Get all enemies of the enemy
enemies = []
enemies.push($game_player) if e.hate_group.include?(0) and in_range?(e.event, $game_player, e.see_range) or in_direction?(e.event, $game_player)
if e.hate_group.size > 1 or (e.hate_group.size == 1 and !e.hate_group.include?(0))
#Get the hate enemies
for enemy in @enemies.values
next if enemy == nil or enemy == e or !e.hate_group.include?(enemy.enemy_id) or
!in_range?(e.event, enemy.event, e.see_range) or !in_direction?(e.event, enemy.event)
#Insert in to the list if the enemy is in hate group
enemies.push(enemy)
end
end
#Return false if the list is nil or empty
return false if enemies == nil or enemies == []
#Order the enemies
if !e.closest_enemy
#Order from hate points
enemies.sort! {|a,b|
e.hate_points[b.event_id] - e.hate_points[a.event_id] }
else
enemies.sort! {|a,b|
get_range(e.event,a.event) - get_range(e.event,b.event) }
end
#Add to enemy attack list
e.attacking = enemies[0]
#Enemy is now in battle
e.in_battle = true
#Setup the movement
setup_movement(e)
#Return true
return true
end
#--------------------------------------------------------------------------
# * Setup the Movement Type to 0(Enemy)
#--------------------------------------------------------------------------
def setup_movement(e)
#Set Speed
e.event.move_speed = e.temp_speed
#Set Frequency
e.event.move_frequency = e.temp_frequency
#Set Move Type
e.temp_move_type = e.event.move_type
e.event.move_type = 0
end
#--------------------------------------------------------------------------
# * Restore the Movement Type(Enemy)
#--------------------------------------------------------------------------
def restore_movement(e)
#Restore Speed
e.temp_speed = e.event.move_speed
#Restore Frequency
e.temp_frequency = e.event.move_frequency
#Restore Move Type
e.event.move_type = e.temp_move_type
e.temp_move_type = 0
end
#--------------------------------------------------------------------------
# * Can Enemy Hear(Enemy)
#--------------------------------------------------------------------------
def can_enemy_hear(e)
enemies = []
#Get player
d = 0
d = DASH_SPEED if @dashing
enemies.push($game_player) if e.hate_group.include?(0) and !@sneaking and
in_range?(e.event, $game_player, e.hear_range+d)
if e.hate_group.size > 1 or (e.hate_group.size == 1 and !e.hate_group.include?(0))
#Get the hate enemies
for enemy in @enemies.values
next if enemy == nil or enemy == e or !e.hate_group.include?(enemy.enemy_id) or
!in_range?(e.event, enemy.event, e.hear_range+d)
#Insert in to the list if the enemy is in hate group
enemies.push(enemy)
end
end
#Return False
return false if enemies == nil or enemies == []
#Order the enemies
if !e.closest_enemy
#Order from hate points
enemies.sort! {|a,b|
e.hate_points[b.event_id] - e.hate_points[a.event_id] }
else
enemies.sort! {|a,b|
get_range(e.event,a.event) - get_range(e.event,b.event) }
end
#Add to enemy attack list
e.attacking = enemies[0]
#Enemy is now in battle
e.in_battle = true
#Setup the movement
setup_movement(e)
#Return true
return true
end
#--------------------------------------------------------------------------
# * Enemy Ally in_battle?(Enemy)
#--------------------------------------------------------------------------
def enemy_ally_in_battle?(enemy)
#Start list
allies = []
#Get all allies
for ally in @enemies.values
#Skip NIL Value or value is in hate group
next if ally == nil or enemy.hate_group.include?(ally.enemy_id)
#Skip if the ally is not in_battle or the enemy can't see ally
next if !ally.in_battle or !in_range?(enemy.event, ally.event, enemy.see_range)
#Skip if the enemy can't hear ally
next if !in_range?(enemy.event, ally.event, enemy.hear_range)
#Skip if is player and can't be player
next if ally.attacking == $game_player and !enemy.hate_group.include?(0)
#Add to enemy attack list
enemy.attacking = ally.attacking
#Enemy is now in battle
enemy.in_battle = true
#Setup the movement
setup_movement(enemy)
#Return True
return true
end
#Return False
return false
end
#--------------------------------------------------------------------------
# * Update Dash
#--------------------------------------------------------------------------
def update_dash
return if @sneaking
if Input.pressed?(DASH_KEY)
#Check State Effect
if STATE_EFFECTS
for id in $game_party.actors[0].states
return if CLUMSY_EFFECT.include?(id) or PARALAYZE_EFFECT.include?(id) or DELAY_EFFECT.include?(id)
end
end
if $game_player.moving?
@old_speed = $game_player.move_speed if !@dashing
$game_player.character_name = "#{$game_player.character_name}#{DASH_ANIMATION}" if !@dashing and DASH_SHO_AN
@dashing = true
$game_player.move_speed = DASH_SPEED
@dash_min -= 1
if @dash_min <= 0
@dashing = false
$game_player.move_speed = 4
end
end
elsif @dashing
@dashing = false
$game_player.move_speed = @old_speed if !@sneaking
$game_player.character_name = $game_player.character_name.sub(/#{DASH_ANIMATION}/){} if DASH_SHO_AN
else
@dash_min += 1 if @dash_min < @dash_max
end
end
#--------------------------------------------------------------------------
# * Update Sneak
#--------------------------------------------------------------------------
def update_sneak
return if @dashing
if Input.pressed?(SNEAK_KEY)
#Check State Effect
if STATE_EFFECTS
for id in $game_party.actors[0].states
return if CLUMSY_EFFECT.include?(id) or PARALAYZE_EFFECT.include?(id) or DELAY_EFFECT.include?(id)
end
end
if $game_player.moving?
@old_speed = $game_player.move_speed if !@sneaking
$game_player.character_name = "#{$game_player.character_name}#{SNEAK_ANIMATION}" if !@sneaking and SNEAK_SHO_AN
@sneaking = true
$game_player.move_speed = SNEAK_SPEED
@sneak_min -= 1
if @sneak_min <= 0
@sneaking = false
$game_player.move_speed = 4
end
end
elsif @sneaking
@sneaking = false
$game_player.move_speed = @old_speed if !@dashing
$game_player.character_name = $game_player.character_name.sub(/#{SNEAK_ANIMATION}/){} if SNEAK_SHO_AN
else
@sneak_min += 1 if @sneak_min < @sneak_max
end
end
#--------------------------------------------------------------------------
# * Get Range(Element, Object) - Near Fantastica
#--------------------------------------------------------------------------
def get_range(element, object)
x = (element.x - object.x) * (element.x - object.x)
y = (element.y - object.y) * (element.y - object.y)
r = x + y
#r = Math.sqrt(r)
return r.to_i
end
#--------------------------------------------------------------------------
# * Checks the object range
#--------------------------------------------------------------------------
def in_screen?(object)
screne_x = $game_ma
| Aller à la page: 1
|
|
|