Exemple #1
0
// multiple turrets display removed the pointless mountRotation
void displayComponentObject(DROID *psDroid)
{
	Vector3i position, rotation;
	Spacetime st = interpolateObjectSpacetime(psDroid, graphicsTime);

	leftFirst = angleDelta(player.r.y - st.rot.direction) <= 0;

	/* Push the matrix */
	pie_MatBegin();

	/* Get the real position */
	position.x = st.pos.x - player.p.x;
	position.z = -(st.pos.y - player.p.z);
	position.y = st.pos.z;

	if(psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER)
	{
		position.y += bobTransporterHeight();
	}

	/* Get all the pitch,roll,yaw info */
	rotation.y = -st.rot.direction;
	rotation.x = st.rot.pitch;
	rotation.z = st.rot.roll;

	/* Translate origin */
	pie_TRANSLATE(position.x,position.y,position.z);

	/* Rotate for droid */
	pie_MatRotY(rotation.y);
	pie_MatRotX(rotation.x);
	pie_MatRotZ(rotation.z);

	if (graphicsTime - psDroid->timeLastHit < GAME_TICKS_PER_SEC && psDroid->lastHitWeapon == WSC_ELECTRONIC)
	{
		objectShimmy( (BASE_OBJECT*) psDroid );
	}

	if (psDroid->lastHitWeapon == WSC_EMP && graphicsTime - psDroid->timeLastHit < EMP_DISABLE_TIME)
	{
		Vector3i position;

		//add an effect on the droid
		position.x = st.pos.x + DROID_EMP_SPREAD;
		position.y = st.pos.z + rand()%8;
		position.z = st.pos.y + DROID_EMP_SPREAD;
		effectGiveAuxVar(90+rand()%20);
		addEffect(&position,EFFECT_EXPLOSION,EXPLOSION_TYPE_PLASMA,false,NULL,0);
	}

	if ((psDroid->visible[selectedPlayer] == UBYTE_MAX) || demoGetStatus())
	{
		//ingame not button object
		//should render 3 mounted weapons now
		displayCompObj(psDroid, false);
	}
	else
	{
		int frame = graphicsTime/BLIP_ANIM_DURATION + psDroid->id % 8192; // de-sync the blip effect, but don't overflow the int
		pie_Draw3DShape(getImdFromIndex(MI_BLIP), frame, 0, WZCOL_WHITE, pie_ADDITIVE, psDroid->visible[selectedPlayer] / 2);
	}
	pie_MatEnd();
}
Exemple #2
0
static void processLeaderSelection( void )
{
    DROID *psDroid;
    DROID *psPresent;
    DROID *psNew = NULL;
    UDWORD leaderClass;
    BOOL bSuccess;
    UDWORD dif;
    UDWORD bestSoFar;

    if (demoGetStatus())
    {
        return;
    }

    if (getWarCamStatus())
    {
        /* Only do if we're tracking a droid */
        if (trackingCamera.target->type != OBJ_DROID)
        {
            return;
        }
    }
    else
    {
        return;
    }

    /* Don't do if we're driving?! */
    if (getDrivingStatus())
    {
        return;
    }

    psPresent = (DROID*)trackingCamera.target;

    if (keyPressed(KEY_LEFTARROW))
    {
        leaderClass = LEADER_LEFT;
    }

    else if (keyPressed(KEY_RIGHTARROW))
    {
        leaderClass = LEADER_RIGHT;
    }

    else if (keyPressed(KEY_UPARROW))
    {
        leaderClass = LEADER_UP;
    }

    else if (keyPressed(KEY_DOWNARROW))
    {
        leaderClass = LEADER_DOWN;
    }
    else
    {
        leaderClass = LEADER_STATIC;
    }

    bSuccess = false;
    bestSoFar = UDWORD_MAX;

    switch (leaderClass)
    {
    case	LEADER_LEFT:
        for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext)
        {
            /* Is it even on the sscreen? */
            if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent)
            {
                if (psDroid->sDisplay.screenX < psPresent->sDisplay.screenX)
                {
                    dif = psPresent->sDisplay.screenX - psDroid->sDisplay.screenX;
                    if (dif < bestSoFar)
                    {
                        bestSoFar = dif;
                        bSuccess = true;
                        psNew = psDroid;
                    }
                }
            }
        }
        break;
    case	LEADER_RIGHT:
        for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext)
        {
            /* Is it even on the sscreen? */
            if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent)
            {
                if (psDroid->sDisplay.screenX > psPresent->sDisplay.screenX)
                {
                    dif = psDroid->sDisplay.screenX - psPresent->sDisplay.screenX;
                    if (dif < bestSoFar)
                    {
                        bestSoFar = dif;
                        bSuccess = true;
                        psNew = psDroid;
                    }
                }
            }
        }
        break;
    case	LEADER_UP:
        for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext)
        {
            /* Is it even on the sscreen? */
            if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent)
            {
                if (psDroid->sDisplay.screenY < psPresent->sDisplay.screenY)
                {
                    dif = psPresent->sDisplay.screenY - psDroid->sDisplay.screenY;
                    if (dif < bestSoFar)
                    {
                        bestSoFar = dif;
                        bSuccess = true;
                        psNew = psDroid;
                    }
                }
            }
        }
        break;
    case	LEADER_DOWN:
        for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext)
        {
            /* Is it even on the sscreen? */
            if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent)
            {
                if (psDroid->sDisplay.screenY > psPresent->sDisplay.screenY)
                {
                    dif = psDroid->sDisplay.screenY - psPresent->sDisplay.screenY;
                    if (dif < bestSoFar)
                    {
                        bestSoFar = dif;
                        bSuccess = true;
                        psNew = psDroid;
                    }
                }
            }
        }
        break;
    case	LEADER_STATIC:
        break;
    }
    if (bSuccess)
    {
        camAllignWithTarget((BASE_OBJECT*)psNew);
    }
}
Exemple #3
0
// multiple turrets display removed the pointless mountRotation
void displayComponentObject(DROID *psDroid)
{
	Vector3i	position, rotation;
	int32_t		xShift,zShift;
	SDWORD		frame;
	PROPULSION_STATS	*psPropStats;
	UDWORD	tileX,tileY;
	MAPTILE	*psTile;
	SPACETIME st = interpolateObjectSpacetime((SIMPLE_OBJECT *)psDroid, graphicsTime);

	psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;

	leftFirst = angleDelta(player.r.y - st.rot.direction) <= 0;

	/* Push the matrix */
	pie_MatBegin();

	/* Get internal tile units coordinates */
	xShift = map_round(player.p.x);
	zShift = map_round(player.p.z);

	/* Mask out to tile_units resolution */
	pie_TRANSLATE(xShift,0,-zShift);

	/* Get the real position */
	position.x = (st.pos.x - player.p.x) - terrainMidX*TILE_UNITS;
	position.z = terrainMidY*TILE_UNITS - (st.pos.y - player.p.z);
	position.y = st.pos.z;

	if(psDroid->droidType == DROID_TRANSPORTER)
	{
		position.y += bobTransporterHeight();
	}

	/* Get all the pitch,roll,yaw info */
	rotation.y = -st.rot.direction;
	rotation.x = st.rot.pitch;
	rotation.z = st.rot.roll;

	/* Translate origin */
	pie_TRANSLATE(position.x,position.y,position.z);

	/* Rotate for droid */
	pie_MatRotY(rotation.y);
	pie_MatRotX(rotation.x);
	pie_MatRotZ(rotation.z);

	if( (gameTime-psDroid->timeLastHit < GAME_TICKS_PER_SEC) && psDroid->lastHitWeapon == WSC_ELECTRONIC)
	{
		objectShimmy( (BASE_OBJECT*) psDroid );
	}

	if (psDroid->lastHitWeapon == WSC_EMP &&
	    (gameTime - psDroid->timeLastHit < EMP_DISABLE_TIME))
	{
		Vector3i position;

		//add an effect on the droid
		position.x = st.pos.x + DROID_EMP_SPREAD;
		position.y = st.pos.z + rand()%8;
		position.z = st.pos.y + DROID_EMP_SPREAD;
		effectGiveAuxVar(90+rand()%20);
		addEffect(&position,EFFECT_EXPLOSION,EXPLOSION_TYPE_PLASMA,false,NULL,0);
	}

	if ((psDroid->visible[selectedPlayer] == UBYTE_MAX) || demoGetStatus())
	{
		//ingame not button object
		//should render 3 mounted weapons now
		displayCompObj(psDroid, false);
	}
	else
	{

		// make sure it's not over water.
		tileX = st.pos.x/TILE_UNITS;
		tileY = st.pos.y/TILE_UNITS;
		// double check it's on map
		if ( tileX < mapWidth && tileY < mapHeight )
		{
			psTile = mapTile(tileX,tileY);
			if (terrainType(psTile) != TER_WATER)
			{
				frame = gameTime/BLIP_ANIM_DURATION + psDroid->id; //visible[selectedPlayer];
				pie_Draw3DShape(getImdFromIndex(MI_BLIP), frame, 0, WZCOL_WHITE, WZCOL_BLACK, pie_ADDITIVE, psDroid->visible[selectedPlayer] / 2);
				/* set up all the screen coords stuff - need to REMOVE FROM THIS LOOP */
			}
		}
	}
	pie_MatEnd();
}