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