]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_nex.c
better fix for LMS crash
[divverent/nexuiz.git] / data / qcsrc / server / gamec / w_nex.c
1
2 void W_Nex_Attack (void)
3 {
4         //w_shotorg = self.origin + self.view_ofs + v_forward * 5 + v_right * 14 + v_up * -7;
5         W_SetupShot(self, '5 14 -8', TRUE, 5, "weapons/nexfire.ogg");
6
7         // assure that nexdamage is high enough in minstagib
8         if (cvar("g_minstagib"))
9                 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * 8192, 1000, IT_NEX);
10         else
11                 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * 8192, cvar("g_balance_nex_damage"), IT_NEX);
12
13         // show as if shot started outside of gun
14         // muzzleflash light
15         //te_smallflash (w_shotorg + w_shotdir * 24);
16         // beam effect
17         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
18         WriteByte (MSG_BROADCAST, 76);
19         WriteCoord (MSG_BROADCAST, w_shotorg_x + w_shotdir_x * 18);
20         WriteCoord (MSG_BROADCAST, w_shotorg_y + w_shotdir_y * 18);
21         WriteCoord (MSG_BROADCAST, w_shotorg_z + w_shotdir_z * 18);
22         WriteCoord (MSG_BROADCAST, trace_endpos_x);
23         WriteCoord (MSG_BROADCAST, trace_endpos_y);
24         WriteCoord (MSG_BROADCAST, trace_endpos_z);
25         WriteCoord (MSG_BROADCAST, 0);
26         WriteCoord (MSG_BROADCAST, 0);
27         WriteCoord (MSG_BROADCAST, 0);
28         // flash and burn the wall
29         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
30                 te_plasmaburn (trace_endpos - w_shotdir * 6);
31         // play a sound
32         PointSound (trace_endpos, "weapons/neximpact.ogg", 1, ATTN_NORM);
33
34         if (cvar("g_use_ammunition") && !cvar("g_instagib"))
35         {
36                 if (cvar("g_minstagib"))
37                         self.ammo_cells = self.ammo_cells - 1;
38                 else
39                         self.ammo_cells = self.ammo_cells - cvar("g_balance_nex_ammo");
40         }
41
42         /*
43         local entity flash;
44         flash = spawn ();
45         setorigin (flash, self.origin + self.view_ofs + v_forward * 33 + v_right * 14 + v_up * -7);
46         flash.angles = vectoangles (w_shotdir);
47         //setattachment(flash, self.weaponentity, "bone01");
48         //flash.origin = '150 0 0';
49         //setattachment(flash, self.weaponentity, "");
50         //flash.origin = '150 -16 -8';
51         //flash.angles_z = 90;
52         //flash.scale = 4;
53         setmodel (flash, "models/nexflash.md3");
54         SUB_SetFade (flash, time, 0.4);
55         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
56         */
57 }
58
59 void nex_selfkill (void)
60 {
61         if (!cvar("g_minstagib") || gameover)
62                 return;
63
64         if (self.ammo_cells <= 0)
65         {
66                 if (self.health == 5)
67                 {
68                         centerprint(self, "you're dead now...\n");
69                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
70                         stuffcmd(self, "play2 announcer/robotic/terminated.ogg\n");
71                 }
72                 if (self.health == 10)
73                 {
74                         centerprint(self, "^11^7 second left to find some ammo\n");
75                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
76                         stuffcmd(self, "play2 announcer/robotic/1.ogg\n");
77                 }
78                 if (self.health == 20)
79                 {
80                         centerprint(self, "^12^7 seconds left to find some ammo\n");
81                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
82                         stuffcmd(self, "play2 announcer/robotic/2.ogg\n");
83                 }
84                 if (self.health == 30)
85                 {
86                         centerprint(self, "^13^7 seconds left to find some ammo\n");
87                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
88                         stuffcmd(self, "play2 announcer/robotic/3.ogg\n");
89                 }
90                 if (self.health == 40)
91                 {
92                         centerprint(self, "^14^7 seconds left to find some ammo\n");
93                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
94                         stuffcmd(self, "play2 announcer/robotic/4.ogg\n");
95                 }
96                 if (self.health == 50)
97                 {
98                         centerprint(self, "^15^7 seconds left to find some ammo\n");
99                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
100                         stuffcmd(self, "play2 announcer/robotic/5.ogg\n");
101                 }
102                 if (self.health == 60)
103                 {
104                         centerprint(self, "^36^7 seconds left to find some ammo\n");
105                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
106                         stuffcmd(self, "play2 announcer/robotic/6.ogg\n");
107                 }
108                 if (self.health == 70)
109                 {
110                         centerprint(self, "^37^7 seconds left to find some ammo\n");
111                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
112                         stuffcmd(self, "play2 announcer/robotic/7.ogg\n");
113                 }
114                 if (self.health == 80)
115                 {
116                         centerprint(self, "^38^7 seconds left to find some ammo\n");
117                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
118                         stuffcmd(self, "play2 announcer/robotic/8.ogg\n");
119                 }
120                 if (self.health == 90)
121                 {
122                         centerprint(self, "^39^7 seconds left to find some ammo\n");
123                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
124                         stuffcmd(self, "play2 announcer/robotic/9.ogg\n");
125                 }
126                 if (self.health == 100)
127                 {
128                         // LordHavoc: why does this fire here?
129                         if (weapon_prepareattack(0, 1))
130                         {
131                                 W_Nex_Attack();
132                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_animtime"), w_ready);
133                         }
134                         centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
135                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
136                         stuffcmd(self, "play2 announcer/robotic/10.ogg\n");
137                 }
138
139         }
140         self.think = nex_selfkill;
141         self.nextthink = time + 1;
142
143 }
144
145 float(float req) w_nex =
146 {
147         if (req == WR_AIM)
148                 self.button0 = bot_aim(1000000, 0, 1, FALSE);
149         else if (req == WR_THINK)
150         {
151                 if (self.button0)
152                 if (weapon_prepareattack(0, cvar("g_balance_nex_refire")))
153                 {
154                         W_Nex_Attack();
155                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_animtime"), w_ready);
156                 }
157         }
158         else if (req == WR_SETUP)
159                 weapon_setup(WEP_NEX, "nex", IT_CELLS);
160         else if (req == WR_CHECKAMMO1)
161         {
162                 if (cvar("g_minstagib"))
163                         return self.ammo_cells >= 1;
164                 else
165                         return self.ammo_cells >= cvar("g_balance_nex_ammo");
166         }
167         else if (req == WR_CHECKAMMO2)
168                 return FALSE;
169         return TRUE;
170 };