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