]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_hagar.qc
new: sv_vote_majority_factor
[divverent/nexuiz.git] / data / qcsrc / server / w_hagar.qc
1 void W_Hagar_Explode (void)
2 {
3         vector  org2;
4         float b;
5         org2 = findbetterlocation (self.origin, 12);
6         pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
7         b = crandom();
8         if (b<-0.7)
9                 sound (self, CHAN_BODY, "weapons/hagexp1.wav", 1, ATTN_NORM);
10         else if (b<0.4)
11                 sound (self, CHAN_BODY, "weapons/hagexp2.wav", 1, ATTN_NORM);
12         else if (b<1)
13                 sound (self, CHAN_BODY, "weapons/hagexp3.wav", 1, ATTN_NORM);
14
15         self.event_damage = SUB_Null;
16         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);
17
18         remove (self);
19 }
20
21 void W_Hagar_Explode2 (void)
22 {
23         vector  org2;
24         float b;
25         org2 = findbetterlocation (self.origin, 12);
26         pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
27         b = crandom();
28         if (b<-0.7)
29                 sound (self, CHAN_BODY, "weapons/hagexp1.wav", 1, ATTN_NORM);
30         else if (b<0.4)
31                 sound (self, CHAN_BODY, "weapons/hagexp2.wav", 1, ATTN_NORM);
32         else if (b<1)
33                 sound (self, CHAN_BODY, "weapons/hagexp3.wav", 1, ATTN_NORM);
34
35         self.event_damage = SUB_Null;
36         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);
37
38         remove (self);
39 }
40
41 void W_Hagar_Touch (void)
42 {
43         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
44         {
45                 remove(self);
46                 return;
47         }
48         if (other == self.owner)
49                 return;
50
51         self.think ();
52 }
53
54 void W_Hagar_Touch2 (void)
55 {
56         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
57         {
58                 remove(self);
59                 return;
60         }
61
62         if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
63                 self.think();
64         } else {
65                 self.cnt++;
66                 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
67         }
68 }
69
70 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
71 {
72         self.health = self.health - damage;
73         if (self.health <= 0)
74                 self.think ();
75 }
76
77 void W_Hagar_Attack (void)
78 {
79         local entity missile;
80
81         if (cvar("g_use_ammunition"))
82                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_primary_ammo");
83         W_SetupShot (self, '25 5 -8', FALSE, 2, "weapons/hagar_fire.wav");
84         //W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/hagar_fire.wav"); // TODO: move model a little to the right
85
86         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
87
88         missile = spawn ();
89         missile.owner = self;
90         missile.classname = "missile";
91         missile.bot_dodge = TRUE;
92         missile.bot_dodgerating = cvar("g_balance_hagar_primary_damage");
93         missile.touch = W_Hagar_Touch;
94         missile.think = W_Hagar_Explode;
95         missile.nextthink = time + cvar("g_balance_hagar_primary_lifetime");
96         missile.solid = SOLID_BBOX;
97         missile.scale = 0.4; // BUG: the model is too big
98         setorigin (missile, w_shotorg);
99         setmodel (missile, "models/hagarmissile.mdl"); // precision set below
100         setsize (missile, '0 0 0', '0 0 0');
101         //missile.takedamage = DAMAGE_YES;
102         //missile.damageforcescale = 4;
103         //missile.health = 10;
104         //missile.event_damage = W_Hagar_Damage;
105         missile.effects = EF_LOWPRECISION;
106         missile.modelflags = MF_GRENADE;
107
108         missile.movetype = MOVETYPE_FLY;
109         missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_primary_spread")) * cvar("g_balance_hagar_primary_speed");
110         W_SetupProjectileVelocity(missile);
111
112         missile.angles = vectoangles (missile.velocity);
113         missile.flags = FL_PROJECTILE;
114 }
115
116 void W_Hagar_Attack2 (void)
117 {
118         local entity missile;
119
120         if (cvar("g_use_ammunition"))
121                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_secondary_ammo");
122         W_SetupShot (self, '25 5 -8', FALSE, 2, "weapons/hagar_fire.wav");
123         //W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/hagar_fire.wav"); // TODO: move model a little to the right
124
125         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
126
127         missile = spawn ();
128         missile.owner = self;
129         missile.classname = "missile";
130         missile.bot_dodge = TRUE;
131         missile.bot_dodgerating = cvar("g_balance_hagar_secondary_damage");
132         missile.touch = W_Hagar_Touch2;
133         missile.cnt = 0;
134         missile.think = W_Hagar_Explode;
135         missile.nextthink = time + cvar("g_balance_hagar_secondary_lifetime");
136         missile.solid = SOLID_BBOX;
137         missile.scale = 0.4; // BUG: the model is too big
138         setorigin (missile, w_shotorg);
139         setmodel (missile, "models/hagarmissile.mdl"); // precision set below
140         setsize (missile, '0 0 0', '0 0 0');
141         //missile.takedamage = DAMAGE_YES;
142         //missile.damageforcescale = 4;
143         //missile.health = 10;
144         //missile.event_damage = W_Hagar_Damage;
145         missile.effects = EF_LOWPRECISION;
146         missile.modelflags = MF_GRENADE;
147
148         missile.movetype = MOVETYPE_BOUNCEMISSILE;
149         missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_secondary_spread")) * cvar("g_balance_hagar_secondary_speed");
150         W_SetupProjectileVelocity(missile);
151         missile.avelocity = '100 10 10';
152
153         missile.angles = vectoangles (missile.velocity);
154         missile.flags = FL_PROJECTILE;
155 }
156
157 float(float req) w_hagar =
158 {
159         if (req == WR_AIM)
160                 if (random()>0.15)
161                         self.button0 = bot_aim(cvar("g_balance_hagar_primary_speed"), 0, cvar("g_balance_hagar_primary_lifetime"), FALSE);
162                 else
163                 {
164                         // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
165                         self.button3 = bot_aim(cvar("g_balance_hagar_primary_speed"), 0, cvar("g_balance_hagar_primary_lifetime"), FALSE);
166                 }
167         else if (req == WR_THINK)
168         {
169                 if (self.button0)
170                 if (weapon_prepareattack(0, cvar("g_balance_hagar_primary_refire")))
171                 {
172                         W_Hagar_Attack();
173                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_primary_refire"), w_ready);
174                 }
175                 if (self.button3)
176                 if (weapon_prepareattack(1, cvar("g_balance_hagar_secondary_refire")))
177                 {
178                         W_Hagar_Attack2();
179                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_secondary_refire"), w_ready);
180                 }
181         }
182         else if (req == WR_PRECACHE)
183         {
184                 precache_model ("models/hagarmissile.mdl");
185                 precache_model ("models/weapons/g_hagar.md3");
186                 precache_model ("models/weapons/v_hagar.md3");
187                 precache_model ("models/weapons/w_hagar.zym");
188                 precache_sound ("weapons/hagar_fire.wav");
189                 precache_sound ("weapons/hagexp1.wav");
190                 precache_sound ("weapons/hagexp2.wav");
191                 precache_sound ("weapons/hagexp3.wav");
192         }
193         else if (req == WR_SETUP)
194                 weapon_setup(WEP_HAGAR, "hagar", IT_ROCKETS);
195         else if (req == WR_CHECKAMMO1)
196                 return self.ammo_rockets >= cvar("g_balance_hagar_primary_ammo");
197         else if (req == WR_CHECKAMMO2)
198                 return self.ammo_rockets >= cvar("g_balance_hagar_secondary_ammo");
199         else if (req == WR_REGISTER)
200                 weapon_register(WEP_HAGAR, min(cvar("g_balance_hagar_primary_ammo"), cvar("g_balance_hagar_secondary_ammo")));
201         return TRUE;
202 };