Jump to content

How to increase damage against hounds?


Recommended Posts

Hey all, I'm pretty new in this, i'm just trying to do my first character.

 

I would like him to have like 1.5 or 1.7 damage multiplier against hounds, how do I do that?

 

 

 

 

Thanks in advance.

Link to comment
Share on other sites

I'm not a code genius, but it will work.

	inst:ListenForEvent("onhitother", function(inst, data)		local old_damage = inst.components.combat.defaultdamage		local weapon = inst.components.combat:GetWeapon()		if data.target:HasTag("hound") then			inst.components.combat.defaultdamage = old_damage * 1.5 --or 1.7			if weapon then				local weapon_old_damage = weapon.components.weapon.damage				weapon.components.weapon.damage = weapon_old_damage * 1.5 --or 1.7			end		else			if weapon then				weapon.components.weapon.damage = weapon_old_damage			end			inst.components.combat.defaultdamage = old_damage		end	end)
Link to comment
Share on other sites

 

I'm not a code genius, but it will work.

	inst:ListenForEvent("onhitother", function(inst, data)		local old_damage = inst.components.combat.defaultdamage		local weapon = inst.components.combat:GetWeapon()		if data.target:HasTag("hound") then			inst.components.combat.defaultdamage = old_damage * 1.5 --or 1.7			if weapon then				local weapon_old_damage = weapon.components.weapon.damage				weapon.components.weapon.damage = weapon_old_damage * 1.5 --or 1.7			end		else			if weapon then				weapon.components.weapon.damage = weapon_old_damage			end			inst.components.combat.defaultdamage = old_damage		end	end)

 

I put it in prefab file isnt it?

Link to comment
Share on other sites

Put it in your character file:

 

local fn = function(inst)

       --CODE

end

 

 

Do you also know how can i increse the sanity lost while nearby hounds? i've been searching this on forum but i'm also not getting it very well. I didn't put it working yet.

Link to comment
Share on other sites

Do you also know how can i increse the sanity lost while nearby hounds? i've been searching this on forum but i'm also not getting it very well. I didn't put it working yet.

 

Put this in your modmain.lua

local function NearbyHounds(inst)	if GLOBAL.GetPlayer().prefab == "YOUR CHARACTER NAME" then		inst.components.sanityaura.aura = -TUNING.SANITYAURA_MED * 1 -- HOW MUCH YOU WANT INCREASE (MULTIPLICATION)	endendAddPrefabPostInit("hound", NearbyHounds)AddPrefabPostInit("icehound", NearbyHounds)AddPrefabPostInit("firehound", NearbyHounds)
Link to comment
Share on other sites

 

Put this in your modmain.lua

local function NearbyHounds(inst)	if GLOBAL.GetPlayer().prefab == "YOUR CHARACTER NAME" then		inst.components.sanityaura.aura = -TUNING.SANITYAURA_MED * 1 -- HOW MUCH YOU WANT INCREASE (MULTIPLICATION)	endendAddPrefabPostInit("hound", NearbyHounds)AddPrefabPostInit("icehound", NearbyHounds)AddPrefabPostInit("firehound", NearbyHounds)

 

 

Sorry but I just noticed now :/ 

 

The aura is working but the damage against hounds is not working :/ i don't know why.

Link to comment
Share on other sites

Sorry but I just noticed now :/ 

 

The aura is working but the damage against hounds is not working :/ i don't know why.

 

Sorry, I discovered today that this code is not working very well (It keeps increasing the damage like crazy).

Delete the damage against hounds code and put this new code in your modmain.lua

This new code is shorter and will work. 

local function HoundOnAttacked(inst)	local bonus_damage = 20 -- the bonus damage, I put it 20	inst:ListenForEvent("attacked", function(inst, data)		if data.attacker.prefab == "YOUR CHARACTER NAME" then			inst.components.health:DoDelta(-bonus_damage)		end	end)endAddPrefabPostInit("hound", HoundOnAttacked)AddPrefabPostInit("icehound", HoundOnAttacked)AddPrefabPostInit("firehound", HoundOnAttacked)
Link to comment
Share on other sites

