第205页:统御战狼
展开二零五.统御战狼(按键盘X键召唤战狼,誓死护卫你,给5块疯肉升级为金刚战狼)
1.用记事本打开游戏目录\data\DLC0001\scripts\prefabs\player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容:
TheInput:AddKeyUpHandler(KEY_X, function()
if inst.components.inventory:Has("goldnugget", 20) then
inst.components.inventory:ConsumeByName("goldnugget", 20)
inst.AnimState:PlayAnimation("give")
inst.SoundEmitter:PlaySound("dontstarve/common/horn_beefalo")
local mywolf = SpawnPrefab("greenamulet")
local pt = GetPlayer():GetPosition()
mywolf.Transform:SetPosition(pt.x+(math.random(3)-math.random(3)), 0, pt.z+(math.random(3)-math.random(3)))
mywolf.AnimState:SetBank("warg")
mywolf.AnimState:SetBuild("warg_build")
mywolf.AnimState:PlayAnimation("idle")
mywolf.Transform:SetScale(0.6, 0.6, 0.6)
mywolf.Transform:SetFourFaced()
local sound = mywolf.entity:AddSoundEmitter()
local shadow = mywolf.entity:AddDynamicShadow()
shadow:SetSize(1.2, 0.7)
MakeCharacterPhysics(mywolf, 100, 1)
mywolf:RemoveComponent("equippable")
mywolf:RemoveComponent("inventoryitem")
mywolf:RemoveComponent("finiteuses")
mywolf:RemoveComponent("deployable")
mywolf:AddComponent("named")
mywolf.components.named:SetName("Wolf")
mywolf:AddComponent("follower")
mywolf.components.follower:SetLeader(GetPlayer())
mywolf:AddComponent("lootdropper")
mywolf.components.lootdropper:SetLoot({"monstermeat", "houndstooth"})
mywolf:AddComponent("health")
mywolf.components.health:SetMaxHealth(1000)
mywolf.components.health:StartRegen(50, 10)
mywolf:AddComponent("combat")
mywolf.components.combat:SetDefaultDamage(50)
mywolf.components.combat:SetAttackPeriod(0.5)
mywolf.components.combat:SetRange(3)
mywolf.components.combat:SetRetargetFunction(1, function(mywolf)
if not mywolf.components.health:IsDead() then
return FindEntity(mywolf, 25, function(guy)
if guy.components.combat then
return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
end
end )
end
end )
mywolf.components.combat:SetKeepTargetFunction(function(mywolf, target) return target and target:IsValid() end )
mywolf:ListenForEvent("attacked", function(mywolf, data)
if data.attacker ~= GetPlayer() then
mywolf.components.combat:SetTarget(data.attacker)
mywolf.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("mywolfs") and not dude.components.health:IsDead() end, 10)
else
mywolf.components.health:Kill()
end
end )
mywolf:AddComponent("locomotor")
mywolf.components.locomotor.runspeed = 18
mywolf.components.locomotor:SetShouldRun(true)
mywolf:SetStateGraph("SGwarg")
local brain = require "brains/abigailbrain"
mywolf:SetBrain(brain)
mywolf:AddComponent("trader")
mywolf.components.trader:SetAcceptTest(function(mywolf, item)
if GetPlayer().components.inventory:Has("monstermeat", 5) then
if item.prefab == "monstermeat" then
if not mywolf:HasTag("superwolf") then
return true
end
end
end
return false
end )
mywolf.components.trader.onaccept = function(mywolf, giver, item)
if item.prefab == "monstermeat" then
giver.components.inventory:ConsumeByName("monstermeat", 4)
mywolf:AddTag("superwolf")
mywolf.components.named:SetName("Super Wolf")
mywolf.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
mywolf.Transform:SetScale(0.7, 0.7, 0.7)
mywolf.components.health:SetMaxHealth(2000)
mywolf.components.health:DoDelta(2000)
mywolf.components.combat:SetDefaultDamage(100)
mywolf.components.locomotor.runspeed = 25
end
end
mywolf.components.inspectable.getstatus = function(mywolf)
if not mywolf:HasTag("stophere") then
mywolf:AddTag("stophere")
mywolf.components.locomotor:Stop()
mywolf:SetBrain(nil)
mywolf.components.follower:SetLeader(nil)
else
mywolf:RemoveTag("stophere")
local brain = require "brains/abigailbrain"
mywolf:SetBrain(brain)
mywolf:RestartBrain()
mywolf.components.follower:SetLeader(GetPlayer())
end
end
mywolf:AddTag("companion")
mywolf:AddTag("mywolfs")
end
end )
2.用记事本打开游戏目录\data\DLC0001\scripts\prefabs\amulet.lua文件,在inst.AnimState:PlayAnimation("greenamulet")的下一行插入以下内容:
local function onsave(inst, data)
if inst:HasTag("mywolfs") then
data.mywolfs = true
end
if inst:HasTag("superwolf") then
data.superwolf = true
end
if inst:HasTag("stophere") then
data.stophere = true
end
end
local function onload(inst, data)
if data and data.mywolfs then
inst.AnimState:SetBank("warg")
inst.AnimState:SetBuild("warg_build")
inst.AnimState:PlayAnimation("idle")
inst.Transform:SetScale(0.6, 0.6, 0.6)
inst.Transform:SetFourFaced()
local sound = inst.entity:AddSoundEmitter()
local shadow = inst.entity:AddDynamicShadow()
shadow:SetSize(1.2, 0.7)
MakeCharacterPhysics(inst, 100, 1)
inst:RemoveComponent("equippable")
inst:RemoveComponent("inventoryitem")
inst:RemoveComponent("finiteuses")
inst:RemoveComponent("deployable")
inst:AddComponent("named")
inst.components.named:SetName("Wolf")
inst:AddComponent("follower")
inst.components.follower:SetLeader(GetPlayer())
inst:AddComponent("lootdropper")
inst.components.lootdropper:SetLoot({"monstermeat", "houndstooth"})
inst:AddComponent("health")
inst.components.health:SetMaxHealth(1000)
inst.components.health:StartRegen(50, 10)
inst:AddComponent("combat")
inst.components.combat:SetDefaultDamage(50)
inst.components.combat:SetAttackPeriod(0.5)
inst.components.combat:SetRange(3)
inst.components.combat:SetRetargetFunction(1, function(inst)
if not inst.components.health:IsDead() then
return FindEntity(inst, 25, function(guy)
if guy.components.combat then
return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
end
end )
end
end )
inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end )
inst:ListenForEvent("attacked", function(inst, data)
if data.attacker ~= GetPlayer() then
inst.components.combat:SetTarget(data.attacker)
inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("mywolfs") and not dude.components.health:IsDead() end, 10)
else
inst.components.health:Kill()
end
end )
inst:AddComponent("locomotor")
inst.components.locomotor.runspeed = 18
inst.components.locomotor:SetShouldRun(true)
inst:SetStateGraph("SGwarg")
local brain = require "brains/abigailbrain"
inst:SetBrain(brain)
inst:AddComponent("trader")
inst.components.trader:SetAcceptTest(function(inst, item)
if GetPlayer().components.inventory:Has("monstermeat", 5) then
if item.prefab == "monstermeat" then
if not inst:HasTag("superwolf") then
return true
end
end
end
return false
end )
inst.components.trader.onaccept = function(inst, giver, item)
if item.prefab == "monstermeat" then
giver.components.inventory:ConsumeByName("monstermeat", 4)
inst:AddTag("superwolf")
inst.components.named:SetName("Super Wolf")
inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
inst.Transform:SetScale(0.7, 0.7, 0.7)
inst.components.health:SetMaxHealth(2000)
inst.components.health:DoDelta(2000)
inst.components.combat:SetDefaultDamage(100)
inst.components.locomotor.runspeed = 25
end
end
inst.components.inspectable.getstatus = function(inst)
if not inst:HasTag("stophere") then
inst:AddTag("stophere")
inst.components.locomotor:Stop()
inst:SetBrain(nil)
inst.components.follower:SetLeader(nil)
else
inst:RemoveTag("stophere")
local brain = require "brains/abigailbrain"
inst:SetBrain(brain)
inst:RestartBrain()
inst.components.follower:SetLeader(GetPlayer())
end
end
inst:AddTag("companion")
inst:AddTag("mywolfs")
end
if data and data.superwolf then
inst:AddTag("superwolf")
inst.components.named:SetName("Super Wolf")
inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
inst.Transform:SetScale(0.7, 0.7, 0.7)
inst.components.health:SetMaxHealth(2000)
inst.components.health:DoDelta(2000)
inst.components.combat:SetDefaultDamage(100)
inst.components.locomotor.runspeed = 25
end
if data and data.stophere then
inst:AddTag("stophere")
inst.components.locomotor:Stop()
inst:SetBrain(nil)
inst.components.follower:SetLeader(nil)
end
end
inst.OnSave = onsave
inst.OnLoad = onload
即可按键盘X键召唤战狼,每只花费20个黄金,身上黄金数不足时无法召唤。战狼极其忠诚,会誓死护卫你,鼠标左键点击可停在原地,再次点击则继续跟随。如果想赐战狼死,用任何武器打击一下即可(按Ctrl + 鼠标左键攻击),它不会还击。战狼生命力顽强,会自动回血。当一只战狼遭到攻击时,其他战狼会围攻敌人。给战狼5块疯肉(拿着疯肉对战狼点鼠标左键),可将其升级为金刚战狼,生命值、攻击力、速度会大幅提升。统御你的战狼部队,横扫大陆吧
更多相关内容请关注:饥荒专区
责任编辑:Shy夏夏