Jump to content

Recommended Posts

I'm making a custom character that, when he reads a certain book, gains a x3 damage multiplier. All the other changes to his character that occur when the book is read apply, except the damage modifier. 
Example:
What should happen:
Before reading the book, a spider takes 10 punches to kill. After reading, it takes 4.
What does happen:
Before reading the book, a spider takes 10 punches to kill. After reading, it still takes 10.

This is what the code looks like.
 

reader:DoTaskInTime(3, function()	
			reader.sanitytask = reader:DoPeriodicTask(1, function() reader.components.sanity:SetPercent(0) end)
			reader.soundsname = "wendy"
			reader.components.talker.colour = Vector3(0, 0, 0)
			reader.components.talker:Say("GRIMA'S POWER STRENGTHENS ME!")
			reader.components.combat.damagemultiplier = 3
			reader:ListenForEvent("onattackother", OnHenryAttack)
			reader:AddTag("evil")	
		end)

Sanity task properly functions, his voice successfully changes to wendy's, his dialogue color successfully changes, he says the quote, the onattackother event happens, and he gets the evil tag, but the damage multiplier doesn't effect him at all.

 

If anyone can take a look and figure out what's wrong, I'll be forever grateful. Knowing me it's probably something stupidly small but I just can't seem to figure it out.

You have been hit by the difference between original DS and the newer code in the DLCs. In the original DS and RoG, the "damagemultiplier" variable is present, but in SW and Hamlet they instead use inst.components.combat:AddDamageModifier()

In order for your mod to be compatible with both DS / RoG and SW / Hamlet, you have to make two versions of the code, and use the appropriate one depending on which version of the game is running, OR just indicate in the modinfo.lua which versions the mod is compatible with.

Edited by Ultroman

Added this to the code and it works like a charm

 

if IsDLCEnabled(CAPY_DLC) or IsDLCEnabled(PORKLAND_DLC) then
	reader.components.combat:AddDamageModifier("evil", 3)
else
	reader.components.combat.damagemultiplier = 3
end

Thank you so much!

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