local function HoundOnAttacked(inst)	local bonus_damage = 20 -- the bonus damage, I put it 20	inst:ListenForEvent("attacked", function(inst, data)		if data.attacker.prefab == "YOUR CHARACTER NAME" then			inst.components.health:DoDelta(-bonus_damage)		end	end)endAddPrefabPostInit("hound", HoundOnAttacked)AddPrefabPostInit("icehound", HoundOnAttacked)AddPrefabPostInit("firehound", HoundOnAttacked)

 

 

 

Game crashes, it says that on this lines:

 

AddPrefabPostInit("hound", HoundOnAttacked)

AddPrefabPostInit("icehound", HoundOnAttacked)

AddPrefabPostInit("firehound", HoundOnAttacked)

 

 

 

the "AddPrefabPostInit" is not declared :/ i get confused when this kind of errors happens, do you know what can be wrong?

Link to comment
Share on other sites

Game crashes, it says that on this lines:

 

AddPrefabPostInit("hound", HoundOnAttacked)

AddPrefabPostInit("icehound", HoundOnAttacked)

AddPrefabPostInit("firehound", HoundOnAttacked)

 

 

 

the "AddPrefabPostInit" is not declared :/ i get confused when this kind of errors happens, do you know what can be wrong?

 

It's working in my game, are you sure that the code is in your modmain.lua?

Link to comment
Share on other sites

It's working in my game, are you sure that the code is in your modmain.lua?

 

 

OPS!

 

I knew it was to be in modmain but somehow i opened the character prefab instead xD, sorry for this and thanks for the help, that part of the character is working at 100% :-)

 

 

 

EDIT: BTW   that code you gave me to increase the negative sanity nearby hounds... I think it is working, and I can open a server and enter with the character, but when I do this:

 

 I enter the server, go to an area nearby hounds, save the world. Then I try to open the game again.

 

It crashes,but just if i try to save the server while i'm there, if i go to an area with hounds and then I leave and go far enough (is not too much) it's all ok.

 

 

 

It says  "atempt  to index a nil value"

 

And it says the error is in this line:

 

    if GLOBAL.GetPlayer().prefab == "YOUR CHARACTER NAME" then

 

Link to comment
Share on other sites

OPS!

 

I knew it was to be in modmain but somehow i opened the character prefab instead xD, sorry for this and thanks for the help, that part of the character is working at 100% :-)

 

 

 

EDIT: BTW   that code you gave me to increase the negative sanity nearby hounds... I think it is working, and I can open a server and enter with the character, but when I do this:

 

 I enter the server, go to an area nearby hounds, save the world. Then I try to open the game again.

 

It crashes,but just if i try to save the server while i'm there, if i go to an area with hounds and then I leave and go far enough (is not too much) it's all ok.

 

 

 

It says  "atempt  to index a nil value"

 

And it says the error is in this line:

 

    if GLOBAL.GetPlayer().prefab == "YOUR CHARACTER NAME" then

 

This is for DS though, if you are coding for DST you should have at least mentioned it, or gone here.

 

It's not "GetPlayer()" but "ThePlayer" in DST

Link to comment
Share on other sites

This is for DS though, if you are coding for DST you should have at least mentioned it, or gone here.

 

It's not "GetPlayer()" but "ThePlayer" in DST

 

 

Yes, My bad i forgot to refer about DST,

 

Thanks for telling me that, but i did the change and the error stays.

 

now the line looks like this:

    if GLOBAL.ThePlayer.prefab == "cory" then

But it shows the same error. 

I tried both:    ThePlayer   and ThePlayer()

 

 

@Finerlobster , @Mobbstar  does any of you know what can it be?

Link to comment
Share on other sites

Archived

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