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:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
|
main(){
windfx = loadfx ("props/car_glass_large");
windtrigs = getentarray("windtrig","targetname");
for(i=0;i<windtrigs.size;i++){
windtrigs[i] thread dowindow(windfx);
}
}
dowindow(windfx){
targetdamage=80;
totaldamage=0;
WindowShattered=false;
WindowBroken=false;
self enablegrenadetouchdamage();
NormalState = getent(self.target,"targetname");
ShatteredState = getent(NormalState.target,"targetname");ShatteredState hide();
BrokenState = getent(shatteredState.target,"targetname");BrokenState hide();
while(!windowbroken){
self waittill ("damage", amount,attacker, direction_vec, point, type);
totaldamage+=amount;
if(totaldamage>targetdamage || getdamagetype(type)=="melee"){
WindowBroken=true;
}
if(!WindowShattered){
NormalState delete();
ShatteredState show();
WindowShattered=true;
}
}
BrokenState show();
self playsound("glass_break");
PlayFX(windfx, BrokenState.origin );
ShatteredState delete();
self delete();
}
getDamageType(type){
if(!isdefined(type)){
return "unknown";
}
type = tolower(type);
switch(type){
case "mod_melee":
case "mod_crush":
case "melee":
return "melee";
default:
return "other";
}
} |