コード例 #1
0
ファイル: isdf07.cpp プロジェクト: Nielk1/bz2-sp-fixes
void isdf07Mission::CommandShab() {
	char tempstr[128];
	switch (shabState) {
		case 0: //setup the first batch of enemies
			shabEnemy1 = BuildObject("fvsent", comp_team, spawn1);
			shabEnemy2 = BuildObject("fvsent", comp_team, spawn2);
			Attack(shabEnemy1, shabayev, 1);
			Attack(shabEnemy2, shabayev, 1);
			Attack(shabayev, shabEnemy1, 1);
			shabState++;
			break;
		case 1: //do nothing until the first enemy gets killed
			if (!IsAlive(shabEnemy1)) {
				if (IsAlive(shabEnemy2)) {
					Attack(shabayev, shabEnemy2, 1);
					shabState++;
				}
				else {
					shabState++;
				}
			}

			if (gunTowBuilt) { //If shab can't kill anybody do it for her
				Damage(shabEnemy1, 3000);
				if (IsAlive(shabEnemy2)) {
					Damage(shabEnemy2, 3000);
				}
				ClearObjectives();
				AddObjective("isdf0707.otf", WHITE);
				Goto(shabayev, "tree_point", 1);
				AudioMessage("isdf0728.wav");
				shabState = 3;
				BugFix=GetTime()+60.0f;
			}

			break;
		case 2: //go NEAR the ruin when all of the enemies are killed
			if ((missionState>8) && (IsAlive(shabEnemy2))) { //If shab can't kill anybody do it for her
				Damage(shabEnemy2, 3000);
			}
			if ((!IsAlive(shabEnemy1)) && (!IsAlive(shabEnemy2)) && (!gunTowBuilt)) {
				shabEnemy2 = BuildObject("fvsent", 2, spawn1);
				Attack(shabayev, shabEnemy2, 1);
				Attack(shabEnemy2, shabayev, 1);

			}
			if ((!IsAlive(shabEnemy1)) && (!IsAlive(shabEnemy2)) && (gunTowBuilt)) {
				ClearObjectives();
				AddObjective("isdf0710.otf", WHITE);
				AudioMessage("isdf0728.wav");
				Goto(shabayev, "tree_point", 1);
				BugFix=GetTime()+20.0f;
				shabState++;
			}
			break;
		case 3: //hop out of the vehicle when near the ruin
			if (GetTime()>BugFix)
			{
				Goto(shabayev,"tree_point");
				BugFix=GetTime()+10.0f;	
			}
			if (((GetDistance(shabayev, "tree_point") < 25.0)) && ((!IsAlive(enemy1)) || (!IsAlive(enemy2))))
			{
				ClearObjectives();
				AudioMessage("isdf0725.wav");

				AddObjective("isdf0707.otf", WHITE);
				justHoped = true;
				HopOut(shabayev);
//				SetObjectiveOn(shabOnFoot);
				hunter=	BuildObject("fvsent",comp_team,"hunter");
	//			Patrol(temp,"hunter_path");
				Attack(hunter,shabayev); // blow up shabs craft
				CameraReady();
				reminderTimer=GetTime()+60.0f;
				shabState++;
			}
			break;
		case 4:
			oldPlayer=HoppedOutOf(shabOnFoot);	// because shab becomes 0
			{
				Vector pos;
				pos = GetPosition(oldPlayer);
				CameraObject(oldPlayer,2,5,-7,oldPlayer);		
				LookAt(shabOnFoot, ruins, 1);
				RemoveObject(oldPlayer);
				oldPlayer=BuildObject("petank",1,pos);
			}
			shabState++;
			break;
		case 5:
			if (movie_counter<70)
			{
				CameraObject(oldPlayer,2,2,-7,oldPlayer);
				movie_counter++;
			}
			else
			{
				RemoveObject(oldPlayer);
				Handle temp=BuildObject("ibnav",1,"tree_point");
				TranslateString2(tempstr, sizeof(tempstr), "Mission0701");  // Rescue
				SetObjectiveName(temp,tempstr);
				SetObjectiveOn(temp);
				CameraFinish();
				shabState++;
			}
			break;
		case 6: //order the player to get out of his vehicle once he gets close
			if ((!IsAround(shabayev)) && (!ship_blown_up))
			{
				Patrol(hunter,"hunter_path");
				SetIndependence(hunter,0);
				ship_blown_up=true;

			}

			if ((!IsAlive(shabOnFoot) && (!shab_dead)))	
			{
				AudioMessage("isdf0732.wav");
				ClearObjectives();
				AddObjective("isdf05l1.otf",RED,15.0f);
				FailMission(GetTime()+5.0f,"isdf05l1.otf");
				shab_dead=true;
			}

			if (GetTime()>reminderTimer) {
				AudioMessage("isdf0725.wav");
				reminderTimer=GetTime()+60.0f;
			}
			
			if ((GetDistance(shabOnFoot, player) < 50.0)) {

				//RemoveObject(shabayev);
				Attack(shabEnemy1,shabayev);
				Attack(shabEnemy2,shabayev);
				ClearObjectives();
				AudioMessage("isdf0729.wav");
				AddObjective("isdf0708.otf", WHITE);
				shabState++;
			}
			break;

		case 7: //send shab to get the relic
			if ((!IsAlive(shabOnFoot) && (!shab_dead)))	
			{
				AudioMessage("isdf0732.wav");
				ClearObjectives();
				AddObjective("isdf05l1.otf",RED,15.0f);
				FailMission(GetTime()+5.0f,"isdf05l1.otf");
				shab_dead=true;
			}
			if (playerOnFoot) {
				Attack(shabEnemy1,oldPlayer);
				Attack(shabEnemy2,oldPlayer);
				Goto(shabOnFoot, ruins, 1);
				//we should start the patrols here
				shabState++;
			}
			break;
		case 8: //get shab hurt
			if ((!IsAlive(shabOnFoot) && (!shab_dead)))	
			{
				AudioMessage("isdf0732.wav");
				ClearObjectives();
				AddObjective("isdf05l1.otf",RED,15.0f);
				FailMission(GetTime()+5.0f,"isdf05l1.otf");
				shab_dead=true;
			}

			if ((GetDistance(shabOnFoot, ruins) < 20.0f) || (GetDistance(player,ruins)<10.0f))
			{
				if (winMission == false) {
					AudioMessage("isdf0731.wav"); // wrong file name
					SucceedMission(GetTime()+5.0f,"isdf07w1.txt");
					winMission = true;
				}
			}
			break;
		case 9: //hide shab
			
			break;
		case 10: //play closing cineractive
		// The following is an example of how to play a movie in a script.
			moviePlaying = PlayMovie("temp");
			if (!moviePlaying) {
				missionState++;
				moviePlaying = true;
				//IFace_SetInteger("script.mission.state", 1);
			}
			break;
	}

	if (GetHealth(shabayev) < 0.7f) { //keep shab alive
		AddHealth(shabayev, 100);
	}

	if ((GetAmmo(shabayev)) < 0.5f) {
		AddAmmo(shabayev, 500);
	}
	if ((justHoped) && (!IsAlive(shabOnFoot)))
	{
		int i;
		i=1;
		// Houston we have a problem
	}

}
コード例 #2
0
void ACMIView::Draw()
{
	static int lastButton = -1;
	Tpoint
		pos;

	Trotation
		rot;

	int i, numEntities;
	SimTapeEntity *ep;
	SimTapeEntity *targep;
	int targindex;

	TCHAR speedstring[20];
	TCHAR altitudestring[20];
	TCHAR headingstring[20];

	float ACMI_heading=0;
	float ACMI_altitude=0;
	float mph			= 0.0f;

	Tpoint posb;
	ThreeDVertex spos;

	if(TapeHasLoaded() && Tape() != NULL && Tape()->IsLoaded())
	{	
		gMainHandler->Unlock(); // Make surface available...

		// pos = _camPos;
		pos.x = 0.0f;
		pos.y = 0.0f;
		pos.z = 0.0f;
		rot = _camRot;

		// make sure the internal hud view object isn't displayed
		if((_cameraState == INTERNAL_CAM) )
			Tape()->RemoveEntityFromFrame( CameraObject() );

		// edg: ?????
		/*
		** Remove Bing-ism
		** causing a crash ....
		if(TESTBUTTONPUSH == 0 && TESTBUTTONPUSH != lastButton)
		{
			lastButton = TESTBUTTONPUSH;
			TheTerrTextures.SetOverrideTexture( wireTexture.TexHandle() );
			Viewpoint()->Update(&pos);
			_renderer->StartFrame();
			_renderer->DrawScene(&pos, &rot);
			_renderer->PostSceneCloudOcclusion();
			_renderer->FinishFrame();
			Viewpoint()->Update(&_camWorldPos);
		}
		*/

		//JAM 16Dec03
		if(DisplayOptions.bZBuffering)
			_renderer->context.SetZBuffering(TRUE);

		// start the render frame + Draw
		_renderer->context.StartFrame();
		_renderer->StartDraw();

		// render the 3d view
		_renderer->DrawScene(&pos, &rot);

		//JAM 12Dec03 - ZBUFFERING OFF
		if(DisplayOptions.bZBuffering)
			_renderer->context.FlushPolyLists();

//		_renderer->PostSceneCloudOcclusion();

		// now we do post-3d rendering
		// this includes putting in things like alt poles( shouldn't really
		// be done here), crapola hud, and some label stuff.  We need
		// to traverse the entity list on the tape in order to do this

		numEntities = Tape()->NumEntities();

		// 1st pass, turn off target boxes (bleck)
		for(i = 0; i < numEntities; i++)
		{
			// get the entity
			ep = Tape()->GetSimTapeEntity( i );
			// do these only for aircraft
			if ( ep->flags & ENTITY_FLAG_AIRCRAFT )
			{
				// default target box to off
				((DrawablePoled *)ep->objBase->drawPointer)->SetTarget( FALSE );
			}
		}

		for(i = 0; i < numEntities; i++)
		{
			// get the entity
			ep = Tape()->GetSimTapeEntity( i );

			// is it in existance at the moment?
			// also no poles or anything on chaff and flares
			if ( (ep->flags & ( ENTITY_FLAG_CHAFF | ENTITY_FLAG_FLARE ) ) ||
				 !Tape()->IsEntityInFrame( i ) )
			{
				continue;
			}

			// get world pos and screen pos of object
			ep->objBase->drawPointer->GetPosition(&pos);
			_renderer->TransformPoint( &pos, &spos);


			// radar target line
			if ( _doLockLine == 1 )
			{
				targindex = Tape()->GetEntityCurrentTarget( i );
				if ( targindex != -1 )
				{
					// get the target entity
					targep = Tape()->GetSimTapeEntity( targindex );
					ep->objBase->drawPointer->GetPosition(&pos);
					targep->objBase->drawPointer->GetPosition(&posb);

					rot = ((DrawableBSP *)ep->objBase->drawPointer)->orientation;

					// start line out in front of aircraft
					pos.x += rot.M11 * ep->objBase->drawPointer->Radius();
					pos.y += rot.M21 * ep->objBase->drawPointer->Radius();
					pos.z += rot.M31 * ep->objBase->drawPointer->Radius();


					// do target boxes and lines
					if ( _cameraState != FREE_CAM )//&& targindex == CameraObject() )//me123 we wanna see all lock lines
					{
						// current attached camera object is target
						if ( targep->flags & ENTITY_FLAG_AIRCRAFT ) 
						{
							((DrawablePoled *)targep->objBase->drawPointer)->SetTarget( TRUE );
							((DrawablePoled *)targep->objBase->drawPointer)->SetTargetBoxColor( 0xff00ffff );
						}
						
						_renderer->SetColor (0xff00ffff);
						_renderer->Render3DLine( &pos, &posb);

					} 
					else if ( _cameraState != FREE_CAM && i == CameraObject() )
					{
						// current attached camera object's target
						if ( targep->flags & ENTITY_FLAG_AIRCRAFT ) 
						{
							((DrawablePoled *)targep->objBase->drawPointer)->SetTarget( TRUE );
							((DrawablePoled *)targep->objBase->drawPointer)->SetTargetBoxColor( 0xffffffff );
						}
						_renderer->SetColor (0xffffffff);
						_renderer->Render3DLine( &pos, &posb);
					} 
					else if ( _cameraState == FREE_CAM )
					{
						_renderer->SetColor (0xff00ffff);
						_renderer->Render3DLine( &pos, &posb);
					} 

				} // if target
			} // if radar lines on


			// if we're in internal cam and we're the target object
			// display the "hud"
			if((_cameraState == INTERNAL_CAM) && i == CameraObject())
			{
			
				//HEADING
				ACMI_heading = ep->yaw * RTD;
				if ( ACMI_heading < 0.0f )
					ACMI_heading += 360.0f;
	
				// ALTITUDE
				ACMI_altitude = -(ep->z);
	
				// SPEED
				// mph=ep->aveSpeed * FTPSEC_TO_KNOTS;
				mph = CalcKIAS( ep->aveSpeed, -ep->z );
	
	
				// WIRE COCKPIT.
				if(GLOBAL_WIRE_COCKPIT == 1)
				{
					_renderer->SetColor (0xff00ff00);
					_renderer->Line( -.8f,-1.0f,-0.5f,-0.5f );
					_renderer->Line( -0.5f,-0.5f,0.5f,-0.5f );
					//_renderer->Line(  0.5f,-0.5f,1.0f,-1.3f );
					_renderer->Line(  0.5f,-0.5f,1.0f,-1.4f );
													
					_renderer->Line(  -0.5f,-0.5f,-.5f,.5f );
					_renderer->Line(  -.5f,.5f, .5f,.5f );
					_renderer->Line(  .5f,.5f, .5f,-.5f );
					if (g_bNewAcmiHud) {
						sprintf(speedstring,"%0.0f",mph);
						sprintf(altitudestring,"%0.0f",ACMI_altitude);
						sprintf(headingstring,"%0.0f",ACMI_heading);
						int ofont = _renderer->CurFont();
						_renderer->SetFont(2);
						_renderer->TextLeft(-0.48f, 0, speedstring);
						_renderer->TextRight(0.48f, 0, altitudestring);
						_renderer->TextCenter(0, 0.48f, headingstring);
						_renderer->TextCenter(0, -0.45f, ((DrawableBSP*)ep->objBase->drawPointer)->Label());
						_renderer->SetFont(ofont);
					} else {
						sprintf(speedstring,"%s: %0.0f",gStringMgr->GetString(TXT_AIRSPEED),mph);
						sprintf(altitudestring,"%s: %0.0f",gStringMgr->GetString(TXT_ALTITUDE),ACMI_altitude);
						sprintf(headingstring,"%s: %0.0f",gStringMgr->GetString(TXT_HEADING),ACMI_heading);
						_renderer->ScreenText(250.0f,160.0f,((DrawableBSP*)ep->objBase->drawPointer)->Label(),0);
						_renderer->ScreenText(250.0f,170.0f,speedstring,0);
						_renderer->ScreenText(250.0f,180.0f,altitudestring,0);
						_renderer->ScreenText(250.0f,190.0f,headingstring,0);
					}
					_renderer->SetColor (0xffff0000);
				}
			}
		}

		// tell renderer we're done
		_renderer->EndDraw();
		_renderer->context.FinishFrame(NULL);
		if(_takeScreenShot)
		{
			TakeScreenShot();
		}
		gMainHandler->Lock();

		// update the entities
		// MUST be done after render
		Tape()->UpdateSimTapeEntities();

	}
}
コード例 #3
0
/*
** Name: UpdateViewPosRot
** Description:
**		Updates the view world position and rotation depending on
**		the camera setting and what we're tracking and panner positions
*/
void ACMIView::UpdateViewPosRot( void )
{
	int camObj;
	int trackObj;
	SimTapeEntity *camEnt;
	SimTapeEntity *trackEnt;
	Tpoint dPos;
	float dT;
	float dRoll;
	float dist;
	float objScale;

	// get any camera objects we might need
	camObj = CameraObject();
	trackObj = TrackingObject();
	camEnt = Tape()->GetSimTapeEntity( camObj );
	trackEnt = Tape()->GetSimTapeEntity( trackObj );

	// get current scaling
	objScale = Tape()->GetObjScale();


	// if we're not in free camera mode, our world position is
	// based on the camera object
	if ( _cameraState != FREE_CAM )
	{
		_camWorldPos.x = camEnt->x;
		_camWorldPos.y = camEnt->y;
		_camWorldPos.z = camEnt->z;
	}

	// first pass:
	// 	get yaw pitch and roll for camera
	switch(_cameraState)
	{
		case INTERNAL_CAM:			//internal
			_camYaw = camEnt->yaw;
			_camPitch = camEnt->pitch;
			_camRoll = camEnt->roll;
			break;
		case EXTERNAL_CAM:			// orbit
			_camYaw += _pannerAz;
			_camPitch += _pannerEl;
			_camRoll = 0.0f;
			_camRange += _pannerX;
			if ( _camRange > -50.0f )
				_camRange = -50.0f;
			break;
		case TRACKING_CAM:			// tracking
			_camYaw += _pannerAz;
			_camPitch += _pannerEl;
			_camRoll = 0.0f;
			_camRange += _pannerX;
			if ( _camRange > -50.0f )
				_camRange = -50.0f;
			break;
		case CHASE_CAM:			//Chase
			_camRange += _pannerX;
			if ( _camRange > -50.0f )
				_camRange = -50.0f;

			// where we want camera to be
			_chaseX = camEnt->objBase->dmx[0][0] * _camRange * objScale;
			_chaseY = camEnt->objBase->dmx[0][1] * _camRange * objScale;
			_chaseZ = camEnt->objBase->dmx[0][2] * _camRange * objScale;

			dT = Tape()->GetDeltaSimTime();
			if ( dT <= 0.0f )
				dT = 0.1f;

			// "spring" constants for camera roll and move
			#define KMOVE			0.29f
			#define KROLL			0.30f
		
			// convert frame loop time to secs from ms
			// dT = (float)frameTime * 0.001;
		
			// get the diff between desired and current camera pos
			dPos.x = _chaseX - _camPos.x;
			dPos.y = _chaseY - _camPos.y;
			dPos.z = _chaseZ - _camPos.z;
		
			// send the camera thataway
			_camPos.x += dPos.x * dT * KMOVE;
			_camPos.y += dPos.y * dT * KMOVE;
			_camPos.z += dPos.z * dT * KMOVE;
		
			// "look at" vector
			dPos.x = -_camPos.x;
			dPos.y = -_camPos.y;
			dPos.z = -_camPos.z;

			// get new camera roll
			dRoll = camEnt->roll - _camRoll;

			// roll in shortest direction
			if ( fabs( dRoll ) > 180.0f * DTR )
			{
				if ( dRoll < 0.0f )
					dRoll = 360.0f * DTR + camEnt->roll - _camRoll;
				else
					dRoll = -360.0f * DTR + camEnt->roll - _camRoll;
			}
		
			// apply roll
			_camRoll += dRoll * dT * KROLL;
		
			// keep chase cam roll with +/- 180
			if ( _camRoll > 1.0f * PI )
				_camRoll -= 2.0f * PI;
			else if ( _camRoll < -1.0f * PI )
				_camRoll += 2.0f * PI;
		
			// now get yaw and pitch based on look at vector
			dist = (float)sqrt( dPos.x * dPos.x + dPos.y * dPos.y + dPos.z * dPos.z );
			_camPitch	= (float)-asin( dPos.z/dist );
			_camYaw	= (float)atan2( dPos.y, dPos.x );

			break;
		case SAT_CAM:		// Satellite
			_camYaw += _pannerAz;
			_camPitch += _pannerEl;
			if ( _camPitch > -45.0f * DTR )
				_camPitch = -45.0f * DTR;
			else if ( _camPitch < -90.0f * DTR )
				_camPitch = -90.0f * DTR;
			_camRoll = 0.0f;
			_camRange += _pannerX * 100.0f;
			if ( _camRange > -1000.0f )
				_camRange = -1000.0f;
			break;
		case ISO_CAM:		// ISOMETRIC
			_camYaw += _pannerAz;
			_camPitch += _pannerEl;
			if ( _camPitch > -15.0f * DTR )
				_camPitch = -15.0f * DTR;
			else if ( _camPitch < -60.0f * DTR )
				_camPitch = -60.0f * DTR;
			_camRoll = 0.0f;
			_camRange += _pannerX * 100.0f;
			if ( _camRange > -50.0f )
				_camRange = -50.0f;
			break;
		case FREE_CAM:			// Free
			_camYaw += _pannerAz;
			_camPitch += _pannerEl;
			_camRoll = 0.0f;
			_pannerX *= 20.0f;
			_pannerY *= 20.0f;
			_pannerZ *= 20.0f;
			// head in the direction we're currently facing (ie based on
			// current cam rotation
			_camWorldPos.x += _camRot.M11 * _pannerX + _camRot.M12 * _pannerY + _camRot.M13 * _pannerZ;
			_camWorldPos.y += _camRot.M21 * _pannerX + _camRot.M22 * _pannerY + _camRot.M23 * _pannerZ;
			_camWorldPos.z += _camRot.M31 * _pannerX + _camRot.M32 * _pannerY + _camRot.M33 * _pannerZ;
			break;
		default:
			_camYaw = camEnt->yaw;
			_camPitch = camEnt->pitch;
			_camRoll = camEnt->roll;
			break;
	};

	// second pass:
	//		create the rotation matrix
	float costha,sintha,cosphi,sinphi,cospsi,sinpsi;

	costha = (float)cos(_camPitch);
	sintha = (float)sin(_camPitch);
	cosphi = (float)cos(_camRoll);
	sinphi = (float)sin(_camRoll);
	cospsi = (float)cos(_camYaw);
	sinpsi = (float)sin(_camYaw);

	_camRot.M11 = cospsi*costha;
	_camRot.M21 = sinpsi*costha;
	_camRot.M31 = -sintha;

	_camRot.M12 = -sinpsi*cosphi + cospsi*sintha*sinphi;
	_camRot.M22 = cospsi*cosphi + sinpsi*sintha*sinphi;
	_camRot.M32 = costha*sinphi;

	_camRot.M13 = sinpsi*sinphi + cospsi*sintha*cosphi;
	_camRot.M23 = -cospsi*sinphi + sinpsi*sintha*cosphi;
	_camRot.M33 = costha*cosphi;

	// third pass:
	//		Set the relative camera positiion
	switch(_cameraState)
	{
		case INTERNAL_CAM:			//internal
			_camPos.x = 0.0f;
			_camPos.y = 0.0f;
			_camPos.z = 0.0f;
			break;
		case EXTERNAL_CAM:			// orbit
			_camPos.x = _camRot.M11 * _camRange * objScale;
			_camPos.y = _camRot.M21 * _camRange * objScale;
			_camPos.z = _camRot.M31 * _camRange * objScale;
			break;
		case TRACKING_CAM:			// orbit
			if ( camObj == trackObj )
			{
				_camPos.x = _camRot.M11 * _camRange * objScale;
				_camPos.y = _camRot.M21 * _camRange * objScale;
				_camPos.z = _camRot.M31 * _camRange * objScale;
			}
			else
			{
				// line up a vector between cam and track obj and place
				// camera on the vector, slightly up
				dPos.x = trackEnt->x - camEnt->x;
				dPos.y = trackEnt->y - camEnt->y;
				dPos.z = trackEnt->z - camEnt->z;
				dist = 1.0F/(float)sqrt( dPos.x * dPos.x + dPos.y * dPos.y + dPos.z * dPos.z );
				_camPos.x = dPos.x * dist * _camRange * objScale;
				_camPos.y = dPos.y * dist * _camRange * objScale;
				_camPos.z = dPos.z * dist * _camRange *objScale + _camRange * 0.2f;
			}
			break;
		case CHASE_CAM:			//Chase
			break;
		case SAT_CAM:		// Satellite
			_camPos.x = _camRot.M11 * _camRange;
			_camPos.y = _camRot.M21 * _camRange;
			_camPos.z = _camRot.M31 * _camRange;
			break;
		case ISO_CAM:		// ISOMETRIC
			_camPos.x = _camRot.M11 * _camRange;
			_camPos.y = _camRot.M21 * _camRange;
			_camPos.z = _camRot.M31 * _camRange;
			break;
		case FREE_CAM:			// Free
			_camPos.x = 0.0f;
			_camPos.y = 0.0f;
			_camPos.z = 0.0f;
			break;
		default:
			_camPos.x = 0.0f;
			_camPos.y = 0.0f;
			_camPos.z = 0.0f;
			break;
	};

	// fourth pass
	//		if we're tracking an object we need to set a new rotation
	//		matrix
	// determine if we're tracking an object or not
	if (  _cameraState == TRACKING_CAM && camObj != trackObj )
	{
		// get the diff between desired and current camera pos
		// for look at vector
		dPos.x = trackEnt->x - (_camPos.x + _camWorldPos.x);
		dPos.y = trackEnt->y - (_camPos.y + _camWorldPos.y);
		dPos.z = trackEnt->z - (_camPos.z + _camWorldPos.z);

		// now get yaw and pitch based on look at vector
		dist = (float)sqrt( dPos.x * dPos.x + dPos.y * dPos.y + dPos.z * dPos.z );
		float p	= (float)-asin( dPos.z/dist );
		float y	= (float)atan2( dPos.y, dPos.x );

		costha = (float)cos(p);
		sintha = (float)sin(p);
		cosphi = (float)(1.0f);
		sinphi = (float)(0.0f);
		cospsi = (float)cos(y);
		sinpsi = (float)sin(y);
	
		_camRot.M11 = cospsi*costha;
		_camRot.M21 = sinpsi*costha;
		_camRot.M31 = -sintha;
	
		_camRot.M12 = -sinpsi*cosphi + cospsi*sintha*sinphi;
		_camRot.M22 = cospsi*cosphi + sinpsi*sintha*sinphi;
		_camRot.M32 = costha*sinphi;
	
		_camRot.M13 = sinpsi*sinphi + cospsi*sintha*cosphi;
		_camRot.M23 = -cospsi*sinphi + sinpsi*sintha*cosphi;
		_camRot.M33 = costha*cosphi;
	}


	// reset panning
	ResetPanner();

}
コード例 #4
0
ファイル: isdf05.cpp プロジェクト: Nielk1/bz2-sp-fixes
void isdf05Mission::Execute(void)
{

	/*
	a) The player is asked to patrol around the base

	(through steps b-d sent & scouts attack)

	b) Once the base is secure, the player is supposed
	to look for scrap veins and send a scavenger (twice)

	c)Eventually you get to some turrets.  
	Shebayev detaches some mortar bikes to help you take 
	out the turrets.  

	d) Once the turrets are destroyed you need to
	deploy

	e) Follow Manson to the teleporter?  Drop off a bomb
	*/
	char tempstr[128];
	Handle nearguy = 0;
	// this is the start of the mission
	if (!start_done)
	{

		/*
		Alright Sgt Cooke, this looks like
		a good place to establish a base.  
		Patrol the area around this recycler.  
		If it looks safe, deploy the recycler.  
		*/
		shabayev = BuildObject("ivtan5",1,"shab_start");//"patrol_east");
		constructor = BuildObject("ivcons",1,"spawn_constructor");
		Stop(constructor,1);
		scav_comp= GetHandle("scav3");
		SetGroup(scav_comp,-1);
		Handle temppool=GetHandle("poolx");
		Goto(scav_comp,temppool,1);
		//	SetPlan("isdf05.aip",3);  // build stuff
		AudioMessage("isdf0500.wav");
		SetObjectiveOn(shabayev);
		SetObjectiveName(shabayev,"Cmdr. Shabayev");


		audmsg=AudioMessage("isdf0501.wav");
		patrol_phase=true;
		start_done = true;

		Handle tempscav=GetHandle("ivscav1");
		KillPilot(tempscav);
		tempscav=GetHandle("ivscav2");
		KillPilot(tempscav);
		//		Handle fv=BuildObject("fvarch",2,"scrap_field1");
		//		SetSkill(fv,3);
		SetSkill(shabayev,3);
		//		Patrol(shabayev,"patrol1",1);
		//		Attack(shabayev,fv,1);
		recy=BuildObject("ivrec5",1,"recy_start");
		//		Goto(recy,"recy_deploy");
		Dropoff(recy, "recy_deploy");
		Follow(shabayev,recy,1);
		SetScrap(1,40);
		SetScrap(3,40);  // allied resources
	}

	/*
	Here is where you put what happens every frame.  
	*/

	player = GetPlayerHandle();
	if ((!IsAlive(shabayev) && (!shab_dead)))
	{
		AudioMessage("isdf0732.wav");
		ClearObjectives();
		AddObjective("isdf05l1.otf",RED,15.0f);
		FailMission(GetTime()+5.0f,"isdf05l1.otf");
		shab_dead=true;
	}

	// determining if the player is out of his ship
	if (IsOdf(player,"isuser"))
	{
		if (!out_of_ship) GiveWeapon(player, "igsatc");
		out_of_ship = true;
	}
	else
	{
		out_of_ship = false;
	}

	if ((GetDistance(player,"spawn2")<150.f) && (!warning_message))
	{
		AudioMessage("isdf0520.wav");
		/*
		Stay away from those alien structures
		they aren't 
		vital to our mission-
		but they may be dangerous. 
		*/
		warning_message=true;
	}
	// this is checking to make sure the player does not attack his wingman /////////
	if ((!in_combat) && (!fire_message))
	{
		if ((IsAlive(shabayev)) && (IsAlive(player)))
		{
			if (GetTime() - GetLastFriendShot(shabayev) < .2f)
			{
				AudioMessage("ff01.wav"); // (shab) watch your firing!
				fire_reset = GetTime() + 2.f;
				fire_message = true;
			}
		}

		if ((IsAlive(manson)) && (IsAlive(player)))
		{
			if (GetTime() - GetLastFriendShot(manson) < .2f)
			{
				AudioMessage("isdf0555.wav"); // (manson) watch your firing!
				fire_reset = GetTime() + 2.f;
				fire_message = true;
			}
		}
	}

	if ((fire_message) && (fire_reset < GetTime()))
	{
		fire_reset = GetTime() + 999999.9f;
		fire_message = false;
	}
	if ((!IsAlive(constructor)) && (mission_state<10))
	{
		// the constructor is dead, you lose
		mission_state=12;
	}

	switch (mission_state)
	{
	case 0:

		// Shabayev starts the base
		if (GetDistance(recy,"recy_deploy") < 25.0)
		{
			//				Dropoff(recy,"recy_deploy");
			Patrol(shabayev,"patrol1",1);
			SetIndependence(shabayev,1);
			ClearObjectives();
			AddObjective("isdf0501.otf", WHITE, 10.0f);
			patrol_reminder_time=GetTime()+30.0f;
			MoviePlaying=true;
			CameraReady();
			// but danger looms..
			atk1=BuildObject("fvscout",2,"spawn1");
			wasDead1=false;
			Attack(atk1,player);
			mission_state++;
		}
		break;

	case 1:
		if (MoviePlaying)
		{
			//CameraObject(recycler,5,5,5,recycler);
			MoviePlaying = PlayMovie("isdf0501.cin");	
			//		if (IsAudioMessageDone(audmsg)) {
			if (!MoviePlaying)
			{
				//	MoviePlaying=false;
				CameraFinish();
				Build(constructor,"ibpge5",1);
				drop_off=true;
				Attack(shabayev,atk1);
				mission_state++;
			}
		}
		ReallyKillCineractive = 0;
		break;

	case 2: // patrol_phase

		// Kick this out a few extra times.
		if((ReallyKillCineractive == 0) || (ReallyKillCineractive == 10) || 
			(ReallyKillCineractive == 20))
			CameraFinish();
		ReallyKillCineractive++;

		if (drop_off)
		{
			Dropoff(constructor,"pgen1",1);
			drop_off=false;
			Handle temp=GetHandle("unnamed_ivdrop");
			Attack(shabayev,atk1,1);
			RemoveObject(temp);
		}

		if (!IsAlive(atk1))
		{
			wait_count++;
			if (wait_count==250)
			{
				wasDead1=false;
				wasDead2=false;
				raid1=BuildObject("fvsent",2,"raid1");
				Goto(raid1,recy);
				raid2=BuildObject("fvtank",2,"raid2");
				Goto(raid2,recy);
				//				raid3=BuildObject("fvsent",2,"raid3");
				//				Goto(raid3,recy);
				//				raid4=BuildObject("fvtank",2,"raid4");
				//				Goto(raid4,recy);
				ClearObjectives();
				AddObjective("isdf0517.otf",WHITE,10.0f);
				Goto(shabayev,constructor);
				AudioMessage("isdf0543.wav");
				mission_state++;
				wait_count=0;
			}
		}
		break;

	case 3:
		if (power2)
		{
			Dropoff(constructor,"pgen2",1);
			power2=false;
		}
		if (com1)
		{
			Dropoff(constructor,"rbunker1",1);
			com1=false;
		}
		if (!IsAliveAndPilot(raid1)) {
			wasDead1=true;	
		}
		if (!IsAliveAndPilot(raid2)) {
			wasDead2=true;
		}
		if ((wasDead1) && (wasDead2))
		{
			if (raid_count==1)  // should be 2
			{
				/*
				Now look for scrap veins
				around the base.  
				If you find one mark it with 
				a nav beacon.  
				*/
				scout_phase=true;
				ClearObjectives();
				AddObjective("isdf0507.otf",WHITE,5.0f);
				SetObjectiveOff(shabayev);
				nav1=BuildObject("ibnav",1,"scrap_field1");
				TranslateString2(tempstr, sizeof(tempstr), "Mission0501");  // tempstr
				SetObjectiveName(nav1,tempstr);
				SetObjectiveOn(nav1);
				//					SetObjectiveName(pool1,"bio-metal");
				//					SetObjectiveOn(pool1);

				AudioMessage("isdf0507.wav");	
				// Add an attacked for spice
				Handle atk1=BuildObject("fvscout",2,"spawn1");
				Goto(atk1,"attack1");
				Patrol(shabayev,"patrol1",1);
				SetIndependence(shabayev,1);
				// AudioMessage(
				// You go on John, I'll guard the base
				mission_state++;
			}
			else
			{
				wait_count++;
				if (wait_count==400)
				{
					if  (pgen2==NULL)
					{	
						// was follow
						Goto(shabayev,constructor,1);
						Build(constructor,"ibpge5");
						power2=true;
					}
					else 
					{
						//was Follow
						Goto(shabayev,constructor,1);
						Build(constructor,"ibcbu5");
						com1=true;
					}
					raid_count++;
					AddHealth(constructor,500);
					AddHealth(shabayev,500);
					raid1=BuildObject("fvtank",2,"raid1");
					Goto(raid1,recy);
					raid2=BuildObject("fvtank",2,"raid2");
					Goto(raid2,recy);
					wasDead1=false;
					wasDead2=false;
					//					raid3=BuildObject("fvsent",2,"raid3");
					//					Goto(raid3,recy);
					//					raid4=BuildObject("fvtank",2,"raid4");
					//					Goto(raid4,recy);
					wait_count=0;
				}
			}
		}

		break;

	case 4: 	
		// there is one, mark it with the geyser
		// mark that with a power up
		// good, now find another.  
		if ((GetDistance(player,pool1)<75.0f) && (!found_field1))
		{
			// there is a field, deploy the scavenger

			AudioMessage("isdf0508.wav");
			found_field1=true;
		}
		if (scav2_deployed) // any scav is deployed
		{
			mission_state++;
			scav1_deployed=true;
			ClearObjectives();
			AddObjective("isdf0508.otf",WHITE,10.0f);
			/*
			SetObjectiveOff(pool1);
			SetObjectiveName(pool2,"bio-metal 1");
			SetObjectiveOn(pool2);
			*/
			nav2=BuildObject("ibnav",1,"scrap_field3");
			TranslateString2(tempstr, sizeof(tempstr), "Mission0502");  // Bio-Metal 2
			SetObjectiveName(nav2,tempstr);
			SetObjectiveOff(nav1);
			SetObjectiveOn(nav2);
			AudioMessage("isdf0509.wav");  // good job
			if (!found_field1)
			{
				AudioMessage("isdf0519.wav");
				/*
				Don't send out scavengers unescorted.  
				Be sure to stay with them.
				*/
			}
		}
		break;

	case 5:
		if ((scav2_deployed) && (!found_field3) && (GetDistance(player,"scrap_field3")<225.0f))
		{
			found_field3=true;
			/*
			Watch out!
			That field looks hot.  
			*/
			AudioMessage("isdf0512.wav");
			ClearObjectives();
			AddObjective("isdf0511.otf",RED,10.0f);
			mortar_delay=GetTime()+15.0f;
		}
		nearguy=GetNearestEnemy(player);
		if ((found_field3) && (GetTime()>mortar_delay)
			&& (GetDistance(player,nearguy)>150.0f))
		{
			/*
			Cineractive
			Cooke, I'm sending you
			force to help 
			you take out those turrets!
			Here are some mortar bikes.  
			*/

			Build(constructor,"ibfact5",1);
			factory=true;

			audmsg=AudioMessage("isdf0527.wav");
			//was AudioMessage("isdf0513.wav");
			ClearObjectives();
			AddObjective("isdf0516.otf",WHITE,10.0f);
			/*
			int grp=GetFirstEmptyGroup();			
			mbike1=BuildObject("ivmbike",1,"patrol_south");
			SetGroup(mbike1,grp);
			Follow(mbike1,player,0);
			Handle mb=BuildObject("ivmbike",1,"patrol_east");
			SetGroup(mb,grp);
			Follow(mb,player,0);
			mb=BuildObject("ivmbike",1,"patrol_west");
			SetGroup(mb,grp);
			Follow(mb,player,0);
			mb=BuildObject("ivmbike",1,"patrol_north");
			SetGroup(mb,grp);
			Follow(mb,player,0);
			*/
			mission_state++;
			CameraReady();
			MoviePlaying=true;
		}
		break;

	case 6:// attack phase 
		/*
		First check to see if you blew up
		sturret1-4
		then create Manson
		at manson_start
		"Good job Cooke, you show promise"
		Then follow Manson (he's an objective)
		into the base
		When you get close
		lets run past those towers

		when you get there
		hop out and use your demolition charge

		Then run away.  Everything blows up.  
		*/
		if (factory)
		{
			Dropoff(constructor,"fact");
			factory=false;
		}
		if (MoviePlaying)
		{
			CameraObject(constructor,1,11,22,constructor);
			if (IsAudioMessageDone(audmsg))
			{
				MoviePlaying=false;
				CameraFinish();
			}
		}

		if ((!killed_turrets) &&
			(!IsAlive(sturret1)) && 
			(!IsAlive(sturret2)) &&
			(!IsAlive(sturret3)) && (!IsAlive(sturret4))
			&&
			(!IsAlive(sturret5)) && (!IsAlive(sturret6)))
		{
			AudioMessage("isdf0514.wav"); // you show promise
			killed_turrets=true;
			ClearObjectives();
			AddObjective("isdf0512.otf",WHITE,10.0f);
			manson_shows=GetTime()+10.0f;
			manson=BuildObject("ivtank",3,"manson_start");
			SetObjectiveName(manson, "Maj. Manson");
			Handle minion=BuildObject("ivtank",3,"manson_escort1");
			SetObjectiveName(minion, "Sgt. Zdarko");
			Follow(minion,manson);
			minion=BuildObject("ivtank",3,"manson_escort2");
			SetObjectiveName(minion, "Sgt. Masiker");
			Follow(minion,manson);
		}
		if ((killed_turrets) && (!manson_message) && 
			(GetTime()>manson_shows))
		{
			/*
			We found the objective, 
			follow me
			*/
			AudioMessage("isdf0515.wav");
			SetObjectiveOff(nav2);
			SetObjectiveOn(manson);
			ClearObjectives();
			AddObjective("isdf0518.otf",WHITE,10.0f);
			manson_message=true;
			mission_state++;
		}
		break;

	case 7:
		if (GetDistance(player,manson)<50.0f)
		{
			ClearObjectives();
			AddObjective("isdf0513.otf",WHITE,10.0f);
			SetIndependence(manson,0);
			SetAvoidType(manson,0);
			AudioMessage("isdf0539a.wav");
			Goto(manson,"manson_path1");				
			mission_state++;
		}	
		break;

	case 8:
		AddHealth(manson,100); // we don't want him to die here
		if ((wait_up) && (GetDistance(player,manson)<100.0f))
		{
			// right now this goes off too 
			// soon.   You go on to path 2 before 1 is doen
			// But at least it makes sure
			// you are close once.  
			wait_up=false;
			Goto(manson,"manson_path2");
		}
		if ((!gun_tower_message) && (GetDistance(manson,"guntower2")<200.0f))
		{
			/*
			There are gun towers ahead
			let's try to go past fast.  
			*/
			AudioMessage("isdf0516.wav");
			gun_tower_message=true;
			ClearObjectives();
			AddObjective("isdf0514.otf",WHITE,10.0f);
			gun_tower_counter=0;
		}
		if (gun_tower_message) 
		{
			gun_tower_counter++;
			if (gun_tower_counter>450)  // you are on a timer
			{
				AudioMessage("isdf0529.wav");
				ClearObjectives();
				AddObjective("isdf0520.otf",RED,10.0f);
				FailMission(GetTime()+10.0f,"isdf0520.otf");
				mission_state=12;
			}
			if (gun_tower_counter==300)
			{
				AudioMessage("isdf0528.wav");
			}
		}
		if ((gun_tower_message) && (!hop_out_message) &&
			(GetDistance(player,teleportal)<100.0f))
		{
			/* 
			Get out and use your
			demolition charge on
			that building
			*/
			AudioMessage("isdf0173.wav");  // that looks like one of ours?
			AudioMessage("isdf0517.wav");
			hop_out_message=true;
			SetObjectiveOff(manson);
			SetObjectiveOn(teleportal);
			TranslateString2(tempstr, sizeof(tempstr), "Mission0503");  // Excavator
			SetObjectiveName(teleportal,tempstr);
			ClearObjectives();
			AddObjective("isdf0515.otf",WHITE,10.0f);
			SetIndependence(manson,1);
			mission_state++;
		}
		break;

	case 9:
		if ((!out_of_ship_ever) && (out_of_ship)) {
			out_of_ship_ever=true;
			ClearObjectives();
			AddObjective("isdf0521.otf",WHITE,5.0f);
		}
		if (!IsAlive(teleportal))
		{
			if (out_of_ship_ever)
			{
				AudioMessage("isdf0518.wav");
				SucceedMission(GetTime()+10.0f,"isdf05w1.txt");
				mission_state++;
			}
			else
			{
				AudioMessage("isdf0521.wav");
				/*
				I said use your
				demolition charge
				*/
				FailMission(GetTime()+10.0f,"isdfl1.txt");
				mission_state++;
			}
		}
		break;

	case 12:
		/*
		If you lose the constructor
		this condition occurs.  
		*/
		AudioMessage("isdf0522.wav");
		ClearObjectives();
		AddObjective("isdf0519.otf",RED,10.0f);
		FailMission(GetTime()+10.0f,"isdf0519.otf");
		mission_state++;
		break;
	case 13:
		// waiting for the end of the world.  
		break;
	}



	/*
	the lurkers
	*/
	if ((lurker1==NULL) && (GetDistance(player,"lurker1")<150.0f))
	{
		lurker1=BuildObject("fvsent",2,"lurker1");
	}
	if ((lurker2==NULL) && (GetDistance(player,"lurker2")<150.0f))
	{
		lurker2=BuildObject("fvsent",2,"lurker1");
	}
	if ((lurker3==NULL) && (GetDistance(player,"lurker3")<150.0f))
	{
		lurker3=BuildObject("fvsent",2,"lurker3");
	}
	if ((lurker4==NULL) && (GetDistance(player,"lurker4")<150.0f))
	{
		lurker4=BuildObject("fvsent",2,"lurker4");
	}
}