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