]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_nex.qc
Merge commit 'origin/master' into diabolik/weaponscale
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_nex.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(NEX, w_nex, IT_CELLS, 7, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "nex", "nex", "Nex");
3 #else
4 void SendCSQCNexBeamParticle() {
5         vector v;
6         v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
7         WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
8         WriteByte(MSG_BROADCAST, TE_CSQC_NEXGUNBEAMPARTICLE);
9         
10         WriteCoord(MSG_BROADCAST, w_shotorg_x);
11         WriteCoord(MSG_BROADCAST, w_shotorg_y);
12         WriteCoord(MSG_BROADCAST, w_shotorg_z);
13         WriteCoord(MSG_BROADCAST, v_x);
14         WriteCoord(MSG_BROADCAST, v_y);
15         WriteCoord(MSG_BROADCAST, v_z);
16 }
17
18 void W_Nex_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, 5, "weapons/nexfire.wav", cvar("g_balance_nex_damage"));
24
25         yoda = 0;
26         FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, cvar("g_balance_nex_damage"), cvar("g_balance_nex_force"), cvar("g_balance_nex_damagefalloff_mindist"), cvar("g_balance_nex_damagefalloff_maxdist"), cvar("g_balance_nex_damagefalloff_halflife"), cvar("g_balance_nex_damagefalloff_forcehalflife"), WEP_NEX);
27
28         if(yoda && flying)
29                 AnnounceTo(self, "yoda");
30
31         //beam and muzzle flash done on client
32         SendCSQCNexBeamParticle();
33         
34         // flash and burn the wall
35         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
36                 Damage_DamageInfo(trace_endpos, cvar("g_balance_nex_damage"), 0, 0, cvar("g_balance_nex_force") * w_shotdir, WEP_NEX, self);
37
38         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
39                 self.ammo_cells = self.ammo_cells - cvar("g_balance_nex_ammo");
40 }
41
42 void spawnfunc_weapon_nex (void); // defined in t_items.qc
43
44 float w_nex(float req)
45 {
46         if (req == WR_AIM)
47                 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
48         else if (req == WR_THINK)
49         {
50                 if (self.BUTTON_ATCK)
51                 {
52                         if (weapon_prepareattack(0, cvar("g_balance_nex_refire")))
53                         {
54                                 W_Nex_Attack();
55                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_animtime"), w_ready);
56                         }
57                 }
58         }
59         else if (req == WR_PRECACHE)
60         {
61                 precache_model ("models/nexflash.md3");
62                 precache_model ("models/weapons/g_nex.md3");
63                 precache_model ("models/weapons/v_nex.md3");
64                 precache_model ("models/weapons/h_nex.iqm");
65                 precache_sound ("weapons/nexfire.wav");
66                 precache_sound ("weapons/nexwhoosh1.wav");
67                 precache_sound ("weapons/nexwhoosh2.wav");
68                 precache_sound ("weapons/nexwhoosh3.wav");
69         }
70         else if (req == WR_SETUP)
71                 weapon_setup(WEP_NEX);
72         else if (req == WR_CHECKAMMO1)
73                 return self.ammo_cells >= cvar("g_balance_nex_ammo");
74         else if (req == WR_CHECKAMMO2)
75                 return FALSE;
76         else if (req == WR_SUICIDEMESSAGE)
77                 w_deathtypestring = "did the impossible";
78         else if (req == WR_KILLMESSAGE)
79                 w_deathtypestring = "has been vaporized by";
80         return TRUE;
81 };
82 #endif