Forum

> > CS2D > Scripts > Flamethrower damaging through shield
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Flamethrower damaging through shield

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Flamethrower damaging through shield

SkullFace
User Off Offline

Zitieren
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.

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

alt Re: Flamethrower damaging through shield

DC
Admin Off Offline

Zitieren
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...

alt Re: Flamethrower damaging through shield

SkullFace
User Off Offline

Zitieren
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.

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

alt Re: Flamethrower damaging through shield

Promaster
User Off Offline

Zitieren
@user SkullFace: reduced some lines

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

alt Re: Flamethrower damaging through shield

SkullFace
User Off Offline

Zitieren
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"

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.

alt Re: Flamethrower damaging through shield

Promaster
User Off Offline

Zitieren
Here you go!

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

alt Re: Flamethrower damaging through shield

ReVoltage
User Off Offline

Zitieren
Just fyi, why your code didn't work.

It checks this first,
1
if weapon==46 then
If the above is false, it check this afterwards,
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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht