]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_rocketlauncher.c
Some changes to the grenade launcher and shotgun that weren't my changes
[divverent/nexuiz.git] / qcsrc / gamec / w_rocketlauncher.c
1 void() rlauncher_ready_01;
2 void() rlauncher_fire1_01;
3 void() rlauncher_fire2_01;
4 void() rlauncher_deselect_01;
5 void() rlauncher_select_01;
6 void() W_Rocket_Attack2;
7
8 float() rlauncher_check = 
9 {
10         if (self.ammo_rockets > 0) 
11                 return TRUE; 
12         return FALSE;
13 };
14
15 void(float req) w_rlauncher =
16 {
17         if (req == WR_IDLE)
18                 rlauncher_ready_01();
19         else if (req == WR_FIRE1)
20                 weapon_prepareattack(rlauncher_check, rlauncher_check, rlauncher_fire1_01, 1.5);
21         else if (req == WR_FIRE2)
22         {
23                 if (time < self.attack_finished)
24                         W_Rocket_Attack2();
25         }
26         else if (req == WR_RAISE)
27                 rlauncher_select_01();
28         else if (req == WR_UPDATECOUNTS)
29                 self.currentammo = self.ammo_rockets;
30         else if (req == WR_DROP)
31                 rlauncher_deselect_01();
32         else if (req == WR_SETUP)
33                 weapon_setup(WEP_ROCKET_LAUNCHER, "w_rl.zym", IT_ROCKETS);
34         else if (req == WR_CHECKAMMO)
35                 weapon_hasammo = rlauncher_check();
36 };               
37
38
39 void W_Rocket_Explode (entity ignore)
40 {
41         ImpactEffect (self, IT_ROCKET_LAUNCHER);
42
43         self.event_damage = nullfunction;
44         RadiusDamage (self, self.owner, 130, 50, 170, ignore, 600, IT_ROCKET_LAUNCHER);
45
46         remove (self);
47 }
48
49 void W_Rocket_Think (void)
50 {
51         W_Rocket_Explode (world);
52 }
53
54 void W_Rocket_Touch (void)
55 {
56         if (other == self.owner)
57                 return;
58         else if (pointcontents (self.origin) == CONTENT_SKY)
59         {
60                 remove (self);
61                 return;
62         }
63         else
64                 W_Rocket_Explode (world);
65 }
66
67 void W_Rocket_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
68 {
69         self.health = self.health - damage;
70         if (self.health <= 0)
71                 W_Rocket_Explode(world);
72 }
73
74 void W_Rocket_Attack (void)
75 {
76         entity  missile;
77         vector  org;
78         makevectors (self.v_angle);
79         sound (self, CHAN_WEAPON, "weapons/rocket_fire.wav", 1, ATTN_NORM);
80
81         missile = spawn ();
82         missile.owner = self;
83         missile.classname = "missile";
84
85         missile.takedamage = DAMAGE_YES;
86         missile.damageforcescale = 4;
87         missile.health = 10;
88         missile.event_damage = W_Rocket_Damage;
89
90         missile.movetype = MOVETYPE_FLY;
91         missile.solid = SOLID_BBOX;
92         setmodel (missile, "models/rocketmissile.mdl");
93         setsize (missile, '0 0 0', '0 0 0');
94
95         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 3 + v_up * -11;
96
97         setorigin (missile, org);
98         missile.velocity = v_forward * 850;
99         missile.angles = vectoangles (missile.velocity);
100
101         missile.touch = W_Rocket_Touch ;
102         missile.think = W_Rocket_Think;
103         missile.nextthink = time + 9;
104
105         self.attack_finished = time + 1.5;
106
107         if (!(game & GAME_ROCKET_ARENA))
108                 self.ammo_rockets = self.ammo_rockets - 1;
109
110         entity  flash;
111         flash = spawn ();
112         //flash.drawonlytoclient;
113         setorigin (flash, org);
114         setmodel (flash, "models/flash.md3");
115         flash.velocity = v_forward * 20;
116         flash.angles = vectoangles (flash.velocity);
117         SUB_SetFade (flash, time);
118         flash.effects = flash.effects | EF_ADDITIVE;
119 }
120
121 void W_Rocket_Attack2 (void)
122 {
123         entity  proj;
124         proj = findradius (self.origin, 50000);
125         while (proj)
126         {
127                 if (proj.classname == "missile" && proj.owner == self)
128                 {
129                         proj.nextthink = time;
130                 }
131                 proj = proj.chain;
132         }
133
134         self.attack_finished = time + 0.1;
135 }
136
137 // weapon frames 
138
139 void()  rlauncher_ready_01 =    {weapon_thinkf(WFRAME_IDLE, 0.1, rlauncher_ready_01); self.weaponentity.state = WS_READY;};
140 void()  rlauncher_select_01 =   {weapon_thinkf(-1, PLAYER_WEAPONSELECTION_DELAY, w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
141 void()  rlauncher_deselect_01 = {weapon_thinkf(-1, PLAYER_WEAPONSELECTION_DELAY, w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
142 void()  rlauncher_fire1_01 =    
143 {
144         weapon_doattack(rlauncher_check, rlauncher_check, W_Rocket_Attack);
145         weapon_thinkf(WFRAME_FIRE1, 0.3, rlauncher_ready_01);
146 };
147 void()  rlauncher_fire2_01 =    
148 {
149         weapon_doattack(rlauncher_check, rlauncher_check, W_Rocket_Attack2);
150         weapon_thinkf(WFRAME_FIRE2, 0.3, rlauncher_ready_01);
151 };