]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_hagar.qc
make the remainign weapons csqc projectiles
[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_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
10         else if (b<0.4)
11                 sound (self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
12         else if (b<1)
13                 sound (self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
14
15         self.event_damage = SUB_Null;
16         RadiusDamage (self, self.realowner, 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"), self.projectiledeathtype, other);
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_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
30         else if (b<0.4)
31                 sound (self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
32         else if (b<1)
33                 sound (self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
34
35         self.event_damage = SUB_Null;
36         RadiusDamage (self, self.realowner, 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"), self.projectiledeathtype, other);
37
38         remove (self);
39 }
40
41 void W_Hagar_Touch (void)
42 {
43         PROJECTILE_TOUCH;
44         self.use ();
45 }
46
47 void W_Hagar_Touch2 (void)
48 {
49         PROJECTILE_TOUCH;
50
51         if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
52                 self.use();
53         } else {
54                 self.cnt++;
55                 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
56                 self.angles = vectoangles (self.velocity);
57                 self.owner = world;
58                 self.projectiledeathtype |= HITTYPE_BOUNCE;
59         }
60
61         if(trace_ent && trace_ent.solid > SOLID_TRIGGER) // CSQC doesn't know about these entities well enough
62                 UpdateCSQCProjectile(self);
63 }
64
65 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
66 {
67         self.health = self.health - damage;
68         if (self.health <= 0)
69                 W_PrepareExplosionByDamage(attacker, self.think);
70 }
71
72 void W_Hagar_Attack (void)
73 {
74         local entity missile;
75
76         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
77                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_primary_ammo");
78         W_SetupShot (self, '25 5 -8', FALSE, 2, "weapons/hagar_fire.wav");
79         //W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/hagar_fire.wav"); // TODO: move model a little to the right
80
81         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
82
83         missile = spawn ();
84         missile.owner = missile.realowner = self;
85         missile.classname = "missile";
86         missile.bot_dodge = TRUE;
87         missile.bot_dodgerating = cvar("g_balance_hagar_primary_damage");
88         missile.touch = W_Hagar_Touch;
89         missile.use = W_Hagar_Explode;
90         missile.think = adaptor_think2use;
91         missile.nextthink = time + cvar("g_balance_hagar_primary_lifetime");
92         missile.solid = SOLID_BBOX;
93         missile.scale = 0.4; // BUG: the model is too big
94         missile.projectiledeathtype = WEP_HAGAR;
95         setorigin (missile, w_shotorg);
96         setmodel (missile, "models/hagarmissile.mdl"); // precision set below
97         setsize (missile, '0 0 0', '0 0 0');
98         //missile.takedamage = DAMAGE_YES;
99         //missile.damageforcescale = 4;
100         //missile.health = 10;
101         //missile.event_damage = W_Hagar_Damage;
102         missile.effects = EF_LOWPRECISION;
103         missile.modelflags = MF_GRENADE;
104
105         missile.movetype = MOVETYPE_FLY;
106         missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_primary_spread")) * cvar("g_balance_hagar_primary_speed");
107         W_SetupProjectileVelocity(missile);
108
109         missile.angles = vectoangles (missile.velocity);
110         missile.flags = FL_PROJECTILE;
111
112         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR);
113 }
114
115 void W_Hagar_Attack2 (void)
116 {
117         local entity missile;
118
119         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
120                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_secondary_ammo");
121         W_SetupShot (self, '25 5 -8', FALSE, 2, "weapons/hagar_fire.wav");
122         //W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/hagar_fire.wav"); // TODO: move model a little to the right
123
124         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
125
126         missile = spawn ();
127         missile.owner = missile.realowner = self;
128         missile.classname = "missile";
129         missile.bot_dodge = TRUE;
130         missile.bot_dodgerating = cvar("g_balance_hagar_secondary_damage");
131         missile.touch = W_Hagar_Touch2;
132         missile.cnt = 0;
133         missile.use = W_Hagar_Explode;
134         missile.think = adaptor_think2use;
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         missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
139         setorigin (missile, w_shotorg);
140         setmodel (missile, "models/hagarmissile.mdl"); // precision set below
141         setsize (missile, '0 0 0', '0 0 0');
142         //missile.takedamage = DAMAGE_YES;
143         //missile.damageforcescale = 4;
144         //missile.health = 10;
145         //missile.event_damage = W_Hagar_Damage;
146         missile.effects = EF_LOWPRECISION;
147         missile.modelflags = MF_GRENADE;
148
149         missile.movetype = MOVETYPE_BOUNCEMISSILE;
150         missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_secondary_spread")) * cvar("g_balance_hagar_secondary_speed");
151         W_SetupProjectileVelocity(missile);
152         missile.avelocity = '100 10 10';
153
154         missile.angles = vectoangles (missile.velocity);
155         missile.flags = FL_PROJECTILE;
156
157         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING);
158 }
159
160 void spawnfunc_weapon_hagar (void)
161 {
162         weapon_defaultspawnfunc(WEP_HAGAR);
163 }
164
165 float w_hagar(float req)
166 {
167         if (req == WR_AIM)
168                 if (random()>0.15)
169                         self.BUTTON_ATCK = bot_aim(cvar("g_balance_hagar_primary_speed"), 0, cvar("g_balance_hagar_primary_lifetime"), FALSE);
170                 else
171                 {
172                         // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
173                         self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_hagar_primary_speed"), 0, cvar("g_balance_hagar_primary_lifetime"), FALSE);
174                 }
175         else if (req == WR_THINK)
176         {
177                 if (self.BUTTON_ATCK)
178                 if (weapon_prepareattack(0, cvar("g_balance_hagar_primary_refire")))
179                 {
180                         W_Hagar_Attack();
181                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_primary_refire"), w_ready);
182                 }
183                 if (self.BUTTON_ATCK2)
184                 if (weapon_prepareattack(1, cvar("g_balance_hagar_secondary_refire")))
185                 {
186                         W_Hagar_Attack2();
187                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_secondary_refire"), w_ready);
188                 }
189         }
190         else if (req == WR_PRECACHE)
191         {
192                 precache_model ("models/hagarmissile.mdl");
193                 precache_model ("models/weapons/g_hagar.md3");
194                 precache_model ("models/weapons/v_hagar.md3");
195                 precache_model ("models/weapons/w_hagar.zym");
196                 precache_sound ("weapons/hagar_fire.wav");
197                 precache_sound ("weapons/hagexp1.wav");
198                 precache_sound ("weapons/hagexp2.wav");
199                 precache_sound ("weapons/hagexp3.wav");
200         }
201         else if (req == WR_SETUP)
202                 weapon_setup(WEP_HAGAR);
203         else if (req == WR_CHECKAMMO1)
204                 return self.ammo_rockets >= cvar("g_balance_hagar_primary_ammo");
205         else if (req == WR_CHECKAMMO2)
206                 return self.ammo_rockets >= cvar("g_balance_hagar_secondary_ammo");
207         else if (req == WR_SUICIDEMESSAGE)
208                 w_deathtypestring = "played with tiny rockets";
209         else if (req == WR_KILLMESSAGE)
210         {
211                 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
212                         w_deathtypestring = "hoped #'s missiles wouldn't bounce";
213                 else // unchecked: SPLASH, SECONDARY
214                         w_deathtypestring = "was pummeled by";
215         }
216         return TRUE;
217 };