distance-based nex damage falloff option (not used in any config yet)
[divverent/nexuiz.git] / data / qcsrc / server / w_nex.qc
1 void SendCSQCNexBeamParticle() {
2         WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
3         WriteByte(MSG_BROADCAST, TE_CSQC_NEXGUNBEAMPARTICLE);
4         
5         WriteCoord(MSG_BROADCAST, w_shotorg_x);
6         WriteCoord(MSG_BROADCAST, w_shotorg_y);
7         WriteCoord(MSG_BROADCAST, w_shotorg_z);
8         WriteCoord(MSG_BROADCAST, trace_endpos_x);
9         WriteCoord(MSG_BROADCAST, trace_endpos_y);
10         WriteCoord(MSG_BROADCAST, trace_endpos_z);
11 }
12
13 void W_Nex_Attack (void)
14 {
15         float flying;
16         flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
17
18         W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", cvar("g_balance_nex_damage"));
19
20         yoda = 0;
21         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"), WEP_NEX);
22
23         if(yoda && flying)
24                 announce(self, "announcer/male/yoda.wav");
25
26         //beam and muzzle flash done on client
27         SendCSQCNexBeamParticle();
28         
29         // flash and burn the wall
30         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
31                 Damage_DamageInfo(trace_endpos, cvar("g_balance_nex_damage"), 0, 0, cvar("g_balance_nex_force") * w_shotdir, WEP_NEX, self);
32
33         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
34                 self.ammo_cells = self.ammo_cells - cvar("g_balance_nex_ammo");
35 }
36
37 void spawnfunc_weapon_nex (void); // defined in t_items.qc
38
39 float w_nex(float req)
40 {
41         if (req == WR_AIM)
42                 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
43         else if (req == WR_THINK)
44         {
45                 if (self.BUTTON_ATCK)
46                 {
47                         if (weapon_prepareattack(0, cvar("g_balance_nex_refire")))
48                         {
49                                 W_Nex_Attack();
50                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_animtime"), w_ready);
51                         }
52                 }
53         }
54         else if (req == WR_PRECACHE)
55         {
56                 precache_model ("models/nexflash.md3");
57                 precache_model ("models/weapons/g_nex.md3");
58                 precache_model ("models/weapons/v_nex.md3");
59                 precache_model ("models/weapons/h_nex.dpm");
60                 precache_sound ("weapons/nexfire.wav");
61                 precache_sound ("weapons/nexwhoosh1.wav");
62                 precache_sound ("weapons/nexwhoosh2.wav");
63                 precache_sound ("weapons/nexwhoosh3.wav");
64         }
65         else if (req == WR_SETUP)
66                 weapon_setup(WEP_NEX);
67         else if (req == WR_CHECKAMMO1)
68                 return self.ammo_cells >= cvar("g_balance_nex_ammo");
69         else if (req == WR_CHECKAMMO2)
70                 return FALSE;
71         else if (req == WR_SUICIDEMESSAGE)
72                 w_deathtypestring = "did the impossible";
73         else if (req == WR_KILLMESSAGE)
74                 w_deathtypestring = "has been vaporized by";
75         return TRUE;
76 };