Jump to content

Help with Intimidation


Recommended Posts

I can guess it's improper etiquette to post multiple topics so close to each other, but the one about player tags isn't important. It's just a thought I had that I figured someone may find interesting. This one is a request for help.

I'm trying to make a character that has the whip ability naturally, like a chance to spook the enemy when she attacks either with or without a weapon without it having a different chance on monsters or bosses. I couldn't figure out how to do it from the whip's code, so I looked at the code of other mods and came up with this.

inst.components.combat.onhitotherfn = function (attacker, inst, damage, stimuli)
		if not inst:HasTag("player") then
			local scare_chance = math.random(0, 3) --0, 3 is true chance. 0,1 is to test.
			if scare_chance == 0 then
				inst.components.hauntable:Panic(30)
				attacker.SoundEmitter:PlaySound("dontstarve/common/whip_large")
			end
		end
	end

It works on prey, hounds, pigs, merms, but then I tried it on a boss and it crashes. Any advice?

 

20181230172129_1.jpg

Link to comment
Share on other sites

First up, disable all other mods when doing initial functionality testing for a new mod. You can test for compatibility once the base functionality is working; but you don't want another mod bugging something out and making you think that there's something wrong you the mod you're making

...if I'm not mistaken, you're using the Haunting mechanic to emulate fear? So the first thing I'd test is what actually haunting the same boss monster does (or if it's even haunt-able), and get a log of what happens when you do haunt it, if it's successful; then compare that to what the mod attempted to do before crashing.

Testing what happens with an actual whip could be worthwhile too.

Edited by lifetheuniverse
Link to comment
Share on other sites

probably bosses don't have the hauntable component so it crashes.

Try using code like this

inst.components.combat.onhitotherfn = function (attacker, inst, damage, stimuli)
		if not inst:HasTag("player") then
			local scare_chance = math.random(0, 3) --0, 3 is true chance. 0,1 is to test.
			if scare_chance == 0 then
				if not inst.components.hauntable then
				inst:AddComponent("hauntable") --dont know if this and MakeHauntablePanic(inst) are both required, maybe only MakeHauntablePanic(inst) is required try it out
				MakeHauntablePanic(inst)
				inst.components.hauntable:Panic(30)
				else
				inst.components.hauntable:Panic(30)
				end
				attacker.SoundEmitter:PlaySound("dontstarve/common/whip_large")
			end
		end
	end

 

Link to comment
Share on other sites

18 hours ago, SuperDavid said:

probably bosses don't have the hauntable component so it crashes.

Try using code like this


inst.components.combat.onhitotherfn = function (attacker, inst, damage, stimuli)
		if not inst:HasTag("player") then
			local scare_chance = math.random(0, 3) --0, 3 is true chance. 0,1 is to test.
			if scare_chance == 0 then
				if not inst.components.hauntable then
				inst:AddComponent("hauntable") --dont know if this and MakeHauntablePanic(inst) are both required, maybe only MakeHauntablePanic(inst) is required try it out
				MakeHauntablePanic(inst)
				inst.components.hauntable:Panic(30)
				else
				inst.components.hauntable:Panic(30)
				end
				attacker.SoundEmitter:PlaySound("dontstarve/common/whip_large")
			end
		end
	end

 

Add hauntable when it goes through. Clever. It doesn't seem to send the Toadstool into a panic, but at least it doesn't crash.

Link to comment
Share on other sites

34 minutes ago, icantevenname said:

Add hauntable when it goes through. Clever. It doesn't seem to send the Toadstool into a panic, but at least it doesn't crash.

Welp, I guess the panic stuff is a part of the mobs brain and bosses can't be haunted I assume so they wouldn't have it I guess.. sorry i couldn't be of more help :( and good luck :D!

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