rons0n Posted August 17, 2017 Share Posted August 17, 2017 (edited) So right now I'm trying to do 2 things, one: character has the ability to turn invisible by keyhandler but her sanity drain stacks up whenever she goes invisible. two: I have a lightning attack that attacks the target multiple times but is intended to hit in an Area of Effect multiple times. Any help is appreciated! The invisibility and the sanity stacking each time i press the keyhandler: local function NamiFn(inst) if inst:HasTag("playerghost") then return end if inst.transformed then --Normal local x, y, z = inst.Transform:GetWorldPosition() local fx = SpawnPrefab("deer_ice_burst") inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/bearger/groundpound") fx.Transform:SetPosition(x, y, z) SpawnPrefab("collapse_big").Transform:SetPosition(inst:GetPosition():Get()) inst:RemoveTag("notarget") inst:RemoveTag("namicloak") inst.AnimState:SetMultColour(1,1,1,1) inst.components.talker:Say("Decloaked!", 2.5,true) else --Cloaked local x, y, z = inst.Transform:GetWorldPosition() local fx = SpawnPrefab("deer_ice_burst") inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/bearger/groundpound") fx.Transform:SetPosition(x, y, z) SpawnPrefab("collapse_big").Transform:SetPosition(inst:GetPosition():Get()) inst:AddTag("notarget") inst:AddTag("namicloak") inst.AnimState:SetMultColour(0.2,0.2,0.2,.2) local x,y,z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, 100) -- Stop anyone from actively attacking me (notarget tag will make it so you dont get retarggeted) -- for k,v in pairs(ents) do -- if v.components.combat and v.components.combat.target == inst then -- v.components.combat.target = nil -- end -- end inst.cloak_func = function(inst) if inst.components.sanity and inst:HasTag("namicloak") then inst.components.sanity:DoDelta(-0.0375 * 1, true, "Cloak") end end inst.cloak_speed = 0.003 inst.cloak_task = inst:DoPeriodicTask (inst.cloak_speed, inst.cloak_func ) inst.components.talker:Say("MIIIIIIRAGE TEMPO!", 2.5,true) end inst.transformed = not inst.transformed -- inst.components.sanity:DoDelta(-10) return true end AddModRPCHandler("Nami", "NAMI", NamiFn) And then two the AOE attack thats not working: local function spell(attacker, target, inst) local pt = target:GetPosition() local numlightning = 15 target:StartThread(function() for k = 1, numlightning do local theta = math.random() * 2 * PI local radius = math.random(5, 5) local result_offset = FindValidPositionByFan(theta, radius, 12, function(offset) local pos = pt + offset return #TheSim:FindEntities(pos.x, 0, pos.z, 1, nil, { "INLIMBO", "FX" }) <= 0 and TheWorld.Map:IsDeployPointClear(pos, nil, 1) end) if result_offset ~= nil then local x, z = pt.x + result_offset.x, pt.z + result_offset.z local lightning = SpawnPrefab("lightning") lightning.Transform:SetPosition(x, 0, z) lightning:DoTaskInTime(0, lightning.TriggerFX) SpawnPrefab("deer_ice_burst").Transform:SetPosition(x, 0, z) end target.components.combat:SuggestTarget(attacker) target.components.combat:SetAreaDamage(7, 7) target.components.combat:GetAttacked(attacker, 25, inst) target.components.combat:SetAreaDamage(7, 1) Sleep(.33) end end) end Edited August 17, 2017 by rons0n Link to comment Share on other sites More sharing options...
ZupaleX Posted August 18, 2017 Share Posted August 18, 2017 For the first one, I do not see you cancelling the cloak_task, so it will effectively stack. For the second one, you say it is not working. What is not working exactly? And why do you use StartThread? That seems like an overkill to me considering what you want to achieve. Link to comment Share on other sites More sharing options...
rons0n Posted August 18, 2017 Author Share Posted August 18, 2017 Thanks ZupaleX i totally forgot about that, goodbye to those annoying stacks! The second does work but it only targets a single target, I want it to effect all the targets. I thought just slapping on target.components.combat:SetAreaDamage(7, 1) to see if that would do it but nothing happend. Im sure its something obvious but my slow processing mind doesn't know Link to comment Share on other sites More sharing options...
ZupaleX Posted August 18, 2017 Share Posted August 18, 2017 Why not simply a FindEntities from the target position requiring that the matching entities must have a combat component and apply the attack to all of them? Link to comment Share on other sites More sharing options...
rons0n Posted August 19, 2017 Author Share Posted August 19, 2017 Wow you have a point, thanks! I'll get right to it and edit this post to show how i did it Again, appreciated! Link to comment Share on other sites More sharing options...
ZupaleX Posted August 19, 2017 Share Posted August 19, 2017 Your welcome. Yes please let us know if this works 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