예제 #1
0
static  char    UseMessage( char cmp, char target, char used_at ) {
//=================================================================

    if( sw_compiler == 'o' ) {
        if( (cmp != 'o') && (cmp != ' ') && (cmp != '.') && (cmp != 'c') ) {
            return( 0 );
        }
    } else if( sw_compiler == 'w' ) {
        if( (cmp != 'w') && (cmp != ' ') && (cmp != '.') ) {
            return( 0 );
        }
    } else if( sw_compiler == 'l' ) {
        if( (cmp != 'l') && (cmp != 'c') && (cmp != '.') ) {
            return( 0 );
        }
    }
    if( IsTarget( target ) ) {
        if( sw_compiler == 'w' ) {
            if( sw_used_at == ' ' ) {
                // load'n go compiler doesn't care whether message is
                // used at compile-time or run-time
                return( 1 );
            } else if( (sw_used_at == used_at) || (used_at == ' ') ) {
                return( 1 );
            }
        } else if( (sw_used_at == used_at) || (used_at == ' ') ) {
            return( 1 );
        }
    }
    return( 0 );
}
void plPhysBridgeComponent::ValidateSections()
{
    int i;

    // Make sure everything we're attached to is in our list of sections
    for (i = 0; i < NumTargets(); i++)
    {
        INode* node = (INode*)GetTarget(i);

        bool found = false;
        int count = fCompPB->Count(kSections);
        for (int j = 0; j < count; j++)
        {
            if (node == fCompPB->GetINode(kSections, 0, j))
            {
                found = true;
                break;
            }
        }

        if (!found)
            fCompPB->Append(kSections, 1, &node);
    }

    // Make sure we're still attached to everything in our list of sections
    for (i = fCompPB->Count(kSections)-1; i >= 0; i--)
    {
        plMaxNodeBase* node = (plMaxNodeBase*)fCompPB->GetINode(kSections, 0, i);

        if (!IsTarget(node))
            fCompPB->Delete(kSections, i, 1);
    }
}
예제 #3
0
void IOrderModule::ObjDestroyed (CShip *pShip, const SDestroyCtx &Ctx)

//	ObjDestroyed
//
//	And object was destroyed

	{
	int i;
	bool bCancelOrder = false;

	for (i = 0; i < m_iObjCount; i++)
		if (Ctx.pObj == m_Objs[i])
			{
			//	If this object is a target, and a friendly ship destroyed it, then
			//	thank the object who helped.

			if (IsTarget(i) && Ctx.Attacker.IsCausedByFriendOf(pShip) && Ctx.Attacker.GetObj())
				pShip->Communicate(Ctx.Attacker.GetObj(), msgNiceShooting);

			//	Clear out the variable. We do this first because the derrived class
			//	might set it to something else (thus we don't want to clear it after
			//	the OnObjDestroyed call).

			m_Objs[i] = NULL;

			//	Let our derrived class handle it
				
			OnObjDestroyed(pShip, Ctx, i, &bCancelOrder);

			//	If our derrived class wants us to cancel the order, then we're done.
			//	(After we cancel the order, the order module will be invalid, so
			//	we need to leave.

			if (bCancelOrder)
				{
				pShip->CancelCurrentOrder();
				return;
				}
			}
	}
void AAIAirForceManager::CheckBombTarget(int unit_id, int def_id)
{
	// dont continue if target list already full
	if(num_of_targets >= cfg->MAX_AIR_TARGETS)
		return;

	// do not add own units or units that ar already on target list
	if(my_team != cb->GetUnitTeam(unit_id) && !IsTarget(unit_id))
	{
		float3 pos = cb->GetUnitPos(unit_id);

		// calculate in which sector unit is located
		int x = pos.x/map->xSectorSize;
		int y = pos.z/map->ySectorSize;

		// check if unit is within the map
		if(x >= 0 && x < map->xSectors && y >= 0 && y < map->ySectors)
		{
			AddTarget(unit_id, def_id);
		}
	}
}
예제 #5
0
파일: Snake.cpp 프로젝트: phersho/snake
 /*
  * Indicates if this snake is collisioning with 'location'.
  */
 bool Snake::IsCollided(const Location& location) const
 {
     return IsTarget(location) && body->front().GetDistance(location) == 0;
 }