コード例 #1
0
ファイル: homies_util.cpp プロジェクト: PtrickH/homies
//creates a bunch of light from file
PUBLIC RETCODE GUTLoadLights(const char *filename)
{
	D3DLIGHT8 lightStruct;

	//load up file
	FILE *fp = fopen(filename, "rt");

	if(fp)
	{
		char buff[MAXCHARBUFF];

		//get num light
		int max;
		fscanf(fp, "numLight=%d\n", &max);

		for(int i = 0; i < max; i++)
		{
			//get light type
			fscanf(fp, "%s\n", buff);

			if(stricmp("point", buff) == 0)
				lightStruct.Type = D3DLIGHT_POINT;
			else if(stricmp("spot", buff) == 0)
				lightStruct.Type = D3DLIGHT_SPOT;
			else if(stricmp("directional", buff) == 0)
				lightStruct.Type = D3DLIGHT_DIRECTIONAL;

			//get diffuse color
			fscanf(fp, "diff: %f,%f,%f,%f\n", 
				&lightStruct.Diffuse.r, &lightStruct.Diffuse.g, &lightStruct.Diffuse.b, &lightStruct.Diffuse.a);

			//get specular color
			fscanf(fp, "spec: %f,%f,%f,%f\n", 
				&lightStruct.Specular.r, &lightStruct.Specular.g, &lightStruct.Specular.b, &lightStruct.Specular.a);

			//get ambient color
			fscanf(fp, "amb: %f,%f,%f,%f\n", 
				&lightStruct.Ambient.r, &lightStruct.Ambient.g, &lightStruct.Ambient.b, &lightStruct.Ambient.a);

			//get position
			fscanf(fp, "pos: %f,%f,%f\n", &lightStruct.Position.x, &lightStruct.Position.y, &lightStruct.Position.z);

			//get direction
			fscanf(fp, "dir: %f,%f,%f\n", &lightStruct.Direction.x, &lightStruct.Direction.y, &lightStruct.Direction.z);

			//get range
			fscanf(fp, "rng: %f\n", &lightStruct.Range);

			//get falloff
			fscanf(fp, "foff: %f\n", &lightStruct.Falloff);

			//get Attenuation 0/1/2
			fscanf(fp, "atten012: %f,%f,%f\n", &lightStruct.Attenuation0, &lightStruct.Attenuation1, &lightStruct.Attenuation2);

			//get inner/outer angle
			fscanf(fp, "inAngle: %f\n", &lightStruct.Theta);
			fscanf(fp, "outAngle: %f\n", &lightStruct.Phi);

			LightAdd(&lightStruct);
		}

		fclose(fp);
		return RETCODE_SUCCESS;
	}

	return RETCODE_FAILURE;
}
コード例 #2
0
ファイル: CheatMgr.cpp プロジェクト: rickyharis39/nolf2
bool CCheatMgr::Process( CheatCode nCheatCode, CParsedMsg &cMsg )
{
	if ( nCheatCode <= CHEAT_NONE || nCheatCode >= CHEAT_MAX ) return false;

#ifdef _FINAL
	// Don't do cheats in multiplayer...
    if (IsMultiplayerGame())
	{
		// Well, okay, let them toggle between 1st and 3rd person ;)
		// and, well, blood is pretty cool...
		switch ( nCheatCode )
		{
			case CHEAT_CHASETOGGLE:
				ChaseToggle();
			break;

			case CHEAT_EXITLEVEL:	// exit the current level
				SetExitLevel();
			break;

			case CHEAT_NEXTMISSION:	// exit the current mission
				NextMission();
			break;

			case CHEAT_BOOT:		// boot players
				BootPlayer(cMsg);
			break;

			default :
				return false;
			break;
		}

		m_bPlayerCheated = LTTRUE;
		return true;
	}
#endif // _FINAL

	// process cheat codes
	switch ( nCheatCode )
	{
		case CHEAT_GOD:			// god mode toggle
			SetGodMode(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_SKILLZ:		// give em skill points
			GetSkills();
		break;

		case CHEAT_ARMOR:		// full armor
			SetArmor();
		break;

		case CHEAT_HEALTH:		// full health
			SetHealth();
		break;

		case CHEAT_EXITLEVEL:	// exit the current level
			SetExitLevel();
		break;

		case CHEAT_VERSION:		// display version info
			Version();
		break;

		case CHEAT_BUILDGUID:	// display build guid
			BuildGuid();
		break;

		case CHEAT_INVISIBLE:	// time to mess with the AI
			SetInvisible(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_BODYGOLFING:	// bodies fly far	
			BodyGolfing(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_POS:			// show/hide player position
			SetPos(!s_CheatInfo[nCheatCode].bActive);
		break;

#ifndef _TO2DEMO
		
		case CHEAT_KFA:			// give em everything
			SetKFA();
		break;

		case CHEAT_AMMO:		// full ammo
			SetAmmo();
		break;

		case CHEAT_MODSQUAD:	// give all mods for current weapons
			ModSquad();
		break;

		case CHEAT_CONSOLE:
			SetConsole(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_NEXTMISSION:	// exit the current mission
			NextMission();
		break;

		case CHEAT_BOOT:	// exit the current mission
			BootPlayer(cMsg);
		break;

		case CHEAT_FULL_WEAPONS:   // give all weapons
			SetFullWeapons();
		break;

		case CHEAT_SNOWMOBILE:	  // spawn in snowmobile
			Snowmobile(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_FULL_GEAR:	// give all gear
			FullGear();
		break;

		case CHEAT_TEARS:	      // toggle tears cheat
			Tears(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_GIMMEGUN:
			GimmeGun( cMsg );
		break;

		case CHEAT_GIMMEMOD:
			GimmeMod( cMsg );
		break;

		case CHEAT_GIMMEGEAR:
			GimmeGear( cMsg );
		break;

		case CHEAT_GIMMEAMMO:
			GimmeAmmo( cMsg );
		break;

		case CHEAT_ENDGAME:
			ToggleEndgameFlag();
		break;

#ifndef _FINAL

		case CHEAT_CHASETOGGLE:	   // toggle 3rd person view
			ChaseToggle();
		break;

		case CHEAT_CLIP:		// toggle clipping mode
			SetClipMode(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_TELEPORT:	// teleport to beginning
			Teleport();
		break;

		case CHEAT_CAM_POSROT:    // show/hide camera position/rotation
			SetCamPosRot(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_POSWEAPON:		    // toggle adjust of weapon pos
			PosWeapon(!s_CheatInfo[nCheatCode].bActive);
		break;

  		case CHEAT_POSWEAPON_MUZZLE:	// toggle adjust of weapon muzzle pos
  			PosWeaponMuzzle(!s_CheatInfo[nCheatCode].bActive);
  		break;

  		case CHEAT_WEAPON_BREACHOFFSET:	// toggle adjust of weapon breach offset pos
  			WeaponBreachOffset(!s_CheatInfo[nCheatCode].bActive);
  		break;

		case CHEAT_LIGHTSCALE:	      // toggle client light scale offset
			LightScale(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_LIGHTADD:	      // toggle client light add offset
			LightAdd(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_FOV:				// toggle fov cheat
			FOV(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_REMOVEAI:	  // remove all ai
			RemoveAI(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_TRIGGERBOX:	  // toggle trigger boxes on/off
			TriggerBox(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_POS1STCAM:	  // toggle 1st person camera adjust on/off
			Pos1stCam(!s_CheatInfo[nCheatCode].bActive);
		break;

#endif  // _FINAL
#endif // _TO2DEMO

		default:
			return false;			// skip setting global cheat indicator for unhandled cheats
	}

    m_bPlayerCheated = LTTRUE;

	return true;
}