代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
一九0.近卫军(主角受攻击自动出现机械护卫,不要与“菩萨低眉”一同修改)
用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst.Transform:SetFourFaced()的下一行插入以下内容:
local function OnAttacked(inst, data)
local spawn = ""
if math.random()<.1 then
spawn = "rook_nightmare"
elseif math.random()<.5 then
spawn = "bishop_nightmare"
else
spawn = "knight_nightmare"
end
SpawnAt("maxwell_smoke",inst)
local it = SpawnAt(spawn,inst)
if it.components.follower then
it.components.follower:SetLeader(GetPlayer())
end
end
inst:ListenForEvent("attacked", OnAttacked)
即可在主角受到攻击时,自动产生机械兵(共三种)保护主角。如果主角强制攻击(按Ctrl + 鼠标左键)其中一个机械兵,则其他机械兵会帮主角清理门户