Xide Posted October 9, 2017 Share Posted October 9, 2017 Is it possible to modify the original file stalker.lua to have the Skeleton become Ancient Fuel Weaver on the surface, so you don't have to be in caves/atrium to fight the Ancient Fuel Weaver. Even better if we can use a spawned in Ancient Gateway on the surface to become a faux-atrium but it isn't a priority. Any suggestions, tips or ideas on how to confront this? Like maybe a custom stand-alone Ancient Fuel Weaver instead? I personally don't have much coding experience, and was talking to Hekkaryk regarding this and he said he'll be giving it a shot. Link to comment Share on other sites More sharing options...
Hekkaryk Posted October 9, 2017 Share Posted October 9, 2017 Done not API-friendly way - modifying fossil_mound.lua I need help overriding OnAccept in a way different than just adding scripts/prefabs/fossil_mound.lua to my mod local function OnAccept(inst, giver, item) if item.prefab == "shadowheart" then local stalker -- if not TheWorld:HasTag("cave") then -- stalker = SpawnPrefab("stalker_forest") -- elseif not giver.components.areaaware:CurrentlyInTag("Atrium") then -- stalker = SpawnPrefab("stalker") -- else local stargate = FindEntity(inst, ATRIUM_RANGE, ActiveStargate, {"stargate"}) if stargate ~= nil then stalker = SpawnPrefab("stalker_atrium") -- override the spawn point so stalker stays around the gate stalker.components.entitytracker:TrackEntity("stargate", stargate) stargate:TrackStalker(stalker) else --should not be possible stalker = SpawnPrefab("stalker") end -- end local x, y, z = inst.Transform:GetWorldPosition() local rot = inst.Transform:GetRotation() inst:Remove() stalker.Transform:SetPosition(x, y, z) stalker.Transform:SetRotation(rot) stalker.sg:GoToState("resurrect") giver.components.sanity:DoDelta(TUNING.REVIVE_SHADOW_SANITY_PENALTY) end end Link to comment Share on other sites More sharing options...
ptr Posted October 10, 2017 Share Posted October 10, 2017 22 hours ago, Hekkaryk said: I need help overriding OnAccept in a way different than just adding scripts/prefabs/fossil_mound.lua to my mod You just need to override inst.components.trader.onaccept with AddPrefabPostInit, and remember to make it server only Link to comment Share on other sites More sharing options...
Hekkaryk Posted October 10, 2017 Share Posted October 10, 2017 (edited) Thanks, will try that! ^_^ EDIT: I'm obviously doing something silly wrong... but I can't get a hang of it. Could somebody point the way? if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("fossil_mound", function(inst) local function newOnAccept(inst, giver, item) if item.prefab == "shadowheart" then local stalker local stargate = FindEntity(inst, ATRIUM_RANGE, ActiveStargate, {"stargate"}) if stargate ~= nil then stalker = SpawnPrefab("stalker_atrium") stalker.components.entitytracker:TrackEntity("stargate", stargate) stargate:TrackStalker(stalker) else stalker = SpawnPrefab("stalker") end local x, y, z = inst.Transform:GetWorldPosition() local rot = inst.Transform:GetRotation() inst:Remove() stalker.Transform:SetPosition(x, y, z) stalker.Transform:SetRotation(rot) stalker.sg:GoToState("resurrect") giver.components.sanity:DoDelta(TUNING.REVIVE_SHADOW_SANITY_PENALTY) end end inst.components.trader.onaccept = newOnAccept end) end Edited October 10, 2017 by Hekkaryk Link to comment Share on other sites More sharing options...
ptr Posted October 10, 2017 Share Posted October 10, 2017 3 hours ago, Hekkaryk said: I'm obviously doing something silly wrong... but I can't get a hang of it. Could somebody point the way? Well, your code seems far from effective. local G = GLOBAL AddPrefabPostInit("fossil_stalker", function(inst) if not G.TheWorld.ismastersim then return end local ATRIUM_RANGE = 8.5 local function ActiveStargate(gate) return gate:IsWaitingForStalker() end local function ItemTradeTest(inst, item, giver) if item == nil or item.prefab ~= "shadowheart" or giver == nil or giver.components.areaaware == nil then return false elseif inst.form ~= 1 then return false, "WRONGSHADOWFORM" elseif giver.components.areaaware:CurrentlyInTag("Atrium") and ( G.FindEntity(inst, ATRIUM_RANGE, ActiveStargate, { "stargate" }) == nil or G.GetClosestInstWithTag("stalker", inst, 40) ~= nil ) then return false, "CANTSHADOWREVIVE" end return true end local function OnAccept(inst, giver, item) if item.prefab == "shadowheart" then local stalker if not G.TheWorld:HasTag("cave") then stalker = G.SpawnPrefab("stalker_atrium") elseif not giver.components.areaaware:CurrentlyInTag("Atrium") then stalker = G.SpawnPrefab("stalker") else local stargate = G.FindEntity(inst, ATRIUM_RANGE, ActiveStargate, { "stargate" }) if stargate ~= nil then stalker = G.SpawnPrefab("stalker_atrium") -- override the spawn point so stalker stays around the gate stalker.components.entitytracker:TrackEntity("stargate", stargate) stargate:TrackStalker(stalker) else --should not be possible stalker = SpawnPrefab("stalker") end end local x, y, z = inst.Transform:GetWorldPosition() local rot = inst.Transform:GetRotation() inst:Remove() stalker.Transform:SetPosition(x, y, z) stalker.Transform:SetRotation(rot) stalker.sg:GoToState("resurrect") giver.components.sanity:DoDelta(TUNING.REVIVE_SHADOW_SANITY_PENALTY) end end inst.components.trader:SetAbleToAcceptTest(ItemTradeTest) inst.components.trader.onaccept = OnAccept end) AddPrefabPostInit("stalker_atrium", function(inst) if not G.TheWorld.ismastersim then return end local OldIsNearAtrium=inst.IsNearAtrium function inst.IsNearAtrium(inst, other) if not G.TheWorld:HasTag("cave") then return true else return OldIsNearAtrium(inst, other) end end end) 1 Link to comment Share on other sites More sharing options...
Hekkaryk Posted October 11, 2017 Share Posted October 11, 2017 17 hours ago, ptr said: Well, your code seems far from effective. local G = GLOBAL AddPrefabPostInit("fossil_stalker", function(inst) if not G.TheWorld.ismastersim then return end local ATRIUM_RANGE = 8.5 local function ActiveStargate(gate) return gate:IsWaitingForStalker() end local function ItemTradeTest(inst, item, giver) if item == nil or item.prefab ~= "shadowheart" or giver == nil or giver.components.areaaware == nil then return false elseif inst.form ~= 1 then return false, "WRONGSHADOWFORM" elseif giver.components.areaaware:CurrentlyInTag("Atrium") and ( G.FindEntity(inst, ATRIUM_RANGE, ActiveStargate, { "stargate" }) == nil or G.GetClosestInstWithTag("stalker", inst, 40) ~= nil ) then return false, "CANTSHADOWREVIVE" end return true end local function OnAccept(inst, giver, item) if item.prefab == "shadowheart" then local stalker if not G.TheWorld:HasTag("cave") then stalker = G.SpawnPrefab("stalker_atrium") elseif not giver.components.areaaware:CurrentlyInTag("Atrium") then stalker = G.SpawnPrefab("stalker") else local stargate = G.FindEntity(inst, ATRIUM_RANGE, ActiveStargate, { "stargate" }) if stargate ~= nil then stalker = G.SpawnPrefab("stalker_atrium") -- override the spawn point so stalker stays around the gate stalker.components.entitytracker:TrackEntity("stargate", stargate) stargate:TrackStalker(stalker) else --should not be possible stalker = SpawnPrefab("stalker") end end local x, y, z = inst.Transform:GetWorldPosition() local rot = inst.Transform:GetRotation() inst:Remove() stalker.Transform:SetPosition(x, y, z) stalker.Transform:SetRotation(rot) stalker.sg:GoToState("resurrect") giver.components.sanity:DoDelta(TUNING.REVIVE_SHADOW_SANITY_PENALTY) end end inst.components.trader:SetAbleToAcceptTest(ItemTradeTest) inst.components.trader.onaccept = OnAccept end) AddPrefabPostInit("stalker_atrium", function(inst) if not G.TheWorld.ismastersim then return end local OldIsNearAtrium=inst.IsNearAtrium function inst.IsNearAtrium(inst, other) if not G.TheWorld:HasTag("cave") then return true else return OldIsNearAtrium(inst, other) end end end) Thank you again : ) You code greatly helped me get this to work - I obviously failed to use proper namespaces and prefab first time, didn't I? ^_^" Also, does replacing GLOBAL with local G and using G.TheWorld.ismastersin best practice? Here's the final product - it differs from yours in that it allows both Ancient Fuelweaver and Reanimated Skeleton to be summoned (summoning Ancient Fuelweaver obviously requires both Ancient Key and Ancient Gateway and it's intended): local G = GLOBAL if G.TheNet:GetIsServer() then local ATRIUM_RANGE = 8.5 local function ActiveStargate(gate) return gate:IsWaitingForStalker() end local function IsNearAtrium(inst, other) local stargate = inst.components.entitytracker:GetEntity("stargate") return stargate ~= nil and stargate:HasTag("intense") end AddPrefabPostInit("fossil_stalker", function(inst) local function ItemTradeTest(inst, item, giver) if item == nil or item.prefab ~= "shadowheart" or giver == nil or giver.components.areaaware == nil then return false elseif inst.form ~= 1 then return false, "WRONGSHADOWFORM" elseif giver.components.areaaware:CurrentlyInTag("Atrium") and (G.FindEntity(inst, ATRIUM_RANGE, ActiveStargate, {"stargate"}) == nil or G.GetClosestInstWithTag("stalker", inst, 40) ~= nil) then return false, "CANTSHADOWREVIVE" end return true end local function OnAccept(inst, giver, item) if item.prefab == "shadowheart" then local stalker local stargate = G.FindEntity(inst, ATRIUM_RANGE, ActiveStargate, {"stargate"}) if stargate ~= nil then stalker = G.SpawnPrefab("stalker_atrium") stalker.components.entitytracker:TrackEntity("stargate", stargate) stargate:TrackStalker(stalker) else stalker = G.SpawnPrefab("stalker") end local x, y, z = inst.Transform:GetWorldPosition() local rot = inst.Transform:GetRotation() inst:Remove() stalker.Transform:SetPosition(x, y, z) stalker.Transform:SetRotation(rot) stalker.sg:GoToState("resurrect") giver.components.sanity:DoDelta(TUNING.REVIVE_SHADOW_SANITY_PENALTY) end end inst.components.trader.onaccept = OnAccept inst.components.trader:SetAbleToAcceptTest(ItemTradeTest) end) end Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now