]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_hagar.c
Updating
[divverent/nexuiz.git] / qcsrc / gamec / w_hagar.c
1 void() hagar_ready_01;
2 void() hagar_fire1_01;
3 void() hagar_fire2_01;
4 void() hagar_fire3_01;
5 void() hagar_deselect_01;
6 void() hagar_select_01;
7
8 float() hagar_check = 
9 {
10         if (self.ammo_rockets > 0) 
11                 return TRUE; 
12         return FALSE;
13 };
14
15 void(float req) w_hagar =
16 {
17         if (req == WR_IDLE)
18                 hagar_ready_01();
19         else if (req == WR_FIRE1)
20                 weapon_prepareattack(hagar_check, hagar_check, hagar_fire1_01, 0.2);
21         else if (req == WR_FIRE2)
22                 weapon_prepareattack(hagar_check, hagar_check, hagar_fire2_01, 0.2);
23         else if (req == WR_FIRE3)
24                 weapon_prepareattack(hagar_check, hagar_check, hagar_fire3_01, 0);
25         else if (req == WR_RAISE)
26                 hagar_select_01();
27         else if (req == WR_UPDATECOUNTS)
28                 self.currentammo = self.ammo_rockets;
29         else if (req == WR_DROP)
30                 hagar_deselect_01();
31         else if (req == WR_SETUP)
32                 weapon_setup(WEP_HAGAR, "w_hagar.zym", IT_ROCKETS);
33         else if (req == WR_CHECKAMMO)
34                 weapon_hasammo = hagar_check();
35 };               
36
37 void W_Hagar_Explode (void)
38 {
39         ImpactEffect (self, IT_HAGAR);
40
41         self.event_damage = SUB_Null;
42         RadiusDamage (self, self.owner, 40, 15, 70, world, 100, IT_HAGAR);
43
44         remove (self);
45 }
46
47 void W_Hagar_Touch (void)
48 {
49         if (other == self.owner)
50                 return;
51         else if (pointcontents (self.origin) == CONTENT_SKY)
52         {
53                 remove (self);
54                 return;
55         }
56
57         W_Hagar_Explode ();
58 }
59
60 void W_Hagar_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
61 {
62         self.health = self.health - damage;
63         if (self.health <= 0)
64                 W_Hagar_Explode();
65 }
66
67 void W_Hagar_Attack (void)
68 {
69         entity  missile;
70
71         makevectors(self.v_angle);
72         sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);
73
74         missile = spawn ();
75         missile.owner = self;
76         missile.classname = "missile";
77
78         missile.takedamage = DAMAGE_YES;
79         missile.damageforcescale = 4;
80         missile.health = 10;
81         missile.event_damage = W_Hagar_Damage;
82
83         missile.movetype = MOVETYPE_FLY;
84         missile.solid = SOLID_BBOX;
85         setmodel (missile, "models/hagarmissile.mdl");
86         setsize (missile, '0 0 0', '0 0 0');
87
88         setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
89
90         missile.velocity = v_forward * 2000;
91         missile.velocity = missile.velocity + v_right * ( crandom() * 70 );
92         missile.velocity = missile.velocity + v_up * ( crandom() * 30 );
93         missile.angles = vectoangles (missile.velocity);
94         setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
95
96         missile.touch = W_Hagar_Touch;
97         missile.think = W_Hagar_Explode;
98         missile.nextthink = time + 10;
99
100         self.attack_finished = time + 0.2;
101         self.ammo_rockets = self.ammo_rockets - 0.25;
102 }
103
104 void W_Hagar_Attack2 (void)
105 {
106         entity  missile;
107
108         sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);
109
110         makevectors(self.v_angle);
111
112         missile = spawn ();
113         missile.owner = self;
114         missile.classname = "missile";
115
116         missile.movetype = MOVETYPE_TOSS;
117         missile.solid = SOLID_BBOX;
118
119         missile.takedamage = DAMAGE_YES;
120         missile.damageforcescale = 4;
121         missile.health = 5;
122         missile.event_damage = W_Hagar_Damage;
123
124         setmodel (missile, "models/hagarmissile.mdl");
125         setsize (missile, '-6 -6 -3', '6 6 3');
126
127         setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
128
129         missile.velocity = v_forward * 1400 + v_up * 100;
130         missile.angles = vectoangles (missile.velocity);
131         missile.avelocity = '100 10 10';
132
133         missile.touch = W_Hagar_Touch;
134         missile.think = W_Hagar_Explode;
135         missile.nextthink = time + 10;
136
137         self.attack_finished = time + 0.2;
138         self.ammo_rockets = self.ammo_rockets - 0.25;
139 }
140
141 void W_Hagar_Attack3 (void)
142 {
143         entity  proj;
144         makevectors(self.v_angle);
145         proj = findradius (self.origin, 50000);
146         while (proj)
147         {
148                 if (proj.classname == "missile" && proj.owner == self)
149                 {
150                         proj.velocity = proj.velocity - v_up * 500;
151                         proj.velocity = proj.velocity - v_forward * 1000;
152                 }
153                 proj = proj.chain;
154         }
155
156         self.attack_finished = time;
157 }
158
159
160 // weapon frames 
161 void()  hagar_ready_01 =        {weapon_thinkf(WFRAME_IDLE, 0.1, hagar_ready_01); self.weaponentity.state = WS_READY;};
162 void()  hagar_select_01 =       {weapon_thinkf(-1, 0.3, w_ready); weapon_boblayer1(16, '0 0 0');};
163 void()  hagar_deselect_01 =     {weapon_thinkf(-1, 0.3, w_clear); weapon_boblayer1(16, '0 20 -40');};
164 void()  hagar_fire1_01 =        
165 {
166         weapon_doattack(hagar_check, hagar_check, W_Hagar_Attack);
167         weapon_thinkf(WFRAME_FIRE1, 0.15, hagar_ready_01);
168 };
169 void()  hagar_fire2_01 =        
170 {
171         weapon_doattack(hagar_check, hagar_check, W_Hagar_Attack2);
172         weapon_thinkf(WFRAME_FIRE2, 0.15, hagar_ready_01);
173 };
174 void()  hagar_fire3_01 =        
175 {
176         weapon_doattack(hagar_check, hagar_check, W_Hagar_Attack3);
177         weapon_thinkf(WFRAME_FIRE2, 0.15, hagar_ready_01);
178 };
179