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