Jump to content

How to make a Character deal EXTRA damage to specific enemies


Recommended Posts

Hello guys :))

Today I started researching if there was a way to tell the game that, if you are fighting let's say a "clockwork Bishop" then you can deal to him 1 damage extra damage in general. Regardless of what weapon you are using. I want to make my character 

As I said, Im very new in Moding and I've been reading a lot of the posts in the Forum.
I would love to hear if you guys by any chance know how to do something like this or know how to make something that could work like this  :)) 

Thank you lots, Marisa

  • Like 1
Link to comment
Share on other sites

In your characters prefab file put this after the 'combat' component:
 

inst.components.combat.bonusdamagefn = BonusDamageFn -- BonusDamageFn is just a function name, you can rename it to anything you want

And add a local function for the damage:
 

local function BonusDamageFn(inst, target, damage, weapon)
	return (target.prefab == "bishop" and 1) or 0 -- Checking if target is a certain prefab and then assigning bonus damage, value after 'or' is set if targets prefab isn't 'bishop', so no additional damage for them
end

 

  • Like 2
  • Big Ups 2
Link to comment
Share on other sites

On 8/11/2020 at 1:04 PM, -t- said:

In your characters prefab file put this after the 'combat' component:
 


inst.components.combat.bonusdamagefn = BonusDamageFn -- BonusDamageFn is just a function name, you can rename it to anything you want

And add a local function for the damage:
 


local function BonusDamageFn(inst, target, damage, weapon)
	return (target.prefab == "bishop" and 1) or 0 -- Checking if target is a certain prefab and then assigning bonus damage, value after 'or' is set if targets prefab isn't 'bishop', so no additional damage for them
end

 

Hi, 

I'm trying to increase damage against toadstool and frogs, but it didn't work.

I went over many iterations and the game breaks every time I try to introduce this change. 

Is there something obvious that I'm doing wrong?

I'm really lost :(

 

Thank you in advance <3

image.thumb.png.f31816a1d7937e3e4336f60baa377ed5.png

Link to comment
Share on other sites

2 hours ago, Aquarell said:

Hi, 

I'm trying to increase damage against toadstool and frogs, but it didn't work.

I went over many iterations and the game breaks every time I try to introduce this change. 

Is there something obvious that I'm doing wrong?

I'm really lost :(

 

Thank you in advance <3

image.thumb.png.f31816a1d7937e3e4336f60baa377ed5.png

You are trying to do arithmetic on a function but not calling the function.

If you read the previous instructions you were suppose to add your function to the bonusfn reference and not the damagemultiplier.

inst.components.combat.bonusdamagefn = BonusDamageFn
  • Like 3
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...