Forum

> > CS2D > Scripts > Flamethrower damaging through shield
Forums overviewCS2D overview Scripts overviewLog in to reply

English Flamethrower damaging through shield

7 replies
To the start Previous 1 Next To the start

old Flamethrower damaging through shield

Casper-
User Off Offline

Quote
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

old Re: Flamethrower damaging through shield

DC
Admin Off Offline

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

old Re: Flamethrower damaging through shield

Casper-
User Off Offline

Quote
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

old Re: Flamethrower damaging through shield

Promaster
User Off Offline

Quote
@user Casper-: 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

old Re: Flamethrower damaging through shield

Casper-
User Off Offline

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

old Re: Flamethrower damaging through shield

Promaster
User Off Offline

Quote
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

old Re: Flamethrower damaging through shield

ReVoltage
User Off Offline

Quote
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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview