]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_nex.qc
Merge remote branch 'origin/fruitiex/fruitbalance' into fruitiex/fruitbalance
[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 (float issecondary)
20 {
21         float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, f;
22         if(issecondary)
23         {
24                 mydmg = cvar("g_balance_nex_secondary_damage");
25                 myforce = cvar("g_balance_nex_secondary_force");
26                 mymindist = cvar("g_balance_nex_secondary_damagefalloff_mindist");
27                 mymaxdist = cvar("g_balance_nex_secondary_damagefalloff_maxdist");
28                 myhalflife = cvar("g_balance_nex_secondary_damagefalloff_halflife");
29                 myforcehalflife = cvar("g_balance_nex_secondary_damagefalloff_forcehalflife");
30                 myammo = cvar("g_balance_nex_secondary_ammo");
31         }
32         else
33         {
34                 mydmg = cvar("g_balance_nex_primary_damage");
35                 myforce = cvar("g_balance_nex_primary_force");
36                 mymindist = cvar("g_balance_nex_primary_damagefalloff_mindist");
37                 mymaxdist = cvar("g_balance_nex_primary_damagefalloff_maxdist");
38                 myhalflife = cvar("g_balance_nex_primary_damagefalloff_halflife");
39                 myforcehalflife = cvar("g_balance_nex_primary_damagefalloff_forcehalflife");
40                 myammo = cvar("g_balance_nex_primary_ammo");
41         }
42
43         float flying;
44         flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
45
46         f = ExponentialFalloff(cvar("g_balance_nex_velocitydependent_minspeed"), cvar("g_balance_nex_velocitydependent_maxspeed"), cvar("g_balance_nex_velocitydependent_halflife"), vlen('1 0 0' * self.velocity_x + '0 1 0' * self.velocity_y));
47
48         // TODO: make it more obvious (through effects, indicator on weapon) that damage increases when speed increases
49         mydmg *= f;
50         myforce *= f;
51
52         W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", mydmg);
53
54         yoda = 0;
55         FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_NEX);
56
57         if(yoda && flying)
58                 AnnounceTo(self, "yoda");
59
60         //beam and muzzle flash done on client
61         SendCSQCNexBeamParticle();
62         
63         // flash and burn the wall
64         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
65                 Damage_DamageInfo(trace_endpos, mydmg, 0, 0, myforce * w_shotdir, WEP_NEX, self);
66
67         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
68                 self.ammo_cells = self.ammo_cells - myammo;
69 }
70
71 void spawnfunc_weapon_nex (void); // defined in t_items.qc
72
73 float w_nex(float req)
74 {
75         if (req == WR_AIM)
76         {
77                 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
78                 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 1, FALSE);
79         }
80         else if (req == WR_THINK)
81         {
82                 if (self.BUTTON_ATCK)
83                 {
84                         if (weapon_prepareattack(0, cvar("g_balance_nex_primary_refire")))
85                         {
86                                 W_Nex_Attack(0);
87                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_primary_animtime"), w_ready);
88                         }
89                 }
90                 if (self.BUTTON_ATCK2)
91                 {
92                         if(cvar("g_balance_nex_secondary"))
93                         {
94                                 if (weapon_prepareattack(0, cvar("g_balance_nex_secondary_refire")))
95                                 {
96                                         W_Nex_Attack(1);
97                                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_secondary_animtime"), w_ready);
98                                 }
99                         }
100                 }
101         }
102         else if (req == WR_PRECACHE)
103         {
104                 precache_model ("models/nexflash.md3");
105                 precache_model ("models/weapons/g_nex.md3");
106                 precache_model ("models/weapons/v_nex.md3");
107                 precache_model ("models/weapons/h_nex.iqm");
108                 precache_sound ("weapons/nexfire.wav");
109                 precache_sound ("weapons/nexwhoosh1.wav");
110                 precache_sound ("weapons/nexwhoosh2.wav");
111                 precache_sound ("weapons/nexwhoosh3.wav");
112         }
113         else if (req == WR_SETUP)
114                 weapon_setup(WEP_NEX);
115         else if (req == WR_CHECKAMMO1)
116                 return self.ammo_cells >= cvar("g_balance_nex_primary_ammo");
117         else if (req == WR_CHECKAMMO2)
118                 return self.ammo_cells >= cvar("g_balance_nex_secondary_ammo");
119         return TRUE;
120 };
121 #endif
122 #ifdef CSQC
123 float w_nex(float req)
124 {
125         if(req == WR_IMPACTEFFECT)
126         {
127                 vector org2;
128                 org2 = w_org + w_backoff * 6;
129                 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
130                 if(!w_issilent)
131                         sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
132         }
133         else if(req == WR_PRECACHE)
134         {
135                 precache_sound("weapons/neximpact.wav");
136         }
137         else if (req == WR_SUICIDEMESSAGE)
138                 w_deathtypestring = "%s did the impossible";
139         else if (req == WR_KILLMESSAGE)
140                 w_deathtypestring = "%s has been vaporized by %s";
141         return TRUE;
142 }
143 #endif
144 #endif