]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_hagar.qc
fix sound spam issue with projectiles stuck on jumppads
[divverent/nexuiz.git] / data / qcsrc / server / w_hagar.qc
1 // NO bounce protection, as bounces are limited!
2 void W_Hagar_Explode (void)
3 {
4         self.event_damage = SUB_Null;
5         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);
6
7         remove (self);
8 }
9
10 void W_Hagar_Explode2 (void)
11 {
12         self.event_damage = SUB_Null;
13         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);
14
15         remove (self);
16 }
17
18 void W_Hagar_Touch (void)
19 {
20         PROJECTILE_TOUCH;
21         self.use ();
22 }
23
24 void W_Hagar_Touch2 (void)
25 {
26         PROJECTILE_TOUCH;
27
28         if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
29                 self.use();
30         } else {
31                 self.cnt++;
32                 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
33                 self.angles = vectoangles (self.velocity);
34                 self.owner = world;
35                 self.projectiledeathtype |= HITTYPE_BOUNCE;
36         }
37 }
38
39 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
40 {
41         self.health = self.health - damage;
42         if (self.health <= 0)
43                 W_PrepareExplosionByDamage(attacker, self.think);
44 }
45
46 void W_Hagar_Attack (void)
47 {
48         local entity missile;
49
50         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
51                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_primary_ammo");
52         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav");
53
54         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
55
56         missile = spawn ();
57         missile.owner = missile.realowner = self;
58         missile.classname = "missile";
59         missile.bot_dodge = TRUE;
60         missile.bot_dodgerating = cvar("g_balance_hagar_primary_damage");
61         missile.touch = W_Hagar_Touch;
62         missile.use = W_Hagar_Explode;
63         missile.think = adaptor_think2use;
64         missile.nextthink = time + cvar("g_balance_hagar_primary_lifetime");
65         missile.solid = SOLID_BBOX;
66         missile.projectiledeathtype = WEP_HAGAR;
67         setorigin (missile, w_shotorg);
68         //missile.takedamage = DAMAGE_YES;
69         //missile.damageforcescale = 4;
70         //missile.health = 10;
71         //missile.event_damage = W_Hagar_Damage;
72
73         missile.movetype = MOVETYPE_FLY;
74         missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_primary_spread")) * cvar("g_balance_hagar_primary_speed");
75         W_SetupProjectileVelocity(missile);
76
77         missile.angles = vectoangles (missile.velocity);
78         missile.flags = FL_PROJECTILE;
79
80         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
81 }
82
83 void W_Hagar_Attack2 (void)
84 {
85         local entity missile;
86
87         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
88                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_secondary_ammo");
89         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav");
90         //W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav"); // TODO: move model a little to the right
91
92         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
93
94         missile = spawn ();
95         missile.owner = missile.realowner = self;
96         missile.classname = "missile";
97         missile.bot_dodge = TRUE;
98         missile.bot_dodgerating = cvar("g_balance_hagar_secondary_damage");
99         missile.touch = W_Hagar_Touch2;
100         missile.cnt = 0;
101         missile.use = W_Hagar_Explode;
102         missile.think = adaptor_think2use;
103         missile.nextthink = time + cvar("g_balance_hagar_secondary_lifetime");
104         missile.solid = SOLID_BBOX;
105         missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
106         setorigin (missile, w_shotorg);
107         //missile.takedamage = DAMAGE_YES;
108         //missile.damageforcescale = 4;
109         //missile.health = 10;
110         //missile.event_damage = W_Hagar_Damage;
111
112         missile.movetype = MOVETYPE_BOUNCEMISSILE;
113         missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_secondary_spread")) * cvar("g_balance_hagar_secondary_speed");
114         W_SetupProjectileVelocity(missile);
115         missile.avelocity = '100 10 10';
116
117         missile.angles = vectoangles (missile.velocity);
118         missile.flags = FL_PROJECTILE;
119
120         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
121 }
122
123 void spawnfunc_weapon_hagar (void)
124 {
125         weapon_defaultspawnfunc(WEP_HAGAR);
126 }
127
128 float w_hagar(float req)
129 {
130         if (req == WR_AIM)
131                 if (random()>0.15)
132                         self.BUTTON_ATCK = bot_aim(cvar("g_balance_hagar_primary_speed"), 0, cvar("g_balance_hagar_primary_lifetime"), FALSE);
133                 else
134                 {
135                         // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
136                         self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_hagar_primary_speed"), 0, cvar("g_balance_hagar_primary_lifetime"), FALSE);
137                 }
138         else if (req == WR_THINK)
139         {
140                 if (self.BUTTON_ATCK)
141                 if (weapon_prepareattack(0, cvar("g_balance_hagar_primary_refire")))
142                 {
143                         W_Hagar_Attack();
144                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_primary_refire"), w_ready);
145                 }
146                 if (self.BUTTON_ATCK2)
147                 if (weapon_prepareattack(1, cvar("g_balance_hagar_secondary_refire")))
148                 {
149                         W_Hagar_Attack2();
150                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_hagar_secondary_refire"), w_ready);
151                 }
152         }
153         else if (req == WR_PRECACHE)
154         {
155                 precache_model ("models/weapons/g_hagar.md3");
156                 precache_model ("models/weapons/v_hagar.md3");
157                 precache_model ("models/weapons/h_hagar.dpm");
158                 precache_sound ("weapons/hagar_fire.wav");
159         }
160         else if (req == WR_SETUP)
161                 weapon_setup(WEP_HAGAR);
162         else if (req == WR_CHECKAMMO1)
163                 return self.ammo_rockets >= cvar("g_balance_hagar_primary_ammo");
164         else if (req == WR_CHECKAMMO2)
165                 return self.ammo_rockets >= cvar("g_balance_hagar_secondary_ammo");
166         else if (req == WR_SUICIDEMESSAGE)
167                 w_deathtypestring = "played with tiny rockets";
168         else if (req == WR_KILLMESSAGE)
169         {
170                 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
171                         w_deathtypestring = "hoped #'s missiles wouldn't bounce";
172                 else // unchecked: SPLASH, SECONDARY
173                         w_deathtypestring = "was pummeled by";
174         }
175         return TRUE;
176 };