Eusong Posted May 10, 2017 Share Posted May 10, 2017 (edited) Hello, I'm trying to create a creature that summons tornadoes when it attacks, however the problem is that it takes damage from those same tornadoes. I'd like to edit it to be immune to damage from that prefab, but I can't seem to get it to work. I looked at this topic however the solution that was reached offered me absolutely no help when I used it. Any help would be greatly appreciated Edited May 11, 2017 by Eusong Link to comment Share on other sites More sharing options...
Leonardo Cox Posted May 10, 2017 Share Posted May 10, 2017 (edited) --as its own function above masterpostinit local function tornadoimmunity(inst, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb) return afflicter ~= nil and afflicter.prefab == "prefabnamehere") --you can also do afflicter:HasTag("name") if you want to filter it by tags. end --in masterpostinit inst.components.health.redirect = tornadoimmunity Edited May 10, 2017 by DarkKingBoo Link to comment Share on other sites More sharing options...
Eusong Posted May 10, 2017 Author Share Posted May 10, 2017 10 minutes ago, DarkKingBoo said: --as its own function above masterpostinit local function tornadoimmunity(inst, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb) return afflicter ~= nil and afflicter.prefab == "prefabnamehere") --you can also do afflicter:HasTag("name") if you want to filter it by tags. end --in masterpostinit inst.components.health.redirect = tornadoimmunity It works! Thank you so much! However it still gets stunned by the tornado. Is there a piece of code you know that could get rid of it being stunned by it? Thanks again for the first piece. ^-^ Link to comment Share on other sites More sharing options...
Leonardo Cox Posted May 10, 2017 Share Posted May 10, 2017 Hmm I was not aware that the health redirect doesn't stop stunning, my bad. I'm assuming the tornado is staff_tornado prefab. You may need to add additional code to the tornado stategraph to specifically ignore your character in the destroystuff function. I'm sure there is some form of AddStategraphPostInit (there is another method but I need to remember how to do it), however I can't look it up today. Since your character is summoning tornadoes, you can take the simple way and simply make a copy of the SGtornado (and rename it to something else) and make the changes and have the tornadoes use that stategraph when summoned. I'll answer back with a "cleaner" solution when I can. Link to comment Share on other sites More sharing options...
DarkXero Posted May 10, 2017 Share Posted May 10, 2017 (edited) 1 hour ago, Eusong said: Is there a piece of code you know that could get rid of it being stunned by it? You could use the code that the tornado uses. local tornado = SpawnPrefab("tornado") tornado.WINDSTAFF_CASTER_ISPLAYER = true Now the tornados won't hit players (unless PVP is enabled). Edited May 10, 2017 by DarkXero Link to comment Share on other sites More sharing options...
Eusong Posted May 10, 2017 Author Share Posted May 10, 2017 It's not a player that's summoning the tornadoes DarkXero, it's a custom bird that I'm making. And thank you DarkKingBoo, I look forward to your solution. Link to comment Share on other sites More sharing options...
DarkXero Posted May 10, 2017 Share Posted May 10, 2017 local tornado = SpawnPrefab("tornado") tornado.WINDSTAFF_CASTER = inst tornado.WINDSTAFF_CASTER_ISPLAYER = true And make that inst be the creature. Link to comment Share on other sites More sharing options...
Eusong Posted May 11, 2017 Author Share Posted May 11, 2017 3 hours ago, DarkXero said: local tornado = SpawnPrefab("tornado") tornado.WINDSTAFF_CASTER = inst tornado.WINDSTAFF_CASTER_ISPLAYER = true And make that inst be the creature. Thank you so much! It 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