Exemplo n.º 1
0
/*
================
idBotAI::Buffalo_Air_To_Ground_Movement

Ground Specific attack case for the buffalo
================
*/
bool idBotAI::Buffalo_Air_To_Ground_Movement() {
	float desiredRange = 4500.0f;
	const clientInfo_t& enemyPlayerInfo = botWorld->clientInfo[ enemy ];

	idVec3 distToTarget = enemyPlayerInfo.origin - botVehicleInfo->origin;
	distToTarget.z = 0.0f;

	if ( distToTarget.LengthSqr() > Square( desiredRange ) )  {
		Bot_SetupVehicleMove( vec3_zero, enemy, ACTION_NULL );

		if ( MoveIsInvalid() ) {
			Bot_IgnoreEnemy( enemy, ENEMY_IGNORE_TIME ); //mal: no valid path to this client for some reason - ignore him for a while
			Bot_ResetEnemy();
			return false;
		}

		combatMoveTime = botWorld->gameLocalInfo.time + 500;

		Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, NULLMOVETYPE );
		Bot_LookAtLocation( botAAS.path.viewGoal, SMOOTH_TURN );
		return true;
	}

	if ( InFrontOfVehicle( botVehicleInfo->entNum, enemyPlayerInfo.origin ) && combatMoveTime < botWorld->gameLocalInfo.time ) {
		if ( botVehicleInfo->xyspeed < 100.0f ) {
			Bot_LookAtEntity( enemy, SMOOTH_TURN );
			botUcmd->botCmds.topHat = true;
		}
		Bot_CheckVehicleAttack(); //mal: always see if we can get a shot off.
	}

	Bot_MoveToGoal( vec3_zero, vec3_zero, NULLMOVEFLAG, FULL_STOP );

	return true;
}
Exemplo n.º 2
0
/*
================
idBotAI::COMBAT_Vehicle_AttackEnemy
================
*/
bool idBotAI::COMBAT_Vehicle_AttackEnemy() {

    bool keepEnemy = true;

    if ( !enemyInfo.enemyVisible && enemyInfo.enemyLastVisTime + 5000 < botWorld->gameLocalInfo.time ) {
        if ( !Bot_ShouldVehicleChaseHiddenEnemy() ) {
            Bot_ResetEnemy();
            return false;
        }

        Bot_PickVehicleChaseType();
        return false;
    }

    Bot_PickBestVehicleWeapon();

    if ( vehicleUpdateTime < botWorld->gameLocalInfo.time ) {
        if ( VEHICLE_COMBAT_MOVEMENT_STATE == NULL ) {
            keepEnemy = Bot_FindBestVehicleCombatMovement();
        }
    }

    if ( !keepEnemy ) { //mal: make sure enemy is reachable by our current move state/abilities/limitations. If not, we have to forget them.
        Bot_IgnoreEnemy( enemy, 3000 ); //mal: perhaps in 3 seconds, we will have moved to a better position for a kill...
        Bot_ResetEnemy();
        return false;
    }

    if ( VEHICLE_COMBAT_MOVEMENT_STATE != NULL ) {
        CallFuncPtr( VEHICLE_COMBAT_MOVEMENT_STATE );
    }

    if ( ClientIsValid( enemy, enemySpawnID ) && enemyInfo.enemyVisible ) {
        if ( botVehicleInfo->type <= ICARUS || botInfo->proxyInfo.weapon == MINIGUN ) {
            Bot_LookAtEntity( enemy, AIM_TURN ); //mal: aim at the enemy - but let the game side code handle it.
            Bot_CheckVehicleAttack();
        }
    }

    return false;
}
Exemplo n.º 3
0
/*
================
idBotAI::COMBAT_Vehicle_EvadeEnemy
================
*/
bool idBotAI::COMBAT_Vehicle_EvadeEnemy() {
    bool bailOut = false;
    idVec3 vec;

    if ( !ClientIsValid( enemy, -1 ) ) {
        Bot_ResetEnemy();
        return false;
    }

    if ( botVehicleInfo->type == MCP ) {
        assert( actionNum > -1 );

        if ( Bot_CheckActionIsValid( actionNum ) ) {
            vec = botThreadData.botActions[ actionNum ]->GetActionOrigin() - botVehicleInfo->origin;
            if ( vec.LengthSqr() > Square( MCP_PARKED_DIST ) ) {
                Bot_SetupVehicleMove( vec3_zero, -1, actionNum );

                if ( MoveIsInvalid() ) { //mal: this should NEVER happen - but if it does, the bot is better off leaving.
                    Bot_ExitVehicleAINode( true );
                    Bot_ExitVehicle( false );
                    assert( false );
                    return false;
                }
                Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, NULLMOVETYPE );
            } else {
                Bot_ExitVehicleAINode( true ); //mal: reached our goal, so just leave, and let the MCP deploy!
                Bot_ExitVehicle( false );
                return false;
            }
        }
    } else {
        if ( AIStack.stackActionNum != ACTION_NULL ) {
            float evadeDist = 1200.0f;

            vec = botThreadData.botActions[ AIStack.stackActionNum ]->origin - botInfo->origin;

            if ( botVehicleInfo->type > ICARUS ) {
                evadeDist = 550.0f;
                bailOut = true;
                vec.z = 0.0f;
            }

            if ( vec.LengthSqr() > Square( evadeDist ) ) {
                Bot_SetupVehicleMove( vec3_zero, -1, AIStack.stackActionNum );
                bailOut = false;
                if ( MoveIsInvalid() ) {
                    VEHICLE_COMBAT_AI_SUB_NODE = &idBotAI::Enter_COMBAT_Vehicle_AttackEnemy; //mal: if theres a problem getting to our target, just fight our enemy normally.
                    return false;
                }
                Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, NULLMOVETYPE );
            }

            if ( vec.LengthSqr() < Square( 800.0f ) && botVehicleInfo->type != MCP  ) { //mal: get to the outpost if MCP, even to the bitter end!
                VEHICLE_COMBAT_AI_SUB_NODE = &idBotAI::Enter_COMBAT_Vehicle_AttackEnemy; //mal: we're right at our target, so just fight our enemy normally.
                return false;
            }
        } else {
//			assert( false );
            VEHICLE_COMBAT_AI_SUB_NODE = &idBotAI::Enter_COMBAT_Vehicle_AttackEnemy;
            return false;
        }
    }

    if ( bailOut ) {
        Bot_ExitVehicle();
        return false;
    }

    Bot_PickBestVehicleWeapon();

    if ( !enemyInfo.enemyVisible && enemyInfo.enemyLastVisTime + 500 < botWorld->gameLocalInfo.time ) {
        UpdateNonVisEnemyInfo();

        if ( BotLeftEnemysSight() ) {
            vec = bot_LS_Enemy_Pos;
        } else {
            vec = enemyInfo.enemy_LS_Pos;
        }

        Bot_LookAtLocation( vec, AIM_TURN );
    } else {
        if ( botVehicleInfo->type > ICARUS ) {
            vec = botWorld->clientInfo[ enemy ].origin - botVehicleInfo->origin;
            vec[ 2 ] = 0.0f;
            if ( vec.LengthSqr() > Square( 2500.0f ) && InFrontOfVehicle( botVehicleInfo->entNum, botWorld->clientInfo[ enemy ].origin ) && botVehicleInfo->type != BUFFALO ) {
                Bot_LookAtEntity( enemy, AIM_TURN );
                Bot_CheckVehicleAttack();
            } else {
                Bot_LookAtLocation( botAAS.path.viewGoal, SMOOTH_TURN );
                if ( botVehicleInfo->type != BUFFALO ) {
                    Bot_CheckVehicleAttack();
                }
            }
        } else {
            Bot_LookAtEntity( enemy, AIM_TURN );
            Bot_CheckVehicleAttack();
        }
    }

    return true;
}
Exemplo n.º 4
0
/*
================
idBotAI::Vehicle_Air_To_Ground_Movement

Ground Specific attack case.
Special case: Air vehicles can't attack one way, while move in another. So they need to have their attack/move unified.
This is a bit of a hack, but theres no time to do anything else. :-(
================
*/
bool idBotAI::Vehicle_Air_To_Ground_Movement() {
	bool overRideLook = false;
	bool inVehicle = false;
	float desiredRange = 5800.0f;
	float tooCloseRange = 2700.0f;
	float enemySpeed = 0.0f;
	float dist;
	proxyInfo_t enemyVehicleInfo;
	idVec3 enemyOrg;
	idVec3 vec;

	if ( botWorld->clientInfo[ enemy ].proxyInfo.entNum != CLIENT_HAS_NO_VEHICLE ) {
		GetVehicleInfo( botWorld->clientInfo[ enemy ].proxyInfo.entNum, enemyVehicleInfo );
		enemyOrg = enemyVehicleInfo.origin;
		inVehicle = true;
	} else {
		enemyOrg = botWorld->clientInfo[ enemy ].origin;
	}

	enemySpeed = botWorld->clientInfo[ enemy ].xySpeed;

	vec = enemyOrg - botVehicleInfo->origin;
	vec[ 2 ] = 0.0f;
	dist = vec.LengthSqr();

	Bot_CheckVehicleAttack(); //mal: always see if we can get a shot off.

	if ( botInfo->enemyHasLockon && dist < Square( 6000.0f ) && botWorld->gameLocalInfo.botSkill > BOT_SKILL_EASY ) { //mal: OH NOES! Panic and run for it. 
		Bot_IgnoreEnemy( enemy, 3000 );
		Bot_ResetEnemy();
		return false;
	}

//mal: we're too close, so manuever around our enemy and fire. 
	if ( dist < Square( tooCloseRange ) && combatMoveTime < botWorld->gameLocalInfo.time && enemySpeed < SPRINTING_SPEED ) { //mal: if they're moving fast, just let them move into our crosshairs..
		int actionNumber = ACTION_NULL;

		if ( botWorld->gameLocalInfo.botSkill > BOT_SKILL_EASY ) {
			actionNumber = Bot_FindNearbySafeActionToMoveToward( botInfo->origin, ( desiredRange ) );
		}

		if ( actionNumber != -1 ) {
			combatMoveActionGoal = actionNumber;
			combatMoveTime = botWorld->gameLocalInfo.time + 10000;
			combatMoveTooCloseRange = ( inVehicle ) ? 5000.0f : tooCloseRange + 1000.0f;
		} else {
			int n = botThreadData.random.RandomInt( 3 );

			if ( n == 0 ) {
				combatMoveDir = BACK;
			} else if ( n == 1 ) {
				combatMoveDir = RIGHT;
			} else {
				combatMoveDir = LEFT;
			}

			combatMoveTime = botWorld->gameLocalInfo.time + 5000;
			combatMoveTooCloseRange = tooCloseRange;
		}
	}

	if ( combatMoveTime > botWorld->gameLocalInfo.time ) {
		if ( dist > Square( combatMoveTooCloseRange ) ) { //mal: we're far enough away to get a shot - attack.
			combatMoveTime = 0;
			combatMoveActionGoal = ACTION_NULL;
			overRideLook = true;
		}
	}

	if ( combatMoveTime > botWorld->gameLocalInfo.time ) {
		if ( combatMoveActionGoal != ACTION_NULL ) {
			Bot_SetupVehicleMove( vec3_zero, -1, combatMoveActionGoal );
		} else {
			vec = enemyOrg;
			if ( combatMoveDir == BACK ) {
				vec += ( -tooCloseRange * botWorld->clientInfo[ enemy ].viewAxis[ 0 ] );
			} else if ( combatMoveDir == RIGHT ) {
				vec += ( tooCloseRange * ( botWorld->clientInfo[ enemy ].viewAxis[ 1 ] * -1 ) );
			} else if ( combatMoveDir == LEFT ) {
				vec += ( -tooCloseRange * ( botWorld->clientInfo[ enemy ].viewAxis[ 1 ] * -1 ) );
			}

			vec.z = botVehicleInfo->origin.z;

			if ( !botThreadData.Nav_IsDirectPath( AAS_VEHICLE, botInfo->team, botInfo->areaNumVehicle, botInfo->aasVehicleOrigin, vec ) ) {
				combatMoveTime = 0;
				return true;
			}

			Bot_SetupVehicleMove( vec, -1, ACTION_NULL );
		}

		if ( MoveIsInvalid() ) {
			combatMoveTime = 0;
			combatMoveActionGoal = ACTION_NULL;
			return true;
		}

		Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, NULLMOVETYPE );
		Bot_LookAtLocation( botAAS.path.viewGoal, SMOOTH_TURN );
		return true;
	}

	if ( dist > Square( desiredRange ) )  {
		Bot_SetupVehicleMove( vec3_zero, enemy, ACTION_NULL );

		if ( MoveIsInvalid() ) {
			Bot_IgnoreEnemy( enemy, ENEMY_IGNORE_TIME ); //mal: no valid path to this client for some reason - ignore him for a while
			Bot_ResetEnemy();
			return false;
		}

		Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, NULLMOVETYPE );

		if ( InFrontOfVehicle( botVehicleInfo->entNum, enemyOrg ) || overRideLook ) {
			Bot_LookAtEntity( enemy, SMOOTH_TURN );
		} else {
			Bot_LookAtLocation( botAAS.path.viewGoal, SMOOTH_TURN );
		}
	} else {
		Bot_SetupVehicleMove( vec3_zero, enemy, ACTION_NULL ); //mal: still want to take into account obstacles, so do a move check.

		if ( MoveIsInvalid() ) {
			Bot_IgnoreEnemy( enemy, ENEMY_IGNORE_TIME ); //mal: no valid path to this client for some reason - ignore him for a while
			Bot_ResetEnemy();
			return false;
		}

		botMoveTypes_t defaultMoveType = AIR_BRAKE;

		if ( botWorld->gameLocalInfo.botSkill > BOT_SKILL_EASY && Bot_VehicleIsUnderAVTAttack() != -1 || Bot_CheckIfEnemyHasUsInTheirSightsWhenInAirVehicle() || Bot_CheckEnemyHasLockOn( -1, true ) || combatKeepMovingTime > botWorld->gameLocalInfo.time ) { //mal: do a bombing run if someone is shooting at us!
			defaultMoveType = NULLMOVETYPE;

			if ( combatKeepMovingTime < botWorld->gameLocalInfo.time ) {
				combatKeepMovingTime = botWorld->gameLocalInfo.time + FLYER_AVOID_DANGER_TIME;
			}
		}

		Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, ( botAAS.obstacleNum == -1 ) ? defaultMoveType : NULLMOVETYPE );
		Bot_LookAtEntity( enemy, SMOOTH_TURN );
	}

	return true;
}
Exemplo n.º 5
0
/*
================
idBotAI::Vehicle_Air_To_Air_Movement

Air to Air specific attack case.
Special case: Air vehicles can't attack one way, while move in another. So they need to have their attack/move unified.
This is a bit of a hack, but theres no time to do anything else. :-(
================
*/
bool idBotAI::Vehicle_Air_To_Air_Movement() {
	bool overRideLook = false;
	bool enemyInFront;
	bool botInFrontOfEnemy;
	float desiredRange;
	float tooCloseDist;
	float dist;
	proxyInfo_t enemyVehicleInfo;
	idVec3 enemyOrg;
	idVec3 vec;

	if ( botWorld->clientInfo[ enemy ].proxyInfo.entNum == CLIENT_HAS_NO_VEHICLE ) {
		Bot_ResetEnemy();
		return false;
	}

	GetVehicleInfo( botWorld->clientInfo[ enemy ].proxyInfo.entNum, enemyVehicleInfo );
	enemyOrg = enemyVehicleInfo.origin;

	vec = enemyOrg - botVehicleInfo->origin;
	vec.z = 0.0f;
	dist = vec.LengthSqr();
	float tempDist = vec.LengthFast();

	Bot_CheckVehicleAttack(); //mal: always see if we can get a shot off.

	if ( botInfo->enemyHasLockon && dist < Square( 6000.0f ) && botWorld->gameLocalInfo.botSkill == BOT_SKILL_EASY ) { //mal: OH NOES!1 Panic and run for it.
		Bot_IgnoreEnemy( enemy, 3000 );
		Bot_ResetEnemy();
		return false;
	}

	if ( botVehicleInfo->type == ANANSI ) {
		desiredRange = 5000.0f;
		tooCloseDist = 2500.0f;

		if ( Bot_CheckEnemyHasLockOn( enemy ) && botWorld->gameLocalInfo.botSkill > BOT_SKILL_EASY && botWorld->gameLocalInfo.botSkill != BOT_SKILL_DEMO ) { //mal: they need a bit of an edge
			botUcmd->botCmds.launchDecoysNow = true;
		}

		if ( dist < Square( tooCloseDist ) && combatMoveTime < botWorld->gameLocalInfo.time && botWorld->gameLocalInfo.botSkill > BOT_SKILL_EASY ) {
			combatMoveDir = BACK;
			combatMoveTime = botWorld->gameLocalInfo.time + 5000;
			botUcmd->botCmds.launchDecoys = true; //mal: we're exposing our flank, so fire some decoys to cover our move.
		}

		if ( combatMoveTime > botWorld->gameLocalInfo.time ) {
			if ( !InAirVehicleGunSights( enemyVehicleInfo.entNum, botInfo->origin ) ) { //mal: he can't see us anymore, so attack!
				combatMoveTime = 0;
				overRideLook = true;
			}
		}

		if ( combatMoveTime > 0 ) {
			vec = enemyOrg;
			vec += ( -desiredRange * enemyVehicleInfo.axis[ 0 ] ); 

			if ( !botThreadData.Nav_IsDirectPath( AAS_VEHICLE, botInfo->team, botInfo->areaNumVehicle, botInfo->aasVehicleOrigin, vec ) ) {
				combatMoveTime = 0;
				return true;
			}

			Bot_SetupVehicleMove( vec, -1, ACTION_NULL );

			if ( MoveIsInvalid() ) {
				combatMoveTime = 0;
				return true;
			}

			Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, NULLMOVETYPE );
			Bot_LookAtLocation( botAAS.path.viewGoal, SMOOTH_TURN );
			return true;
		}
	} else { //must be in a hornet
		 desiredRange = 2500.0f; //mal: was 1500
		 tooCloseDist = 0.0f;

		if ( dist < Square( desiredRange ) && combatMoveTime < botWorld->gameLocalInfo.time && botWorld->gameLocalInfo.botSkill > BOT_SKILL_EASY ) {
			int n = botThreadData.random.RandomInt( 3 ); //mal: we're too close, so manuever around our enemy and fire. low skill bots need not apply.

			if ( n == 0 ) {
				combatMoveDir = BACK;
			} else if ( n == 1 ) {
				combatMoveDir = RIGHT;
			} else {
				combatMoveDir = LEFT;
			}

			combatMoveTime = botWorld->gameLocalInfo.time + 5000;
			botUcmd->botCmds.launchDecoys = true; //mal: we're exposing our flank, so fire some decoys to cover our move.
		}

		if ( combatMoveTime > botWorld->gameLocalInfo.time ) {
			if ( !InAirVehicleGunSights( enemyVehicleInfo.entNum, botInfo->origin ) ) { //mal: he can't see us anymore, so attack!
				combatMoveTime = 0;
				overRideLook = true;
			}
		}

		if ( combatMoveTime > 0 ) {
			vec = enemyOrg;
			if ( combatMoveDir == BACK ) {
				vec += ( -desiredRange * botInfo->viewAxis[ 0 ] ); //mal: this seems wrong, but it works SO well.
			} else if ( combatMoveDir == RIGHT ) {
				vec += ( desiredRange * ( botInfo->viewAxis[ 1 ] * -1 ) );
			} else if ( combatMoveDir == LEFT ) {
				vec += ( -desiredRange * ( botInfo->viewAxis[ 1 ] * -1 ) );
			}

			if ( !botThreadData.Nav_IsDirectPath( AAS_VEHICLE, botInfo->team, botInfo->areaNumVehicle, botInfo->aasVehicleOrigin, vec ) ) {
				combatMoveTime = 0;
				return true;
			}

			Bot_SetupVehicleMove( vec, -1, ACTION_NULL );

			if ( MoveIsInvalid() ) {
				combatMoveTime = 0;
				return true;
			}

			Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, NULLMOVETYPE );
			Bot_LookAtLocation( botAAS.path.viewGoal, SMOOTH_TURN );
			return true;
		}
	}

	enemyInFront = InFrontOfVehicle( botVehicleInfo->entNum, enemyOrg );
	botInFrontOfEnemy = InFrontOfVehicle( enemyVehicleInfo.entNum, botInfo->origin );

	if ( dist > Square( desiredRange ) )  {
		Bot_SetupVehicleMove( vec3_zero, enemy, ACTION_NULL );

		if ( MoveIsInvalid() ) {
			Bot_IgnoreEnemy( enemy, ENEMY_IGNORE_TIME ); //mal: no valid path to this client for some reason - ignore him for a while
			Bot_ResetEnemy();
			return false;
		}

//mal: if we're just moving into range of the target, we'll try to get a lock. If not ( or in danger ) we'll gun it. Fighter pilot mantra: speed is life.
		Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, ( botInFrontOfEnemy && enemyInFront && dist > Square( 6000.0f ) && botVehicleInfo->forwardSpeed > 1500.0f && !botInfo->enemyHasLockon ) ? AIR_COAST : NULLMOVETYPE );

		if ( enemyInFront || overRideLook ) {
			Bot_LookAtEntity( enemy, SMOOTH_TURN );
		} else {
			Bot_LookAtLocation( botAAS.path.viewGoal, SMOOTH_TURN );
		}
	} else {
		Bot_SetupVehicleMove( vec3_zero, enemy, ACTION_NULL ); //mal: still want to take into account obstacles, so do a move check.

		if ( MoveIsInvalid() ) {
			Bot_IgnoreEnemy( enemy, ENEMY_IGNORE_TIME ); //mal: no valid path to this client for some reason - ignore him for a while
			Bot_ResetEnemy();
			return false;
		}

		Bot_MoveToGoal( botAAS.path.moveGoal, vec3_zero, RUN, ( botAAS.obstacleNum == -1 ) ? AIR_BRAKE : NULLMOVETYPE );
		Bot_LookAtEntity( enemy, SMOOTH_TURN );
	}

	return true;
}