Forum

> > CS2D > Scripts > Modify damage inflicted
Forums overviewCS2D overview Scripts overviewLog in to reply

English Modify damage inflicted

10 replies
To the start Previous 1 Next To the start

old Modify damage inflicted

Zeik
User Off Offline

Quote
Is there a way to modify damage inflicted with the hit hook?

Would it work if I return a modified damage value? or there is no way at all?

If not..
Can I inflict damage to a defined player with a defined value somehow? (not slap command)

Thanks

old Re: Modify damage inflicted

Zeik
User Off Offline

Quote
user Suprise has written
For the first, i dunno
But the second thing can be done with sethealth.


Mhmmm I'll try it but I don't think it could work as I want it to... Thanks, I hope it does work.

If someone knows another method, tell me

old Re: Modify damage inflicted

Zeik
User Off Offline

Quote
user Suprise has written
you want something like this?
!slap 3 30
so player with id3 loses 30 hp. something like that?


What I want to do is more complex.. I want to add criticals, so when you get the chance to hit one, it will do more damage depending on the weapon.

The only problem is changing the damage inflicted on hit, I don't know how to do that.

old Re: Modify damage inflicted

tonton2d
User Off Offline

Quote
http://cs2d.com/help.php?hookcat=all&hook=hit#hook

use the hit hook to know how much domage the player get, then set the new heath&&Kevlar in consequance

for exemple the same weapon can have differents domages depending the victim team
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("hit","_hit")
function _hit(id,sources,weapon,hpdmg,apdmg,rawdmg)
	local alive_plyer_list=player(0,"tableliving")
	local new_health = hpdmg
	local new_kev = apdmg
	for _,id in pairs(alive_plyer_list) do
   		if player(id,"team") == 1 then 
			new_health = player(id,health) - 10
			--[[ here whatever the weapon, terrorist lose 10hp every hit ]]-- 
			parse("sethealth(id, new_health)")
		else 
			new_health = player(id,health) - 20
			--[[ here whatever the weapon, terrorist lose 20hp every hit ]]-- 
			parse("sethealth(id, new_health)")
		end
	end 
end
   
return 1 --no domage by the hit.
end

old Re: Modify damage inflicted

_Yank
User Off Offline

Quote
1
2
3
4
5
addhook("hit","_hit")
function _hit(victim,source,weapon,hpdmg,apdmg,raw)
	parse("sethealth "..victim.." "..player(id,"health") - (hpdmg + 10)) -- Adds 10 to the damage.
	return 1 -- Ignore the hit
end
Simple like that. Theres no other complex way.

EDIT : Damn tonton ninjad me.

old Re: Modify damage inflicted

tonton2d
User Off Offline

Quote
lol @user _Yank: WATTAAA

Quote
What I want to do is more complex.. I want to add criticals, so when you get the chance to hit one, it will do more damage depending on the weapon.

then it depends more on the sources

1
2
3
4
5
--[[  
Here the function with all the IDs of player who are in Critical mode

return table_id_criticals_ninja
--]]

1
2
3
4
5
6
7
8
9
10
11
function _hit(id,sources,weapon,hpdmg,apdmg,rawdmg)

local boolen_id = value_is_in_table(table_id_criticals_ninja, #table_id_criticals_ninja, sources) 
--[[function which check if sources id is in the list of the criticals player, return a boolean]]--
	if boolen_id == true then 
		--[[setheath method]]--
		return 1
	else
		return 0 -- hit like normal 
	end  	
end
edited 1×, last 24.12.13 11:46:33 pm

old Re: Modify damage inflicted

Zeik
User Off Offline

Quote
So you basically used the sethealth command, I didn't have time to do it by myself lol.

Thank you all

old Re: Modify damage inflicted

r4ndxm
User Off Offline

Quote
1
2
3
4
5
6
if (player(id,"health")<=(rawdmg*2)) then
	parse("customkill "..source.." "..itemtype(weapon,"name").." "..id)
else
	parse ("sethealth "..id.." "..player(id,"health")-(rawdmg*2))
	return 1
end

You can add this thing so the damage will be double, and also you can edit the player(id,"health")-(rawdmg*2) to something else like 0.05 so it acts like a super armor or something.

old Re: Modify damage inflicted

sheeL
User Off Offline

Quote
you're talking about a personalized damage?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
admins={xxxxx} -- your usgn here

function admincheck(usgn)
     for num, val in iparis(admins) do
          if val==usgn then
               return true
          else
               return false
          end
     end
end

weaponid = weaponid(ex: 30)
weapondamage = custom weapon damage(ex: 125)

addhook("hit","customdamage")
function customdamage(id,pl,weapon)
     if admincheck(player(pl,"usgn"))~=false then
          if weapon==weaponid then
               if (player(id,"health")-weapondamage)>0 then
                    parse("sethealth "..id.." "..(player(id,"health")-weapondamage)) --sethealth SETS the health, doesn't subtract it.
               else
                    parse("customkill "..pl.." \""..itemtype(weapon,"name").."\" "..id)
               end
               return 1
          end
     end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview