Jump to content

Damage multiplier not applying to damage dealt

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

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)
	reader.components.combat.damagemultiplier = 3

Thank you so much!

Link to comment
Share on other sites

Perfect! Good job :)

I would probably save the results of IsDLCEnabled(CAPY_DLC) and IsDLCEnabled(PORKLAND_DLC) in some local variables, to avoid calling them all the time.

Just remember to remove the damage modifier again.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

  • Create New...