Jump to content

Recommended Posts

What coding could allow me to change the damage AN ITEM does on a certain monster. Coraline, my revamp mod, originally done by Psycosis, will have pruners that do 2.5x damage to plant-based mobs since they do 17 damage originally and there are very few plant monsters.

 

I do NOT want this to effect the character as it could be used to multiply other weapons for one-shotting.

 

Help will be very much appreciated. Thanks in advanced.

The first thing I would try is using prefab post-inits to add a unique tag to all plant monsters.

(I'm a tad rusty, but I think it'd be inst.AddTag: "PLANTBEAST" but it's not hard to check.)

 

 

From there, I think you could check if the target has the "PLANTBEAST" tag, on attack, and if it does, apply a damage multiplier of 2.5.

Like this?

 

@%1;

local function fn()	if inst.AddTag("eyeplant") then		inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*1.25)	end		if inst.AddTag("lureplantbulb") then		inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*1.25)	endend
Edited by Dryicefox

No, no...

I'm not sure if this is right, but I think you add something like this to your weapon prefab:

local function onattack(inst, attacker, target)if target:HasTag("PLANTBEAST") theninst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*2.5)elseinst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*1)endend  local function fn(Sim).........    inst.components.Weapon:SetOnAttack( onattack )... end

 

And in your modmain, you would need:

function PlantbeastPostInit( inst )inst:AddTag("PLANTBEAST")end AddPrefabPostInit("lureplant", PlantbeastPostInit)
local function onattack(inst, attacker, target)if target:HasTag("lureplantbulb") theninst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*1.25)elseinst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE/2)endend    local function fn(Sim).........    inst.components.Weapon:SetOnAttack( onattack )...  end

I think I shall use this, the lure plant bulb already has a tag I can make reference to.

I'll test it later. In the mean time, do you think this will work?

I would still add the tag through post-init. You're going to want it to affect more than one enemy, and if another plant monster is added, maintenance then becomes as simple as applying the post-init to another prefab.

 

I think it will work... but I don't have it in me to fully research and test it thoroughly. It's untested, and theoretical. About all I can muster before I need to rest.

@Dryicefox, you could do this:

local PRUNER_VS_PLANT_MULTIPLIER = 2.5local function tag_as_plant(inst)	inst:AddTag("PLANTBEAST")endAddPrefabPostInit("eyeplant", tag_as_plant)AddPrefabPostInit("lureplantbulb", tag_as_plant)AddSimPostInit(function(player)	local combat = player.components.combat	local oldCalcDamage = combat.CalcDamage	combat.CalcDamage = function(self, target, weapon, multiplier)		multiplier = multiplier or self.damagemultiplier or 1		if weapon.prefab == "pruner" and target and target:HasTag("PLANTBEAST") then			multiplier = multiplier*PRUNER_VS_PLANT_MULTIPLIER		end		return oldCalcDamage(self, target, weapon, multiplier)	endend)
Replace "pruner" with the accurate prefab name for it. The above code is untested, but should work. Edited by simplex

@Dryicefox, you could do this:

local PRUNER_VS_PLANT_MULTIPLIER = 2.5local function tag_as_plant(inst)	inst:AddTag("PLANTBEAST")endAddPrefabPostInit("eyeplant", tag_as_plant)AddPrefabPostInit("lureplantbulb", tag_as_plant)AddSimPostInit(function(player)	local combat = player.components.combat	local oldCalcDamage = combat.CalcDamage	combat.CalcDamage = function(self, target, weapon, multiplier)		multiplier = multiplier or self.damagemultiplier or 1		if weapon.prefab == "pruner" and target and target:HasTag("PLANTBEAST") then			multiplier = multiplier*PRUNER_VS_PLANT_MULTIPLIER		end		return oldCalcDamage(self, target, weapon, multiplier)	endend)
Replace "pruner" with the accurate prefab name for it. The above code is untested, but should work.

 

Add this to my modmain.lua, correct?

 

Sorry for such a late reply. RL stuff.

It is pretty old topic, but...

local function onattack(inst, attacker, target)if target:HasTag("lureplantbulb") then --let's say lureplantinst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*1.25) --let's say 50 dmgelseinst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE/2) --let's say 25 dmgendend

this one does set damage AFTER attack was done. Is it possible to SetDamage before attack?

see comments in code first. if my dmg was 25 and i hit lureplant, i dealt 25 damage to it. but after that, my dmg set to 50. and every new hits i deal 50 dmg to lureplant. is it possible to set before attack? 

It is pretty old topic, but...

local function onattack(inst, attacker, target)if target:HasTag("lureplantbulb") then --let's say lureplantinst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*1.25) --let's say 50 dmgelseinst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE/2) --let's say 25 dmgendend

this one does set damage AFTER attack was done. Is it possible to SetDamage before attack?

see comments in code first. if my dmg was 25 and i hit lureplant, i dealt 25 damage to it. but after that, my dmg set to 50. and every new hits i deal 50 dmg to lureplant. is it possible to set before attack? 

 

It would be easier to deal the minimum damage per default and hurt the lureplant afterwards again. #outofthebox

@Amalleus Have you tried Simplex's solution above? It seems to be modifying the damage calculation (which I presume comes before the attack) instead of using the onattack function.

No. i made much easier after a short advice =)

f.e. base damage of weapon is 20. i want to make x3 against mosters (=60)

in function OnAttack: you need to CalcDamage and then GetAttacked (hope it is right name). so i hit mob with 20 and then GetAttacked function increases damage for 40 more if it was monster =)

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