Jump to content

Need help coding in perks! {Custom character for Don't starve together}


Recommended Posts

I'm new here and I'm not very good with coding, so I'm not sure if I'm posting this in the right place. Anyway I have a mod I've been wanting to add perks into for a while, but can't seem to find any help online, I've had a few friends trying to help me the the codes just keep crashing.

Please can anyone help me with  the following list below:

  • Ability to shoot bombs, throwing grenades is close enough. I also want to make this non-craft able, as in, You start with this power and you don't need to craft anything to use it (also help make every time he throws a grenade, he gains sanity)
  • Has a chance to drop weapons/toolsbasically anything he holds will sometimes slip when it's in uses, but instead it's always and not just from wetness
  • Ignore spoilage, it's pretty simple since WX-78 has this code, but I can't seem to get it to work with me.
  • When sanity is low, the character will automatically throw a grenade at the closest object, I'm not sure if this perk is even possible, but I'd really appreciate it if any one could somehow get this to work for me? It's kinda like when willow's sanity is low, she makes fire with her feet.

I'm not sure how easily all this can be coded, but I'd really appreciate any sorta of help, even any links to ask for help is good enough for me, I'm just tired of searching the web and finding codes that don't seem to work, and not being able to contact help.

 

 

Edited by Bunnyash
Link to comment
Share on other sites

This's for ignoring spoilage, add it into YOURCHARACTER.lua inside master_postinit

Spoiler

inst.components.eater.ignoresspoilage = true

And for items falling, it can be anything that's equipped, right? Put this in YOURCHARACTER.lua inside master_postinit

Spoiler

inst:ListenForEvent("attacked", function(inst, data) -- when attacked might drop equips, if you don't want it for when you get attacked just change the event to be something else that you want.
    if math.random() > 0.5 then
    local body
    if EQUIPSLOTS.BACK then -- For Extra Equip Slots mod.
    body = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BACK)
    else
    local body_fall = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY) -- chance to drop backpack/armor
    body = body_fall and body_fall
    end
    if body and math.random() > 0.5 then
    inst.components.inventory:DropItem(body)
    inst.components.talker:Say("Oh no~!")
    end
---------------
    local head
    local head_fall = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) -- chance to drop hat
    head = head_fall and head_fall
    if head and math.random() > 0.5 then
    inst.components.inventory:DropItem(head)
    inst.components.talker:Say("Dang it~!")
    end
---------------
    local tool
    local tool_fall = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) -- chance to drop tool
    tool = tool_fall and tool_fall
    if tool and math.random() > 0.5 then
    inst.components.inventory:DropItem(tool)
    inst.components.talker:Say("Dang~!")
    end
    end
end)

 

I don't know how to do the grenade stuff though, sorry :(! Hope I helped in someway :D!

EDIT: And welcome to Klei forums :D!!

Edited by SuperDavid
Link to comment
Share on other sites

8 hours ago, SuperDavid said:

 

Hey man! Thanks so much for these codes! But I still have a few questions, I only wanted the tools; such as axes, pickaxes, spears etc, to have a chance to be dropped when he uses them, hats and armour/backpacks will not fall off.

Besides that.These codes work perfectly fine!

Thank you so much!

Link to comment
Share on other sites

15 hours ago, Bunnyash said:

I only wanted the tools; such as axes, pickaxes, spears etc, to have a chance to be dropped when he uses them, hats and armour/backpacks will not fall off.

Then put this in YOURCHRACTER.lua inside master_postinit :D!

Spoiler

inst:ListenForEvent("working", function(inst, data) -- when working might drop equips.
    local tool
	local randomchance = math.random(1,4) -- You can replace 4 with 2 for 50% chance or 4 with a higher number for a lower % chance.
    local tool_fall = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) -- chance to drop tool
    tool = tool_fall and tool_fall
       if tool and randomchance == 1 then -- 25% of dropping tool.
          inst.components.inventory:DropItem(tool)
       end
end)

inst:ListenForEvent("onattackother", function(inst, data) -- when attacking something might drop equips.
    local tool
	local randomchance = math.random(1,4) -- You can replace 4 with 2 for 50% chance or 4 with a higher number for a lower % chance.
    local tool_fall = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) -- chance to drop tool
    tool = tool_fall and tool_fall
       if tool and randomchance == 1 then -- 25% of dropping tool.
          inst.components.inventory:DropItem(tool)
       end
end)

 

 

Link to comment
Share on other sites

On 11/26/2016 at 7:01 AM, SuperDavid said:

Then put this in YOURCHRACTER.lua inside master_postinit :D!

  Reveal hidden contents


inst:ListenForEvent("working", function(inst, data) -- when working might drop equips.
    local tool
	local randomchance = math.random(1,4) -- You can replace 4 with 2 for 50% chance or 4 with a higher number for a lower % chance.
    local tool_fall = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) -- chance to drop tool
    tool = tool_fall and tool_fall
       if tool and randomchance == 1 then -- 25% of dropping tool.
          inst.components.inventory:DropItem(tool)
       end
end)

inst:ListenForEvent("onattackother", function(inst, data) -- when attacking something might drop equips.
    local tool
	local randomchance = math.random(1,4) -- You can replace 4 with 2 for 50% chance or 4 with a higher number for a lower % chance.
    local tool_fall = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) -- chance to drop tool
    tool = tool_fall and tool_fall
       if tool and randomchance == 1 then -- 25% of dropping tool.
          inst.components.inventory:DropItem(tool)
       end
end)

 

 

Ah! Thank you so much!!!

I appreciate the help! I dunno if I can thank you enough!!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...