/*
*	initialize.cpp
*	----------------------------------------
*	A part of "Intelligent AI"
*	© 2001 SCC Team 064
*	----------------------------------------
*
*	This file:
*		€ Contains functions for the initialization of all variables to default values.
*		€ Contains functions for initializing the simulation state prior to
*		   the start of a new simulation (using parameters needed for setting
*		   up the simulation).
*		€ Logs all initialization to a file (if this preference is enabled
*		   by the User).
*/

#include "Project.h"


player_class 			player[MAX_PLAYERS];
double					startLocation[MAX_PLAYERS][3];


/*------------------------------------------------------------------------------------------*/
/*									INITIALIZATION FUNCTIONS								*/
/*------------------------------------------------------------------------------------------*/



/* This initilizes the starting location for the comand centers of each player
/*----------------------------------------------------------------------------------*/
void initStartLocations()
{
	startLocation[0][0]	= 20;
	startLocation[0][1]	= -20;
	startLocation[0][2]	= 50;

	startLocation[1][0]	= 0;
	startLocation[1][1]	= 0;
	startLocation[1][2]	= 50;
}


/*									Initilize Simulation							*/
/*----------------------------------------------------------------------------------*/
/*
* AI calls this function to initilize its fighter
*/
void initSimState()
{
	CreateUnit(SIMFIGHTER);
}


/*										Create Unit									*/
/*----------------------------------------------------------------------------------*/
/*
* This function initilizes the new unit's attributes and location, and added it to the 
* appropriate player array.
*/
void CreateUnit(int whichType)
{
	for (int i = 0; i < MAX_PLAYERS; i++)
	{
		player[i].xPos		= startLocation[i][0];		//Start location for each player
		player[i].yPos		= startLocation[i][1];
		player[i].zPos		= startLocation[i][2];

		init_stdAttributes(i, whichType);

	/* These variables are constant for every type of unit  */
		player[i].pitch 	= 0;
		player[i].yaw 	= 0;
		player[i].roll	 	= 0;

		player[i].targetPitch 	= 0;
		player[i].targetYaw 	= 0;
		player[i].targetRoll	= 0;

		player[i].lockOn		= 0;
		player[i].underFire	= false;
		player[i].firing		= false;
		player[i].flashColor	= false;
		player[i].status 		= inactive;
		player[i].whichPlayer	= i;
	}
}


/*								Init Standard Attributes							*/
/*----------------------------------------------------------------------------------*/
void init_stdAttributes(int i, int unitType)
{
	switch (unitType)
	{
	/* Initalizes standard attributes for a SIMFIGHTER */
		case SIMFIGHTER:
			player[i].range = 10;
			player[i].hitPoints = 70;
			player[i].damage = 1;
			player[i].speedX = 0;
			player[i].speedY = 0;
			player[i].speedZ = 0;
			player[i].turnRate = 500.;

			player[i].liftCoef = 10;
			player[i].dragCoef = -.05; 	//when max speed is 1491.31km/h
			player[i].mass = 10000;
			player[i].thrust = 111200;	//80000
			player[i].maxThrust = 111200;

			player[i].uType = SIMFIGHTER;
		break;
	
	/* Initalizes standard attributes for a MINIFIGHTER */
		case MINIFIGHTER:
			player[i].range = 6;

			player[i].hitPoints = 5;
			player[i].damage = 3;
			player[i].speed = .08;
			player[i].turnRate = 150;
			player[i].uType = MINIFIGHTER;
		break;

	/* Initalizes standard attributes for a SCOUT */
		case SCOUT:
			player[i].range = 10;
			player[i].hitPoints = 6;
			player[i].speed = .1.1;
			player[i].turnRate = 50;

			player[i].damage = 1;
			player[i].uType = SCOUT;
		break;
	}
}