]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_rocketlauncher.c
fix two rocket launcher kill bugs detailed in the thread http://www.nexuiz.com/forums...
[divverent/nexuiz.git] / qcsrc / gamec / w_rocketlauncher.c
1 void() rlauncher_ready_01;
2 void() rlauncher_fire1_01;
3 void() rlauncher_deselect_01;
4 void() rlauncher_select_01;
5
6 float() rlauncher_check =
7 {
8         if (self.ammo_rockets >= 3)
9                 return TRUE;
10         return FALSE;
11 };
12
13 void(float req) w_rlauncher =
14 {
15         if (req == WR_IDLE)
16                 rlauncher_ready_01();
17         else if (req == WR_FIRE1)
18                 weapon_prepareattack(rlauncher_check, rlauncher_check, rlauncher_fire1_01, cvar("g_balance_rocketlauncher_refire"));
19         else if (req == WR_RAISE)
20                 rlauncher_select_01();
21         else if (req == WR_UPDATECOUNTS)
22                 self.currentammo = self.ammo_rockets;
23         else if (req == WR_DROP)
24                 rlauncher_deselect_01();
25         else if (req == WR_SETUP)
26                 weapon_setup(WEP_ROCKET_LAUNCHER, "w_rl.zym", IT_ROCKETS);
27         else if (req == WR_CHECKAMMO)
28                 weapon_hasammo = rlauncher_check();
29 };
30
31
32 void W_Rocket_Explode (void)
33 {
34         vector  org2;
35         org2 = findbetterlocation (self.origin);
36         te_explosion (org2);
37         effect (org2, "models/sprites/rocketexplosion.spr32", 0, 26, 30);
38         sound (self, CHAN_BODY, "weapons/rocket_impact.wav", 1, ATTN_NORM);
39
40         self.event_damage = SUB_Null;
41         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);
42
43         remove (self);
44 }
45
46 void W_Rocket_Think (void)
47 {
48         self.nextthink = time;
49         if (time > self.cnt)
50         {
51                 W_Rocket_Explode ();
52                 return;
53         }
54         if (self.owner.weapon == WEP_ROCKET_LAUNCHER)
55         if (self.owner.button3)
56                 W_Rocket_Explode ();
57 }
58
59 void W_Rocket_Touch (void)
60 {
61         if (pointcontents (self.origin) == CONTENT_SKY)
62         {
63                 remove (self);
64                 return;
65         }
66         else
67                 W_Rocket_Explode ();
68 }
69
70 void W_Rocket_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
71 {
72         self.health = self.health - damage;
73         if (self.health <= 0)
74                 W_Rocket_Explode();
75 }
76
77 void W_Rocket_Attack (void)
78 {
79         local entity missile;
80         local entity flash;
81         local vector org;
82         sound (self, CHAN_WEAPON, "weapons/rocket_fire.wav", 1, ATTN_NORM);
83         if (cvar("g_rocketarena") == 0)
84                 self.ammo_rockets = self.ammo_rockets - 3;
85         self.punchangle_x = -4;
86         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 3 + v_up * -11;
87         te_smallflash(org);
88
89         missile = spawn ();
90         missile.owner = self;
91         missile.classname = "missile";
92
93         missile.takedamage = DAMAGE_YES;
94         missile.damageforcescale = 4;
95         missile.health = 30;
96         missile.event_damage = W_Rocket_Damage;
97
98         missile.movetype = MOVETYPE_FLY;
99         missile.solid = SOLID_BBOX;
100         setmodel (missile, "models/rocket.md3");
101         setsize (missile, '0 0 0', '0 0 0');
102
103         setorigin (missile, org);
104         missile.velocity = v_forward * cvar("g_balance_rocketlauncher_speed");
105         missile.angles = vectoangles (missile.velocity);
106
107         missile.touch = W_Rocket_Touch;
108         missile.think = W_Rocket_Think;
109         missile.nextthink = time;
110         missile.cnt = time + 9;
111         sound (missile, CHAN_BODY, "weapons/rocket_fly.wav", 0.4, ATTN_NORM);
112
113         flash = spawn ();
114         setorigin (flash, org);
115         setmodel (flash, "models/flash.md3");
116         flash.velocity = v_forward * 20;
117         flash.angles = vectoangles (flash.velocity);
118         SUB_SetFade (flash, time, 0.4);
119         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT;
120 }
121
122 // weapon frames
123
124 void()  rlauncher_ready_01 =    {weapon_thinkf(WFRAME_IDLE, 0.1, rlauncher_ready_01); self.weaponentity.state = WS_READY;};
125 void()  rlauncher_select_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
126 void()  rlauncher_deselect_01 = {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
127 void()  rlauncher_fire1_01 =
128 {
129         weapon_doattack(rlauncher_check, rlauncher_check, W_Rocket_Attack);
130         weapon_thinkf(WFRAME_FIRE1, 0.3, rlauncher_ready_01);
131 };
132