]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_nex.c
a piece of code I forgot to commit... but it's ifdeffed out anyway (variable
[divverent/nexuiz.git] / data / qcsrc / server / gamec / w_nex.c
1 void() nex_ready_01;
2 void() nex_fire1_01;
3 void() nex_deselect_01;
4 void() nex_select_01;
5 void() nex_selfkill;
6
7 float() nex_check =
8 {
9         if (cvar("g_minstagib"))
10         {
11                 if (self.ammo_cells >= 1)
12                         return TRUE;
13         } else {
14                 if (self.ammo_cells >= cvar("g_balance_nex_ammo"))
15                         return TRUE;
16         }
17         return FALSE;
18 };
19
20 void nex_selfkill (void)
21 {
22         if (!cvar("g_minstagib") || gameover)
23                 return;
24
25         if (self.ammo_cells <= 0)
26         {
27                 if (self.health == 5)
28                 {
29                         centerprint(self, "you're dead now...\n");
30                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
31                         stuffcmd(self, "play2 announcer/robotic/terminated.ogg\n");
32                 }
33                 if (self.health == 10)
34                 {
35                         centerprint(self, "^11^7 second left to find some ammo\n");
36                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
37                         stuffcmd(self, "play2 announcer/robotic/1.ogg\n");
38                 }
39                 if (self.health == 20)
40                 {
41                         centerprint(self, "^12^7 seconds left to find some ammo\n");
42                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
43                         stuffcmd(self, "play2 announcer/robotic/2.ogg\n");
44                 }
45                 if (self.health == 30)
46                 {
47                         centerprint(self, "^13^7 seconds left to find some ammo\n");
48                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
49                         stuffcmd(self, "play2 announcer/robotic/3.ogg\n");
50                 }
51                 if (self.health == 40)
52                 {
53                         centerprint(self, "^14^7 seconds left to find some ammo\n");
54                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
55                         stuffcmd(self, "play2 announcer/robotic/4.ogg\n");
56                 }
57                 if (self.health == 50)
58                 {
59                         centerprint(self, "^15^7 seconds left to find some ammo\n");
60                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
61                         stuffcmd(self, "play2 announcer/robotic/5.ogg\n");
62                 }
63                 if (self.health == 60)
64                 {
65                         centerprint(self, "^36^7 seconds left to find some ammo\n");
66                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
67                         stuffcmd(self, "play2 announcer/robotic/6.ogg\n");
68                 }
69                 if (self.health == 70)
70                 {
71                         centerprint(self, "^37^7 seconds left to find some ammo\n");
72                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
73                         stuffcmd(self, "play2 announcer/robotic/7.ogg\n");
74                 }
75                 if (self.health == 80)
76                 {
77                         centerprint(self, "^38^7 seconds left to find some ammo\n");
78                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
79                         stuffcmd(self, "play2 announcer/robotic/8.ogg\n");
80                 }
81                 if (self.health == 90)
82                 {
83                         centerprint(self, "^39^7 seconds left to find some ammo\n");
84                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
85                         stuffcmd(self, "play2 announcer/robotic/9.ogg\n");
86                 }
87                 if (self.health == 100)
88                 {
89                         weapon_prepareattack(nex_check, nex_check, nex_fire1_01, 1.0);
90                         centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
91                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
92                         stuffcmd(self, "play2 announcer/robotic/10.ogg\n");
93                 }
94
95         }
96         self.think = nex_selfkill;
97         self.nextthink = time + 1;
98
99 }
100
101 void(float req) w_nex =
102 {
103         if (req == WR_IDLE)
104                 nex_ready_01();
105         else if (req == WR_AIM)
106                 self.button0 = bot_aim(1000000, 0, 1, FALSE);
107         else if (req == WR_FIRE1)
108                 weapon_prepareattack(nex_check, nex_check, nex_fire1_01, cvar("g_balance_nex_refire"));
109         else if (req == WR_RAISE)
110                 nex_select_01();
111         else if (req == WR_UPDATECOUNTS)
112                 self.currentammo = self.ammo_cells;
113         else if (req == WR_DROP)
114                 nex_deselect_01();
115         else if (req == WR_SETUP)
116                 weapon_setup(WEP_NEX, "w_nex.zym", IT_CELLS);
117         else if (req == WR_CHECKAMMO)
118                 weapon_hasammo = nex_check();
119 };
120
121
122 void W_Nex_Attack (void)
123 {
124         local vector org, org2;
125         local entity flash;
126
127         local vector trueaim;
128         trueaim = W_TrueAim();
129
130         sound (self, CHAN_WEAPON, "weapons/nexfire.ogg", 1, ATTN_NORM);
131         if (self.items & IT_STRENGTH && !cvar("g_minstagib"))
132                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
133
134         self.punchangle_x = -5;
135
136         org = self.origin + self.view_ofs + v_forward * 5 + v_right * 14 + v_up * -7;
137         traceline_hitcorpse(self, org, trueaim + normalize(trueaim - org) * 8192, TRUE, self);
138         trueaim = trace_endpos;
139
140         // assure that nexdamage is high enough in minstagib
141         if (cvar("g_minstagib"))
142                 FireRailgunBullet (org, trueaim, 1000, IT_NEX);
143         else
144                 FireRailgunBullet (org, trueaim, cvar("g_balance_nex_damage"), IT_NEX);
145
146         // trace as if shot started inside gun
147         traceline_hitcorpse (self,org, trueaim, TRUE, self);
148         // show as if shot started outside of gun
149         org = self.origin + self.view_ofs + v_forward * 35 + v_right * 14 + v_up * -8;
150         org2 = self.origin + self.view_ofs + v_forward * 52 + v_right * 14 + v_up * -8;
151         // muzzleflash light
152         te_smallflash (org2);
153         // beam effect
154         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
155         WriteByte (MSG_BROADCAST, 76);
156         WriteCoord (MSG_BROADCAST, org_x);
157         WriteCoord (MSG_BROADCAST, org_y);
158         WriteCoord (MSG_BROADCAST, org_z);
159         WriteCoord (MSG_BROADCAST, trace_endpos_x);
160         WriteCoord (MSG_BROADCAST, trace_endpos_y);
161         WriteCoord (MSG_BROADCAST, trace_endpos_z);
162         WriteCoord (MSG_BROADCAST, 0);
163         WriteCoord (MSG_BROADCAST, 0);
164         WriteCoord (MSG_BROADCAST, 0);
165         // flash and burn the wall
166         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
167                 te_plasmaburn (findbetterlocation (trace_endpos, 6));
168         /*
169         // flame effect at impact
170         dir = trace_plane_normal * 100;
171         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
172         WriteByte (MSG_BROADCAST, TE_FLAMEJET);
173         WriteCoord (MSG_BROADCAST, trace_endpos_x);
174         WriteCoord (MSG_BROADCAST, trace_endpos_y);
175         WriteCoord (MSG_BROADCAST, trace_endpos_z);
176         WriteCoord (MSG_BROADCAST, dir_x);
177         WriteCoord (MSG_BROADCAST, dir_y);
178         WriteCoord (MSG_BROADCAST, dir_z);
179         WriteByte (MSG_BROADCAST, 255);
180         */
181         // play a sound
182         PointSound (trace_endpos, "weapons/neximpact.ogg", 1, ATTN_NORM);
183
184         if (cvar("g_use_ammunition") && !cvar("g_instagib"))
185         {
186                 if (cvar("g_minstagib"))
187                         self.ammo_cells = self.ammo_cells - 1;
188                 else
189                         self.ammo_cells = self.ammo_cells - cvar("g_balance_nex_ammo");
190         }
191
192         flash = spawn ();
193         org = self.origin + self.view_ofs + v_forward * 33 + v_right * 14 + v_up * -7;
194         setorigin (flash, org);
195         setmodel (flash, "models/nexflash.md3");
196         flash.velocity = v_forward * 20;
197         flash.angles = vectoangles (flash.velocity);
198         SUB_SetFade (flash, time, 0.4);
199         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
200 }
201
202 // weapon frames
203 void()  nex_ready_01 =  {weapon_thinkf(WFRAME_IDLE, 0.1, nex_ready_01); self.weaponentity.state = WS_READY;};
204 void()  nex_select_01 = {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0'); nex_selfkill();};
205 void()  nex_deselect_01 =       {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
206 void()  nex_fire1_01 =
207 {
208         weapon_doattack(nex_check, nex_check, W_Nex_Attack);
209         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_animtime"), nex_ready_01);
210 };
211