BotLib/Way/Routing: Go over and integrate the link-flags stuff properly,
as fixed in a recent FTE commit
This commit is contained in:
parent
1dd2547fe2
commit
53ed1962eb
4 changed files with 168 additions and 42 deletions
|
@ -144,17 +144,17 @@ bot::CheckRoute(void)
|
|||
|
||||
flDist = floor(vlen(evenpos));
|
||||
|
||||
if (flDist < 16) {
|
||||
if (flDist < 32) {
|
||||
dprint(sprintf("^2CBaseMonster::^3CheckRoute^7: " \
|
||||
"%s reached node\n", this.targetname));
|
||||
m_iCurNode--;
|
||||
velocity *= 0.5f;
|
||||
|
||||
if (m_iCurNode >= 0) {
|
||||
//print(sprintf("NODE FLAGS: %i\n", m_pRoute[m_iCurNode].m_iFlags));
|
||||
if (m_pRoute[m_iCurNode].m_iFlags)
|
||||
print(sprintf("NODE FLAGS: %i\n", m_pRoute[m_iCurNode].m_iFlags));
|
||||
|
||||
/* if a node is flagged as jumpy, jump! */
|
||||
if (m_pRoute[m_iCurNode].m_iFlags & WP_JUMP)
|
||||
if (m_pRoute[m_iCurNode].m_iFlags & LF_JUMP)
|
||||
input_buttons |= INPUT_BUTTON2;
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ bot::CheckRoute(void)
|
|||
input_buttons |= INPUT_BUTTON2;
|
||||
} else {
|
||||
/* entire way-link needs to be crouched. that's the law of the land */
|
||||
if (m_pRoute[m_iCurNode].m_iFlags & WP_CROUCH)
|
||||
if (m_pRoute[m_iCurNode].m_iFlags & LF_CROUCH)
|
||||
input_buttons |= INPUT_BUTTON8;
|
||||
}
|
||||
}
|
||||
|
@ -323,10 +323,13 @@ bot::RunAI(void)
|
|||
else
|
||||
aimpos = m_pRoute[m_iCurNode].m_vecDest;
|
||||
}
|
||||
|
||||
|
||||
/* now we'll set the movevalues relative to the input_angle */
|
||||
vecDirection = normalize(aimpos - origin) * 240;
|
||||
if (m_iCurNode >= 0 && m_pRoute[m_iCurNode].m_iFlags & LF_WALK)
|
||||
vecDirection = normalize(aimpos - origin) * 120;
|
||||
else
|
||||
vecDirection = normalize(aimpos - origin) * 240;
|
||||
|
||||
makevectors(input_angles);
|
||||
input_movevalues = [v_forward * vecDirection, v_right * vecDirection, v_up * vecDirection];
|
||||
}
|
||||
|
|
137
src/botlib/way.c
137
src/botlib/way.c
|
@ -219,25 +219,6 @@ Way_Waypoint_SetRadius(int iID, float flRadValue)
|
|||
g_pWaypoints[iID].flRadius = flRadValue;
|
||||
}
|
||||
|
||||
void
|
||||
Way_Waypoint_MakeJump(int iID)
|
||||
{
|
||||
if (iID < 0i || iID >= g_iWaypoints) {
|
||||
print("RT_Waypoint_SetRadius: invalid waypoint\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0i; j < g_pWaypoints[iID].iNeighbours; j++) {
|
||||
int iTarget = g_pWaypoints[iID].neighbour[j].node;
|
||||
|
||||
for (int b = 0i; b < g_pWaypoints[iTarget].iNeighbours; b++) {
|
||||
if (g_pWaypoints[iTarget].neighbour[b].node == iID) {
|
||||
g_pWaypoints[iTarget].neighbour[b].iFlags = WP_JUMP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Way_FindClosestWaypoint(vector vecOrigin)
|
||||
{
|
||||
|
@ -267,6 +248,84 @@ Way_FindClosestWaypoint(vector vecOrigin)
|
|||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
Way_Waypoint_LinkJump(void)
|
||||
{
|
||||
static int waylink_status;
|
||||
static int way1, way2;
|
||||
|
||||
if (waylink_status == 0) {
|
||||
way1 = Way_FindClosestWaypoint(self.origin);
|
||||
waylink_status = 1;
|
||||
centerprint(self, "Selected first waypoint!\n");
|
||||
} else if (waylink_status == 1) {
|
||||
way2 = Way_FindClosestWaypoint(self.origin);
|
||||
waylink_status = 0;
|
||||
|
||||
if (way1 != way2) {
|
||||
for (int b = 0i; b < g_pWaypoints[way1].iNeighbours; b++) {
|
||||
if (g_pWaypoints[way1].neighbour[b].node == way2) {
|
||||
g_pWaypoints[way1].neighbour[b].iFlags = LF_JUMP;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
centerprint(self, "Failed to link, the two points are the same!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Way_Waypoint_LinkCrouch(void)
|
||||
{
|
||||
static int waylink_status;
|
||||
static int way1, way2;
|
||||
|
||||
if (waylink_status == 0) {
|
||||
way1 = Way_FindClosestWaypoint(self.origin);
|
||||
waylink_status = 1;
|
||||
centerprint(self, "Selected first waypoint!\n");
|
||||
} else if (waylink_status == 1) {
|
||||
way2 = Way_FindClosestWaypoint(self.origin);
|
||||
waylink_status = 0;
|
||||
|
||||
if (way1 != way2) {
|
||||
for (int b = 0i; b < g_pWaypoints[way1].iNeighbours; b++) {
|
||||
if (g_pWaypoints[way1].neighbour[b].node == way2) {
|
||||
g_pWaypoints[way1].neighbour[b].iFlags = LF_CROUCH;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
centerprint(self, "Failed to link, the two points are the same!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Way_Waypoint_LinkWalk(void)
|
||||
{
|
||||
static int waylink_status;
|
||||
static int way1, way2;
|
||||
|
||||
if (waylink_status == 0) {
|
||||
way1 = Way_FindClosestWaypoint(self.origin);
|
||||
waylink_status = 1;
|
||||
centerprint(self, "Selected first waypoint!\n");
|
||||
} else if (waylink_status == 1) {
|
||||
way2 = Way_FindClosestWaypoint(self.origin);
|
||||
waylink_status = 0;
|
||||
|
||||
if (way1 != way2) {
|
||||
for (int b = 0i; b < g_pWaypoints[way1].iNeighbours; b++) {
|
||||
if (g_pWaypoints[way1].neighbour[b].node == way2) {
|
||||
g_pWaypoints[way1].neighbour[b].iFlags = LF_WALK;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
centerprint(self, "Failed to link, the two points are the same!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Way_GoToPoint(entity pl)
|
||||
{
|
||||
|
@ -342,13 +401,25 @@ Way_DrawDebugInfo(void)
|
|||
|
||||
waypoint_t *w2 = &g_pWaypoints[k];
|
||||
|
||||
if (fl & WP_JUMP) {
|
||||
R_PolygonVertex(org, [0,1], [1,0,0], 1);
|
||||
R_PolygonVertex(w2->vecOrigin, [1,1], [0,1,0], 1);
|
||||
} else {
|
||||
R_PolygonVertex(org, [0,1], [1,0,1], 1);
|
||||
R_PolygonVertex(w2->vecOrigin, [1,1], [0,1,0], 1);
|
||||
if (fl & LF_JUMP) {
|
||||
vector middle;
|
||||
middle = (w2->vecOrigin + org) / 2;
|
||||
R_PolygonVertex(org + [0,0,1], [0,1], [1,1,0], 1);
|
||||
R_PolygonVertex(middle + [0,0,32], [0,1], [0.5,0.5,0], 1);
|
||||
R_EndPolygon();
|
||||
R_PolygonVertex(middle + [0,0,32], [0,1], [0.5,0.5,0], 1);
|
||||
R_PolygonVertex(w2->vecOrigin + [0,0,1], [1,1], [0,0,0], 1);
|
||||
R_EndPolygon();
|
||||
}
|
||||
|
||||
if (fl & LF_CROUCH) {
|
||||
R_PolygonVertex(org + [0,0,-1], [0,1], [0,0,1], 1);
|
||||
R_PolygonVertex(w2->vecOrigin + [0,0,-1], [1,1], [0,0,1], 1);
|
||||
R_EndPolygon();
|
||||
}
|
||||
|
||||
R_PolygonVertex(org, [0,1], [1,0,1], 1);
|
||||
R_PolygonVertex(w2->vecOrigin, [1,1], [0,1,0], 1);
|
||||
R_EndPolygon();
|
||||
}
|
||||
}
|
||||
|
@ -495,11 +566,23 @@ Way_Cmd(void)
|
|||
}
|
||||
Way_Waypoint_SetRadius( Way_FindClosestWaypoint( self.origin ), stof( argv( 2 ) ) );
|
||||
break;
|
||||
case "makejump":
|
||||
case "linkjump":
|
||||
if ( !self ) {
|
||||
return;
|
||||
}
|
||||
Way_Waypoint_MakeJump( Way_FindClosestWaypoint( self.origin ) );
|
||||
Way_Waypoint_LinkJump();
|
||||
break;
|
||||
case "linkcrouch":
|
||||
if ( !self ) {
|
||||
return;
|
||||
}
|
||||
Way_Waypoint_LinkCrouch();
|
||||
break;
|
||||
case "linkwalk":
|
||||
if ( !self ) {
|
||||
return;
|
||||
}
|
||||
Way_Waypoint_LinkWalk();
|
||||
break;
|
||||
case "save":
|
||||
Way_DumpWaypoints( argv( 2 ) );
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
|
||||
#define COST_INFINITE 99999
|
||||
|
||||
enumflags
|
||||
{
|
||||
WP_JUMP, /* also implies that the bot must first go behind the wp... */
|
||||
WP_CLIMB,
|
||||
WP_CROUCH,
|
||||
WP_USE
|
||||
};
|
||||
#define LF_EDGE 0x00000001i
|
||||
#define LF_JUMP 0x00000002i
|
||||
#define LF_CROUCH 0x00000004i
|
||||
#define LF_TELEPORT 0x00000008i
|
||||
#define LF_WALK 0x00000010i
|
||||
#define LF_USER 0x7fffff00i
|
||||
#define LF_DESTINATION 0x80000000i
|
||||
|
|
|
@ -24,7 +24,8 @@ Way_Init(void)
|
|||
way_menu.m_strMessage = "1.\tAdd...\n" \
|
||||
"2.\tLink...\n" \
|
||||
"3.\tRemove...\n" \
|
||||
"4.\tAuto-Link Settings...\n" \
|
||||
"4.\tLink Flags...\n" \
|
||||
"5.\tAuto-Link Settings...\n" \
|
||||
"\n" \
|
||||
"\n" \
|
||||
"7.\tSave File\n" \
|
||||
|
@ -87,6 +88,23 @@ Way_Init(void)
|
|||
Titles_AddEntry(way_remove);
|
||||
}
|
||||
/* add waypoint menu */
|
||||
{
|
||||
titles_t way_flags;
|
||||
way_flags.m_strName = "WAY_FLAGS";
|
||||
way_flags.m_strMessage = "1.\tFlag jump (2 steps)\n" \
|
||||
"2.\tFlag crouch (2 steps)\n" \
|
||||
"3.\tFlag walk (2 steps)\n" \
|
||||
"\n" \
|
||||
"\n" \
|
||||
"\n" \
|
||||
"\n" \
|
||||
"\n" \
|
||||
"9.\tBack\n";
|
||||
way_flags.m_flPosX = 0;
|
||||
way_flags.m_flPosY = -1;
|
||||
Titles_AddEntry(way_flags);
|
||||
}
|
||||
/* add waypoint menu */
|
||||
{
|
||||
titles_t way_text;
|
||||
way_text.m_strName = "WAY_AUTOLINK";
|
||||
|
@ -119,6 +137,9 @@ WAY_MENU(int n)
|
|||
Textmenu_Call("WAY_REMOVE");
|
||||
break;
|
||||
case 4:
|
||||
Textmenu_Call("WAY_FLAGS");
|
||||
break;
|
||||
case 5:
|
||||
Textmenu_Call("WAY_AUTOLINK");
|
||||
break;
|
||||
case 7:
|
||||
|
@ -176,6 +197,25 @@ WAY_LINK(int n)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
WAY_FLAGS(int n)
|
||||
{
|
||||
switch (n) {
|
||||
case 1:
|
||||
localcmd("sv way linkjump\n");
|
||||
break;
|
||||
case 2:
|
||||
localcmd("sv way linkcrouch\n");
|
||||
break;
|
||||
case 3:
|
||||
localcmd("sv way linkwalk\n");
|
||||
break;
|
||||
case 9:
|
||||
Textmenu_Call("WAY_MENU");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WAY_REMOVE(int n)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue