Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
wallabra

The Start of a New Bot - Simple item desire code

Recommended Posts

GusDoomScript is a mix of UnrealScript and DECORATE.
The following is a basic bot AI which causes bots to seek for items if their desire match. I'll use it as a starting point for a new Doom bot that surprises Cajun for eternity.

var	Inventory	A;
var()	float		ItemDesire;
var()   Array           DesireItems(Inventory, 128);

DoomDecorate 
{
	actor DoomBot : ScriptedMarine
	{
	States
		{
			Spawn:
                                goto Idle
                        Idle:
				PLAY AB 4 A_FindItems
				PLAY AB 2 A_MarineNoise
				PLAY AB 3 A_JumpIfInventory(CloseItem, 5, "ItemTargetAcquired"")
				PLAY AB 3 A_PlaySound (Bots/ThinkingHmm)
				PLAY ABABABAB 2 A_Wander
				loop
			ItemTargetAcquired:
				PLAY A 3 A_SetTarget(A_FindItems.Found)
				PLAY BA 5 A_ChaseItem(Inventory(Target))
                                PLAY B 3 A_JumpIfNotExist(Target, "Idle")
                                loop
		}
	}
}

decorate function A_FindItems()
{
	local var Found;

	foreach AllThings(class<Inventory>, A)
	{
		if( A.Desireability * ItemDesire > DesireThreshold && DesireItems op_contains A )
		{
			Found = A;
			Caller.Give(CloseItem, A.Desireabiliy * ItemDesire);
		}
	}
}

decorate function A_SetTarget(actor NewTarget)
{
	Caller.Target = NewTarget;
}

Share this post


Link to post
Gustavo6046 said:

PS: How an actual bot works?


Usually, the bot will inject commands into the Doom event buffer for the player it controls. The most common bots in Doom just plop basic nodes everywhere and have bots running around at random while instantly locking on to any nearby enemies. The better bots will take the node builder data to build a navigation mesh of a level so routes to objects may be traversed (so the bots actually can explore). Then you will need lots of gamestate probing such as if a door is open, a monster is awake, something is in the way of the bot, the weapons and items a bot has, etc.

Share this post


Link to post

Or you can put special pathnode actors.

actor PathNode
{
  States
  {
    Spawn:
      TNT1 A -1
      Stop
  }
}

actor InventorySpot : PathNode 
{
}

actor InvActors : Inventory replaces Inventory
{
  {
    Spawn:
      TNT1 A 1 A_Spawn (InventorySpot)
      TNT1 A -1
      Stop
  }
}
The compiled C++ code will tell the bot to seek for InventorySpot actors and nearby monsters and PlayerPawns if they are on a different team. Also it will press use upon UseNode and slow down upon SlowNode and that cool stuff.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×