]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_nex.qc
make use of DP_CON_BESTWEAPON to make the bestweapon command actually work
[divverent/nexuiz.git] / data / qcsrc / server / w_nex.qc
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.wav");
6
7         // assure that nexdamage is high enough in minstagib
8         if (cvar("g_minstagib"))
9                 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 1000, 800, IT_NEX);
10         else
11                 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, cvar("g_balance_nex_damage"), cvar("g_balance_nex_force"), 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.wav", 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"); // precision set below
54         SUB_SetFade (flash, time, 0.4);
55         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
56         */
57 }
58
59
60 .float minstagib_nextthink;
61 void minstagib_ammocheck (void)
62 {
63         if (time < self.minstagib_nextthink || self.deadflag || gameover)
64                 return;
65
66         if (self.ammo_cells <= 0)
67         {
68                 if (self.health == 5)
69                 {
70                         centerprint(self, "you're dead now...\n");
71                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
72                         play2(self, "announcer/robotic/terminated.ogg");
73                 }
74                 if (self.health == 10)
75                 {
76                         centerprint(self, "^11^7 second left to find some ammo\n");
77                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
78                         play2(self, "announcer/robotic/1.ogg");
79                 }
80                 if (self.health == 20)
81                 {
82                         centerprint(self, "^12^7 seconds left to find some ammo\n");
83                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
84                         play2(self, "announcer/robotic/2.ogg");
85                 }
86                 if (self.health == 30)
87                 {
88                         centerprint(self, "^13^7 seconds left to find some ammo\n");
89                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
90                         play2(self, "announcer/robotic/3.ogg");
91                 }
92                 if (self.health == 40)
93                 {
94                         centerprint(self, "^14^7 seconds left to find some ammo\n");
95                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
96                         play2(self, "announcer/robotic/4.ogg");
97                 }
98                 if (self.health == 50)
99                 {
100                         centerprint(self, "^15^7 seconds left to find some ammo\n");
101                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
102                         play2(self, "announcer/robotic/5.ogg");
103                 }
104                 if (self.health == 60)
105                 {
106                         centerprint(self, "^36^7 seconds left to find some ammo\n");
107                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
108                         play2(self, "announcer/robotic/6.ogg");
109                 }
110                 if (self.health == 70)
111                 {
112                         centerprint(self, "^37^7 seconds left to find some ammo\n");
113                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
114                         play2(self, "announcer/robotic/7.ogg");
115                 }
116                 if (self.health == 80)
117                 {
118                         centerprint(self, "^38^7 seconds left to find some ammo\n");
119                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
120                         play2(self, "announcer/robotic/8.ogg");
121                 }
122                 if (self.health == 90)
123                 {
124                         centerprint(self, "^39^7 seconds left to find some ammo\n");
125                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
126                         play2(self, "announcer/robotic/9.ogg");
127                 }
128                 if (self.health == 100)
129                 {
130                         centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
131                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
132                         play2(self, "announcer/robotic/10.ogg");
133                 }
134         }
135         self.minstagib_nextthink = time + 1;
136 }
137
138 float(float req) w_nex =
139 {
140         if (req == WR_AIM)
141                 self.button0 = bot_aim(1000000, 0, 1, FALSE);
142         else if (req == WR_THINK)
143         {
144                 if (self.button0)
145                 {
146                         if(cvar("g_minstagib"))
147                         {
148                                 if (weapon_prepareattack(0, cvar("g_balance_minstagib_nex_refire")))
149                                 {
150                                         W_Nex_Attack();
151                                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_minstagib_nex_animtime"), w_ready);
152                                 }
153                         }
154                         else
155                         {
156                                 if (weapon_prepareattack(0, cvar("g_balance_nex_refire")))
157                                 {
158                                         W_Nex_Attack();
159                                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_animtime"), w_ready);
160                                 }
161                         }
162                 }
163                 else if (self.button3)
164                 {
165                         if (cvar("g_minstagib"))
166                         {
167                                 if (self.jump_interval <= time)
168                                 {
169                                         self.jump_interval = time + 0.9;
170                                         W_Laser_Attack(FALSE);
171                                 }
172                         }
173                 }
174         }
175         else if (req == WR_PRECACHE)
176         {
177                 precache_model ("models/nexflash.md3");
178                 precache_model ("models/weapons/g_nex.md3");
179                 precache_model ("models/weapons/v_nex.md3");
180                 precache_model ("models/weapons/w_nex.zym");
181                 precache_sound ("weapons/nexfire.wav");
182                 precache_sound ("weapons/neximpact.wav");
183         }
184         else if (req == WR_SETUP)
185                 weapon_setup(WEP_NEX, "nex", IT_CELLS);
186         else if (req == WR_CHECKAMMO1)
187         {
188                 if (cvar("g_minstagib"))
189                         return self.ammo_cells >= 1;
190                 else
191                         return self.ammo_cells >= cvar("g_balance_nex_ammo");
192         }
193         else if (req == WR_CHECKAMMO2)
194                 return FALSE;
195         else if (req == WR_REGISTER)
196                 weapon_register(WEP_NEX, cvar("g_balance_nex_ammo"));
197         return TRUE;
198 };