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