第204页:宠物蜻蜓
展开二零四.宠物蜻蜓(用蜻蜓盔甲种宠物蜻蜓,攻击力超强,鼠标右键点击可帮你捡地上的物品)
用记事本打开游戏目录\data\DLC0001\scripts\prefabs\armor_dragonfly.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function OnDeploy (inst, pt)
local myfly = SpawnPrefab("armordragonfly")
myfly.Transform:SetPosition(pt.x, pt.y, pt.z)
myfly.AnimState:SetBank("dragonfly")
myfly.AnimState:SetBuild("dragonfly_build")
myfly.AnimState:PlayAnimation("idle", true)
myfly.Transform:SetScale(0.5, 0.5, 0.5)
myfly.Transform:SetFourFaced()
local sound = myfly.entity:AddSoundEmitter()
local shadow = myfly.entity:AddDynamicShadow()
shadow:SetSize(3, 1.8)
MakeCharacterPhysics(myfly, 50, 0.7)
local light = myfly.entity:AddLight()
myfly.Light:Enable(false)
myfly.Light:SetRadius(2)
myfly.Light:SetFalloff(0.5)
myfly.Light:SetIntensity(.75)
myfly.Light:SetColour(235/255,121/255,12/255)
myfly:RemoveComponent("inventoryitem")
myfly:RemoveComponent("armor")
myfly:RemoveComponent("equippable")
myfly:RemoveComponent("deployable")
MakeLargePropagator(myfly)
myfly.components.propagator.decayrate = 0
myfly:AddComponent("groundpounder")
myfly.components.groundpounder.numRings = 2
myfly.components.groundpounder.burner = true
myfly.components.groundpounder.groundpoundfx = "firesplash_fx"
myfly.components.groundpounder.groundpounddamagemult = .5
myfly.components.groundpounder.groundpoundringfx = "firering_fx"
myfly:AddComponent("named")
myfly.components.named:SetName("My Dragonfly")
myfly:AddComponent("inventory")
myfly:AddComponent("knownlocations")
myfly:AddComponent("follower")
myfly.components.follower:SetLeader(GetPlayer())
myfly:AddComponent("lootdropper")
myfly.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "dragon_scales"})
myfly:AddComponent("health")
myfly.components.health:SetMaxHealth(5000)
myfly:AddComponent("combat")
myfly.components.combat:SetDefaultDamage(300)
myfly.components.combat:SetAttackPeriod(0.5)
myfly.components.combat.hiteffectsymbol = "dragonfly_body"
myfly.components.combat:SetAreaDamage(6, 0.8)
myfly.components.combat.playerdamagepercent = 0
myfly.components.combat:SetRange(4)
myfly.components.combat.battlecryenabled = false
myfly.components.combat:SetHurtSound("dontstarve_DLC001/creatures/dragonfly/hurt")
myfly.components.combat:SetRetargetFunction(1, function(myfly)
if not myfly.components.health:IsDead() then
return FindEntity(myfly, 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 )
myfly.components.combat:SetKeepTargetFunction(function(myfly, target) return target and target:IsValid() end )
myfly:ListenForEvent("attacked", function(myfly, data)
if data.attacker ~= GetPlayer() then
if not data.attacker:HasTag("myflys") then
myfly.components.combat:SetTarget(data.attacker)
end
else
myfly.components.health:Kill()
end
end )
myfly:AddComponent("locomotor")
myfly.components.locomotor.walkspeed = 25
myfly:SetStateGraph("SGdragonfly")
local brain = require "brains/abigailbrain"
myfly:SetBrain(brain)
myfly:DoPeriodicTask(5, function()
if myfly.components.combat and not myfly.components.combat.target then
if myfly.fire_build then
myfly.sg:GoToState("flameoff")
end
if myfly.components.health and myfly.components.health:GetPercent() < 1 then
myfly.components.health:DoDelta(200)
end
end
end )
myfly:AddComponent("machine")
myfly.components.machine.turnonfn = function()
myfly:AddTag("inhaling")
myfly.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
myfly.task = myfly:DoPeriodicTask(.5, function(myfly)
local pos = Vector3(myfly.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 15)
for k,v in pairs(ents) do
local pt1 = v:GetPosition()
if v.components.inventoryitem and v.components.inventoryitem.canbepickedup and v.components.inventoryitem.cangoincontainer
and not v.components.inventoryitem:IsHeld() and not v:HasTag("trap") and not v:HasTag("light") and not v:HasTag("blowdart")
and not v:HasTag("projectile") then
if not GetPlayer().components.inventory:IsFull() then
SpawnPrefab("small_puff").Transform:SetPosition(pt1.x, pt1.y, pt1.z)
GetPlayer().components.inventory:GiveItem(v)
GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available")
end
end
end
end )
end
myfly.components.machine.turnofffn = function()
myfly:RemoveTag("inhaling")
myfly.AnimState:SetBloomEffectHandle( "" )
if myfly.task then myfly.task:Cancel() myfly.task = nil end
end
myfly.components.inspectable.getstatus = function(myfly)
if not myfly:HasTag("stophere") then
myfly:AddTag("stophere")
myfly.components.locomotor:Stop()
myfly:SetBrain(nil)
myfly.components.follower:SetLeader(nil)
myfly.sg:GoToState("flameoff")
else
myfly:RemoveTag("stophere")
local brain = require "brains/abigailbrain"
myfly:SetBrain(brain)
myfly:RestartBrain()
myfly.components.follower:SetLeader(GetPlayer())
end
end
myfly:ListenForEvent("death", function()
myfly.components.machine:TurnOff()
end )
myfly:AddTag("companion")
myfly:AddTag("myflys")
inst:Remove()
end
inst:AddComponent("deployable")
inst.components.deployable.ondeploy = OnDeploy
local function onsave(inst, data)
if inst:HasTag("myflys") then
data.myflys = true
end
if inst:HasTag("stophere") then
data.stophere = true
end
if inst:HasTag("inhaling") then
data.inhaling = true
end
end
local function onload(inst, data)
if data and data.myflys then
inst.AnimState:SetBank("dragonfly")
inst.AnimState:SetBuild("dragonfly_build")
inst.AnimState:PlayAnimation("idle", true)
inst.Transform:SetScale(0.5, 0.5, 0.5)
inst.Transform:SetFourFaced()
local sound = inst.entity:AddSoundEmitter()
local shadow = inst.entity:AddDynamicShadow()
shadow:SetSize(3, 1.8)
MakeCharacterPhysics(inst, 50, 0.7)
local light = inst.entity:AddLight()
inst.Light:Enable(false)
inst.Light:SetRadius(2)
inst.Light:SetFalloff(0.5)
inst.Light:SetIntensity(.75)
inst.Light:SetColour(235/255,121/255,12/255)
inst:RemoveComponent("inventoryitem")
inst:RemoveComponent("armor")
inst:RemoveComponent("equippable")
inst:RemoveComponent("deployable")
MakeLargePropagator(inst)
inst.components.propagator.decayrate = 0
inst:AddComponent("groundpounder")
inst.components.groundpounder.numRings = 2
inst.components.groundpounder.burner = true
inst.components.groundpounder.groundpoundfx = "firesplash_fx"
inst.components.groundpounder.groundpounddamagemult = .5
inst.components.groundpounder.groundpoundringfx = "firering_fx"
inst:AddComponent("named")
inst.components.named:SetName("My Dragonfly")
inst:AddComponent("inventory")
inst:AddComponent("knownlocations")
inst:AddComponent("follower")
inst.components.follower:SetLeader(GetPlayer())
inst:AddComponent("lootdropper")
inst.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "dragon_scales"})
inst:AddComponent("health")
inst.components.health:SetMaxHealth(5000)
inst:AddComponent("combat")
inst.components.combat:SetDefaultDamage(300)
inst.components.combat:SetAttackPeriod(0.5)
inst.components.combat.hiteffectsymbol = "dragonfly_body"
inst.components.combat:SetAreaDamage(6, 0.8)
inst.components.combat.playerdamagepercent = 0
inst.components.combat:SetRange(4)
inst.components.combat.battlecryenabled = false
inst.components.combat:SetHurtSound("dontstarve_DLC001/creatures/dragonfly/hurt")
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
if not data.attacker:HasTag("myflys") then
inst.components.combat:SetTarget(data.attacker)
end
else
inst.components.health:Kill()
end
end )
inst:AddComponent("locomotor")
inst.components.locomotor.walkspeed = 25
inst:SetStateGraph("SGdragonfly")
local brain = require "brains/abigailbrain"
inst:SetBrain(brain)
inst:DoPeriodicTask(5, function()
if inst.components.combat and not inst.components.combat.target then
if inst.fire_build then
inst.sg:GoToState("flameoff")
end
if inst.components.health and inst.components.health:GetPercent() < 1 then
inst.components.health:DoDelta(200)
end
end
end )
inst:AddComponent("machine")
inst.components.machine.turnonfn = function()
inst:AddTag("inhaling")
inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
inst.task = inst:DoPeriodicTask(.5, function(inst)
local pos = Vector3(inst.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 15)
for k,v in pairs(ents) do
local pt1 = v:GetPosition()
if v.components.inventoryitem and v.components.inventoryitem.canbepickedup and v.components.inventoryitem.cangoincontainer
and not v.components.inventoryitem:IsHeld() and not v:HasTag("trap") and not v:HasTag("light") and not v:HasTag("blowdart")
and not v:HasTag("projectile") then
if not GetPlayer().components.inventory:IsFull() then
SpawnPrefab("small_puff").Transform:SetPosition(pt1.x, pt1.y, pt1.z)
GetPlayer().components.inventory:GiveItem(v)
GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available")
end
end
end
end )
end
inst.components.machine.turnofffn = function()
inst:RemoveTag("inhaling")
inst.AnimState:SetBloomEffectHandle( "" )
if inst.task then inst.task:Cancel() inst.task = nil 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)
inst.sg:GoToState("flameoff")
else
inst:RemoveTag("stophere")
local brain = require "brains/abigailbrain"
inst:SetBrain(brain)
inst:RestartBrain()
inst.components.follower:SetLeader(GetPlayer())
end
end
inst:ListenForEvent("death", function()
inst.components.machine:TurnOff()
end )
inst:AddTag("companion")
inst:AddTag("myflys")
end
if data and data.stophere then
inst:AddTag("stophere")
inst.components.locomotor:Stop()
inst:SetBrain(nil)
inst.components.follower:SetLeader(nil)
inst.sg:GoToState("flameoff")
end
if data and data.inhaling then
inst.components.machine.ison = true
inst.components.machine:TurnOn()
end
end
inst.OnSave = onsave
inst.OnLoad = onload
即可用蜻蜓盔甲种宠物蜻蜓,攻击力超强,并自动补血,是战斗时的好帮手。鼠标左键点蜻蜓,可让它停在原地,再次点击可继续跟随。鼠标右键点蜻蜓,可让它帮你捡地上的东西(快速吸取至主角物品栏),再次点击可停止捡东西。不想要宠物蜻蜓了,杀死即可(按Ctrl + 鼠标左键攻击),打一下即死。宠物蜻蜓攻击时会引发火灾,所以带它战斗时不要离基地太近,也不要同时带1个以上的宠物蜻蜓去战斗,否则容易互殴。蜻蜓盔甲在战斗选项(画着两把剑)下,用1个蜻蜓鳞片、1个木盔甲、3个猪皮制造
更多相关内容请关注:饥荒专区
责任编辑:Shy夏夏