Forum

> > CS2D > Scripts > Explosion, that do ignore walls.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Explosion, that do ignore walls.

6 replies
To the start Previous 1 Next To the start

old Explosion, that do ignore walls.

Mora
User Off Offline

Quote
Hello us

I wanna know how to make explosion that ignore all walls, obstacles, with radius i set and it's hurt?
1
parse("explosion_i_don't_care_about_fckng_wallZ "..id.." 1000 1000")
IMG:https://i.pixs.ru/storage/7/3/6/explosionp_1137898_13547736.png

I hope it's that possible to do :<
thank you so much

old Re: Explosion, that do ignore walls.

Mora
User Off Offline

Quote
but @user TimeQuesT:, it's that will work for every explosion that happened? example i just using explosion by cmd "explosion", i don't need for that happened if i throw, as example, HE grenade. It's that possible make that for only explosion i started with cmd?

old Re: Explosion, that do ignore walls.

XoOt
Super User Off Offline

Quote
It is possible @user Mora: not the easiest task but you need to check every explosionrange and create a new hitdmg by using the same range. Check if a player is in that range and let him receive the dmg you want. Im not going to Script that as im not the best scripter here.. i could make the basics but it will be filled with some issues tho. Anyway good luck and i hope you know what i tried to explain.

old Re: Explosion, that do ignore walls.

DC
Admin Off Offline

Quote
Switching cs2d cmd mp_curtailedexplosions is really fast because it doesn't invoke any additional actions. It just changes an integer in CS2D which is checked whenever something explodes. Also doing so doesn't show any message. So you can simply turn it on and off on demand and for single explosion-calls. This way you don't have to script your own solution.

A snippet to show what I'm talking about (untested):
1
2
3
4
oldstate = game("mp_curtailedexplosions")
parse("mp_curtailedexplosions 0")
parse("explosion 300 300 500 50")
parse("mp_curtailedexplosions "..oldstate)
You could also improve this by skipping all the mp_curtailedexplosion-changes when it is set to 0 anyways.

I wouldn't call this approach "best practice" but it should do what you want with minimal effort.

old Re: Explosion, that do ignore walls.

TimeQuesT
User Off Offline

Quote
Oh well. I'm a bit late, but this script will work too.
You just have to call "void_explosion".
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
function void_explosion(owner, x, y, radius, damage, ignore_walls)
	if (ignore_walls) then
		parse("explosion "..x.." "..y.." "..radius.." 0 0");
		local l_list = player(0, "table");
		for _,id in pairs(l_list) do
   			if (id ~= owner) then --do not damage owner
				local l_distance = math.sqrt(int_square(x - player(id, "x")) + int_square(y - player(id, "y")));
				l_distance = math.floor(l_distance);
				
				if (l_distance <= radius) then
					local l_damage = math.floor(damage - (l_distance / radius) * damage);
					if (player(id, "health") - l_damage <= 0) then
						parse("customkill "..owner.." \"explosion\" "..id);
					else
						parse("sethealth "..id.." "..player(id, "health") - l_damage);
					end
				end
			end
		end
	else
		parse("explosion "..x.." "..y.." "..radius.." "..damage.." "..owner);
	end
end

function int_square(factor)
	return factor * factor;
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview