Jump to content

Recommended Posts

Can anyone work out a way to make it so when my custom character kills in innocent or non aggressive mob it looses sanity?

I presume you can do this using the battleborn but I have no idea how to add this

 

Any help would be much appropriated  :joyous:

Thanks!

I've tried adding that in but it just crashes as soon as I load/create a save

 

Here's what I've got, I'm not sure if im missing anything out

local MakePlayerCharacter = require "prefabs/player_common"local assets = {        Asset( "ANIM", "anim/player_basic.zip" ),        Asset( "ANIM", "anim/player_idles_shiver.zip" ),        Asset( "ANIM", "anim/player_actions.zip" ),        Asset( "ANIM", "anim/player_actions_axe.zip" ),        Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),        Asset( "ANIM", "anim/player_actions_shovel.zip" ),        Asset( "ANIM", "anim/player_actions_blowdart.zip" ),        Asset( "ANIM", "anim/player_actions_eat.zip" ),        Asset( "ANIM", "anim/player_actions_item.zip" ),        Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),        Asset( "ANIM", "anim/player_actions_bugnet.zip" ),        Asset( "ANIM", "anim/player_actions_fishing.zip" ),        Asset( "ANIM", "anim/player_actions_boomerang.zip" ),        Asset( "ANIM", "anim/player_bush_hat.zip" ),        Asset( "ANIM", "anim/player_attacks.zip" ),        Asset( "ANIM", "anim/player_idles.zip" ),        Asset( "ANIM", "anim/player_rebirth.zip" ),        Asset( "ANIM", "anim/player_jump.zip" ),        Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),        Asset( "ANIM", "anim/player_teleport.zip" ),        Asset( "ANIM", "anim/wilson_fx.zip" ),        Asset( "ANIM", "anim/player_one_man_band.zip" ),        Asset( "ANIM", "anim/shadow_hands.zip" ),        Asset( "SOUND", "sound/sfx.fsb" ),        Asset( "SOUND", "sound/wilson.fsb" ),        Asset( "ANIM", "anim/beard.zip" ),		-- Don't forget to include your character's custom assets!        Asset( "ANIM", "anim/emma.zip" ),}local prefabs = {}local start_inv ={    "mable",    "backpack",    "icecream",}local smallScale = 0.5local medScale = 0.7local largeScale = 1.1local function onkill(inst, data)	if data.cause == inst.prefab 		and not data.inst:HasTag("prey") 		and not data.inst:HasTag("veggie") 		and not data.inst:HasTag("structure") then		local delta = (data.inst.components.combat.defaultdamage) * 0.25        inst.components.health:DoDelta(delta, false, "battleborn")        inst.components.sanity:DoDelta(delta)        if math.random() < .1 and not data.inst.components.health.nofadeout then        	local time = data.inst.components.health.destroytime or 2        	inst:DoTaskInTime(time, function()        		local s = medScale        		if data.inst:HasTag("smallcreature") then        			s = smallScale    			elseif data.inst:HasTag("largecreature") then    				s = largeScale    			end        		local fx = SpawnPrefab("wathgrithr_spirit")        		fx.Transform:SetPosition(data.inst:GetPosition():Get())        		fx.Transform:SetScale(s,s,s)    		end)        end	endendlocal fn = function(inst)		-- choose which sounds this character will play	inst.soundsname = "willow"	-- a minimap icon must be specified	inst.MiniMapEntity:SetIcon( "wilson.png" )	-- todo: Add an example special power here.	inst.components.sanity:SetMax(75)	inst.components.health:SetMaxHealth(150)	inst.components.hunger:SetMax(75)    	inst.components.hungerrate = 0.7	inst.components.health:SetAbsorptionAmount(TUNING.WATHGRITHR_ABSORPTION) 	inst:ListenForEvent("entity_death", function(wrld, data) onkill(inst, data) end, GetWorld())endreturn MakePlayerCharacter("emma", prefabs, assets, fn, start_inv)

Got it!

Just realised found a sneaky little bit of broken code

inst.components.hungerrate = 0.7

Sorry about that!

 

Thanks for the help


Got it!

Just realised found a sneaky little bit of broken code

inst.components.hungerrate = 0.7

Sorry about that!

 

Thanks for the help


Got it!

Just realised found a sneaky little bit of broken code

inst.components.hungerrate = 0.7

Sorry about that!

 

Thanks for the help

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
×
  • Create New...