TheScareCr0we Posted January 8, 2017 Share Posted January 8, 2017 As the title says, I'm trying to make a character who's damage multiplier goes up whenever they kill an enemy. Similar to how Wigfrid gains stats. I tried using code provided by Finerlobster in another thread, but I don't understand how it's supposed to look. I'm really new at all this, and seeing the code in a straight line like this: inst:ListenForEvent("entity_death", function(wrld, data) if data.cause == inst.prefab then local delta = 10 -- amount inst.components.health:DoDelta(delta) inst.components.sanity:DoDelta(delta) inst.components.hunger:DoDelta(delta) endend, GetWorld()) makes no sense to me. Can someone show me what it's supposed to look like when added to notepad++, as well as what local section it should go under? I currently have it under "local function onattack(inst)". thanks in advance. EDIT: Currently I have it set up like this: local function onattack(inst) inst:ListenForEvent("entity_death", onattack) if data.cause == inst.prefab then local delta = 10 -- amount inst.components.comcat.damagemultiplier:DoDelta(delta) end end Link to comment Share on other sites More sharing options...
Mobbstar Posted January 9, 2017 Share Posted January 9, 2017 inst:ListenForEvent("onkillother", function(inst, data) inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier + .1 end inst.OnSave = function(inst, data) data.mult = inst.components.combat.damagemultiplier end inst.OnLoad = function(inst, data) inst.components.combat.damagemultiplier = data.mult or 1 end This code does the following: When the character kills something ("onkillother") , they gain 10% damage (this could be based on the victim's health, etc.) When the game saves, the current multiplier gets saved. When the game loads, the multiplier gets set to the saved value. If there is no saved value, it will default to 100% Link to comment Share on other sites More sharing options...
TheScareCr0we Posted January 9, 2017 Author Share Posted January 9, 2017 Thank you very much! I'll add it ass soon as I fix the error with his speach.lua One more thing, does this go under local function onattack, or should it go under the one where the base stats and such are located? Link to comment Share on other sites More sharing options...
Mobbstar Posted January 9, 2017 Share Posted January 9, 2017 2 minutes ago, TheScareCr0we said: One more thing, does this go under local function onattack, or should it go under the one where the base stats and such are located? base stats, you won't need "local function onattack" with this code. Link to comment Share on other sites More sharing options...
TheScareCr0we Posted January 9, 2017 Author Share Posted January 9, 2017 3 hours ago, Mobbstar said: base stats, you won't need "local function onattack" with this code. cool thanks Link to comment Share on other sites More sharing options...
TheScareCr0we Posted January 9, 2017 Author Share Posted January 9, 2017 This look correct? EDIT: the log says that the parenthese ("onkillother" needs to be closed. Link to comment Share on other sites More sharing options...
Mobbstar Posted January 10, 2017 Share Posted January 10, 2017 woops, I forgot to close 'em after the first "end" inst:ListenForEvent... inst.components... end) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.