]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/w_minstanex.qc
Merge remote-tracking branch 'origin/master' into samual/weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_minstanex.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(
3 /* WEP_##id  */ MINSTANEX,
4 /* function  */ w_minstanex,
5 /* ammotype  */ IT_CELLS,
6 /* impulse   */ 7,
7 /* flags     */ WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN,
8 /* rating    */ BOT_PICKUP_RATING_HIGH,
9 /* model     */ "minstanex",
10 /* shortname */ "minstanex",
11 /* fullname  */ _("MinstaNex")
12 );
13 #else
14 #ifdef SVQC
15 .float minstanex_lasthit;
16 .float jump_interval;
17
18 void W_MinstaNex_Attack (void)
19 {
20         float flying;
21         flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
22
23         W_SetupShot (self, TRUE, 0, "weapons/minstanexfire.wav", CH_WEAPON_A, 10000);
24
25         yoda = 0;
26         damage_goodhits = 0;
27         FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 10000, 800, 0, 0, 0, 0, WEP_MINSTANEX);
28
29         if(yoda && flying)
30                 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
31         if(damage_goodhits && self.minstanex_lasthit)
32         {
33                 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
34                 damage_goodhits = 0; // only every second time
35         }
36
37         self.minstanex_lasthit = damage_goodhits;
38
39         pointparticles(particleeffectnum("nex_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
40
41         // teamcolor / hit beam effect
42         vector v;
43         v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
44         switch(self.team)
45         {
46                 case NUM_TEAM_1:   // Red
47                         if(damage_goodhits)
48                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED_HIT"), w_shotorg, v);
49                         else
50                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED"), w_shotorg, v);
51                         break;
52                 case NUM_TEAM_2:   // Blue
53                         if(damage_goodhits)
54                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE_HIT"), w_shotorg, v);
55                         else
56                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE"), w_shotorg, v);
57                         break;
58                 case NUM_TEAM_3:   // Yellow
59                         if(damage_goodhits)
60                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW_HIT"), w_shotorg, v);
61                         else
62                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW"), w_shotorg, v);
63                         break;
64                 case NUM_TEAM_4:   // Pink
65                         if(damage_goodhits)
66                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK_HIT"), w_shotorg, v);
67                         else
68                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK"), w_shotorg, v);
69                         break;
70                 default:
71                         if(damage_goodhits)
72                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3_HIT"), w_shotorg, v);
73                         else
74                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), w_shotorg, v);
75                         break;
76         }
77         
78         W_DecreaseAmmo(ammo_cells, ((g_minstagib) ? 1 : autocvar_g_balance_minstanex_ammo), autocvar_g_balance_minstanex_reload_ammo);
79 }
80
81 void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
82
83 float w_minstanex(float req)
84 {
85         float ammo_amount;
86         float minstanex_ammo;
87
88         // now multiple WR_s use this
89         minstanex_ammo = ((g_minstagib) ? 1 : autocvar_g_balance_minstanex_ammo);
90
91         switch(req)
92         {
93                 case WR_AIM:
94                 {
95                         if(self.ammo_cells > 0)
96                                 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
97                         else
98                                 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
99                                 
100                         return TRUE;
101                 }
102                 case WR_THINK:
103                 {
104                         // if the laser uses load, we also consider its ammo for reloading
105                         if(autocvar_g_balance_minstanex_reload_ammo && autocvar_g_balance_minstanex_laser_ammo && self.clip_load < min(minstanex_ammo, autocvar_g_balance_minstanex_laser_ammo)) // forced reload
106                                 weapon_action(self.weapon, WR_RELOAD);
107                         else if(autocvar_g_balance_minstanex_reload_ammo && self.clip_load < minstanex_ammo) // forced reload
108                                 weapon_action(self.weapon, WR_RELOAD);
109                         else if (self.BUTTON_ATCK)
110                         {
111                                 if (weapon_prepareattack(0, autocvar_g_balance_minstanex_refire))
112                                 {
113                                         W_MinstaNex_Attack();
114                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_minstanex_animtime, w_ready);
115                                 }
116                         }
117                         else if (self.BUTTON_ATCK2)
118                         {
119                                 if (self.jump_interval <= time)
120                                 if (weapon_prepareattack(1, -1))
121                                 {
122                                         // handle refire manually, so that primary and secondary can be fired without conflictions (important for minstagib)
123                                         self.jump_interval = time + autocvar_g_balance_minstanex_laser_refire * W_WeaponRateFactor();
124                                         
125                                         // decrease ammo for the laser?
126                                         if(autocvar_g_balance_minstanex_laser_ammo)
127                                                 W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_laser_ammo, autocvar_g_balance_minstanex_reload_ammo);
128
129                                         // ugly minstagib hack to reuse the fire mode of the laser
130                                         float w;
131                                         w = self.weapon;
132                                         self.weapon = WEP_LASER;
133                                         W_Laser_Shockwave();
134                                         self.weapon = w;
135                                         
136                                         // now do normal refire
137                                         weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_minstanex_laser_animtime, w_ready);
138                                 }
139                         }
140                         
141                         return TRUE;
142                 }
143                 case WR_PRECACHE:
144                 {
145                         precache_model ("models/nexflash.md3");
146                         precache_model ("models/weapons/g_minstanex.md3");
147                         precache_model ("models/weapons/v_minstanex.md3");
148                         precache_model ("models/weapons/h_minstanex.iqm");
149                         precache_sound ("weapons/minstanexfire.wav");
150                         precache_sound ("weapons/nexwhoosh1.wav");
151                         precache_sound ("weapons/nexwhoosh2.wav");
152                         precache_sound ("weapons/nexwhoosh3.wav");
153                         W_Laser(WR_PRECACHE);
154                         return TRUE;
155                 }
156                 case WR_SETUP:
157                 {
158                         weapon_setup(WEP_MINSTANEX);
159                         self.current_ammo = ammo_cells;
160                         self.minstanex_lasthit = 0;
161                         return TRUE;
162                 }
163                 case WR_CHECKAMMO1:
164                 {
165                         ammo_amount = self.ammo_cells >= minstanex_ammo;
166                         ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= minstanex_ammo;
167                         return ammo_amount;
168                 }
169                 case WR_CHECKAMMO2:
170                 {
171                         if(!autocvar_g_balance_minstanex_laser_ammo)
172                                 return TRUE;
173                         ammo_amount = self.ammo_cells >= autocvar_g_balance_minstanex_laser_ammo;
174                         ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= autocvar_g_balance_minstanex_laser_ammo;
175                         return ammo_amount;
176                 }
177                 case WR_RESETPLAYER:
178                 {
179                         self.minstanex_lasthit = 0;
180                         return TRUE;
181                 }
182                 case WR_RELOAD:
183                 {
184                         float used_ammo;
185                         if(autocvar_g_balance_minstanex_laser_ammo)
186                                 used_ammo = min(minstanex_ammo, autocvar_g_balance_minstanex_laser_ammo);
187                         else
188                                 used_ammo = minstanex_ammo;
189
190                         W_Reload(used_ammo, autocvar_g_balance_minstanex_reload_ammo, autocvar_g_balance_minstanex_reload_time, "weapons/reload.wav");
191                         return TRUE;
192                 }
193                 case WR_SUICIDEMESSAGE:
194                 {
195                         return WEAPON_THINKING_WITH_PORTALS;
196                 }
197                 case WR_KILLMESSAGE:
198                 {
199                         return WEAPON_MINSTANEX_MURDER;
200                 }
201         }
202         return TRUE;
203 }
204 #endif
205 #ifdef CSQC
206 float w_minstanex(float req)
207 {
208         switch(req)
209         {
210                 case WR_IMPACTEFFECT:
211                 {
212                         vector org2;
213                         org2 = w_org + w_backoff * 6;
214                         pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
215                         if(!w_issilent)
216                                 sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
217                                 
218                         return TRUE;
219                 }
220                 case WR_PRECACHE:
221                 {
222                         precache_sound("weapons/neximpact.wav");
223                         return TRUE;
224                 }
225         }
226         return TRUE;
227 }
228 #endif
229 #endif