24c0af53749b301e482748b89bae76ba8f7af276
[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 #ifdef SVQC
5 void SendCSQCNexBeamParticle() {
6         vector v;
7         v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
8         WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
9         WriteByte(MSG_BROADCAST, TE_CSQC_NEXGUNBEAMPARTICLE);
10         
11         WriteCoord(MSG_BROADCAST, w_shotorg_x);
12         WriteCoord(MSG_BROADCAST, w_shotorg_y);
13         WriteCoord(MSG_BROADCAST, w_shotorg_z);
14         WriteCoord(MSG_BROADCAST, v_x);
15         WriteCoord(MSG_BROADCAST, v_y);
16         WriteCoord(MSG_BROADCAST, v_z);
17 }
18
19 void W_Nex_Attack (void)
20 {
21         float flying;
22         flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
23
24         W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", cvar("g_balance_nex_damage"));
25
26         yoda = 0;
27         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);
28
29         if(yoda && flying)
30                 AnnounceTo(self, "yoda");
31
32         //beam and muzzle flash done on client
33         SendCSQCNexBeamParticle();
34         
35         // flash and burn the wall
36         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
37                 Damage_DamageInfo(trace_endpos, cvar("g_balance_nex_damage"), 0, 0, cvar("g_balance_nex_force") * w_shotdir, WEP_NEX, self);
38
39         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
40                 self.ammo_cells = self.ammo_cells - cvar("g_balance_nex_ammo");
41 }
42
43 void spawnfunc_weapon_nex (void); // defined in t_items.qc
44
45 float w_nex(float req)
46 {
47         if (req == WR_AIM)
48                 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
49         else if (req == WR_THINK)
50         {
51                 if (self.BUTTON_ATCK)
52                 {
53                         if (weapon_prepareattack(0, cvar("g_balance_nex_refire")))
54                         {
55                                 W_Nex_Attack();
56                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_animtime"), w_ready);
57                         }
58                 }
59         }
60         else if (req == WR_PRECACHE)
61         {
62                 precache_model ("models/nexflash.md3");
63                 precache_model ("models/weapons/g_nex.md3");
64                 precache_model ("models/weapons/v_nex.md3");
65                 precache_model ("models/weapons/h_nex.iqm");
66                 precache_sound ("weapons/nexfire.wav");
67                 precache_sound ("weapons/nexwhoosh1.wav");
68                 precache_sound ("weapons/nexwhoosh2.wav");
69                 precache_sound ("weapons/nexwhoosh3.wav");
70         }
71         else if (req == WR_SETUP)
72                 weapon_setup(WEP_NEX);
73         else if (req == WR_CHECKAMMO1)
74                 return self.ammo_cells >= cvar("g_balance_nex_ammo");
75         else if (req == WR_CHECKAMMO2)
76                 return FALSE;
77         else if (req == WR_SUICIDEMESSAGE)
78                 w_deathtypestring = "did the impossible";
79         else if (req == WR_KILLMESSAGE)
80                 w_deathtypestring = "has been vaporized by";
81         return TRUE;
82 };
83 #endif
84 #ifdef CSQC
85 float w_nex(float req)
86 {
87         return TRUE;
88 }
89 #endif
90 #endif