#地图技能类
class Game_MNSkill < Game_Character
#单位长度,技能的实际长宽分别乘以动画的放大率
UNITSIZE=128
attr_reader :collider
def initialize(owner,skill_id)
super()
@skill=$data_skills[skill_id]
@owner=owner
@x=owner.x
@y=owner.y
@real_x=owner.real_x
@real_y=owner.real_y
@animation1=$data_animations[@skill.animation1_id]
@animation2=$data_animations[@skill.animation2_id]
@through=true
@index=0
@frame_max=@animation1.frame_max
#碰撞盒子
val=Toolkit.get_anim_rect(@animation1,@index)
@collider=Rect.new(
@real_x+UNITSIZE*val[0],
@real_y+UNITSIZE*val[1],
UNITSIZE*val[2],
UNITSIZE*val[2]
)
#将一些特殊标记效果存储在marks中,如@marks["瞬杀"]=true
@marks=Hash.new()
@move_speed=@owner.move_speed*1.5
@animation_id=skill_id
#移动初始化处理
moveto(owner.x,owner.y)
@direction=owner.direction
@mmove_type=0#默认静止
#1-直线 2-待定
common_event=$data_common_events[$data_skills[skill_id].common_event_id]
for i in common_event.list
if i.code==108 && i.parameters[0][0,9]=="move_type"
@mmove_type=i.parameters[0][10,1].to_i
#str[0]是一个char,也就是ASCII码值
#str[0,1]是一个长度为1的string
end
end if common_event!=nil
end
def update
super()
@index+=1
@index=0 if @index>=@frame_max
case @mmove_type
when 1
@direction_fix=true
move_forward
end unless moving?
#更新碰撞盒子
val=Toolkit.get_anim_rect(@animation1,@index)
@collider=Rect.new(
@real_x+UNITSIZE*val[0],
@real_y+UNITSIZE*val[1],
UNITSIZE*val[2],
UNITSIZE*val[2]
)
end
#--------------------------------------------------------------------------
# ● 接触事件启动判定
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
result = false
# 事件执行中的情况下
if $game_system.map_interpreter.running?
return result
end
#对所有敌人进行循环
for enemy in $game_mbs.enemy_list
if enemy.collider?(self)
enemy.damage_by(self)
result=true
end
end
#对角色队伍进行循环
for player in $game_players
if player.collider?(self)
player.damage_by(self)
result=true
end
end
return result
end
end
#地图敌人类中的攻击方法
def fire_on(target)
skill=Game_MNSkill.new(self,1)#1代表普攻
@spe_effs.each_pair do |key,val|
if skill.spe_effs.has_key?
case spe_effs[key].class
when Numberic
skill.spe_effs[key] += val
when TrueClass
skill.spe_effs[key] ||= val
next
when FalseClass
skill.spe_effs[key] ||= val
next
end
else
skill.spe_effs[key]=val
end
end
$game_map.add_effect(skill)
end