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