Jump to content

I need help for custom character's perks :(


Recommended Posts

Hello!
I'm noob in this area... Any help will be awesome! :)

I'm trying to make a character with this perks:

  1. Healt autoregeneration: always active, but slow
  2. Healing aura in the night for friends: Mid range.
  3. Lose sanity if hungry: starting when the "stomach meter" is at half (if posible).
  4. Gain sanity from battle.
  5. Don't lose sanity with ghosts and monsters.
  • It could be based on Wilson.

I think I will never put this character for download, but of course I'll give credit to anyone who helps me.

I have my old testing code, It have no errors but is a mess and I can't make it work propertly. XD

Thanks! have a good day and happy new year!

 

Link to comment
Share on other sites

6 hours ago, IgnisDraconi said:

Healing aura in the night for friends: Mid range.

Put this in your character's prefab:

local function stopregen(inst)
	if inst.heal_task ~= nil then
		inst.heal_task:Cancel()
		inst.heal_task = nil
	end
end

local function startregen(inst)
	if inst.heal_task == nil then
		inst.heal_task = inst:DoPeriodicTask(1, function() 
			local x,y,z = inst.Transform:GetWorldPosition()
			local ents = TheSim:FindEntities(x,y,z, 5)
			for k,v in pairs(ents) do
				if v and v:HasTag("player") and v.components.health and not v.components.health:IsDead() and not v:HasTag("playerghost") and v ~= inst then
					if TheWorld.state.isnight or TheWorld.state.iscavenight then
						v.components.health:DoDelta(1)
					end
				end
			end
		end)
	end
end

inst:WatchWorldState("isnight", startregen)
inst:WatchWorldState("iscavenight", startregen)
inst:WatchWorldState("isday", stopregen)
inst:WatchWorldState("iscaveday", stopregen)

This will make it so you regenerate 1 health per second to all players but yourself in a small area, only during nights.

Edited by PanAzej
whoops, a mistake
Link to comment
Share on other sites

8 hours ago, makar5000 said:

For regenerarion you can check heather mod. 

Thanks! I take a look :)
 

7 hours ago, TheMightyPikachu said:

inst.components.health:StartRegen(healthnumber, seconds)

It works perfectly! Thanks very much! =D

 

2 hours ago, PanAzej said:

Put this in your character's prefab:


local function stopregen(inst)
	if inst.heal_task ~= nil then
		inst.heal_task:Cancel()
		inst.heal_task = nil
	end
end

local function startregen(inst)
	if inst.heal_task == nil then
		inst.heal_task = inst:DoPeriodicTask(1, function() 
			local x,y,z = inst.Transform:GetWorldPosition()
			local ents = TheSim:FindEntities(x,y,z, 5)
			for k,v in pairs(ents) do
				if v and v:HasTag("player") and v.components.health and not v.components.health:IsDead() and not v:HasTag("playerghost") and v ~= inst then
					if TheWorld.state.isnight or TheWorld.state.iscavenight then
						v.components.health:DoDelta(1)
					end
				end
			end
		end)
	end
end

inst:WatchWorldState("isnight", startregen)
inst:WatchWorldState("iscavenight", startregen)
inst:WatchWorldState("isday", stopregen)
inst:WatchWorldState("iscaveday", stopregen)

This will make it so you regenerate 1 health per second to all players but yourself in a small area, only during nights.

Thanks so much! I'll test it right away! =D

Edited by IgnisDraconi
Link to comment
Share on other sites

35 minutes ago, IgnisDraconi said:

And... I found this:


local function onkilledcos(inst, data)
     inst.components.sanity:DoDelta(1.5)
end

Could someone tell me if this will help me to regen sanity if I kill anything? :confused:

Thanks

local function onkilled(inst, data)
	if data.victim ~= nil and data.victim.components.health ~= nil then
    	inst.components.sanity:DoDelta(1.5)
	end
end

local function master_init(inst)
	inst:ListenForEvent("killed", onkilled)
end

 

Link to comment
Share on other sites

All the help is working amazing! Thanks everyone! :p
But every time I test the mod I need something to balance the stats XD
So... Here I go with my endless questions :? ...

Any idea on how to stop losing sanity from monsters like spiders and ghosts?

Thanks agan and mercy on this noob :(

Edited by IgnisDraconi
Link to comment
Share on other sites

1 hour ago, IgnisDraconi said:

All the help is working amazing! Thanks everyone! :p
But every time I test the mod I need something to balance the stats XD
So... Here I go with my endless questions :? ...

Any idea on how to stop losing sanity from monsters like spiders and ghosts?

Thanks agan and mercy on this noob :(

inst.components.sanity.neg_aura_mult = 0

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