Jump to content

Recommended Posts

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)
  • Like 1

 

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?

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.

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)
  • Like 1

 

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.

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)
  • Like 1
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?

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?

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

 

Edited by Gryfuz

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

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?

Edited by Gryfuz

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