English Flamethrower damaging through shield

7 replies
Goto Page
To the start Previous 1 Next To the start
Up
SkullFace
User
Offline Off
As the title says, I'm trying to make flamethrower damage the player who is holding a shield.

This is what I've did but, it doesn't warn (e.g. make hurt sound effect) the player who is carrying the shield that he is being hurt. So that he can hear it. I've thought of slap but that would just spam the chat area.

Code:
1
2
3
4
5
6
addhook("shieldhit","flamethrowerDamage")
function flamethrowerDamage(id,source,weapon,attackdirection,attackerobjectid)
     if weapon==46 then
          parse("sethealth "..id.." "..player(id,"health")-10)
     end
end
IMG:https://i.imgur.com/kZBVkjM.gif
P.S. - I've been extracting recently enviromental sound files from other games, if anyone is interested in them for adding them to their maps, scripts, PM me
14.03.18 11:52:01 pm
Up
DC
Admin
Offline Off
You could use cs2d cmd sv_sound2 to play a sound for the player who is hit.

But yeah.. huh.. weird.. there's really no command which hurts a player and gives him feedback (except slap)?
Probably should be added...
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
15.03.18 12:30:40 am
Up
SkullFace
User
Offline Off
I've used sv_soundpos instead, so it's more like it would be hit by a normal hit.
It uses the default hit sound.

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("shieldhit","flamethrowerDamage")
function flamethrowerDamage(id,source,weapon,attackdirection,attackerobjectid)
     local F=math.random(1,3)
     if weapon==46 then
          if F==1 then
          parse("sethealth "..id.." "..player(id,"health")-10)
          parse("sv_soundpos \"player/hit1.wav\" "..player(id,"x").." "..player(id,"y").." ")
          elseif F==2 then
          parse("sethealth "..id.." "..player(id,"health")-10)
          parse("sv_soundpos \"player/hit2.wav\" "..player(id,"x").." "..player(id,"y").." ")
          elseif F==3 then
          parse("sethealth "..id.." "..player(id,"health")-10)
          parse("sv_soundpos \"player/hit3.wav\" "..player(id,"x").." "..player(id,"y").." ")
          end
     end
end
IMG:https://i.imgur.com/kZBVkjM.gif
P.S. - I've been extracting recently enviromental sound files from other games, if anyone is interested in them for adding them to their maps, scripts, PM me
15.03.18 01:11:49 am
Up
Promaster
User
Offline Off
@user SkullFace: reduced some lines

Code:
1
2
3
4
5
6
7
addhook("shieldhit","flamethrowerDamage")
function flamethrowerDamage(id,source,weapon,attackdirection,attackerobjectid)
     if weapon==46 then
          parse("sethealth "..id.." "..player(id,"health")-10)
          parse("sv_soundpos \"player/hit"..math.random(1,3)..".wav\" "..player(id,"x").." "..player(id,"y").." ")
     end
end
IMG:https://image.prntscr.com/image/J20O66l1RQGtFLeN9dmW6g.png
Patch 13.1! Updated. 2018-02-14
15.03.18 06:23:12 pm
Up
SkullFace
User
Offline Off
Hmm, but now I can't make the attacker get +1 if he kills the enemy.

I've tried customkill but it is still
"Fred deaDeD" instead of "Bob Flamethrower Fred"

Code:
1
2
3
4
5
6
7
8
9
10
11
addhook("shieldhit","flamethrowerDamage")
function flamethrowerDamage(id,source,weapon,attackdirection,attackerobjectid)
     if weapon==46 then
          parse("sethealth "..id.." "..player(id,"health")-10)
          parse("sv_soundpos \"player/hit"..math.random(1,3)..".wav\" "..player(id,"x").." "..player(id,"y").." ")
          parse("effect \"smoke\" "..player(id,"x").." "..player(id,"y").." 5 16")
          parse("effect \"fire\" "..player(id,"x").." "..player(id,"y").." 5 16")
     elseif player(id,"health")<=11 and weapon==46 then
          parse("customkill "..source.." Flamethrower "..id.." ")
     end
end


I've also added smoke and fire to the shield carrier so it's more visible that the victim is hurt by flame.
IMG:https://i.imgur.com/kZBVkjM.gif
P.S. - I've been extracting recently enviromental sound files from other games, if anyone is interested in them for adding them to their maps, scripts, PM me
15.03.18 06:52:25 pm
Up
Promaster
User
Offline Off
Here you go!

Code:
1
2
3
4
5
6
7
8
9
10
11
addhook("shieldhit","flamethrowerDamage")
function flamethrowerDamage(id,source,weapon,attackdirection,attackerobjectid)
     if player(id,"health") <= 10 and weapon==46 then
          parse("customkill "..source.." Flamethrower "..id.."")
     elseif weapon==46 then
          parse("sethealth "..id.." "..player(id,"health")-10)
          parse("sv_soundpos \"player/hit"..math.random(1,3)..".wav\" "..player(id,"x").." "..player(id,"y").." ")
          parse("effect \"smoke\" "..player(id,"x").." "..player(id,"y").." 5 16")
          parse("effect \"fire\" "..player(id,"x").." "..player(id,"y").." 5 16")
     end
end
IMG:https://image.prntscr.com/image/J20O66l1RQGtFLeN9dmW6g.png
Patch 13.1! Updated. 2018-02-14
15.03.18 08:28:31 pm
Up
SkullFace
User
Offline Off
Wait, whaaa?.. How did you - Wow.
Just a simple switch of lines solved it all.
Thanks man!
IMG:https://i.imgur.com/kZBVkjM.gif
P.S. - I've been extracting recently enviromental sound files from other games, if anyone is interested in them for adding them to their maps, scripts, PM me
16.03.18 03:14:24 am
Up
ReVoltage
User
Offline Off
Just fyi, why your code didn't work.

It checks this first,
Code:
1
if weapon==46 then

If the above is false, it check this afterwards,
Code:
1
elseif player(id,"health")<=11 and weapon==46 then


The weapon is always 46 (Flamethrower), so it didn't go into elseif.
Basically didn't work because of the order, always pay attention to order
To the start Previous 1 Next To the start