Inside3D tutorials.

Inside3D
 • Front Page
 • Articles
 • Downloads
 • Forums
 • Hosting
 • Help Wanted
 • Interviews
 • Reviews
 • Staff

 
Allied Sites
 - AI Cafe
 - Bot Epidemic
 - Dark Places
 - Flat Earth
 - FrikBot
 - Ghoulish Art
 - Kilbert3D
 - Quake Info Pool
 - QSG: Quake Standards
 - Rusted Fork
 - Stroggs Gone Mad
 - More...
 
Quake
 - Getting Started
 - QuakeC Specs v1.0
 - QuakeC Tutorials
 - Quake Mod Index
 
Quake II
 - Getting Started
 - dll Sourcecode
 - Coding Tutorials
 
.dll Central
 - Getting Started
 - Learning
 - dll Primer
 - dll in C
 - dll in Delphi
 - Compilers
 
Jedi Knight
 - Getting Started
 - COG Specs
 - Sound Specs
 - Tutorials
 
Level Editing
 - Tutorials/Tips
 
 
Telefragged!!!
Created By: Malcolm Lim
eMail: mlbl@botepidemic.com
Difficulty Scale: Medium
Web Page: http://www.botepidemic.com/udm/


Here's a tutorial that will enable the bot model to "yaw" like a real player, i.e : when an enemy is on a higher level on top of the bot, the gun model will point at the enemy instead of just pointing straight forward. This was once a feature that Steven Polge wanted to implement before he went to work for Epic.

Step 1 :
Open up the file ai.qc. Paste this function at the end of the file :
/*
===========
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;
};

Step 2 :
Open up the file botthink.qc. Go to the function BotPostThink. Put in these code right above that function :
// 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();
};

Step 3 :
Now all we need to do is make a call to the function so place this piece of code inside the BotPostThink function, below the "local float fraglimit;" :

checkyaw ();

There you go ! You're done , save the files and recompile. You'll only notice the bot model yaw when you're an observer, a good map to see this happen is on maps like dm4, dm6, etc. Have fun !







The Inside3D content and design is copyrighted by the Inside3D team, and may not be re-produced or copied without proper consent. All rights reserved. Any work credited to any author not part of InsideQC is copyrighted by that author. If you have any feedback, suggestions or flames please send it in to the author. Inside3D is hosted by telefragged and the design was originated by project-9.