Forum

> > CS2D > Scripts > Damaging a wall by a custom amount.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Damaging a wall by a custom amount.

8 replies
To the start Previous 1 Next To the start

old Damaging a wall by a custom amount.

Trotskygrad
User Off Offline

Quote
I'm trying to damage a wall by a custom amount (without messing with mp_wpndmg)

I've tried using explosions within walls, this works but is horribly laggy and can result in

IMG:https://i.imgur.com/pmfVd.jpg


so I would like to know what the best way for doing this is!

thanks!

old Re: Damaging a wall by a custom amount.

Trotskygrad
User Off Offline

Quote
user Infinite Rain has written
Do you mean normal walls? Or buildings? (Wall I... etc)
And your picture does not makes sense.


buildings.

And that picture is what happens when you try to make an explosion within a wall3... results in stack overflows as well.

old Re: Damaging a wall by a custom amount.

Trotskygrad
User Off Offline

Quote
user Tobey has written
if you want to damage the building with shots you can check if the bullet hits a wall and increase the damage with the given hook.


the hook either returns 1 or 0, there's no way to change the damage with the hook

as for the code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
addhook("objectdamage","ops.main.objectdamage")
function ops.main.objectdamage(objid,damage,id)
	curwep = player(id,"weapontype")
	if(damage < 0) then
		return 0
	end
	for _,weapon in pairs(weapons) do
		if(weapon[1] == curwep) then
			damage = weapon[2]*weapon[8]
			if(damage < weapon[2]) then
				--if damage is less than amount in mp_wpndmg
				ops.main.explosion(object(objid,"x") + 16,object(objid,"y") + 16,1,damage,id)
				return 1
			elseif(damage == weapon[2]) then
				return 0
			elseif(damage > weapon[2]) then
				ops.main.explosion(object(objid,"x") + 16,object(objid,"y")+ 16,1,damage - weapon[2],id)
				return 0
			end
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview