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