Aquaterion Posted May 11, 2016 Share Posted May 11, 2016 (edited) remove this: local dapperness = inst.components.sanity.dapperness and replace these dapperness = dapperness + inst.sanitydap dapperness = dapperness - inst.sanitydap with these inst.components.sanity.dapperness = inst.components.sanity.dapperness + inst.sanitydap inst.components.sanity.dapperness = inst.components.sanity.dapperness - inst.sanitydap should work then Edited May 11, 2016 by Aquaterion Link to comment Share on other sites More sharing options...
sparky4 Posted May 11, 2016 Author Share Posted May 11, 2016 ok testing thank you!! <3 Link to comment Share on other sites More sharing options...
sparky4 Posted May 24, 2016 Author Share Posted May 24, 2016 i found a bad bug!!!! ahh please! help there is a console kill bug [00:04:22]: [string "../mods/workshop-639322917/scripts/prefabs/..."]:192: attempt to index local 'data' (a nil value) LUA ERROR stack traceback: ../mods/workshop-639322917/scripts/prefabs/winnie.lua:192 in (local) fn (Lua) <192-192> player = 114396 - winnie (valid:true) data = nil scripts/entityscript.lua:960 in (method) PushEvent (Lua) <954-977> self (valid:true) = DynamicShadow = DynamicShadow (0x360b51c0) inlimbo = false GetMoistureRateScale = function - scripts/prefabs/player_common.lua:132 deathclientobj = table: 0x175422c0 SetCameraDistance = function - scripts/prefabs/player_common.lua:1259 ScreenFlash = function - scripts/prefabs/player_common.lua:1321 player_classified = 114397 - player_classified (valid:true) Link to comment Share on other sites More sharing options...
Aquaterion Posted May 24, 2016 Share Posted May 24, 2016 4 hours ago, sparky4 said: i found a bad bug!!!! ahh please! help there is a console kill bug [00:04:22]: [string "../mods/workshop-639322917/scripts/prefabs/..."]:192: attempt to index local 'data' (a nil value) LUA ERROR stack traceback: ../mods/workshop-639322917/scripts/prefabs/winnie.lua:192 in (local) fn (Lua) <192-192> player = 114396 - winnie (valid:true) data = nil scripts/entityscript.lua:960 in (method) PushEvent (Lua) <954-977> self (valid:true) = DynamicShadow = DynamicShadow (0x360b51c0) inlimbo = false GetMoistureRateScale = function - scripts/prefabs/player_common.lua:132 deathclientobj = table: 0x175422c0 SetCameraDistance = function - scripts/prefabs/player_common.lua:1259 ScreenFlash = function - scripts/prefabs/player_common.lua:1321 player_classified = 114397 - player_classified (valid:true) which 1 is line 192? and what did you kill? can you post a longer version? Link to comment Share on other sites More sharing options...
sparky4 Posted May 24, 2016 Author Share Posted May 24, 2016 ah this is line 192 inst:ListenForEvent("death", function(player, data) ondeath(inst, data.victim, player) end) winnie.lua Link to comment Share on other sites More sharing options...
Muche Posted May 24, 2016 Share Posted May 24, 2016 Death event is being pushed in health component as follows: self.inst:PushEvent("death", { cause = cause, afflicter = afflicter }) that is, it means the inst has died, and parameter data contains what caused that death. Link to comment Share on other sites More sharing options...
sparky4 Posted May 24, 2016 Author Share Posted May 24, 2016 (edited) ok!~ how to fix? ^^ Edited May 24, 2016 by sparky4 Link to comment Share on other sites More sharing options...
Muche Posted May 24, 2016 Share Posted May 24, 2016 (edited) Technically, it could be fixed with inst:ListenForEvent("death", function(player, data) ondeath(inst, player, data ~= nil and data.afflicter or nil) end) However, the question is, why does the character need to listen to its own death? Also, it would have no effect, since ondeath function does if deadthing == inst then return, which is true in this case. Some other inconsistencies: Line 192 in attached winnie.lua is actually inst:ListenForEvent("entity_death", function(wrld, data) ondeath(inst, data.inst) end, TheWorld). Line 192 in winnie.lua of published mod is indeed inst:ListenForEvent("death", function(player, data) ondeath(inst, data.victim, player) end). It's not clear why data passed to the function is actually nil when Health:SetVal() pushes the event with non-nil table. Do you have other mods enabled, e.g. Too Many Items or Moderator Commands, that can indeed push the death event with nil data? Edited May 24, 2016 by Muche Link to comment Share on other sites More sharing options...
sparky4 Posted May 24, 2016 Author Share Posted May 24, 2016 (edited) ah yes other mods are enabled ! i am going to test winnie alone now~ player listen to their own death for resetting battle born ^^; Edited May 24, 2016 by sparky4 Link to comment Share on other sites More sharing options...
sparky4 Posted May 27, 2016 Author Share Posted May 27, 2016 where did everyone find the information of the game variables and functions? ^^ the documentations ? ^^ Link to comment Share on other sites More sharing options...
Muche Posted May 27, 2016 Share Posted May 27, 2016 1 hour ago, sparky4 said: where did everyone find the information of the game variables and functions? ^^ the documentations ? ^^ Personally, I started by reading then read code, read other mods' code, searched in all files for places where a variable/function of interest is being declared/called and experimenting. Link to comment Share on other sites More sharing options...
sparky4 Posted June 14, 2016 Author Share Posted June 14, 2016 Master: [00:04:15]: [string "scripts/stategraphs/SGwilson.lua"]:1017: Left death state. Master: LUA ERROR stack traceback: Master: =[C]:-1 in (global) assert (C) <-1--1> Master: scripts/stategraphs/SGwilson.lua:1017 in (field) onexit (Lua) <1015-1018> Master: inst = 107960 - winnie (valid:true) Master: scripts/stategraph.lua:462 in (method) GoToState (Lua) <450-511> Master: self = Master: timelineindex = 1 Master: tags = table: 0x1a145bd0 Master: mem = table: 0x1b45f8c8 Master: statemem = table: 0x1a145fd0 Master: currentstate = table: 0x16a81f78 Master: timeinstate = 0.033333335071802 Master: sg = Stategraph : wilson Master: inst = 107960 - winnie (valid:true) Master: bufferedevents = table: 0x1a14f3e0 Master: lastupdatetime = 119.6333395727 Master: statestarttime = 119.60000623763 Master: laststate = table: 0x15b84ab8 Master: prevstate = table: 0x16a81f78 Master: statename = death Master: params = nil Master: state = table: 0x16a81f78 Master: scripts/stategraphs/SGwilson.lua:471 in (field) fn (Lua) <465-472> Master: inst = 107960 - winnie (valid:true) Master: scripts/stategraph.lua:400 in (method) HandleEvents (Lua) <391-411> Master: self = Master: timelineindex = 1 Master: tags = table: 0x1a145bd0 Master: mem = table: 0x1b45f8c8 Master: statemem = table: 0x1a145fd0 Master: currentstate = table: 0x16a81f78 Master: timeinstate = 0.033333335071802 Master: sg = Stategraph : wilson Master: inst = 107960 - winnie (valid:true) Master: bufferedevents = table: 0x1a14f3e0 Master: lastupdatetime = 119.6333395727 Master: statestarttime = 119.60000623763 Master: laststate = table: 0x15b84ab8 Master: prevstate = table: 0x16a81f78 Master: buff_events = table: 0x1a14f3e0 Master: k = 1 Master: event = table: 0x1ade5570 Master: handler = table: 0x16988b60 Master: scripts/stategraph.lua:145 in (method) Update (Lua) <109-148> Master: self = Master: updaters = table: 0x1af76de0 Master: OnEnterNewState = function - scripts/stategraph.lua:27 Master: tickwaiters = table: 0x97270d8 Master: haveEvents = table: 0x1ae0cd20 Master: hibernaters = table: 0x92f29b0 Master: instances = table: 0xa74e6f0 Master: current_tick = 3594 Master: waiters = table: 0x1af178a8 Master: updaters = table: 0x1af853d8 Master: evs = table: 0x1af89fe0 Master: k = sg="wilson", state="death", time=0.20, tags = "busy,pausepredict,nomorph," Master: v = true Master: scripts/update.lua:209 in () ? (Lua) <150-223> Master: dt = 0.033333335071802 Master: tick = 3594 Master: i = 3594 Master: Master: [00:04:15]: [string "scripts/stategraphs/SGwilson.lua"]:1017: Left death state. Master: LUA ERROR stack traceback: Master: =[C]:-1 in (global) assert (C) <-1--1> Master: scripts/stategraphs/SGwilson.lua:1017 in (field) onexit (Lua) <1015-1018> Master: scripts/stategraph.lua:462 in (method) GoToState (Lua) <450-511> Master: scripts/stategraphs/SGwilson.lua:471 in (field) fn (Lua) <465-472> Master: scripts/stategraph.lua:400 in (method) HandleEvents (Lua) <391-411> Master: scripts/stategraph.lua:145 in (method) Update (Lua) <109-148> Master: scripts/update.lua:209 in () ? (Lua) <150-223> Master: Master: [00:04:15]: CURL ERROR: <url> malformed HOLY MOLY I THINK --thanks to everyone who helped me with the codde --mary4 --http://forums.kleientertainment.com/topic/67141-winnie-the-mauderer-refinement/ --arigatou kure-kun~ for balance advice! --licence is GNU LGPLv3 i think?? wwww local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = { "knife_winnie" } -- Custom starting items local start_inv = { "knife_winnie" } --sanity wwww local function resetbloodlust(inst) inst.totaldaytime = 240 * math.random(1,4)-- 1 day = 480s -- print(string.format("[winnie|resetbloodlust()] inst.bloodlust=%s inst.requirekills=%s dapperness=%s", -- tostring(inst.bloodlust), tostring(inst.requirekills), tostring(inst.components.sanity.dapperness))) if inst.bloodlust then inst.bloodlust:Cancel() inst.bloodlust = nil end if inst.requirekills then inst.requirekills = nil inst.components.sanity.dapperness = inst.components.sanity.dapperness + inst.sanitydap inst.components.sanity.neg_aura_mult = inst.components.sanity.neg_aura_mult + inst.sanitydap if not inst.revivemute then inst.components.talker:Say("Much better!~") else inst.revivemute=0 end end inst.bloodlust = inst:DoTaskInTime(inst.totaldaytime, function() inst.components.sanity.dapperness = inst.components.sanity.dapperness - inst.sanitydap inst.components.sanity.neg_aura_mult = inst.components.sanity.neg_aura_mult - inst.sanitydap inst.requirekills = true if not inst.revivemute then inst.components.talker:Say("I NEED TO KILL!!") else inst.revivemute=0 end end) end local function OnIsFullmoon(inst, isfullmoon) if isfullmoon then --inst.components.sanity.rate_modifier = -8 inst.components.sanity.night_drain_mult = TUNING.CRAZINESS_MED--(inst.sanitydap) inst.components.sanity.neg_aura_mult = TUNING.CRAZINESS_MED--inst.sanitydap else inst.components.sanity.night_drain_mult = TUNING.WENDY_SANITY_MULT inst.components.sanity.neg_aura_mult = TUNING.WENDY_SANITY_MULT end end local function IsValidVictim(victim) return victim ~= nil and not (victim:HasTag("veggie") or victim:HasTag("structure") or victim:HasTag("wall") or victim:HasTag("companion") or victim:HasTag("smashable")) and victim.components.health ~= nil and victim.components.combat ~= nil end local CRAZYBORN_STORE_TIME = 4 local CRAZYBORN_DECAY_TIME = 8 local CRAZYBORN_TRIGGER_THRESHOLD = 1 local function onattack(inst, data) -- print(string.format("[winnie|onattack(%s,%s)]#1 data=%s", -- tostring(inst), tostring(data), type(data) ~= "table" and "???" or tabletodictstring(data) -- )) local victim = data.target if not inst.components.health:IsDead() and IsValidVictim(victim) then local total_health = victim.components.health:GetMaxWithPenalty() local damage = data.weapon ~= nil and data.weapon.components.weapon.damage or inst.components.combat.defaultdamage local percent = (damage <= 0 and 0) or (total_health <= 0 and math.huge) or damage / total_health local pee if victim.components.combat.defaultdamage==0 then pee=4 * math.random(1,6) else pee=0 end --math and clamp does account for 0 and infinite cases local delta = math.clamp(victim.components.combat.defaultdamage+pee * 0.25 * percent, .33, 2) --decay stored crazyborn if inst.crazyborn > 0 then local dt = GetTime() - inst.crazyborn_time - CRAZYBORN_STORE_TIME if dt >= CRAZYBORN_DECAY_TIME then inst.crazyborn = 0 elseif dt > 0 then local k = dt / CRAZYBORN_DECAY_TIME inst.crazyborn = Lerp(inst.crazyborn, 0, k * k) end end -- print(string.format("[winnie|onattack(%s,%s)]#2 total_health=%s, damage=%s, percent=%s, delta=%s, inst.crazyborn=%s", -- tostring(inst), tostring(data), tostring(total_health), tostring(damage), tostring(percent), tostring(delta), tostring(inst.crazyborn) -- )) --store new crazyborn inst.crazyborn = inst.crazyborn + delta inst.crazyborn_time = GetTime() --consume crazyborn if enough has been stored if inst.crazyborn > CRAZYBORN_TRIGGER_THRESHOLD then -- print(string.format("[winnie|onattack(%s,%s)]#3a apply crazyborn bonuses", tostring(inst), tostring(data))) inst.components.health:DoDelta(inst.crazyborn, false, "crazyborn") inst.components.sanity:DoDelta(inst.crazyborn) inst.crazyborn = 0 -- else -- print(string.format("[winnie|onattack(%s,%s)]#3b crazyborn %s it not over threshold %s yet", -- tostring(inst), tostring(data), tostring(inst.crazyborn), tostring(CRAZYBORN_TRIGGER_THRESHOLD) -- )) end end end local function ondeath(inst, deadthing, killer) -- print(string.format("[winnie|ondeath(%s)]#1", tostring(inst))) if deadthing ~= nil then --if player did not become pepperoni local _isneardeadthing = deadthing ~= nil and deadthing:IsValid() and inst:IsNear(deadthing, 16) or nil local _destdeadthing = deadthing ~= nil and deadthing:IsValid() and inst:IsValid() and inst:GetDistanceSqToInst(deadthing) or nil local _isnearkiller = killer ~= nil and killer:IsValid() and inst:IsNear(killer, 16) or nil local _destkiller = killer ~= nil and killer:IsValid() and inst:IsValid() and inst:GetDistanceSqToInst(killer) or nil --IsValidVictim(deadthing)=%s, deadthing:IsValid()=%s, --tostring(IsValidVictim(deadthing)), -- print(string.format("[winnie|ondeath(%s,%s,%s)]#1 _isneardeadthing=%s, _destdeadthing=%s, _isnearkiller=%s, _destkiller=%s", -- tostring(inst), tostring(deadthing), tostring(killer), -- tostring(_isneardeadthing), tostring(_destdeadthing), tostring(_isnearkiller), tostring(_destkiller) -- )) if IsValidVictim(deadthing) and deadthing:IsValid() then if not inst:IsNear(deadthing, 16) then -- print(string.format("[winnie|ondeath(%s,%s,%s)]#2 deadthing is not near inst", tostring(inst), tostring(deadthing), tostring(killer))) return elseif deadthing == inst then return -- elseif killer == nil or not inst:IsNear(killer, 16) then -- print(string.format("[winnie|ondeath(%s,%s,%s)]#3 killer is not near inst", tostring(inst), tostring(deadthing), tostring(killer))) -- return end local pee if deadthing.components.combat.defaultdamage==0 then pee=4 * math.random(1,6) else pee=0 end --math and clamp does account for 0 and infinite cases local delta = math.clamp(deadthing.components.combat.defaultdamage+pee * 0.50, .33, 2)--(deadthing.components.combat.defaultdamage)+pee -- print(string.format("[winnie|ondeath(%s,%s,%s)]#4 delta=%s", tostring(inst), tostring(deadthing), tostring(killer), tostring(delta))) inst.components.health:DoDelta(delta) inst.components.sanity:DoDelta(delta) end -- else -- print(string.format("[winnie|ondeath(%s)]#5 deadthing is nil", tostring(inst))) end inst.crazyborn = 0 end local function onkilled(inst, deadthing, killer) resetbloodlust(inst) -- inst being the player ondeath(inst, deadthing, killer) end -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when reviving from ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "esctemplate_speed_mod", 1) OnIsFullmoon(inst, TheWorld.state.isfullmoon) inst.revivemute = 1 --muting winnie when she gets revived~ resetbloodlust(inst) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "winnie_speed_mod") inst:StopWatchingWorldState("isfullmoon", OnIsFullmoon) inst.revivemute = 1 inst.totaldaytime=nil inst.bloodlust = nil inst.requirekills = nil end -- When loading or spawning the character local function onload(inst) inst:WatchWorldState("isfullmoon", OnIsFullmoon) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) inst:AddTag("crazy_killer") inst:AddTag("winnie") -- Minimap icon inst.MiniMapEntity:SetIcon( "winnie.tex" ) end -- This initializes for the server only. Components are added here. local master_postinit = function(inst) -- choose which sounds this character will play inst.soundsname = "willow" inst:ListenForEvent("killed", function(player, data) onkilled(inst, data.victim, player) end) inst:ListenForEvent("onattackother", onattack) inst:ListenForEvent("death", function(player, data) ondeath(inst, data ~= nil and data.afflicter or nil, player) end) inst:ListenForEvent("entity_death", function(wrld, data) ondeath(inst, data.inst) end, TheWorld) inst.crazyborn = 0 inst.crazyborn_time = 0 inst.sanitydap = 1 -- amount to increase/decrease dapperness inst.revivemute = 0 -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used --inst.talker_path_override = "dontstarve_DLC001/characters/" -- Stats inst.components.health:SetMaxHealth(150) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(80) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2)--1.1 inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2)--1.1 resetbloodlust(inst) -- inst being the player OnIsFullmoon(inst, TheWorld.state.isfullmoon) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1.32--1.75 -- Hunger rate (optional) inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.5)--1.4 inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("winnie", prefabs, assets, common_postinit, master_postinit, start_inv) inst:ListenForEvent("death", function(player, data) ondeath(inst, data ~= nil and data.afflicter or nil, player) end) this line may be causing all the issues Link to comment Share on other sites More sharing options...
sparky4 Posted June 14, 2016 Author Share Posted June 14, 2016 i fixed inst:ListenForEvent("death", function(player, data) ondeath(inst, data ~= nil and data.afflicter and inst or nil, player) end)--****!! wwww 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