Jump to content

Need Perk help and sound help!


Recommended Posts

Hello! I am making a modded character for DST and I'm having some issues with the perks and the character's voice.

1. I am trying to make a perk that makes the character not aggro monsters except for giants. I don't know/have any idea how to start that code or what that code is.

2. I edited my character's sound clips in Audacity and exported the audio files as .wav files. In FMOD I added the sounds to their corresponding categories (speech files for talk_LP, etc), and yet the sounds will not sound. They also do not sound in game. Why are the sounds silent? When I play them in media player they are fine.

Link to comment
Share on other sites

10 hours ago, Boot said:

Anyone able to help me?

Give it time, these forum's are full of people willing to help.

1. Put this in your modmain

if GLOBAL.TheNet:GetIsServer() then
	AddComponentPostInit("combat",function(self)
		local old = self.SuggestTarget
		self.SuggestTarget = function(self,target)
			if target and self.inst:HasTag("monster") and self.inst:HasTag("epic") == false and target:HasTag("monsterstealth") then
				return false
			end
			if old then
				return old(self,target)
			end
		end
	end)
end

and give your character 

inst:AddTag("monsterstealth")

at the end of their prefab.lua

And that should prevent "monsters" from aggroing you unless you attack them or they are a giant, this also technically prevents monsters from teaming up on you.  However you said only monsters so this doesn't include bunnymen if your holding meat, as they technically aren't monsters.

2. There's a tutorial on the forum's for custom sounds for characters, I can't quite remember which one I used otherwise I would link it.  If I find it I'll post it, though I think it's in one of the recommended tutorials section.

Edited by Zackreaver
Put in a check to see if target is nil.
Link to comment
Share on other sites

I put in that large code into modmain and the inst:AddTag("monsterstealth") in the character.lua, but when i try to host the world I crash. What's that edit where you said "put in a check to see if target is nil"?

As for the sound, I used to follow the old sound guide but the download link for the fmod sound template and the guide has been altered since then. I tried following the esctemplate vid and everything should've worked out... I don't know why the sounds are silent.

Link to comment
Share on other sites

I added the inst:AddTag("monsterstealth") under the section in the character.lua that said I could "add tags here," rather than at the end of the document. Now that works! :D 

So I think the only issue left is the sound that is silent.... 


((Merms still attack me o___o ))

Edited by Boot
merms still attack me
Link to comment
Share on other sites

A friend helping me with the coding and sound. Apparently what you wrote here checks for the monster tag, but some mobs aren't monsters. Although I still need the monsterhealth tag, the code they gave is:

AddComponentPostInit("combat", function(Combat, inst)
    local SuggestTarget_prev = Combat.SuggestTarget
    function Combat:SuggestTarget(target)
        if target and target:HasTag("monsterstealth") and not inst:HasTag("epic") then
            return false
        else
            -- Target normally
            return SuggestTarget_prev(self, target)
        end
    end
end)
 

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