BeeChoc Posted November 11, 2024 Share Posted November 11, 2024 Hi everyone, it's me, again ... x) Im currently trying to improve my character with more perks. Im not really good with coding, for now im only taking some parts of others mods to create mine BUT ... Do y'all think it's possible to add a perks that can spawn a bee every time i get hit, they would basicaly protect the character and attack the enemies ? And i saw a few times peoples talking about a perk that give you sanity when you get hit too, i didnt quite understood how to make this up but if someone can help me with that too, this would be great. Link to comment https://forums.kleientertainment.com/forums/topic/160623-character-mod-perks-questions/ Share on other sites More sharing options...
Baguettes Posted November 13, 2024 Share Posted November 13, 2024 (edited) In your character .lua, above common and master postinit functions: local function SpawnBeesOnHit(inst, attacker, damage, spdamage) local x, y, z = inst.Transform:GetWorldPosition() --Cooldown of sorts. 5 Seconds between each spawn. if inst._spawnedbees == true then return end inst._spawnedbees = true inst:DoTaskInTime(5, function() inst._spawnedbees = false end) if attacker:IsValid() and attacker.components.combat and attacker.components.health then --Should spawn 3 bees; all of them drop nothing for i = 1, 3 do local bee = SpawnPrefab("bee") bee.Transform:SetPosition(x + math.random(2), y, z + math.random(2)) bee.components.combat:SuggestTarget(attacker) bee.components.lootdropper:ClearRandomLoot() --Kills the bee in 2 secs after it deaggros from its target bee:ListenForEvent("droppedtarget", function() bee:DoTaskInTime(2, function() bee.components.health:Kill() end) end) end end end Then, in your master_postinit, same file, insert: inst.components.combat:SetOnHit(SpawnBeesOnHit) I may or may haven't missed something. Hopefully this'll help in the slightest, however. Edit: For sanity on hit, type inst.components.sanity:DoDelta(PutYourNumberHere) right below local x, y, z for it to always trigger on hit regardless of bee cooldown. Also, character perks are mostly done by combining a lot of the available basegame components together into one functioning... function. Once you delve deeper into DST modding however, you can even create your own component that does your own desired thing. Keep going though, I took a while to learn also Edited November 13, 2024 by Baguettes Added sanity delta Link to comment https://forums.kleientertainment.com/forums/topic/160623-character-mod-perks-questions/#findComment-1756963 Share on other sites More sharing options...
BeeChoc Posted November 14, 2024 Author Share Posted November 14, 2024 15 hours ago, Baguettes said: In your character .lua, above common and master postinit functions: local function SpawnBeesOnHit(inst, attacker, damage, spdamage) local x, y, z = inst.Transform:GetWorldPosition() --Cooldown of sorts. 5 Seconds between each spawn. if inst._spawnedbees == true then return end inst._spawnedbees = true inst:DoTaskInTime(5, function() inst._spawnedbees = false end) if attacker:IsValid() and attacker.components.combat and attacker.components.health then --Should spawn 3 bees; all of them drop nothing for i = 1, 3 do local bee = SpawnPrefab("bee") bee.Transform:SetPosition(x + math.random(2), y, z + math.random(2)) bee.components.combat:SuggestTarget(attacker) bee.components.lootdropper:ClearRandomLoot() --Kills the bee in 2 secs after it deaggros from its target bee:ListenForEvent("droppedtarget", function() bee:DoTaskInTime(2, function() bee.components.health:Kill() end) end) end end end Then, in your master_postinit, same file, insert: inst.components.combat:SetOnHit(SpawnBeesOnHit) I may or may haven't missed something. Hopefully this'll help in the slightest, however. Edit: For sanity on hit, type inst.components.sanity:DoDelta(PutYourNumberHere) right below local x, y, z for it to always trigger on hit regardless of bee cooldown. Also, character perks are mostly done by combining a lot of the available basegame components together into one functioning... function. Once you delve deeper into DST modding however, you can even create your own component that does your own desired thing. Keep going though, I took a while to learn also Damn that's awesome, i didnt have any expectation posting my request but im really happy with the results x) The bees are spawing on hit (3 bees), one of them die sometimes for no reason but it work ! Same for sanity thing, it's working perfectly. Thank you again really 1 Link to comment https://forums.kleientertainment.com/forums/topic/160623-character-mod-perks-questions/#findComment-1757033 Share on other sites More sharing options...
Baguettes Posted November 14, 2024 Share Posted November 14, 2024 10 hours ago, BeeChoc said: one of them die sometimes for no reason but it work ! Once your spawned bees stop targeting your attacker, they'll die out in 2 seconds right after, I did this so you don't slowly amass up too many homeless bees onscreen. Link to comment https://forums.kleientertainment.com/forums/topic/160623-character-mod-perks-questions/#findComment-1757078 Share on other sites More sharing options...
BeeChoc Posted November 14, 2024 Author Share Posted November 14, 2024 5 hours ago, Baguettes said: Once your spawned bees stop targeting your attacker, they'll die out in 2 seconds right after, I did this so you don't slowly amass up too many homeless bees onscreen. Nice ! It is indeed pretty smart, im trying to do some balanced perks here because my original ideas are pretty god like tier and it would make the character too easy to play with and i dont want to do a character that is not as dark and difficult as the game. The character in itself isnt designed for Dont Starve, he have is own story but i like to integrate him pretty much everywhere i can. But in his original story he is a god so, im trying to do something balance between the fact that he is suppose to be powerful buuut the Dont Starve Universe is weakening him reaaly bad. But overall i find it funny to do because the modding parts give a real freedom for creation. (Sorry for bad english tho) 1 Link to comment https://forums.kleientertainment.com/forums/topic/160623-character-mod-perks-questions/#findComment-1757114 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