]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_hagar.c
- added wisellama's advanced bash script (nexuiz-linux.sh can now be symlinked to...
[divverent/nexuiz.git] / data / qcsrc / server / gamec / w_hagar.c
1 void() hagar_ready_01;
2 void() hagar_fire1_01;
3 void() hagar_fire2_01;
4 void() hagar_deselect_01;
5 void() hagar_select_01;
6
7 float() hagar_check =
8 {
9         if (self.ammo_rockets >= cvar("g_balance_hagar_primary_ammo"))
10                 return TRUE;
11         return FALSE;
12 };
13
14 float() hagar_check2 =
15 {
16         if (self.ammo_rockets >= cvar("g_balance_hagar_secondary_ammo"))
17                 return TRUE;
18         return FALSE;
19 };
20
21 void(float req) w_hagar =
22 {
23         if (req == WR_IDLE)
24                 hagar_ready_01();
25         else if (req == WR_FIRE1)
26                 weapon_prepareattack(hagar_check, hagar_check, hagar_fire1_01, cvar("g_balance_hagar_primary_refire"));
27         else if (req == WR_FIRE2)
28                 weapon_prepareattack(hagar_check, hagar_check, hagar_fire2_01, cvar("g_balance_hagar_secondary_refire"));
29         else if (req == WR_RAISE)
30                 hagar_select_01();
31         else if (req == WR_UPDATECOUNTS)
32                 self.currentammo = self.ammo_rockets;
33         else if (req == WR_DROP)
34                 hagar_deselect_01();
35         else if (req == WR_SETUP)
36                 weapon_setup(WEP_HAGAR, "w_hagar.zym", IT_ROCKETS);
37         else if (req == WR_CHECKAMMO)
38                 weapon_hasammo = hagar_check() + hagar_check2();
39 };
40
41 void W_Hagar_Explode (void)
42 {
43         vector  org2;
44         float b;
45         org2 = findbetterlocation (self.origin);
46         te_explosion (org2);
47         effect (org2, "models/sprites/hagar.spr", 0, 12, 35);
48         b = crandom();
49         if (b<-0.7)
50                 sound (self, CHAN_BODY, "weapons/hagexp1.ogg", 1, ATTN_NORM);
51         else if (b<0.4)
52                 sound (self, CHAN_BODY, "weapons/hagexp2.ogg", 1, ATTN_NORM);
53         else if (b<1)
54                 sound (self, CHAN_BODY, "weapons/hagexp3.ogg", 1, ATTN_NORM);
55
56         self.event_damage = SUB_Null;
57         RadiusDamage (self, self.owner, cvar("g_balance_hagar_primary_damage"), cvar("g_balance_hagar_primary_edgedamage"), cvar("g_balance_hagar_primary_radius"), world, cvar("g_balance_hagar_primary_force"), IT_HAGAR);
58
59         remove (self);
60 }
61
62 void W_Hagar_Explode2 (void)
63 {
64         vector  org2;
65         float b;
66         org2 = findbetterlocation (self.origin);
67         te_explosion (org2);
68         effect (org2, "models/sprites/hagar.spr", 0, 12, 35);
69         b = crandom();
70         if (b<-0.7)
71                 sound (self, CHAN_BODY, "weapons/hagexp1.ogg", 1, ATTN_NORM);
72         else if (b<0.4)
73                 sound (self, CHAN_BODY, "weapons/hagexp2.ogg", 1, ATTN_NORM);
74         else if (b<1)
75                 sound (self, CHAN_BODY, "weapons/hagexp3.ogg", 1, ATTN_NORM);
76
77         self.event_damage = SUB_Null;
78         RadiusDamage (self, self.owner, cvar("g_balance_hagar_secondary_damage"), cvar("g_balance_hagar_secondary_edgedamage"), cvar("g_balance_hagar_secondary_radius"), world, cvar("g_balance_hagar_secondary_force"), IT_HAGAR);
79
80         remove (self);
81 }
82
83 void W_Hagar_Touch (void)
84 {
85         if (other == self.owner)
86                 return;
87         else if (pointcontents (self.origin) == CONTENT_SKY)
88         {
89                 remove (self);
90                 return;
91         }
92
93         self.think ();
94 }
95
96 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
97 {
98         self.health = self.health - damage;
99         if (self.health <= 0)
100                 self.think ();
101 }
102
103 void W_Hagar_Attack (void)
104 {
105         local entity missile;
106         local vector org;
107
108         local vector trueaim;
109         trueaim = W_TrueAim();
110
111
112         sound (self, CHAN_WEAPON, "weapons/hagar_fire.ogg", 1, ATTN_NORM);
113         if (self.items & IT_STRENGTH) {
114                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
115         }
116
117         if (cvar("g_use_ammunition"))
118                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_primary_ammo");
119         self.punchangle_x = -2;
120         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -8;
121
122         missile = spawn ();
123         missile.owner = self;
124         missile.classname = "missile";
125         missile.touch = W_Hagar_Touch;
126         missile.think = W_Hagar_Explode;
127         missile.nextthink = time + cvar("g_balance_hagar_primary_lifetime");
128         missile.solid = SOLID_BBOX;
129         missile.scale = 0.4; // BUG: the model is too big
130         setorigin (missile, org);
131         setmodel (missile, "models/hagarmissile.mdl");
132         setsize (missile, '0 0 0', '0 0 0');
133         //missile.takedamage = DAMAGE_YES;
134         //missile.damageforcescale = 4;
135         //missile.health = 10;
136         //missile.event_damage = W_Hagar_Damage;
137         missile.effects = EF_LOWPRECISION | EF_NOSHADOW | EF_FULLBRIGHT;
138
139         missile.movetype = MOVETYPE_FLY;
140         missile.velocity = (normalize(trueaim - org) + randomvec() * cvar("g_balance_hagar_primary_spread")) * cvar("g_balance_hagar_primary_speed");
141
142         missile.angles = vectoangles (missile.velocity);
143 }
144
145 void W_Hagar_Attack2 (void)
146 {
147         local entity missile;
148         local vector org;
149
150         local vector trueaim;
151         trueaim = W_TrueAim();
152
153
154         sound (self, CHAN_WEAPON, "weapons/hagar_fire.ogg", 1, ATTN_NORM);
155         if (self.items & IT_STRENGTH) {
156                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
157         }
158
159         if (cvar("g_use_ammunition"))
160                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_secondary_ammo");
161         self.punchangle_x = -2;
162         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -8;
163
164         missile = spawn ();
165         missile.owner = self;
166         missile.classname = "missile";
167         missile.touch = W_Hagar_Touch;
168         missile.think = W_Hagar_Explode;
169         missile.nextthink = time + cvar("g_balance_hagar_secondary_lifetime");
170         missile.solid = SOLID_BBOX;
171         missile.scale = 0.4; // BUG: the model is too big
172         setorigin (missile, org);
173         setmodel (missile, "models/hagarmissile.mdl");
174         setsize (missile, '0 0 0', '0 0 0');
175         //missile.takedamage = DAMAGE_YES;
176         //missile.damageforcescale = 4;
177         //missile.health = 10;
178         //missile.event_damage = W_Hagar_Damage;
179         missile.effects = EF_LOWPRECISION | EF_NOSHADOW | EF_FULLBRIGHT;
180
181         missile.movetype = MOVETYPE_TOSS;
182         missile.velocity = (v_forward + randomvec() * cvar("g_balance_hagar_secondary_spread")) * cvar("g_balance_hagar_secondary_speed") + v_up * cvar("g_balance_hagar_secondary_speed_up");
183         missile.avelocity = '100 10 10';
184
185         missile.angles = vectoangles (missile.velocity);
186 }
187
188 // weapon frames
189 void()  hagar_ready_01 =        {weapon_thinkf(WFRAME_IDLE, 0.1, hagar_ready_01); self.weaponentity.state = WS_READY;};
190 void()  hagar_select_01 =       {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
191 void()  hagar_deselect_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
192 void()  hagar_fire1_01 =
193 {
194         self.attack_finished = time + cvar("g_balance_hagar_primary_refire");
195         weapon_doattack(hagar_check, hagar_check, W_Hagar_Attack);
196         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_primary_refire"), hagar_ready_01);
197 };
198 void()  hagar_fire2_01 =
199 {
200         self.attack_finished = time + cvar("g_balance_hagar_secondary_refire");
201         weapon_doattack(hagar_check, hagar_check, W_Hagar_Attack2);
202         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_secondary_refire"), hagar_ready_01);
203 };
204