[REQUEST] Special traits for custom characters


KashiKakes

Recommended Posts

Hello! I'm not a coder by any means, I mean I can do the most basic things like finding a couple lines and changing them to change a character's name or dialogue, but I was hoping to make a couple custom traits for my character.

 

I was wondering if someone could provide the code to give a character the following traits

 

some sort of modifier where he loses twice as much sanity when near spiders since he's arachnaphobic, and increased sanity loss at night due to being afraid of the dark.

 

I was also wondering if it would be possible to make it so that rabbits wouldn't be scared of him, or would that require also editing the rabbit's files?

 

if anyone would be so kind I would be eternally grateful

Link to comment
Share on other sites

I was hoping to make this character work in Don't Starve together, so hopefully it would only affect this character specifically :(

Easy, look at Winnie from Up and Away to find the bunnie thing and do this for the spiders in your mod main

 

local function eekaspider(inst)
    if ThePlayer.prefab == "charactername" then
        inst:AddComponent("sanityaura")
        inst.components.sanityaura.aura = (TUNING.SANITYAURA_SMALL * amount)
    else end
end

 

AddPrefabPostInit('spider', eekaspider)

Link to comment
Share on other sites

Easy, look at Winnie from Up and Away to find the bunnie thing and do this for the spiders in your mod main

 

local function eekaspider(inst)
    if ThePlayer.prefab == "charactername" then
        inst:AddComponent("sanityaura")
        inst.components.sanityaura.aura = (TUNING.SANITYAURA_SMALL * amount)
    else end
end

 

AddPrefabPostInit('spider', eekaspider)

 

I was getting around to finally testing my character and I keep getting this error when I go near spiders now

 

warningpls.jpg

 

can you help me out? sorry for asking so many questions :(

Link to comment
Share on other sites

hey that fixed it thanks!

 

 

also you wouldn't happen to know how to make it so that I won't lose sanity when using the wormhole do you?

 

Wormhole just needs some lines of code removed.

local function wormhole(inst)local function OnActivate(inst, doer)--print("OnActivated!")if doer:HasTag("player") then       ProfileStatsSet("wormhole_used", true)doer.components.health:SetInvincible(true)doer.components.playercontroller:Enable(false) if inst.components.teleporter.targetTeleporter ~= nil thenDeleteCloseEntsWithTag(inst.components.teleporter.targetTeleporter, "WORM_DANGER", 15)end GetPlayer().HUD:Hide()TheFrontEnd:SetFadeLevel(1)doer:DoTaskInTime(4, function() TheFrontEnd:Fade(true,2)GetPlayer().HUD:Show()doer.sg:GoToState("wakeup")end)doer:DoTaskInTime(5, function()doer:PushEvent("wormholespit")doer.components.health:SetInvincible(false)doer.components.playercontroller:Enable(true)end)--doer.SoundEmitter:PlaySound("dontstarve/common/teleportworm/travel", "wormhole_travel")elseif doer.SoundEmitter theninst.SoundEmitter:PlaySound("dontstarve/common/teleportworm/swallow", "wormhole_swallow")endend inst.components.teleporter.onActivate = OnActivatereturn instend AddPrefabPostInit("wormhole", wormhole)

As far as the rabbit goes, you need to remove the RunAway lines from their brain.

 

function RabbitBrain:OnStart()    local clock = GetClock()        local root = PriorityNode(    {        WhileNode( function() return self.inst.components.health.takingfiredamage end, "OnFire", Panic(self.inst)),        RunAway(self.inst, "scarytoprey", AVOID_PLAYER_DIST, AVOID_PLAYER_STOP),        RunAway(self.inst, "scarytoprey", SEE_PLAYER_DIST, STOP_RUN_DIST, nil, true),        EventNode(self.inst, "gohome",             DoAction(self.inst, GoHomeAction, "go home", true )),        WhileNode(function() return clock and not clock:IsDay() end, "IsNight",            DoAction(self.inst, GoHomeAction, "go home", true )),        DoAction(self.inst, EatFoodAction),        Wander(self.inst, function() return self.inst.components.knownlocations:GetLocation("home") end, MAX_WANDER_DIST)    }, .25)    self.bt = BT(self.inst, root)end
Link to comment
Share on other sites

 

Wormhole just needs some lines of code removed.

local function wormhole(inst)local function OnActivate(inst, doer)--print("OnActivated!")if doer:HasTag("player") then       ProfileStatsSet("wormhole_used", true)doer.components.health:SetInvincible(true)doer.components.playercontroller:Enable(false) if inst.components.teleporter.targetTeleporter ~= nil thenDeleteCloseEntsWithTag(inst.components.teleporter.targetTeleporter, "WORM_DANGER", 15)end GetPlayer().HUD:Hide()TheFrontEnd:SetFadeLevel(1)doer:DoTaskInTime(4, function() TheFrontEnd:Fade(true,2)GetPlayer().HUD:Show()doer.sg:GoToState("wakeup")end)doer:DoTaskInTime(5, function()doer:PushEvent("wormholespit")doer.components.health:SetInvincible(false)doer.components.playercontroller:Enable(true)end)--doer.SoundEmitter:PlaySound("dontstarve/common/teleportworm/travel", "wormhole_travel")elseif doer.SoundEmitter theninst.SoundEmitter:PlaySound("dontstarve/common/teleportworm/swallow", "wormhole_swallow")endend inst.components.teleporter.onActivate = OnActivatereturn instend AddPrefabPostInit("wormhole", wormhole)

As far as the rabbit goes, you need to remove the RunAway lines from their brain.

function RabbitBrain:OnStart()    local clock = GetClock()        local root = PriorityNode(    {        WhileNode( function() return self.inst.components.health.takingfiredamage end, "OnFire", Panic(self.inst)),        RunAway(self.inst, "scarytoprey", AVOID_PLAYER_DIST, AVOID_PLAYER_STOP),        RunAway(self.inst, "scarytoprey", SEE_PLAYER_DIST, STOP_RUN_DIST, nil, true),        EventNode(self.inst, "gohome",             DoAction(self.inst, GoHomeAction, "go home", true )),        WhileNode(function() return clock and not clock:IsDay() end, "IsNight",            DoAction(self.inst, GoHomeAction, "go home", true )),        DoAction(self.inst, EatFoodAction),        Wander(self.inst, function() return self.inst.components.knownlocations:GetLocation("home") end, MAX_WANDER_DIST)    }, .25)    self.bt = BT(self.inst, root)end

gah! I got really busy and forgot I had made this thread till just now! thank you so much for all this code help man!

Link to comment
Share on other sites

ok now I'm running into a weird new error

 

after putting in that wormhole code EVERYONE stopped losing sanity when using the wormholes, also it stopped the fade to black before you jump out, the animation for jumping out, and the phrase the character says when hopping out.

 

also I did make sure to change 

if doer:HasTag("player") then

 

to my character's name

 

any idea what's wrong? :(

Link to comment
Share on other sites

ok now I'm running into a weird new error

 

after putting in that wormhole code EVERYONE stopped losing sanity when using the wormholes, also it stopped the fade to black before you jump out, the animation for jumping out, and the phrase the character says when hopping out.

 

also I did make sure to change 

if doer:HasTag("player") then

 

to my character's name

 

any idea what's wrong? :(

 

Yeah you changed the section of code that actually make it function correctly for other players. Change it back to doer:HasTag("player").

Link to comment
Share on other sites

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.