Riding Platforms

      As you now know, id software put up "Players Only" signs all over the place. In other words, entities not class-named "player" cannot use doors, buttons, and such. Well, we're going to undo some of the nefarious id's work. A very short but effective lesson here - how to get your bots using platforms, lifts, etc. Open up plats.qc and find this:


void() plat_center_touch =
{
	if (other.classname != "player")
		return;
		

      and change it to:


void() plat_center_touch =
{
	if (other.classname != "player" && other.classname != "bot") //TutorBot PLATS
		return;
		

      Does this look familiar - yep, it's the old "Player Only" sign on the washroom door again. There's just one more to do and that is where you see:

void() plat_outside_touch =
{
	if (other.classname != "player")
		return;

      and change it to this:


void() plat_outside_touch =
{
	if (other.classname != "player" && other.classname != "bot") //TutorBot PLATS
		return;

      See? That was simple. You can save and close that file and compile away to your hearts content. Or, if you want to make the bots pause when they get on the lift, you can do the following steps.
      We will be working in the same two subroutines. First, go back to plat_center_touch(). Somewhere around the middle, squeeze in this code:

	if (other.classname == "bot" && time > other.pausetime + 5)
		{
		other.pausetime = time + 5;
		other.think = bot_wait1;
		other.nextthink = time + 0.1;
		}

      The platform actually has some AI in it right here. You see, if the bot has not paused recently, the platform actually tells the little guy to execute his waiting sequence. If we didn't check the bot's pausetime, he would loop in this sequence, since he'd always be touching the lift.
      Now go back to plat_outside_touch(). Again, somewheres in the middle, add this again:

	if (other.classname == "bot" && time > other.pausetime + 5)
		{
		other.pausetime = time + 5;
		other.think = bot_wait1;
		other.nextthink = time + 0.1;
		}

      Save and close that file. Since plats.qc comes before tutor.qc in out progs.src file, we will be calling bot_wait1() before we write it. That is a no-no. We must define it first. Thus, open up defs.qc, and at the very, very end, add this:

void() bot_wait1;

      That's done. Finally, open up tutor.qc and slip down to the end of your animation scenes. There, paste this new waiting sequence:

void() bot_wait1		=[	$stand1,	bot_wait2	] {};
void() bot_wait2		=[	$stand2,	bot_wait3	] {};
void() bot_wait3		=[	$stand3,	bot_wait4	] {};
void() bot_wait4		=[	$stand4,	bot_wait5	] {};
void() bot_wait5		=[	$stand5,	bot_wait6	] {};
void() bot_wait6		=[	$stand1,	bot_wait7	] {};
void() bot_wait7		=[	$stand2,	bot_wait8	] {};
void() bot_wait8		=[	$stand3,	bot_wait9	] {};
void() bot_wait9		=[	$stand4,	bot_wait10	] {};
void() bot_wait10		=[	$stand5,	bot_wait10	] {if (self.enemy == world) bot_walk1() else bot_run1();};

      Now he'll stand for one second when he gets on a lift. If he has an enemy, he'll run at the end of this; if not, he'll walk. Feel free to tweak, add, or delete. That's today's lesson.

 

 


What We Learned

1. The Quake engine likes reserving things for Players
2. We can tell it Bots are allowed in too
3. Not everything has to be complicated
4. RiEvEr forgets that he has to write this bit at the end...

 


Author: RiEvEr
Questions: riever@planetquake.com
AI chat on ICQ: 25649000