Project1
标题:
A事件追逐B事件的做法該如何作出來?
[打印本页]
作者:
燕征
时间:
2016-2-16 03:16
标题:
A事件追逐B事件的做法該如何作出來?
主角現在是旁觀者,並非是主角被(怪物)事件追逐
我想讓主角先旁觀村民被怪物追著跑,如果能辦到設定上會拆成兩部分:
第一部分先是一進一退的這種設定好的路線(自動執行完開啟開關執行第二部分),
第二部分採用並行處理,這時村民和怪物自己在地圖上亂跑,但怪物一定要是追著村民直到受主角攻擊仇恨轉移(偵測到主角改往主角靠近)
如果上面可以實現的話我還想讓地圖上同時有很多組這樣村民與npc以第二部分的方式存在
總結起來就是
事件追逐事件
了,利用上方的站內蒐尋也沒有找到(1筆沒下文另1筆也沒有解決
不知道這樣的東西是否可以實現?可以實現的話具體實施方法是什麼?
作者:
yang1zhi
时间:
2016-2-16 14:49
出自哪我不知道
这是从群战7.0脚本里复制出来的
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#==============================================================================
# 事件向移动 by SailCat
#------------------------------------------------------------------------------
# 说明:这个脚本实际是利用系统的“接近主角”“远离主角”的功能修改的,可以用作
# 事件向的移动功能,可以用来做追杀NPC的敌人、跟着大人的小孩,或者在自动
# 执行的剧情事件中令主角移向某NPC。
# 使用方法:在移动路线里设置脚本
# 脚本:move_type_toward_event(事件编号,[视野],[机敏度]),设定事件移动类型为
# “接近事件”,后两个是隐含参数
# 脚本:move_toward_event(事件编号),令事件朝指定事件方向移动一步
# 脚本:move_away_from_event(事件编号),令事件朝指定事件相反方向移动一步
# 注意:事件编号是个必须参数,不能省略,另外注意一下参数编号不能是事件自身编号
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# ● 移动类型 : 接近事件
#--------------------------------------------------------------------------
def move_type_toward_event(event, sight = 20, ai = 6)
# 指定自身的情况下不执行动作
if event == self
return
end
# 求得与主角坐标的差
sx = @x - event.x
sy = @y - event.y
# 求得差的绝对值
abs_sx = sx > 0 ? sx : -sx
abs_sy = sy > 0 ? sy : -sy
# 如果方圆超过了视野
if abs_sx ** 2 + abs_sy ** 2 >= sight ** 2
# 随机
move_random
return
end
# 随机 0~5 的分支
case rand(ai)
when 0..3 # 接近主角
move_toward_event(event)
when 4 # 随机
move_random
when 5 # 前进一步
move_forward
end
end
#--------------------------------------------------------------------------
# ● 接近事件
# event_id : 事件编号
#--------------------------------------------------------------------------
def move_toward_event(event)
# 指定自身的情况下不执行动作
if event == self
return
end
# 求得与事件的坐标差
sx = @x - event.x
sy = @y - event.y
# 坐标相等情况下
if sx == 0 and sy == 0
return
end
# 求得差的绝对值
abs_sx = sx.abs
abs_sy = sy.abs
# 横距离与纵距离相等的情况下
if abs_sx == abs_sy
# 随机将边数增加 1
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# 横侧距离长的情况下
if abs_sx > abs_sy
# 左右方向优先。向事件移动
sx > 0 ? move_left : move_right
if not moving? and sy != 0
sy > 0 ? move_up : move_down
end
# 竖侧距离长的情况下
else
# 上下方向优先。向事件移动
sy > 0 ? move_up : move_down
if not moving? and sx != 0
sx > 0 ? move_left : move_right
end
end
end
#--------------------------------------------------------------------------
# ● 远离事件
# event_id : 事件编号
#--------------------------------------------------------------------------
def move_away_from_event(event)
# 指定自身的情况下不执行动作
if event == self
return
end
# 求得与事件的坐标差
sx = @x - event.x
sy = @y - event.y
# 坐标相等情况下
if sx == 0 and sy == 0
return
end
# 求得差的绝对值
abs_sx = sx.abs
abs_sy = sy.abs
# 横距离与纵距离相等的情况下
if abs_sx == abs_sy
# 随机将边数增加 1
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# 横侧距离长的情况下
if abs_sx > abs_sy
# 左右方向优先。远离事件移动
sx > 0 ? move_right : move_left
if not moving? and sy != 0
sy > 0 ? move_down : move_up
end
# 竖侧距离长的情况下
else
# 上下方向优先。远离事件移动
sy > 0 ? move_down : move_up
if not moving? and sx != 0
sx > 0 ? move_right : move_left
end
end
end
#--------------------------------------------------------------------------
# ● 死亡处理
#--------------------------------------------------------------------------
def dead_for_slg
@deadbody = true
@through = true
@opacity = 185
Audio.se_play("Audio/SE/bodyfall_0"+ (rand(1)+1).to_s,se_v, 100)
end
#-----------------------------------------------------------------------------
# returns if the event is inside the circle
#-----------------------------------------------------------------------------
def in_circle?(cx, cy, radius, sx = @x, sy = @y)
return Math.sqrt((cx - sx) ** 2 + (cy - sy) ** 2) <= radius
end
#-----------------------------------------------------------------------------
# returns of the event is inside the square
#-----------------------------------------------------------------------------
def in_square?(mx, my, r, sx = @x, sy = @y)
x_s = mx - r
x_e = mx + r
y_s = my - r
y_e = my + r
return (sx >= x_s and sx <= x_e and sy >= y_s and sy <= y_e)
end
#-----------------------------------------------------------------------------
# returns of the event is inside the rectangle
#-----------------------------------------------------------------------------
def in_rect?(mx, my, width, height, sx = @x, sy = @y)
x_s = mx - width / 2
x_e = mx + width / 2
y_s = my - height / 2
y_e = my + height / 2
return (sx >= x_s and sx <= x_e and sy >= y_s and sy <= y_e)
end
#--------------------------------------------------------------------------
# Blow
#--------------------------------------------------------------------------
def blow(d, power = 1)
@knock_back_prespeed = @move_speed if @knock_back_prespeed == nil
if self.knock_back_disable
@move_speed = XAS_BA::KNOCK_BACK_SPEED
end
return if self.knock_back_disable
power.times do
if passable?(self.x, self.y, d)
@x += ([3,6,9].include?(d) ? 1 : [1,4,7].include?(d) ? -1 : 0)
@y += ([1,2,3].include?(d) ? 1 : [7,8,9].include?(d) ? -1 : 0)
end
end
@knock_back_duration = XAS_BA::KNOCK_BACK_DURATION_HERO
@move_speed = XAS_BA::KNOCK_BACK_SPEED
end
#--------------------------------------------------------------------------
# life_perpose
#--------------------------------------------------------------------------
def save_position
@sence_used_x = @x
@sence_used_y = @y
end
def replace_position_for_scene
return if @sence_used_x == nil
self.moveto(@sence_used_x,@sence_used_y)
end
#--------------------------------------------------------------------------
# ● SE音量
#--------------------------------------------------------------------------
def play_sound(se_name,num = nil)
#p @real_x,@real_y
d = (@x - $game_player.x).abs + (@y - $game_player.y).abs
v = 100 - d*4
if num == nil
Audio.se_play("Audio/SE/" + se_name, v, 100)
else
Audio.se_play("Audio/SE/"+se_name + (rand(num)+1).to_s,v, 100)
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
复制代码
作者:
燕征
时间:
2016-2-18 03:01
使用方法:在移动路线里设置脚本
這意思是指我要把要使用到的對應method貼到 事件指令>>移動路線>>腳本 的意思?
比方說我現在要讓A怪追B,我應該要在A怪的事件指令>>移動路線>>腳本 貼上 move_toward_event(B事件的id) 這樣嗎?
第50行註解寫的event_id有用到嗎??還是其實他就是52行的參數event?
然後我看見了裡面有abs_sx 這樣的變數名稱,熊熊有一種危機感...這該不會是必須使用ABS才能用的腳本?
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1