]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_nex.qc
handle self/oself CORRECTLY this time
[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 (g_minstagib)
9                 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 1000, 800, IT_NEX);
10         else
11         {
12                 yoda = 0;
13                 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, cvar("g_balance_nex_damage"), cvar("g_balance_nex_force"), IT_NEX);
14                 if(yoda)
15                         if(IsFlying(self))
16                                 announce(self, "announcer/male/yoda.ogg");
17         }
18
19         pointparticles(particleeffectnum("nex_muzzleflash"), w_shotorg + v_forward * 32, v_forward * 1000, 1);
20
21         // show as if shot started outside of gun
22         // muzzleflash light
23         //te_smallflash (w_shotorg + w_shotdir * 24);
24         // beam effect
25         trailparticles(world, particleeffectnum("nex_beam"), w_shotorg + w_shotdir * 28, trace_endpos);
26         // flash and burn the wall
27         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
28                 pointparticles(particleeffectnum("nex_impact"), trace_endpos - w_shotdir * 6, '0 0 0', 1);
29         // play a sound
30         PointSound (trace_endpos, "weapons/neximpact.wav", 1, ATTN_NORM);
31
32         if (cvar("g_use_ammunition") && !g_instagib)
33         {
34                 if (g_minstagib)
35                         self.ammo_cells = self.ammo_cells - 1;
36                 else
37                         self.ammo_cells = self.ammo_cells - cvar("g_balance_nex_ammo");
38         }
39
40         /*
41         local entity flash;
42         flash = spawn ();
43         setorigin (flash, self.origin + self.view_ofs + v_forward * 33 + v_right * 14 + v_up * -7);
44         flash.angles = vectoangles (w_shotdir);
45         //setattachment(flash, self.weaponentity, "bone01");
46         //flash.origin = '150 0 0';
47         //setattachment(flash, self.weaponentity, "");
48         //flash.origin = '150 -16 -8';
49         //flash.angles_z = 90;
50         //flash.scale = 4;
51         setmodel (flash, "models/nexflash.md3"); // precision set below
52         SUB_SetFade (flash, time, 0.4);
53         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
54         */
55 }
56
57
58 .float minstagib_nextthink;
59 void minstagib_ammocheck (void)
60 {
61         if (time < self.minstagib_nextthink || self.deadflag || 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                         announce(self, "announcer/robotic/terminated.ogg");
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                         announce(self, "announcer/robotic/1.ogg");
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                         announce(self, "announcer/robotic/2.ogg");
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                         announce(self, "announcer/robotic/3.ogg");
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                         announce(self, "announcer/robotic/4.ogg");
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                         announce(self, "announcer/robotic/5.ogg");
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                         announce(self, "announcer/robotic/6.ogg");
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                         announce(self, "announcer/robotic/7.ogg");
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                         announce(self, "announcer/robotic/8.ogg");
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                         announce(self, "announcer/robotic/9.ogg");
125                 }
126                 if (self.health == 100)
127                 {
128                         centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
129                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
130                         announce(self, "announcer/robotic/10.ogg");
131                 }
132         }
133         self.minstagib_nextthink = time + 1;
134 }
135
136 float(float req) w_nex =
137 {
138         if (req == WR_AIM)
139                 self.button0 = bot_aim(1000000, 0, 1, FALSE);
140         else if (req == WR_THINK)
141         {
142                 if (self.button0)
143                 {
144                         if(g_minstagib)
145                         {
146                                 if (weapon_prepareattack(0, cvar("g_balance_minstagib_nex_refire")))
147                                 {
148                                         W_Nex_Attack();
149                                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_minstagib_nex_animtime"), w_ready);
150                                 }
151                         }
152                         else
153                         {
154                                 if (weapon_prepareattack(0, cvar("g_balance_nex_refire")))
155                                 {
156                                         W_Nex_Attack();
157                                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_animtime"), w_ready);
158                                 }
159                         }
160                 }
161                 else if (self.button3)
162                 {
163                         if (g_minstagib)
164                         {
165                                 if (self.jump_interval <= time)
166                                 {
167                                         self.jump_interval = time + 0.9;
168                                         W_Laser_Attack(FALSE);
169                                 }
170                         }
171                 }
172         }
173         else if (req == WR_PRECACHE)
174         {
175                 precache_model ("models/nexflash.md3");
176                 precache_model ("models/weapons/g_nex.md3");
177                 precache_model ("models/weapons/v_nex.md3");
178                 precache_model ("models/weapons/w_nex.zym");
179                 precache_sound ("weapons/nexfire.wav");
180                 precache_sound ("weapons/neximpact.wav");
181                 if(g_minstagib)
182                         w_laser(WR_PRECACHE);
183         }
184         else if (req == WR_SETUP)
185                 weapon_setup(WEP_NEX, "nex", IT_CELLS);
186         else if (req == WR_CHECKAMMO1)
187         {
188                 if (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 };