]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/damage.qc
make crylink no longer use an impact sound and effect, instead do this on csqc
[divverent/nexuiz.git] / data / qcsrc / client / damage.qc
1 void Ent_DamageInfo()
2 {
3         float hittype, dmg, rad, edge, thisdmg;
4         vector force, org, thisforce;
5         entity oldself;
6
7         oldself = self;
8
9         hittype = ReadShort();
10         org_x = ReadCoord();
11         org_y = ReadCoord();
12         org_z = ReadCoord();
13
14         dmg = ReadByte();
15         rad = ReadByte();
16         edge = ReadByte();
17         force = decompressShortVector(ReadShort());
18
19         for(self = findradius(org, rad); self; self = self.chain)
20         {
21                 print("findradius found something\n");
22
23                 if(rad)
24                 {
25                         thisdmg = vlen(self.origin - org) / rad;
26                         print("thisdmg = ", ftos(thisdmg), "\n");
27                         if(thisdmg >= 1)
28                                 continue;
29                         thisdmg = dmg + (edge - dmg) * thisdmg;
30                         thisforce = force_z * normalize(self.origin - org);
31                 }
32                 else
33                 {
34                         thisdmg = dmg;
35                         thisforce = force;
36                 }
37
38                 if(self.damageforcescale)
39                         if(vlen(thisforce))
40                         {
41                                 self.move_velocity = self.move_velocity + self.damageforcescale * thisforce;
42                                 self.move_flags &~= FL_ONGROUND;
43                         }
44
45                 if(self.event_damage)
46                         self.event_damage(thisdmg, hittype, org, thisforce);
47         }
48
49         self = oldself;
50
51         // TODO spawn particle effects and sounds based on hittype
52         
53         print("hit: ", ftos(hittype), "\n");
54
55         if(!DEATH_ISSPECIAL(hittype))
56         {
57                 float hitwep, secondary;
58                 hitwep = DEATH_WEAPONOFWEAPONDEATH(hittype);
59                 secondary = hittype & HITTYPE_SECONDARY;
60
61                 print("hit: ", ftos(hitwep), "\n");
62
63                 switch(hitwep)
64                 {
65                         case WEP_CRYLINK:
66                                 if(secondary)
67                                 {
68                                         sound (self, CHAN_PROJECTILE, "weapons/crylink_impact2.wav", VOL_BASE, ATTN_NORM);
69                                         pointparticles(particleeffectnum("crylink_impact"), org, '0 0 0', 1);
70                                 }
71                                 else
72                                 {
73                                         sound (self, CHAN_PROJECTILE, "weapons/crylink_impact.wav", VOL_BASE, ATTN_NORM);
74                                         pointparticles(particleeffectnum("crylink_impactbig"), org, '0 0 0', 1);
75                                 }
76                                 break;
77                 }
78         }
79 }