]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_rocketlauncher.c
implemented rocket and electro fly sounds
[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, 20, 40);
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)
55         {
56                 if (self.owner.deadflag)
57                         self.owner = self;
58                 else if (self.owner.weapon == WEP_ROCKET_LAUNCHER && self.owner.button3)
59                         W_Rocket_Explode ();
60         }
61 }
62
63 void W_Rocket_Touch (void)
64 {
65         if (pointcontents (self.origin) == CONTENT_SKY)
66         {
67                 remove (self);
68                 return;
69         }
70         else
71                 W_Rocket_Explode ();
72 }
73
74 void W_Rocket_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
75 {
76         self.health = self.health - damage;
77         if (self.health <= 0)
78                 W_Rocket_Explode();
79 }
80
81 void W_Rocket_Attack (void)
82 {
83         local entity missile;
84         local entity flash;
85         local vector org;
86         sound (self, CHAN_WEAPON, "weapons/rocket_fire.wav", 1, ATTN_NORM);
87         if (cvar("g_rocketarena") == 0)
88                 self.ammo_rockets = self.ammo_rockets - 3;
89         self.punchangle_x = -4;
90         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 3 + v_up * -11;
91         te_smallflash(org);
92
93         missile = spawn ();
94         missile.owner = self;
95         missile.classname = "missile";
96
97         missile.takedamage = DAMAGE_YES;
98         missile.damageforcescale = 4;
99         missile.health = 30;
100         missile.event_damage = W_Rocket_Damage;
101
102         missile.movetype = MOVETYPE_FLY;
103         missile.solid = SOLID_BBOX;
104         setmodel (missile, "models/rocket.md3");
105         setsize (missile, '0 0 0', '0 0 0');
106
107         setorigin (missile, org);
108         missile.velocity = v_forward * cvar("g_balance_rocketlauncher_speed");
109         missile.angles = vectoangles (missile.velocity);
110
111         missile.touch = W_Rocket_Touch;
112         missile.think = W_Rocket_Think;
113         missile.nextthink = time;
114         missile.cnt = time + 9;
115         sound (missile, CHAN_BODY, "weapons/rocket_fly.wav", 0.4, ATTN_NORM);
116
117         flash = spawn ();
118         setorigin (flash, org);
119         setmodel (flash, "models/flash.md3");
120         flash.velocity = v_forward * 20;
121         flash.angles = vectoangles (flash.velocity);
122         SUB_SetFade (flash, time, 0.4);
123         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT;
124 }
125
126 // weapon frames
127
128 void()  rlauncher_ready_01 =    {weapon_thinkf(WFRAME_IDLE, 0.1, rlauncher_ready_01); self.weaponentity.state = WS_READY;};
129 void()  rlauncher_select_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
130 void()  rlauncher_deselect_01 = {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
131 void()  rlauncher_fire1_01 =
132 {
133         weapon_doattack(rlauncher_check, rlauncher_check, W_Rocket_Attack);
134         weapon_thinkf(WFRAME_FIRE1, 0.3, rlauncher_ready_01);
135 };
136