Forum

> > CS2D > Scripts > Hit hook issue
Forums overviewCS2D overview Scripts overviewLog in to reply

English Hit hook issue

8 replies
To the start Previous 1 Next To the start

old Hit hook issue

DarkLight66
User Off Offline

Quote
Hi, i have a problem with the hit hook, the problem is that if i want to decrease the damage dealt by a percentage, it works good until the player that is being hit have lesser hp than the damage of the weapon, reducing the damage dealt to his hp. Is there a way to avoid that?

old Re: Hit hook issue

Apache uwu
User Off Offline

Quote
Hmm well returning 1 at the end of the hook hit (function) will ignore cs2d's hit calculation. You could apply your own there.

old Re: Hit hook issue

DarkLight66
User Off Offline

Quote
I was doing that, the problem is.. imagine that i hit you with deagle, that would be 32 dmg, so i take that damage and divide it by half and then set your hp minus the damage halved (16), and then return 1. But, if i hit you with it when you have 8 hp, i will deal 8 damage, and that halved would be 4, and that halved would be 2, and so on. I just want an automatic way of getting the right damage, instead of creating tables with the damage of all weapons.

old Re: Hit hook issue

DC
Admin Off Offline

Quote
take a look at the hook you're using: cs2d lua hook hit

the original damage that will be caused is a parameter of the hit hook (hpdmg)! so you can use that value. downside: this already calculates how much armor weakens the damage. you might want that to happen but maybe you don't want armors to have any effect in your script.

in the latter case you can use the weapon parameter and the cs2d lua cmd itemtype command with parameter "dmg" to get the damage of that weapon. downside there: only works properly with the primary attack damage (ignoring zoomed damage and stuff).

old Re: Hit hook issue

Starkkz
Moderator Off Offline

Quote
user DC has written
in the latter case you can use the weapon parameter and the cs2d lua cmd itemtype command with parameter "dmg" to get the damage of that weapon. downside there: only works properly with the primary attack damage (ignoring zoomed damage and stuff).


But the damage caused by explosions / buildings / entities, they don't appear in this function so they should be registered in a table when you can't get the damage through this command.

old Re: Hit hook issue

DC
Admin Off Offline

Quote
you have to use the first method then. the table thing doesn't work. explosions for example can have any size and strength, also depending on your distance to them.

I'll add an additional parameter which contains the damage without armor calculations.

old Re: Hit hook issue

DarkLight66
User Off Offline

Quote
Im saying, i was using the hpdmg parameter, the problem is that when the player being hit have less hp than the damage of the weapon, hpdmg does not shows the damage given by the weapon, but the damage received by the player, meaning if you have a 10 dmg weapon, and the enemy have 8 hp left, hpdmg will show 8 dmg instead of 10.

old Re: Hit hook issue

DC
Admin Off Offline

Quote
oh.. yeah. that's another problem, right. there simply is no perfect solution with the current CS2D Lua implementation. don't worry, I already added that new parameter for the next release.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview