]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_nex.c
additional stuffcmd for player name change
[divverent/nexuiz.git] / qcsrc / gamec / w_nex.c
1 void() nex_ready_01;
2 void() nex_fire1_01;
3 void() nex_deselect_01;
4 void() nex_select_01;
5
6 float() nex_check =
7 {
8         if (self.ammo_cells >= 5)
9                 return TRUE;
10         return FALSE;
11 };
12
13 void(float req) w_nex =
14 {
15         if (req == WR_IDLE)
16                 nex_ready_01();
17         else if (req == WR_FIRE1)
18                 weapon_prepareattack(nex_check, nex_check, nex_fire1_01, cvar("g_balance_nex_refire"));
19         else if (req == WR_RAISE)
20                 nex_select_01();
21         else if (req == WR_UPDATECOUNTS)
22                 self.currentammo = self.ammo_cells;
23         else if (req == WR_DROP)
24                 nex_deselect_01();
25         else if (req == WR_SETUP)
26                 weapon_setup(WEP_NEX, "w_nex.zym", IT_CELLS);
27         else if (req == WR_CHECKAMMO)
28                 weapon_hasammo = nex_check();
29 };
30
31
32 void W_Nex_Attack (void)
33 {
34         local vector org;
35         local vector end;
36         local entity flash;
37
38         sound (self, CHAN_WEAPON, "weapons/nexfire.wav", 1, ATTN_NORM);
39         self.punchangle_x = -5;
40         org = self.origin + self.view_ofs + v_forward * 5 + v_right * 14 + v_up * -7;
41         end = self.origin + self.view_ofs + v_forward * 4096;
42
43         FireRailgunBullet (org, end, cvar("g_balance_nex_damage"), IT_NEX);
44
45         // trace as if shot started inside gun
46         traceline (org, end, TRUE, self);
47         // show as if shot started outside of gun
48         org = self.origin + self.view_ofs + v_forward * 28 + v_right * 14 + v_up * -7;
49         // muzzleflash light
50         te_smallflash (org);
51         // beam effect
52         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
53         WriteByte (MSG_BROADCAST, 76);
54         WriteCoord (MSG_BROADCAST, org_x);
55         WriteCoord (MSG_BROADCAST, org_y);
56         WriteCoord (MSG_BROADCAST, org_z);
57         WriteCoord (MSG_BROADCAST, trace_endpos_x);
58         WriteCoord (MSG_BROADCAST, trace_endpos_y);
59         WriteCoord (MSG_BROADCAST, trace_endpos_z);
60         WriteCoord (MSG_BROADCAST, 0);
61         WriteCoord (MSG_BROADCAST, 0);
62         WriteCoord (MSG_BROADCAST, 0);
63         // flash and burn the wall
64         te_plasmaburn (trace_endpos);
65         /*
66         // flame effect at impact
67         dir = trace_plane_normal * 100;
68         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
69         WriteByte (MSG_BROADCAST, TE_FLAMEJET);
70         WriteCoord (MSG_BROADCAST, trace_endpos_x);
71         WriteCoord (MSG_BROADCAST, trace_endpos_y);
72         WriteCoord (MSG_BROADCAST, trace_endpos_z);
73         WriteCoord (MSG_BROADCAST, dir_x);
74         WriteCoord (MSG_BROADCAST, dir_y);
75         WriteCoord (MSG_BROADCAST, dir_z);
76         WriteByte (MSG_BROADCAST, 255);
77         */
78         // play a sound
79         PointSound (trace_endpos, "weapons/neximpact.wav", 1, ATTN_NORM);
80
81         if (cvar("g_instagib") == 0)
82                 self.ammo_cells = self.ammo_cells - 5;
83
84         flash = spawn ();
85         org = self.origin + self.view_ofs + v_forward * 33 + v_right * 14 + v_up * -7;
86         setorigin (flash, org);
87         setmodel (flash, "models/nexflash.md3");
88         flash.velocity = v_forward * 20;
89         flash.angles = vectoangles (flash.velocity);
90         SUB_SetFade (flash, time, 0.4);
91         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT;
92 }
93
94 // weapon frames
95 void()  nex_ready_01 =  {weapon_thinkf(WFRAME_IDLE, 0.1, nex_ready_01); self.weaponentity.state = WS_READY;};
96 void()  nex_select_01 = {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
97 void()  nex_deselect_01 =       {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
98 void()  nex_fire1_01 =
99 {
100         weapon_doattack(nex_check, nex_check, W_Nex_Attack);
101         weapon_thinkf(WFRAME_FIRE1, 0.3, nex_ready_01);
102 };
103