Forum

> > CS2D > Scripts > Damaging a wall by a custom amount.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Damaging a wall by a custom amount.

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Damaging a wall by a custom amount.

Trotskygrad
User Off Offline

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

alt Re: Damaging a wall by a custom amount.

Trotskygrad
User Off Offline

Zitieren
user Infinite Rain hat geschrieben
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.

alt Re: Damaging a wall by a custom amount.

Trotskygrad
User Off Offline

Zitieren
user Tobey hat geschrieben
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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht