.:: Bots United ::.  
filebase forums irc server wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps waypoints yapb

Go Back   .:: Bots United ::. > Developer's Farm > SDK Programming discussions > Half-Life 1 SDK
Half-Life 1 SDK For developments focused around Half-Life (and its mods) Half-Life

Reply
 
Thread Tools
TFC - Teleporters?
Old
  (#1)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default TFC - Teleporters? - 02-10-2005

Does anyone know a reliable way to find a teleporter entrance/exit's owner?
Or how to find a teleporter entrance's exit point?

I read in an archived post from the old hpb bot forums ( somewhere, found it while looking on google ) and someone said that engineer's buildings do not have pev->owner set.

If this is the case, how can we tell who a teleporter belongs to?
I have an idea but its a really big hack...

When the teleporter entity is created...

- Find entities in a small sphere around the teleporter
- Is it an engineer?
- Do the team colors match up?
- Is the engineer's pev->viewmodel cleared?
- Found the owner and the teleporter entrance.

For the exit its basically the same thing but I'd have to check for entity removals as well.
This could cause problems if two engineers build teleporters around the same time close together so thats why I'm asking if there is a better way.
  
Reply With Quote
Re: TFC - Teleporters?
Old
  (#2)
DrEvil
Member
 
DrEvil's Avatar
 
Status: Offline
Posts: 142
Join Date: Jan 2004
Location: Los Angeles, CA
Default Re: TFC - Teleporters? - 03-10-2005

Here's some of my old code from foxbot. If you want to see more you can download the source at foxbot.net

Code:
struct teleport_info_t {
	int iEntranceWaypointIndex;
	int iExitWaypointIndex;
	int iFinalGoal;
	edict_t *pEntrance;
	edict_t *pExit;
	edict_t *pOwner;
	bool bIsUsed;
};

bool BotFindTeleportShortCut(bot_t *pBot)
{
	// This bots team.
	int team = UTIL_GetTeam(pBot->pEdict);
	edict_t *pent = NULL;
	bool bExists;

	// List of friendly teleport owners to this bot.
	std::list<teleport_info_t> teleportOwners;
	std::list<teleport_info_t>::iterator iter;
	teleport_info_t tempTPinfo;

	// Don't do this if the bot has the flag.
	if(pBot->bot_has_flag)
		return false;

	// Search for teleporters.	
	while ((pent = FIND_ENTITY_BY_CLASSNAME(pent, "building_teleporter")) && !FNullEnt(pent))
	{
		bExists = false;

    	// Look to see if there is already a teleport_info for this owner.		
		for (iter = teleportOwners.begin(); iter != teleportOwners.end(); ++iter)
		{		
			// Already exists?
			if ((*iter).pOwner == pent->v.euser1)
			{
				// It's already been made.
				bExists = true;

				// Fill in the appropriate slot
    		    if(pent->v.iuser1 == W_FL_TFC_TELEPORTER_ENTRANCE)
				{
					iter->pEntrance = pent;
    		    	iter->iEntranceWaypointIndex = WaypointFindNearest(pent, 300, -1);
				} 
    			else if(pent->v.iuser1 == W_FL_TFC_TELEPORTER_EXIT)
				{
					iter->pExit = pent;
    		    	iter->iExitWaypointIndex = WaypointFindNearest(pent, 300, -1);
				}
			}
		}

		// Only if it wasn't found above.
		if(!bExists)
		{
			// Set tp info to initial state
			tempTPinfo.bIsUsed = false;
			tempTPinfo.iEntranceWaypointIndex = tempTPinfo.iExitWaypointIndex = -1;
			tempTPinfo.pEntrance = tempTPinfo.pExit = NULL;

			// Make sure the owner is the proper team.
			if (team != UTIL_GetTeam(pent->v.euser1))
				continue;

			// Fill in the appropriate slot
			if(pent->v.iuser1 == W_FL_TFC_TELEPORTER_ENTRANCE)
			{
				tempTPinfo.pOwner = pent->v.euser1;
				tempTPinfo.pEntrance = pent;
    		    tempTPinfo.iEntranceWaypointIndex = WaypointFindNearest(pent, 500, -1);
			} 
			else if(pent->v.iuser1 == W_FL_TFC_TELEPORTER_EXIT)
			{
				tempTPinfo.pOwner = pent->v.euser1;
				tempTPinfo.pExit = pent;
    		    tempTPinfo.iExitWaypointIndex = WaypointFindNearest(pent, 500, -1);
			}

			// Add this to the list of found teleporters.
			teleportOwners.push_back(tempTPinfo);
		}
	}

	// Tag all slots as used that have both entrance and exit
	for (iter = teleportOwners.begin(); iter != teleportOwners.end(); )
	{
		if(iter->pEntrance && iter->pExit)
		{
			++iter;
			continue;
		}
		else
			iter = teleportOwners.erase(iter);
	}

	// We now have only valid teleporters.
	float shortestDistance = 99999.0f;
	teleport_info_t *bestTP = NULL; 
	float totalDistance;
	for (iter = teleportOwners.begin(); iter != teleportOwners.end(); ++iter)
	{
		// Find the teleporter which results in the shortest path to goal.
    	totalDistance = WaypointDistanceFromTo(pBot->curr_waypoint_index, iter->iEntranceWaypointIndex, team) 
    		+ WaypointDistanceFromTo(iter->iExitWaypointIndex, pBot->goto_wp, team);

		if(totalDistance < shortestDistance)
		{
			shortestDistance = totalDistance;
			bestTP = &(*iter);
		}
	}

	// Got the best saving teleporter, now see if it saves us distance to our goal without taking it.
	if(shortestDistance < WaypointDistanceFromTo(pBot->curr_waypoint_index, pBot->goto_wp, team))
	{
		// Copy this teleporters information into the bot struct.
		bestTP->bIsUsed = true;
		pBot->teleportInfo = *bestTP;
	}

	// Clear the remaining entries.
	teleportOwners.clear();

	if(pBot->teleportInfo.bIsUsed)
	{
		pBot->teleportInfo.iFinalGoal = pBot->goto_wp;
		pBot->goto_wp = pBot->teleportInfo.iEntranceWaypointIndex;
		return true;
	}

	return false;
}


Omni-bot AI framework
http://www.omni-bot.com

Foxbot - for Team Fortress Classic
http://www.foxbot.net


  
Reply With Quote
Re: TFC - Teleporters?
Old
  (#3)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: TFC - Teleporters? - 03-10-2005

Thanks, I'll take a look sometime today.
  
Reply With Quote
Re: TFC - Teleporters?
Old
  (#4)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: TFC - Teleporters? - 05-10-2005

In foxbot, which I don't think evil posted up there, when there is a #Teleporter_Entrance_Built/#Teleporter_Exit_Built message (I think), it will search for nearby teleporters and set the user to the builder (given in the message state 3). I tried this and added a few tweaks, such as checking if "pTeleporter->v.framerate == 0" as it shows it was just built, and ensures it doesn't pick up other nearby teleporters.

(it is rather more difficult doing this with sentries though if you want to pick up the building_sentrygun entitiy as they do not appear when the #Sentry_built message is sent.)

It works well, but using teleporters is a bit more complex (see evils code above)

typically what I do, is that if they find a teleporter that is nearby them, and the exit is nearer their goal than they are, and they are not closer to the teleporter exit than the goal, then they will use the teleporter. Things like "looping" can happen though which means they use the teleporter over and over again because they had to go back up where the entrance was. What I tried to do was add the teleporter to a list which it ignored when it used it, but I'm having trouble deciding when to do that.

Last edited by Cheeseh; 05-10-2005 at 12:19..
  
Reply With Quote
Re: TFC - Teleporters?
Old
  (#5)
DrEvil
Member
 
DrEvil's Avatar
 
Status: Offline
Posts: 142
Join Date: Jan 2004
Location: Los Angeles, CA
Default Re: TFC - Teleporters? - 07-10-2005

Foxbots only used teleporters if it saved them time to their current goal, time being the overall path cost. This by design wouldn't allow looping. The nice thing about using floyds pre-calculated lookup tables for paths is that you can do path comparisons very cheaply. if(pathCostToGoal > pathCostToTPEntrance + pathCostTPExitToGoal) then use the tele.

My new pathfinder in Omnibot uses A* and recognizes teleporter flagged waypoints and ignores the cost of travel between 2 teleporter waypoints, so there is no need for multiple path queries to take into account teleporters.


Omni-bot AI framework
http://www.omni-bot.com

Foxbot - for Team Fortress Classic
http://www.foxbot.net


  
Reply With Quote
Re: TFC - Teleporters?
Old
  (#6)
Paddington
Member
 
Status: Offline
Posts: 3
Join Date: Jul 2007
Default Re: TFC - Teleporters? - 09-07-2007

Anyone know where to get Foxbot now?
  
Reply With Quote
Re: TFC - Teleporters?
Old
  (#7)
DrEvil
Member
 
DrEvil's Avatar
 
Status: Offline
Posts: 142
Join Date: Jan 2004
Location: Los Angeles, CA
Default Re: TFC - Teleporters? - 10-07-2007

I have downloads available from the Omni-bot site.


Omni-bot AI framework
http://www.omni-bot.com

Foxbot - for Team Fortress Classic
http://www.foxbot.net


  
Reply With Quote
Re: TFC - Teleporters?
Old
  (#8)
Paddington
Member
 
Status: Offline
Posts: 3
Join Date: Jul 2007
Default Re: TFC - Teleporters? - 10-07-2007

Never seen those Omni-bots before. They work with steam? Any tutorial on installing them? nm found that on the home page. Still looking for what game they actually are for. Sorry for my newbieness.

Last edited by Paddington; 10-07-2007 at 07:58..
  
Reply With Quote
Re: TFC - Teleporters?
Old
  (#9)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,594
Join Date: Jul 2004
Location: Bulgaria
Default Re: TFC - Teleporters? - 10-07-2007

I think that is Enemy-Teritory bot.
  
Reply With Quote
Re: TFC - Teleporters?
Old
  (#10)
DrEvil
Member
 
DrEvil's Avatar
 
Status: Offline
Posts: 142
Join Date: Jan 2004
Location: Los Angeles, CA
Default Re: TFC - Teleporters? - 14-07-2007

Omni-bot is for Enemy Territory, Quake4, Doom3(soon), and in dev for Fortress Forever. As I was a Foxbot developer, and don't have access to the Foxbot web space so I have posted Foxbot files on the Omni-bot site in the downloads section.


Omni-bot AI framework
http://www.omni-bot.com

Foxbot - for Team Fortress Classic
http://www.foxbot.net


  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com