]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_nex.qc
change all function declarations (except builtins and data types) to ANSI C-like...
[divverent/nexuiz.git] / data / qcsrc / server / w_nex.qc
1
2 void W_Nex_Attack (void)
3 {
4         float flying;
5         if not(g_minstagib || g_instagib)
6                 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
7
8         W_SetupShot (self, '25 4 -4', TRUE, 5, "weapons/nexfire.wav");
9         //W_SetupShot (self, '25 8 -8', TRUE, 2, "weapons/nexfire.wav"); // TODO: move model down a little
10
11         // assure that nexdamage is high enough in minstagib
12         if (g_minstagib || g_instagib)
13                 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 1000, 800, IT_NEX);
14         else
15         {
16                 yoda = 0;
17                 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, cvar("g_balance_nex_damage"), cvar("g_balance_nex_force"), IT_NEX);
18
19                 if(yoda)
20                         if(flying)
21                                 announce(self, "announcer/male/yoda.ogg");
22         }
23
24         pointparticles(particleeffectnum("nex_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
25
26         // beam effect
27         trailparticles(world, particleeffectnum("nex_beam"), w_shotorg, trace_endpos);
28         // flash and burn the wall
29         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
30                 pointparticles(particleeffectnum("nex_impact"), trace_endpos - w_shotdir * 6, '0 0 0', 1);
31         // play a sound
32         PointSound (trace_endpos, "weapons/neximpact.wav", 1, ATTN_NORM);
33
34         if (cvar("g_use_ammunition") && !g_instagib)
35         {
36                 if (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
44 .float minstagib_nextthink;
45 void minstagib_ammocheck (void)
46 {
47         if (time < self.minstagib_nextthink || self.deadflag || gameover)
48                 return;
49
50         if (self.ammo_cells <= 0)
51         {
52                 if (self.health == 5)
53                 {
54                         centerprint(self, "you're dead now...\n");
55                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
56                         announce(self, "announcer/robotic/terminated.ogg");
57                 }
58                 if (self.health == 10)
59                 {
60                         centerprint(self, "^11^7 second left to find some ammo\n");
61                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
62                         announce(self, "announcer/robotic/1.ogg");
63                 }
64                 if (self.health == 20)
65                 {
66                         centerprint(self, "^12^7 seconds left to find some ammo\n");
67                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
68                         announce(self, "announcer/robotic/2.ogg");
69                 }
70                 if (self.health == 30)
71                 {
72                         centerprint(self, "^13^7 seconds left to find some ammo\n");
73                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
74                         announce(self, "announcer/robotic/3.ogg");
75                 }
76                 if (self.health == 40)
77                 {
78                         centerprint(self, "^14^7 seconds left to find some ammo\n");
79                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
80                         announce(self, "announcer/robotic/4.ogg");
81                 }
82                 if (self.health == 50)
83                 {
84                         centerprint(self, "^15^7 seconds left to find some ammo\n");
85                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
86                         announce(self, "announcer/robotic/5.ogg");
87                 }
88                 if (self.health == 60)
89                 {
90                         centerprint(self, "^36^7 seconds left to find some ammo\n");
91                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
92                         announce(self, "announcer/robotic/6.ogg");
93                 }
94                 if (self.health == 70)
95                 {
96                         centerprint(self, "^37^7 seconds left to find some ammo\n");
97                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
98                         announce(self, "announcer/robotic/7.ogg");
99                 }
100                 if (self.health == 80)
101                 {
102                         centerprint(self, "^38^7 seconds left to find some ammo\n");
103                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
104                         announce(self, "announcer/robotic/8.ogg");
105                 }
106                 if (self.health == 90)
107                 {
108                         centerprint(self, "^39^7 seconds left to find some ammo\n");
109                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
110                         announce(self, "announcer/robotic/9.ogg");
111                 }
112                 if (self.health == 100)
113                 {
114                         centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
115                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
116                         announce(self, "announcer/robotic/10.ogg");
117                 }
118         }
119         self.minstagib_nextthink = time + 1;
120 }
121
122 float w_nex(float req)
123 {
124         if (req == WR_AIM)
125                 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
126         else if (req == WR_THINK)
127         {
128                 if (self.BUTTON_ATCK)
129                 {
130                         if(g_minstagib)
131                         {
132                                 if (weapon_prepareattack(0, cvar("g_balance_minstagib_nex_refire")))
133                                 {
134                                         W_Nex_Attack();
135                                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_minstagib_nex_animtime"), w_ready);
136                                 }
137                         }
138                         else
139                         {
140                                 if (weapon_prepareattack(0, cvar("g_balance_nex_refire")))
141                                 {
142                                         W_Nex_Attack();
143                                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_animtime"), w_ready);
144                                 }
145                         }
146                 }
147                 else if (self.BUTTON_ATCK2)
148                 {
149                         if (g_minstagib)
150                         {
151                                 if (self.jump_interval <= time)
152                                 {
153                                         self.jump_interval = time + 0.9;
154                                         W_Laser_Attack(FALSE);
155                                 }
156                         }
157                 }
158         }
159         else if (req == WR_PRECACHE)
160         {
161                 precache_model ("models/nexflash.md3");
162                 precache_model ("models/weapons/g_nex.md3");
163                 precache_model ("models/weapons/v_nex.md3");
164                 precache_model ("models/weapons/w_nex.zym");
165                 precache_sound ("weapons/nexfire.wav");
166                 precache_sound ("weapons/neximpact.wav");
167                 if(g_minstagib)
168                         w_laser(WR_PRECACHE);
169         }
170         else if (req == WR_SETUP)
171                 weapon_setup(WEP_NEX, "nex", IT_CELLS);
172         else if (req == WR_CHECKAMMO1)
173         {
174                 if (g_minstagib)
175                         return self.ammo_cells >= 1;
176                 else
177                         return self.ammo_cells >= cvar("g_balance_nex_ammo");
178         }
179         else if (req == WR_CHECKAMMO2)
180                 return FALSE;
181         else if (req == WR_REGISTER)
182         {
183                 if(g_minstagib)
184                         weapon_register(WEP_NEX, 1);
185                 else
186                         weapon_register(WEP_NEX, cvar("g_balance_nex_ammo"));
187         }
188         return TRUE;
189 };