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.

Gryfuz

How to increase damage against hounds?

Recommended Posts

Gryfuz    0

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.

Share this post


Link to post
Share on other sites
Finerlobster    13

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)

Share this post


Link to post
Share on other sites
Gryfuz    0

 

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?

Share this post


Link to post
Share on other sites
Gryfuz    0

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.

Share this post


Link to post
Share on other sites
Finerlobster    13

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)

Share this post


Link to post
Share on other sites
Gryfuz    0

 

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.

Share this post


Link to post
Share on other sites
Finerlobster    13

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)

Share this post


Link to post
Share on other sites
Gryfuz    0
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?

Share this post


Link to post
Share on other sites
Finerlobster    13

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?

Share this post


Link to post
Share on other sites
Gryfuz    0

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

 

Share this post


Link to post
Share on other sites
Mobbstar    14122

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

Share this post


Link to post
Share on other sites
Gryfuz    0

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?

Share this post


Link to post
Share on other sites