Inside3D tutorials.
Created By: | Malcolm Lim |
eMail: | mlbl@botepidemic.com |
Difficulty Scale: | Medium |
Web Page: | http://www.botepidemic.com/udm/ |
/* =========== ChangePitch CN_PATCH Turns towards self.ideal_pitch at 6 degree chunks. Used by Eliminator Bot. Sets the global variable current_pitch ============ */ void() ChangePitch = { local float ideal, move; current_pitch = self.angles_x; ideal = self.ideal_pitch; // only allow movement to within 54 degrees if (ideal > 54) ideal = 54; else if (ideal < -54) ideal = -54; if (current_pitch == ideal) return; move = ideal - current_pitch; if (move > 0) { if (move > 6) move = 6; } else { if (move < -6 ) move = -6; } current_pitch = current_pitch + move; self.angles_x = current_pitch; };
// Code from Eliminator Bot by Cameron Newham void() checkyaw = { local vector los; local vector los_angles; local float o_range; local float missile_factor; local vector spotty_squid; // adds a tiny random for stationary targets local string st; o_range = vlen(self.enemy.origin - self.origin); if ((self.weapon == IT_ROCKET_LAUNCHER) || (self.weapon == IT_NAILGUN) || (self.weapon == IT_SUPER_NAILGUN)) missile_factor = o_range / (1900 + random() * 700); // add scatter else if (self.weapon == IT_GRENADE_LAUNCHER) missile_factor = o_range / (1000 + random() * 50); // add scatter else missile_factor = 0; //other weapons are instantaneous // apply a small randomiser of the distance is large if (o_range > 300) spotty_squid = ('9 9 8') * (random() - 0.5); else spotty_squid = '0 0 0'; // Face bot towards the specified angles los = self.enemy.origin - self.origin + self.enemy.velocity*missile_factor + spotty_squid; los_angles = vectoangles (los); self.ideal_pitch = los_angles_x; if (self.ideal_pitch > 180) self.ideal_pitch = self.ideal_pitch - 360; //stupid id mistake ChangePitch(); };