English Modify damage inflicted

10 replies
Goto Page
To the start Previous 1 Next To the start
24.12.13 10:03:03 pm
Up
Zeik
User
Offline Off
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
24.12.13 10:08:58 pm
Up
Suprise
BANNED
Offline Off
For the first, i dunno
But the second thing can be done with sethealth.
24.12.13 10:12:45 pm
Up
Zeik
User
Offline Off
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
24.12.13 10:39:22 pm
Up
Suprise
BANNED
Offline Off
you want something like this?
!slap 3 30
so player with id3 loses 30 hp. something like that?
24.12.13 10:49:23 pm
Up
Zeik
User
Offline Off
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.
24.12.13 11:00:52 pm
Up
tonton2d
User
Offline Off
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
Code:
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
"Akounamatata"
24.12.13 11:02:36 pm
Up
_Yank
User
Offline Off
Code:
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.
24.12.13 11:45:33 pm
Up
tonton2d
User
Offline Off
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

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

return table_id_criticals_ninja
--]]


Code:
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
"Akounamatata"
24.12.13 11:45:49 pm
Up
Zeik
User
Offline Off
So you basically used the sethealth command, I didn't have time to do it by myself lol.

Thank you all
25.12.13 06:59:05 am
Up
r4ndxm
User
Offline Off
Code:
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.
Worst player ever
25.12.13 08:01:31 am
Up
sheeL
User
Offline Off
you're talking about a personalized damage?

Code:
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