EmperorOfTheMankind Posted January 4, 2016 Share Posted January 4, 2016 Can I some how put a custom cause of death after a certain event? For example after I push this one. owner:PushEvent("death")I want to do that because the game will just announce: "[someone] was killed by shenanigans" or something in this manner. I wish I could change it somehow. Link to comment https://forums.kleientertainment.com/forums/topic/61878-custom-cause-of-death/ Share on other sites More sharing options...
Muche Posted January 4, 2016 Share Posted January 4, 2016 Quick search revealed that prefabs/player_common.lua haslocal function OnPlayerDeath(inst, data)...inst:ListenForEvent("death", OnPlayerDeath)and components/health.lua has this:self.inst:PushEvent("death", { cause = cause, afflicter = afflicter })You might wanna experiment with passing some data to the event. Link to comment https://forums.kleientertainment.com/forums/topic/61878-custom-cause-of-death/#findComment-705317 Share on other sites More sharing options...
EmperorOfTheMankind Posted January 5, 2016 Author Share Posted January 5, 2016 (edited) local function OnPlayerDeath(inst, data) if inst:HasTag("playerghost") then --ghosts should not be able to die atm return end inst:ClearBufferedAction() inst.components.age:PauseAging() inst.components.inventory:Close() inst:PushEvent("ms_closepopups") inst.deathcause = data ~= nil and data.cause or "unknown" inst.deathpkname = data ~= nil and data.afflicter ~= nil and data.afflicter:HasTag("player") and data.afflicter:GetDisplayName() or nil if not inst.ghostenabled then if inst.deathcause ~= "file_load" then inst.player_classified:AddMorgueRecord() local announcement_string = GetNewDeathAnnouncementString(inst, inst.deathcause, inst.deathpkname) if announcement_string ~= "" then TheNet:Announce(announcement_string, inst.entity, false, "death") end end --Early delete in case client disconnects before removal timeout DeleteUserSession(inst) endendThis is what I found in player_common.lua . I still doesn't understand how to make it work. Edited January 5, 2016 by EmperorOfTheMankind Link to comment https://forums.kleientertainment.com/forums/topic/61878-custom-cause-of-death/#findComment-705592 Share on other sites More sharing options...
DarkXero Posted January 5, 2016 Share Posted January 5, 2016 I still doesn't understand how to make it work. He just showed you how.owner:PushEvent("death", {cause = "Hello World"}) Link to comment https://forums.kleientertainment.com/forums/topic/61878-custom-cause-of-death/#findComment-705654 Share on other sites More sharing options...
EmperorOfTheMankind Posted January 6, 2016 Author Share Posted January 6, 2016 He just showed you how.owner:PushEvent("death", {cause = "Hello World"})Tried that. Didn't work. Still got killed by shenanigans. Link to comment https://forums.kleientertainment.com/forums/topic/61878-custom-cause-of-death/#findComment-705889 Share on other sites More sharing options...
Mobbstar Posted January 6, 2016 Share Posted January 6, 2016 Tried that. Didn't work. Still got killed by shenanigans. I can faintly remember that the game checks whether "cause" is in a list of valid causes. If it is, it uses the respective word(s), else it defaults to "shenanigans". Link to comment https://forums.kleientertainment.com/forums/topic/61878-custom-cause-of-death/#findComment-705911 Share on other sites More sharing options...
Dragon Wolf Leo Posted January 6, 2016 Share Posted January 6, 2016 If you take a look in eventannouncer.lua, the cause of death needs its own name, else it defaults to shenanigans.STRINGS.NAMES.SOMETHING = "Something"owner:PushEvent("death", {cause = "something"}) Link to comment https://forums.kleientertainment.com/forums/topic/61878-custom-cause-of-death/#findComment-705924 Share on other sites More sharing options...
EmperorOfTheMankind Posted January 9, 2016 Author Share Posted January 9, 2016 (edited) If you take a look in eventannouncer.lua, the cause of death needs its own name, else it defaults to shenanigans.STRINGS.NAMES.SOMETHING = "Something"owner:PushEvent("death", {cause = "something"})[00:02:13]: [string "scripts/stategraphs/SGwilson.lua"]:1008: Left death state.LUA ERROR stack traceback: =[C]:-1 in (global) assert (C) <-1--1> scripts/stategraphs/SGwilson.lua:1008 in (field) onexit (Lua) <1006-1009> scripts/stategraph.lua:460 in (method) GoToState (Lua) <448-509> scripts/stategraphs/SGwilson.lua:430 in (field) fn (Lua) <388-434> scripts/stategraph.lua:398 in (method) HandleEvents (Lua) <389-409> scripts/stategraph.lua:143 in (method) Update (Lua) <107-146> scripts/update.lua:209 in () ? (Lua) <150-223>Nope, still error. Are you sure, that STRINGS.NAMES.SOMETHING = "Something""Something" and{cause = "something"}"something" shouldn't be both written from capital? Anyway it didn't work when I did the exact same words. Edited January 9, 2016 by EmperorOfTheMankind Link to comment https://forums.kleientertainment.com/forums/topic/61878-custom-cause-of-death/#findComment-707099 Share on other sites More sharing options...
EmperorOfTheMankind Posted January 9, 2016 Author Share Posted January 9, 2016 (edited) OOOOPPPSSSS, my bad You have to put this line STRINGS.NAMES.SOMETHING = "Something"in modmain.lua*facewall* Everything's working fine now. Thank's everyone for help Edited January 9, 2016 by EmperorOfTheMankind Link to comment https://forums.kleientertainment.com/forums/topic/61878-custom-cause-of-death/#findComment-707101 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