Jump to content

Recommended Posts

local function IsInstCombatTargeted(inst)
	local x, y, z = inst.Transform:GetWorldPosition()
	local ents = TheSim:FindEntities(x, y, z, 30, {"_combat"})
	for i, v in ipairs(ents) do
		if v.components.combat.target == inst then
			return true
		end
	end
	return false
end

 

@DarkXero Thanks, but how I make the instance that is being checked be the player?

I am editing the dynamicmusic.lua file, and my objective is to make the StopDanger function check if the player is beeing chased before proceding.

I am a fish out of water on LUA coding, so I am sorry if I am doing everything wrong.

Edited by Mudley

@DarkXero Thank you a lot for writing this code for me, but I'm afraid I have another question: How do I trigger the battle music also using this piece of code? The answer is probably in front of my face, but still.

Thanks once again for helping me.

8 minutes ago, Neutral_Steve said:

Oh, I installed it, but nothing changed.

I downloaded it, installed it, and when I run nearby a spider, it will target me and the music will start playing.

Also tried with Deerclops, he saw me, music started playing.

And it works for hosts and clients.

Edited by DarkXero
5 minutes ago, DarkXero said:

I downloaded it, installed it, and when I run nearby a spider, it will target me and the music will start playing.

Also tried with Deerclops, he saw me, music started playing.

Maybe I installed It wrong, but it wasn't working with me, I will try it later. Thanks!

4 minutes ago, Neutral_Steve said:

Maybe I installed It wrong, but it wasn't working with me, I will try it later. Thanks!

I'm going to bet you extracted the folder and put it as is, resulting in you having mod/folder/folder/modmain.

33 minutes ago, DarkXero said:

I'm going to bet you extracted the folder and put it as is, resulting in you having mod/folder/folder/modmain.

My bad my bad, I was using the dusk and night music mod!

Edited by Neutral_Steve

@DarkXero Once again, sorry for wasting your time, but I have one (hopefully) final question.

I created another function from the one you gave me, called IsPlayerCombatTargetedBoss() that checks if any instance with the "epic" tag has you as a target, and it appears to work.

However, I want to use it to replace the GetClosestInstWithTag() used on the StartDanger() function, so the E.F.S. plays only if you're actually fighting a boss, instead of playing while fighting something else with a boss around. But I am failing to make it work with the _soundemitter.

Also, already asking this too, because I'm certain that I will be too incompetent to work this around: How do I make so the normal battle music will change to the E.F.S. if a boss is going for you, and vice versa?

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