#============================================================================
# * Mr.Mo's ABS
#============================================================================
# Mr.Mo "Muhammet Sivri"
# Version 1
# 09.16.06
#============================================================================
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.state("Mr.Mo's ABS") == true
VICTORY = '002-Victory02' #THis is the ME that will be played when a player wins.
#You can change it if you want.
EXP_GAIN = 10 #How much EXP should the winner gain? IT works like this
#level * EXP_GAIN
#level = the loser's level
GOLD_GAIN = 0.10 #Get the looser's gold. The number is by percents.
#so the example would be;
#Gained_Gold = looser.gold*.10
#0 Would be nothing.
class MrMo_ABS
#--------------------------------------------------------------------------
# * Player Melee Attack
#--------------------------------------------------------------------------
def player_melee
return if $data_weapons[@actor.weapon_id] == nil
return if attacked_monster?
return if attacked_player?
end
#--------------------------------------------------------------------------
# * Player Attacked a Monster?
#--------------------------------------------------------------------------
def attacked_monster?
#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)
#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
#Animate the player
if MELEE_ANIMATION[@actor.weapon_id] == nil
animate($game_player, $game_player.character_name+"_melee") if @player_ani
else
m = MELEE_ANIMATION[@actor.weapon_id]
animate($game_player, $game_player.character_name+m.to_s) if @player_ani
end
#Return if the enemy is dead
return true if enemy_dead?(e,@actor)
return true 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
return false
end
#--------------------------------------------------------------------------
# * Player Attacked a Player?
#--------------------------------------------------------------------------
def attacked_player?
#Get all enemies
for pl in Network::Main.mapplayers.values
#Skip NIL values or dead enemies
next if pl == nil or pl.hp == 0 or pl.map_id != $game_map.map_id
#Skip the enemy if its not close by or not facing
next if !in_direction?($game_player, pl) or !in_range?($game_player, pl, 1)
#Attack the player
damage = pl.attack_effect
#Get Animation
a = $data_weapons[@actor.weapon_id].animation2_id
#Store the player's net id
netid = pl.netid
#Send the demage and aniamtion
Network::Main.socket.send("<attack_id>#{netid}\n") if damage != "Miss" and damage != 0
Network::Main.socket.send("<attack_effect>dam=#{damage}; ani=#{a} id=#{Network::Main.id}</attack_effect>\n") if damage != "Miss" and damage != 0
pl.show_demage(damage,false) if damage != "Miss" and damage != 0
#Hit enemy if the attack succeeds
hit_enemy(pl, @actor, a) if damage != "Miss" and damage != 0
#Animate the player
if MELEE_ANIMATION[@actor.weapon_id] == nil
animate($game_player, $game_player.character_name+"_melee") if @player_ani
else
m = MELEE_ANIMATION[@actor.weapon_id]
animate($game_player, $game_player.character_name+m.to_s) if @player_ani
end
netplayer_killed(pl) if pl.hp <= 0
return true
end
return false
end
#--------------------------------------------------------------------------
# * Player Skill Attack
#--------------------------------------------------------------------------
def player_skill(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)
#Animate
if SKILL_ANIMATION.has_key?(id)
l = SKILL_ANIMATION[id]
animate($game_player, $game_player.character_name+l.to_s) if @player_ani
else
animate($game_player, $game_player.character_name+"_cast") if @player_ani
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
return
end
#If the skill is not ranged
enemies = []
#Get all enemies
for enemy in @enemies.values
next if enemy == nil
enemies.push(enemy)
end
#Get all players
for player in Network::Main.mapplayers.values
next if player == nil
enemies.push(player)
end
#Order them from closest to the farthest
enemies.sort! {|a,b|
get_range(a.event,b.event) - get_range(b.event,a.event) }
return if enemies[0] == nil
#Attack the closest one
enemies[0].effect_skill(@actor, skill)
if enemies[0].is_a?(Game_NetPlayer)
damage = enemies[0].damage
pl = enemies[0]
a = skill.animation2_id
#Store the player's net id
netid = pl.netid
#Send the demage and aniamtion
Network::Main.socket.send("<attack_id>#{netid}\n") if damage != "Miss" and damage != 0
Network::Main.socket.send("<attack_effect>dam=#{damage}; ani=#{a} id=#{Network::Main.id}</attack_effect>\n") if damage != "Miss" and damage != 0
pl.show_demage(damage,false) if damage != "Miss" and damage != 0
end
#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
return if enemies[0].is_a?(Game_NetPlayer)
#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
enemies = get_all_range
#Get all enemies
for e in enemies.values
#Skip NIL values
next if e == nil
#Attack enemy
e.effect_skill(@actor, skill)
#Show Animetion on enemy
hit_enemy(e, @actor, 0) if enemy.damage != "Miss" and enemy.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
enemy.in_battle = true
#Make it attack the player
enemy.attacking = $game_player
#Setup movement
setup_movement(e)
end
return
when 3..4, 7 #User
#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
#--------------------------------------------------------------------------
# * Get ALL Range(Element, Range)
#--------------------------------------------------------------------------
def get_all_range(element, range)
objects = []
for e in @enemies.values
next if e == nil
objects.push(e) if in_range?(element, e.event, range)
end
for player in Network::Main.mapplayers.values
next if player == nil
objects.push(player) if in_range?(element, player, range)
end
return objects
end
#--------------------------------------------------------------------------
# * Netplayer Killed
#--------------------------------------------------------------------------
def netplayer_killed(player)
$game_player.show_demage("#{player.username} Killed",false)
Audio.me_play("Audio/ME/" + VICTORY, 80, 100)
actor = $game_party.actors[0]
if actor.cant_get_exp? == false
last_level = actor.level
exp = player.level * EXP_GAIN
actor.exp += player.level * EXP_GAIN
$game_player.show_demage("Gained #{exp} Exp.",false)
if actor.level > last_level
$game_player.show_demage("Level Up!",false)
actor.hp = actor.maxhp
actor.sp = actor.maxsp
end
end
return if GOLD_GAIN <= 0
return if player.gold <= 0
gold = player.gold*GOLD_GAIN
$game_party.gain_gold(gold.to_i)
end
end
#============================================================================
# * Game Ranged Skill
#============================================================================
class Game_Ranged_Skill < Range_Base
#--------------------------------------------------------------------------
# * Check Event Trigger Touch(x,y)
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
return if @stop
hit_player if x == $game_player.x and y == $game_player.y
for event in $game_map.events.values
if event.x == x and event.y == y
if event.character_name == ""
froce_movement
else
hit_event(event.id)
end
end
end
return if @parent.is_a?(Game_Event)
#Check netplayer hit
for player in Network::Main.mapplayers.values
next if player == nil
next if player.x != x or player.y != y
hit_netplayer(player)
end
end
#--------------------------------------------------------------------------
# * Hit NetPlayer
#--------------------------------------------------------------------------
def hit_netplayer(player)
@stop = true
#Get Actor
actor = player
#Get Enemy
enemy = @actor
#Attack Actor
damage = actor.effect_skill(enemy, @skill)
damage = player.damage
#Store the player's net id
netid = player.netid
a = @skill.animation2_id
player.jump(0,0) if damage != "Miss" and damage != 0
#Send the demage and aniamtion
Network::Main.socket.send("<attack_id>#{netid}\n") if damage != "Miss" and damage != 0
Network::Main.socket.send("<attack_effect>dam=#{damage}; ani=#{a} id=#{Network::Main.id}</attack_effect>\n") if damage != "Miss" and damage != 0
#Show animation on player
player.animation_id = @skill.animation2_id if actor.damage != "Miss" and actor.damage != 0
#Check if enemy is dead
player.show_demage(player.damage,false) if damage != "Miss" and damage != 0
netplayer_killed(player) if player.hp <= 0
end
end
#============================================================================
# * Game Ranged Weapons
#============================================================================
class Game_Ranged_Weapon < Range_Base
#--------------------------------------------------------------------------
# * Check Event Trigger Touch(x,y)
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
return if @stop
hit_player if x == $game_player.x and y == $game_player.y
for event in $game_map.events.values
next if event.x != x or event.y != y
if event.character_name == ""
froce_movement
else
hit_event(event.id)
end
end
return if @parent.is_a?(Game_Event)
#Check netplayer hit
for player in Network::Main.mapplayers.values
next if player == nil
next if player.x != x or player.y != y
hit_netplayer(player)
end
end
#--------------------------------------------------------------------------
# * Hit NetPlayer
#--------------------------------------------------------------------------
def hit_netplayer(player)
@stop = true
#Get Enemy
enemy = @actor
#Attack Actor
damage = player.attack_effect(enemy)
#Store the player's net id
netid = player.netid
a = @range_wepaon[2]
player.jump(0,0) if damage != "Miss" and damage != 0
#Send the demage and aniamtion
Network::Main.socket.send("<attack_id>#{netid}\n") if damage != "Miss" and damage != 0
Network::Main.socket.send("<attack_effect>dam=#{damage}; ani=#{a} id=#{Network::Main.id}</attack_effect>\n") if damage != "Miss" and damage != 0
#Show animation on player
player.animation_id = @range_wepaon[2] if player.damage != "Miss" and player.damage != 0
#Check if enemy is dead
player.show_demage(player.damage,false) if damage != "Miss" and damage != 0
netplayer_killed(player) if player.hp <= 0
end
end
#--------------------------------------------------------------------------
# * SDK End
#--------------------------------------------------------------------------
end