Jump to content

Custom Perks for Custom Character; Help Needed (please)


Recommended Posts

im trying to give my character some special perks, but dont know how to do coding, can someone help me with these please (im using the extended sample character mod btw):

  • gets sanity from inflicting pain (strikethrough = done)
  • no sanity loss from darkness
  • unaffected by the dark sword and night armor's equipped effects
  • passive sanity loss
  • takes thrice as long to build structures/craft items
  • no sanity regains from picking up flowers
  • unaffected by the garland's equipped affects
  • starts with tophat

if anyone knows how to do these codes, please spare your knowledge with me

it would be greatly appreciated

Edited by TotalTrashDream
Link to comment
Share on other sites

I can help with some of these :)

put these code in YOURCHAR.lua inisde the master_postinit

-- No sanity drain from darkness
inst.components.sanity.night_drain_mult = 0

-- Gain 1 point of Sanity everytime you attack something, if you don't want the sanity gain sound everytime then use the DoDelta which has "true" then you will gain sanity but without the noise
inst:ListenForEvent("onattackother", function(inst, data)
	--inst.components.sanity:DoDelta(1, true)
	inst.components.sanity:DoDelta(1) -- You can change the value from 1 to anything you want, just remember you would gain this sanity from any attack on anything with anything, so a small value would op
end)

-- Every 20 seconds lose some sanity, 60 seconds = -5 sanity
inst:DoPeriodicTask(20, function(inst)
	inst.components.sanity:DoDelta(-1.66666666667, true)
end)

 

insid YOURCHAR.lua there will be a code like this

local start_inv =
{
}

replace it with this to start with a tophat

local start_inv =
{
"tophat",
}
Link to comment
Share on other sites

Just now, SuperDavid said:

I can help with some of these :)

put these code in YOURCHAR.lua inisde the master_postinit


-- No sanity drain from darkness
inst.components.sanity.night_drain_mult = 0

-- Gain 1 point of Sanity everytime you attack something, if you don't want the sanity gain sound everytime then use the DoDelta which has "true" then you will gain sanity but without the noise
inst:ListenForEvent("onattackother", function(inst, data)
	--inst.components.sanity:DoDelta(1, true)
	inst.components.sanity:DoDelta(1) -- You can change the value from 1 to anything you want, just remember you would gain this sanity from any attack on anything with anything, so a small value would op
end)

-- Every 20 seconds lose some sanity, 60 seconds = -5 sanity
inst:DoPeriodicTask(20, function(inst)
	inst.components.sanity:DoDelta(-1.66666666667, true)
end)

 

insid YOURCHAR.lua there will be a code like this


local start_inv =
{
}

replace it with this to start with a tophat


local start_inv =
{
"tophat",
}

sorry to disappoint but i already found out how to do some of these

except the sanity gain one which i have been having trouble finding out how to do, so i greatly appreciate the help! thank you!

does murdering things in your inventory work with this code, or is it attack only? cause if it's attack only could you also provide me the code for sanity gain from murder too? thanks!

also is there a code that gives more sanity for attacking players than attacking regular entities?

Edited by TotalTrashDream
Link to comment
Share on other sites

1 hour ago, TotalTrashDream said:

does murdering things in your inventory work with this code, or is it attack only? cause if it's attack only could you also provide me the code for sanity gain from murder too? thanks!

the event is only for when you attack something, so it won't work for murdering stuff & I don't know the event for that so I don't know how to help with that sorry!

 

1 hour ago, TotalTrashDream said:

also is there a code that gives more sanity for attacking players than attacking regular entities?

yes the code I gave edit it this way


inst:ListenForEvent("onattackother", function(inst, data)
	 if data.target:HasTag("player") then
		inst.components.sanity:DoDelta(10)
	else
		inst.components.sanity:DoDelta(1)
	end
end)

 

Link to comment
Share on other sites

Just now, SuperDavid said:
Just now, TotalTrashDream said:

does murdering things in your inventory work with this code, or is it attack only? cause if it's attack only could you also provide me the code for sanity gain from murder too? thanks!

the event is only for when you attack something, so it won't work for murdering stuff & I don't know the event for that so I don't know how to help with that sorry!

ah well its ok

Just now, SuperDavid said:
Just now, TotalTrashDream said:

also is there a code that gives more sanity for attacking players than attacking regular entities?

yes the code I gave edit it this way



inst:ListenForEvent("onattackother", function(inst, data)
	 if data.target:HasTag("player") then
		inst.components.sanity:DoDelta(10)
	else
		inst.components.sanity:DoDelta(1)
	end
end)

and thank you again! this is greatly appreciated

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...