]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_minstanex.qc
unlimited ammo revisited: distinguish between superweapons and normal weapons
[divverent/nexuiz.git] / data / qcsrc / server / w_minstanex.qc
1 .float minstanex_lasthit;
2
3 void W_MinstaNex_Attack (void)
4 {
5         float flying;
6         flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
7
8         W_SetupShot (self, '25 8 -4', TRUE, 5, "weapons/minstanexfire.wav");
9
10         yoda = 0;
11         damage_goodhits = 0;
12         headshot = 0;
13         FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 10000, 800, WEP_MINSTANEX);
14
15         if(g_minstagib)
16         {
17                 if(yoda)
18                         announce(self, "announcer/male/yoda.ogg");
19         }
20         else
21         {
22                 if(yoda && flying)
23                         announce(self, "announcer/male/yoda.ogg");
24                 if(headshot)
25                 {
26                         announce(self, "announcer/male/headshot.ogg");
27                         print("h\n");
28                 }
29                 if(damage_goodhits && self.minstanex_lasthit)
30                 {
31                         if(announce(self, "announcer/male/impressive.ogg"))
32                                 damage_goodhits = 0; // only every second time
33                 }
34         }
35
36         self.minstanex_lasthit = damage_goodhits;
37
38         pointparticles(particleeffectnum("nex_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
39
40         // beam effect
41         trailparticles(world, particleeffectnum("TE_TEI_G3"), w_shotorg, trace_endpos);
42         // flash and burn the wall
43         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
44                 pointparticles(particleeffectnum("nex_impact"), trace_endpos - w_shotdir * 6, '0 0 0', 1);
45         // play a sound
46         soundat (self, trace_endpos, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
47
48         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
49         {
50                 if (g_minstagib)
51                         self.ammo_cells = self.ammo_cells - 1;
52                 else
53                         self.ammo_cells = self.ammo_cells - cvar("g_balance_minstanex_ammo");
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 void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
137
138 float w_minstanex(float req)
139 {
140         if (req == WR_AIM)
141                 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
142         else if (req == WR_THINK)
143         {
144                 if (self.BUTTON_ATCK)
145                 {
146                         if (weapon_prepareattack(0, cvar("g_balance_minstanex_refire")))
147                         {
148                                 W_MinstaNex_Attack();
149                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_minstanex_animtime"), w_ready);
150                         }
151                 }
152                 else if (self.BUTTON_ATCK2)
153                 {
154                         if (self.jump_interval <= time)
155                         {
156                                 self.jump_interval = time + 0.9;
157                                 W_Laser_Attack(FALSE);
158                         }
159                 }
160         }
161         else if (req == WR_PRECACHE)
162         {
163                 precache_model ("models/nexflash.md3");
164                 precache_model ("models/weapons/g_minstanex.md3");
165                 precache_model ("models/weapons/v_minstanex.md3");
166                 precache_model ("models/weapons/w_minstanex.zym");
167                 precache_sound ("weapons/minstanexfire.wav");
168                 precache_sound ("weapons/neximpact.wav");
169                 w_laser(WR_PRECACHE);
170         }
171         else if (req == WR_SETUP)
172         {
173                 weapon_setup(WEP_MINSTANEX);
174                 self.minstanex_lasthit = 0;
175         }
176         else if (req == WR_CHECKAMMO1)
177         {
178                 if (g_minstagib)
179                         return self.ammo_cells >= 1;
180                 else
181                         return self.ammo_cells >= cvar("g_balance_minstanex_ammo");
182         }
183         else if (req == WR_CHECKAMMO2)
184                 return FALSE;
185         else if (req == WR_SUICIDEMESSAGE)
186                 w_deathtypestring = "did the impossible";
187         else if (req == WR_KILLMESSAGE)
188                 w_deathtypestring = "has been vaporized by";
189         return TRUE;
190 };