Helper Bots  v1-01-2000  Release 1  RTCM W0rm

Introduction | What is a Helper Bot | Tough to Create a Helper Bot | Make it Look Like a Helper Bot | Main Problems

Introduction

Many people seem to want to be able to create helper bots for duke3d.
I considered adding them to WIG-CONS, but I didn't because they were far too crude to use.
If you wish to create your own helper bots I can give you some suggestions. There are several bugs with the ones I have currently made - several big bugs...

What the heck is a helper bot?

A helper bot is a computer controlled player in duke3d intended to help duke. This means that it will have to point at and shoot other monsters, and be able to follow duke around wherever he goes.

Why is it so tough to create a helper bot?

Unfortunately, duke was not created to have helper bots. There are no commands to have any actors (AI) face/attack monsters. There are also no commands for these actors to know if there is a monster near, only when duke is near. Another huge problem is that the way for an actor to detect an obstacle such as a wall or stairs to get up is "ifawayfromwall" which barely works. Not only does this command not know which are 'stairs' and which are walls (so it can't tell walls from sector splits), but even if it is beside the wall or staircase (facing away or along it) it will still think that it is facing the wall/staircase. You can probably tell this is not the best means of creating helper AI.

Is there any way to make it look like it is a helper bot?

Yes! You can simply 'fake' a helper bot. As I said just before, you can have the actors see what duke is doing, so we can use this to our advantage. See what I mean below! Note that I simply wrote this up without testing, it may have errors.
A main thing that can be used for a helper bot is "ifnotmoving", much better than ifawayfromwall. This is useful for knowing if there is some sort of obstacle in the way, it is used by monsters to test for doors/elevators and such. This could be used to have the bot follow duke in a smart way.

What are the main problems not completely worked out?

Would have to be having the bot shoot at other monsters. If you've tried to make a helper bot you've probably realized that the "shoot" command automatically shoots weapons towards duke. This can be surprisingly easily overcome. Creating a new actor using the rpg tiles as an example, you can give it an ai to fire straight ahead of the helper bot who would shoot it. So it would basically spawn the missile which would use a "move" to fly straight, when it hits a monster or wall, "ifnotmoving" could be used to set it off. Why did I mention this as a problem? Because there is still no way to know where a monster is located to shoot at him! I still haven't figured that out either, but now you have a cure to the "shoot" command if you didn't before.

Let's set up the different AI functions...

move hbmove 150
move hbfall 150 100
move hbfly 150 -150
ai AIHELPERFACESAME HBSTAND randomangle
ai AIHELPERWALK HBWALK hbmove
ai AIHELPERFLY HBJETPACK hbfly
ai AIHELPERFALL HBJETPACK hbfall
ai AIHELPERDODGE HBWALK 200 dodgebullet
ai AIHELPERFOLLOW HBWALK 150 seekplayer
ai AIHBSPIN HBWALK 150 spin

Later in the code of the actor:

ifai AIHELPERFACESAME // AI to make H.B. face same direction as duke.
{
ifangdiffl 200 // bot is facing same direction as duke?
ifpdistl 5000 // if duke is close
ai AIHELPERWALK // then walk..
else // but if he's not close...
ai AIHELPERFOLLOW // then get closer
}

ifp phigher // if duke is higher than H.B.
ai AIHELPERFLY // fly above him
else // otherwise
ifnotmoving // if H.B. is stuck
ifrnd 5 // if random number is less than 5
operate // try to active a door/elevator
else // if random number is not less than 5
ifrnd 5 // if random number is less than 5
ai AIHBSPIN // run in a circle.

ifai AIHELPERFLY
{
ifp phigher // if duke is still higher
nullop // keep going up
else // otherwise
ai AIHELPERFALL // drop!
}

ifai AIHELPERFALL
{
iffloordistl 10 // if H.B. is touching the floor
ai AIHELPERFACESAME // run and face the same direction code
else // otherwise
nullop // keep falling
}

I will continue the code another time.