andy333 Posted July 23, 2023 Share Posted July 23, 2023 This is how I have my script set up now, and I have confirmed that it is applied after gameplay. -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "esctemplate.tex" ) inst:AddTag("esctemplate") inst:AddComponent("battleborn") end local function IsValidVictim(victim) return victim ~= nil and not ((victim:HasTag("prey") and not victim:HasTag("hostile")) or victim:HasTag("veggie") or victim:HasTag("structure") or victim:HasTag("wall") or victim:HasTag("balloon") or victim:HasTag("groundspike") or victim:HasTag("smashable") or victim:HasTag("companion")) and victim.components.health ~= nil and victim.components.combat ~= nil end local function OnTakeDrowningDamage(inst) inst.components.singinginspiration:SetInspiration(0) end local function onkilled(inst, data) local victim = data.victim if IsValidVictim(victim) then if not victim.components.health.nofadeout and (victim:HasTag("epic") or math.random() < 0.1) then local time = victim.components.health.destroytime or 2 local x, y, z = victim.Transform:GetWorldPosition() local scale = (victim:HasTag("smallcreature") and smallScale) or (victim:HasTag("largecreature") and largeScale) or medScale inst:DoTaskInTime(time, spawnspirit, x, y, z, scale) end end end -- This initializes for the server only. Components are added here. local master_postinit = function(inst) inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default inst.components.health:SetMaxHealth(TUNING._HEALTH) inst.components.hunger:SetMax(TUNING.ESCTEMPLATE_HUNGER) inst.components.sanity:SetMax(TUNING.ESCTEMPLATE_SANITY) if TheNet:GetServerGameMode() == "lavaarena" then event_server_data("lavaarena", "prefabs/esctemplate").master_postinit(inst) elseif TheNet:GetServerGameMode() == "quagmire" then --event_server_data("quagmire", "prefabs/esctemplate").master_postinit(inst) else inst:AddComponent("battleborn") inst.components.battleborn:SetBattlebornBonus(TUNING.WATHGRITHR_BATTLEBORN_BONUS) inst.components.battleborn:SetSanityEnabled(true) inst.components.battleborn:SetHealthEnabled(true) inst.components.battleborn:SetValidVictimFn(IsValidVictim) inst.components.battleborn.allow_zero = false -- Don't regain stats if our attack is trying to deal literally 0 damage. if inst.components.drownable ~= nil then inst.components.drownable:SetOnTakeDrowningDamageFn(OnTakeDrowningDamage) end inst.components.combat.damagemultiplier = TUNING.WATHGRITHR_DAMAGE_MULT inst.components.health:SetAbsorptionAmount(TUNING.WATHGRITHR_ABSORPTION) inst:ListenForEvent("killed", onkilled) end end if GetModConfigData("CraftToggle_spear_wathgrithr", "ESCTEMPLATE") == "y" then local recipe_difficulty = GetModConfigData("spear_wathgrithr", "ESCTEMPLATE") if recipe_difficulty == "default" then local wathgrithr_spear_recipe = AddRecipe("spear_wathgrithr", {Ingredient("twigs", 2), Ingredient("flint", 2), Ingredient("goldnugget", 2)}, RECIPETABS.WAR, TECH.SCIENCE_NONE, nil, nil, nil, nil, "wathgrithr", "images/inventoryimages/spear_wathgrithr.xml") wathgrithr_spear_recipe.sortkey = -2 end end return MakePlayerCharacter("esctemplate", prefabs, assets, common_postinit, master_postinit, prefabs) However, subsequent battles in the game will retain the buff. [string '..lmodslESCTEMPLATE/scriptslprefabslmythenme...")2105: variable 'onkilled' is not declared LUA ERROR stack traceback: =[C):-1 in (global) error (C) <-1--1> scriptslstrict.lua:23 in () ? (Lua) <21-26> ..[mods/ESCTEMPLATE/scriptslprefabs/ESCTEMPLATE.lua:105 in (upvalue) master_postinit (Lua) <78-123> scripts/prefabslplayer_common.lua:2481 in (field) to (Lua) <2008-2524> scripts/mainfunctions.lua:336 in () ? (Lua) <325-371> =[C]:-1 in (method) SendSpawnRequestToServer (C) <-1--1> scriptslmainfnnctions.lua:1970 in (local) cb (Lna) <1938-1971> scripts/frontend.loa:665 in (method) DoI'adingUpdate (Loa) <629-669> The game crashes with these errors. Can someone help me with this? Link to comment https://forums.kleientertainment.com/forums/topic/149748-applying-wathgrithr-battleborn-to-an-oc-character-help/ 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