Jump to content

A few instrument item questions


Recommended Posts

Im looking for help in making a few instruments. All of these are based off the code of an already existing item (which will be stated in the instruments in question)

  • A battle horn (based on beefalo horn) that gives any player that hears it a +50% attack bonus for 30 seconds
  • An improved battle horn (based on the beefalo horn) that gives the player +100% attack bonus AND a health regen for 30 seconds
  • A grasswhistle (based on the pan flute) that gives any player that hear it 5 sanity, and the user 5 sanity for every creature that heard it

Thanks in advance!

Link to comment
Share on other sites

On 6/15/2017 at 2:12 PM, Augustusc said:

A battle horn (based on beefalo horn) that gives any player that hears it a +50% attack bonus for 30 seconds

TUNING.BATTLEHORN_BUFF_DURATION = 30
TUNING.BATTLEHORN_BUFF_MULT     =  5

local function HearBattleHorn(inst, musician, instrument)
	if inst:HasTag("player") and not inst:HasTag("playerghost") then
		
		if inst.debuffbattlehorntask ~= nil then
			inst.debuffbattlehorntask:Cancel()
			inst.debuffbattlehorntask = nil
		else
			local mult = inst.components.combat.damagemultiplier or 1
			inst.components.combat.damagemultiplier = mult * TUNING.BATTLEHORN_BUFF_MULT
		end
		
		inst.debuffbattlehorntask = inst:DoTaskInTime(TUNING.BATTLEHORN_BUFF_DURATION, function(inst)
			inst.debuffbattlehorntask = nil
			inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier / TUNING.BATTLEHORN_BUFF_MULT
		end)
		
	end
end

 

On 6/15/2017 at 2:12 PM, Augustusc said:

A grasswhistle (based on the pan flute) that gives any player that hear it 5 sanity, and the user 5 sanity for every creature that heard it

local function HearGrassWhistle(inst, musician, instrument)
	if inst ~= musician then
		if inst:HasTag("player") and not inst:HasTag("playerghost") then
			inst.components.sanity:DoDelta(TUNING.SANITY_TINY)
		elseif inst:HasTag("creature") then
			musician.components.sanity:DoDelta(TUNING.SANITY_TINY)
		end
	end
end

Untested. The other instrument should be fairly similar.

Edited by alainmcd
inst.debuffbattlehorntask:Cancel()
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...