Пример #1
0
//MAKEME: Make this a smart decision
AActor *DCajunMaster::Find_enemy (AActor *bot)
{
	int count;
	fixed_t closest_dist, temp; //To target.
	AActor *target;
	angle_t vangle;
	AActor *observer;

	if (!deathmatch)
	{ // [RH] Take advantage of the Heretic/Hexen code to be a little smarter
		return P_RoughMonsterSearch (bot, 20);
	}

	//Note: It's hard to ambush a bot who is not alone
	if (bot->player->allround || bot->player->mate)
		vangle = ANGLE_MAX;
	else
		vangle = ENEMY_SCAN_FOV;
	bot->player->allround = false;

	target = NULL;
	closest_dist = FIXED_MAX;
	if (bot_observer)
		observer = players[consoleplayer].mo;
	else
		observer = NULL;

	for (count = 0; count < MAXPLAYERS; count++)
	{
		player_t *client = &players[count];
		if (playeringame[count]
			&& !bot->IsTeammate (client->mo)
			&& client->mo != observer
			&& client->mo->health > 0
			&& bot != client->mo)
		{
			if (Check_LOS (bot, client->mo, vangle)) //Here's a strange one, when bot is standing still, the P_CheckSight within Check_LOS almost always returns false. tought it should be the same checksight as below but.. (below works) something must be f****n wierd screded up. 
			//if(P_CheckSight( bot, players[count].mo))
			{
				temp = P_AproxDistance (client->mo->x - bot->x,
										client->mo->y - bot->y);

				//Too dark?
				if (temp > DARK_DIST &&
					client->mo->Sector->lightlevel < WHATS_DARK &&
					bot->player->Powers & PW_INFRARED)
					continue;

				if (temp < closest_dist)
				{
					closest_dist = temp;
					target = client->mo;
				}
			}
		}
	}

	return target;
}
Пример #2
0
DEFINE_ACTION_FUNCTION(AActor, A_MinotaurLook)
{
    PARAM_ACTION_PROLOGUE;

    if (!self->IsKindOf(RUNTIME_CLASS(AMinotaurFriend)))
    {
        CALL_ACTION(A_Look, self);
        return 0;
    }

    AActor *mo = NULL;
    player_t *player;
    double dist;
    int i;
    AActor *master = self->tracer;

    self->target = NULL;
    if (deathmatch)					// Quick search for players
    {
        for (i = 0; i < MAXPLAYERS; i++)
        {
            if (!playeringame[i]) continue;
            player = &players[i];
            mo = player->mo;
            if (mo == master) continue;
            if (mo->health <= 0) continue;
            dist = self->Distance2D(mo);
            if (dist > MINOTAUR_LOOK_DIST) continue;
            self->target = mo;
            break;
        }
    }

    if (!self->target)				// Near player monster search
    {
        if (master && (master->health>0) && (master->player))
            mo = P_RoughMonsterSearch(master, 20);
        else
            mo = P_RoughMonsterSearch(self, 20);
        self->target = mo;
    }

    if (!self->target)				// Normal monster search
    {
        FActorIterator iterator (0);

        while ((mo = iterator.Next()) != NULL)
        {
            if (!(mo->flags3 & MF3_ISMONSTER)) continue;
            if (mo->health <= 0) continue;
            if (!(mo->flags & MF_SHOOTABLE)) continue;
            dist = self->Distance2D(mo);
            if (dist > MINOTAUR_LOOK_DIST) continue;
            if ((mo == master) || (mo == self)) continue;
            if ((mo->flags5 & MF5_SUMMONEDMONSTER) && (mo->tracer == master)) continue;
            self->target = mo;
            break;			// Found actor to attack
        }
    }

    if (self->target)
    {
        self->SetState (self->SeeState, true);
    }
    else
    {
        self->SetState (self->FindState ("Roam"), true);
    }
    return 0;
}