======================================================================= Title : Lob AI (version 1.1) Date Finished : 4 - 20 - 1997 Author : Patrick Martin Email Address : cmarti39@icon.net Misc. Author Info : I like Doom][ and QUAKE. Description: Below is a source code example of an alternative monster AI for lobbing grenades and other similar projectiles such as gibs. The following code will let ogres or zombies lob their projectiles at a standing target ANYWHERE within a radius of 1000 with frightening accuracy. Feel free to cut-and-paste this code into your projects. OGRE.QC (or ZOMBIE.QC) (All the changes will be made in the function void() OgreFireGrenade = or equivalent in other qc files. After the line local entity missile, mpuff; insert the following code...) //-------------------------------------------------------- New Code -------- local float dist; // Distance between attacker and target. local float base; // This dictates how fast the projectile // will fly up when it is launched. local float g; // Gravity -- g = 1 is Earth gravity. //------------------------------------------------------// // 800 is normal (Earth) gravity. 800 * 0.00125 = 1. // //------------------------------------------------------// g = (cvar("sv_gravity")) * 0.00125; // Find gravity in terms of g. //-------------------------------------------------------------------------- (Then, replace the following line missile.velocity_z = 200; with the code below...) //-------------------------------------------------------- New Code -------- dist = vlen(self.enemy.origin - self.origin); //--------------------------------------------------------------// // The monster will lob a projectile that is guaranteed to hit // // a stationary target within a radius of 1000. If the target // // is moving, it may aim the projectile a bit lower to counter // // any attempt to run underneath the grenade. // // //--------------------------------------------------------------// if (self.enemy.velocity_x || self.enemy.velocity_y) if (random() < 0.9) dist = dist - random()*300; if (dist > 900) base = 200+((dist - (200 - (dist * 0.2)))*0.5); else if (dist > 700) base = 200+((dist - (200 - (dist * 0.15)))*0.5); else if (dist > 500) base = 200+((dist - (200 - (dist * 0.1)))*0.5); else if (dist > 200) base = 200+((dist - 200)*0.5); else base = 200; missile.velocity_z = (missile.velocity_z + (base * g)); //---------------------------------------------------------------- END -----