]> icculus.org git repositories - divverent/nexuiz.git/blob - TeamNexuiz/game/gamec/w_rocketlauncher.c
now menu qc respects g_campaign_name
[divverent/nexuiz.git] / TeamNexuiz / game / gamec / w_rocketlauncher.c
1 void() rlauncher_ready_01;\r
2 void() rlauncher_fire1_01;\r
3 void() rlauncher_deselect_01;\r
4 void() rlauncher_select_01;\r
5 \r
6 float() rlauncher_check =\r
7 {\r
8         if (self.ammo_rockets >= 3)\r
9                 return TRUE;\r
10         return FALSE;\r
11 };\r
12 \r
13 void(float req) w_rlauncher =\r
14 {\r
15         if (req == WR_IDLE)\r
16                 rlauncher_ready_01();\r
17         else if (req == WR_FIRE1)\r
18                 weapon_prepareattack(rlauncher_check, rlauncher_check, rlauncher_fire1_01, cvar("g_balance_rocketlauncher_refire"));\r
19         else if (req == WR_RAISE)\r
20                 rlauncher_select_01();\r
21         else if (req == WR_UPDATECOUNTS)\r
22                 self.currentammo = floor(self.ammo_rockets / 3);\r
23         else if (req == WR_DROP)\r
24                 rlauncher_deselect_01();\r
25         else if (req == WR_SETUP)\r
26                 weapon_setup(WEP_ROCKET_LAUNCHER, "w_rl.zym", IT_ROCKETS);\r
27         else if (req == WR_CHECKAMMO)\r
28                 weapon_hasammo = rlauncher_check();\r
29 };\r
30 \r
31 \r
32 void W_Rocket_Explode (void)\r
33 {\r
34         vector  org2;\r
35         sound (self, CHAN_BODY, "weapons/rocket_impact.ogg", 1, ATTN_NORM);\r
36         org2 = findbetterlocation (self.origin);\r
37         te_explosion (org2);\r
38         effect (org2, "models/sprites/rockexpl.spr", 0, 12, 35);\r
39         self.event_damage = SUB_Null;\r
40         RadiusDamage (self, self.owner, cvar("g_balance_rocketlauncher_damage"), cvar("g_balance_rocketlauncher_edgedamage"), cvar("g_balance_rocketlauncher_radius"), world, cvar("g_balance_rocketlauncher_force"), IT_ROCKET_LAUNCHER);\r
41 \r
42         if (self.owner.weapon == WEP_ROCKET_LAUNCHER)\r
43         {\r
44                 if(cvar("g_homing_missile"))\r
45                                   self.owner.attack_finished = time + cvar("g_balance_rocketlauncher_refire");\r
46         }\r
47         remove (self);\r
48 }\r
49 \r
50 void W_Rocket_Think (void)\r
51 {\r
52         self.nextthink = time;\r
53         if (time > self.cnt)\r
54         {\r
55                 W_Rocket_Explode ();\r
56                 return;\r
57         }\r
58         if (self.owner)\r
59         {\r
60                 if (self.owner.deadflag)\r
61                         self.owner = self;\r
62                 else if (self.owner.wpn == WEP_ROCKET_LAUNCHER && self.owner.button3)\r
63                         W_Rocket_Explode ();\r
64         }\r
65 }\r
66 \r
67 void W_Rocket_Touch (void)\r
68 {\r
69         if (pointcontents (self.origin) == CONTENT_SKY)\r
70         {\r
71                 remove (self);\r
72                 return;\r
73         }\r
74         else\r
75                 W_Rocket_Explode ();\r
76 }\r
77 \r
78 void W_Rocket_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)\r
79 {\r
80         self.health = self.health - damage;\r
81         if (self.health <= 0)\r
82                 W_Rocket_Explode();\r
83 }\r
84 \r
85 void W_Rocket_Attack (void)\r
86 {\r
87         local entity missile;\r
88         local entity flash;\r
89         local vector org;\r
90         local vector end;\r
91         \r
92         local vector trueaim;\r
93         org = self.origin + self.view_ofs;\r
94         end = self.origin + self.view_ofs + v_forward * 4096;\r
95         traceline(org,end,TRUE,self);\r
96         trueaim = trace_endpos;\r
97         \r
98         sound (self, CHAN_WEAPON, "weapons/rocket_fire.ogg", 1, ATTN_NORM);\r
99         if (self.items & IT_STRENGTH) {\r
100                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);\r
101         }\r
102         \r
103         if (cvar("g_use_ammunition") && !cvar("g_rocketarena"))\r
104                 self.ammo_rockets = self.ammo_rockets - 3;\r
105         self.punchangle_x = -4;\r
106         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 3 + v_up * -11;\r
107         te_smallflash(org);\r
108 \r
109         missile = spawn ();\r
110         missile.owner = self;\r
111         missile.classname = "missile";\r
112 \r
113         missile.takedamage = DAMAGE_YES;\r
114         missile.damageforcescale = 4;\r
115         missile.health = 30;\r
116         missile.event_damage = W_Rocket_Damage;\r
117 \r
118         missile.movetype = MOVETYPE_FLY;\r
119         missile.solid = SOLID_BBOX;\r
120         setmodel (missile, "models/rocket.md3");\r
121         setsize (missile, '0 0 0', '0 0 0');\r
122 \r
123         setorigin (missile, org);\r
124         missile.velocity = normalize(trueaim - org) * cvar("g_balance_rocketlauncher_speed");\r
125         missile.angles = vectoangles (missile.velocity);\r
126 \r
127         missile.touch = W_Rocket_Touch;\r
128         missile.think = W_Rocket_Think;\r
129         missile.nextthink = time;\r
130         missile.cnt = time + 9;\r
131         sound (missile, CHAN_BODY, "weapons/rocket_fly.ogg", 0.4, ATTN_NORM);\r
132 \r
133         flash = spawn ();\r
134         setorigin (flash, org);\r
135         setmodel (flash, "models/flash.md3");\r
136         flash.velocity = v_forward * 20;\r
137         flash.angles = vectoangles (flash.velocity);\r
138         SUB_SetFade (flash, time, 0.4);\r
139         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;\r
140         self.clip_rockets = self.clip_rockets - 1;\r
141         if (self.clip_rockets == 0)\r
142         {\r
143                 DoReload (3, 4);        // weapon type 3 is RL, and reload 4 rockets.\r
144         }\r
145 }\r
146 \r
147 // weapon frames\r
148 \r
149 void()  rlauncher_ready_01 =    {weapon_thinkf(WFRAME_IDLE, 0.1, rlauncher_ready_01); self.weaponentity.state = WS_READY;};\r
150 void()  rlauncher_select_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};\r
151 void()  rlauncher_deselect_01 = {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};\r
152 void()  rlauncher_fire1_01 =\r
153 {\r
154         weapon_doattack(rlauncher_check, rlauncher_check, W_Rocket_Attack);\r
155         weapon_thinkf(WFRAME_FIRE1, 0.3, rlauncher_ready_01);\r
156 };\r
157 \r