void LoadedNPC::Load(int progress_start,int progress_interval)
{
	Set_Progress_Bar_Position(progress_start);
	if (filename)
	{
		npc_rif = avp_load_rif_non_env(filename);
		if (INVALID_RIFFHANDLE != npc_rif)
		{
			#if MaxImageGroups>1
			for (img_group=FIRST_FREE_IMAGE_GROUP; image_groups.contains(img_group); ++img_group)
				;
			GLOBALASSERT(img_group<MaxImageGroups);
			image_groups.add_entry(img_group);
			SetCurrentImageGroup(img_group); // PROBLEM AT PRESENT, copy_rif_data changes this
			#endif
			Set_Progress_Bar_Position(progress_start+progress_interval/2);
			copy_rif_data(npc_rif,CCF_IMAGEGROUPSET + CCF_LOAD_AS_HIERARCHY_IF_EXISTS,progress_start+progress_interval/2,progress_interval/2);
			unload_rif(npc_rif); // doesnt destroy copied data
		}
	}
}
예제 #2
0
파일: system.c 프로젝트: dderby/avp_GLES
void LoadRifFile()
{
	
	char file_and_path[100];
	int i = 0;
	
	Set_Progress_Bar_Position(PBAR_LEVEL_START);
	
	// clear the dir names

	for(i = 0; i < 100; i++)
	  {
	  	file_and_path[i] = (char)0;
			EnvFileName[i] = (char)0;
			LevelDir[i] = (char)0;
	  }

	// Set up the dirname for the Rif load
				
	catpathandextension(&file_and_path[0], (char *)&GameDataDirName[0]);
	catpathandextension(&file_and_path[0], Env_List[AvP.CurrentEnv]->main); /* root of the file name,smae as dir*/
	catpathandextension(&file_and_path[0], (char *)&FileNameExtension[0]);	/* extension*/
	
	env_rif = avp_load_rif((const char*)&file_and_path[0]);
	Set_Progress_Bar_Position(PBAR_LEVEL_START+PBAR_LEVEL_INTERVAL*.4);
	
	if(INVALID_RIFFHANDLE == env_rif)
	  {
			finiObjects();
			exit(0x3421);
				
	  };

	#if MaxImageGroups>1
	SetCurrentImageGroup(2); // FOR ENV
	#endif
	copy_rif_data(env_rif,CCF_ENVIRONMENT,PBAR_LEVEL_START+PBAR_LEVEL_INTERVAL*.4,PBAR_LEVEL_INTERVAL*.6);
	//setup_shading_tables();
}
void InitNPCs(RIFFHANDLE h)
{
	
	File_Chunk * old_env_chunk = Env_Chunk; // push Env_Chunk
	
	
	// build list of objects for the npcs in this level

	for(int i=0;i<HNPC_Last;i++)
	{
		Load_HNPC[i]=FALSE;
	}

	#if debug
	if(ForceLoad_Alien)Load_HNPC[HNPC_Alien]=TRUE;
	if(ForceLoad_Marine)Load_HNPC[HNPC_Marine]=TRUE;
	if(ForceLoad_Predator)Load_HNPC[HNPC_Predator]=TRUE;
	if(ForceLoad_Hugger)Load_HNPC[HNPC_Hugger]=TRUE;
	if(ForceLoad_Queen)Load_HNPC[HNPC_AlienQueen]=TRUE;
	if(ForceLoad_Civvie)Load_HNPC[HNPC_Civilian]=TRUE;
	if(ForceLoad_PredAlien)Load_HNPC[HNPC_PredAlien]=TRUE;
	if(ForceLoad_Xenoborg)Load_HNPC[HNPC_Xenoborg]=TRUE;
	if(ForceLoad_Pretorian)Load_HNPC[HNPC_Pretorian]=TRUE;
	if(ForceLoad_SentryGun)Load_HNPC[HNPC_SentryGun]=TRUE;
	#endif
	
	HNPC_Files DefaultGeneratorEnemy;
	
	Chunk * pChunk = ((Chunk_With_Children*)h->envd)->lookup_single_child("GLOGENDC");
	if(pChunk)
	{
		Global_Generator_Data_Chunk* ggdc=(Global_Generator_Data_Chunk*)pChunk;
		switch(ggdc->EnemyGenerated)
		{
			case Generate_Aliens :
				DefaultGeneratorEnemy=HNPC_Alien;
				break;
			case Generate_Marines :
				DefaultGeneratorEnemy=HNPC_Marine;
				break;					
			default :
				GLOBALASSERT("Invalid enemy type"==0);
				
		}

	}
	else
	{
		DefaultGeneratorEnemy=HNPC_Alien;
	}

	if(Current_Level_Requires_Mirror_Image())
	{
		//need to load model for player's character , for mirror
		switch(AvP.PlayerType)
		{
			case I_Marine :
				Load_HNPC[HNPC_Marine]=TRUE;
				break;

			case I_Alien :
				Load_HNPC[HNPC_Alien]=TRUE;
				break;
			
			case I_Predator :
				Load_HNPC[HNPC_Predator]=TRUE;
				break;
		}
	}

	

	if(AvP.Network != I_No_Network)
	{
		/* KJL 19:35:46 01/07/98 - multiplayer only needs the 3 main characters */
		Load_HNPC[HNPC_Alien]=TRUE;
		Load_HNPC[HNPC_Predator]=TRUE;
		Load_HNPC[HNPC_Marine]=TRUE;
	}
	
	
	/* KJL 16:31:03 06/05/98 - Force all characters to be loaded 
	for testing of 'bots etc. */
	
	#if 0 //characters can now be loaded with command line options
	Load_HNPC[HNPC_Alien]=TRUE;
	Load_HNPC[HNPC_Predator]=TRUE;
	Load_HNPC[HNPC_Marine]=TRUE;
	Load_HNPC[HNPC_PredAlien] =TRUE;
	#endif

	Special_Objects_Chunk * soc = 0;
 	soc = (Special_Objects_Chunk *)((Chunk_With_Children*)h->envd)->lookup_single_child ("SPECLOBJ");
	
	if (soc)
	{
		List<Chunk *> cl;
		soc->lookup_child("AVPGENER",cl);
		for (LIF<Chunk *> cli(&cl); !cli.done(); cli.next())
		{
			AVP_Generator_Chunk * agc = (AVP_Generator_Chunk *)cli();
		
			if (agc->type)
			{
				#if 0 //forget about game mode settings for generators / badguys
				if(AvP.PlayerType==I_Alien && (agc->flags & AVPGENFLAG_AVPGAMEMODEALIEN)||
				   AvP.PlayerType==I_Marine && (agc->flags & AVPGENFLAG_AVPGAMEMODEMARINE)||
				   AvP.PlayerType==I_Predator && (agc->flags & AVPGENFLAG_AVPGAMEMODEPREDATOR))
				#endif
				{
					switch (agc->type)
					{
						case 1:
							Load_HNPC[HNPC_Alien]=TRUE;
							break;
						case 2:
							if(AvP.Network == I_No_Network)
								Load_HNPC[HNPC_Predator]=TRUE;
							break;
						
						case 3:
							if(AvP.Network == I_No_Network)
								Load_HNPC[HNPC_Hugger]=TRUE;
							break;
						case 4:
							if(AvP.Network == I_No_Network)
								Load_HNPC[HNPC_Xenoborg]=TRUE;
							break;
						case 5:
							Load_HNPC[HNPC_PredAlien] =TRUE;
							break;
						case 6:
							if(AvP.Network == I_No_Network)
								Load_HNPC[HNPC_AlienQueen]=TRUE;
							break;
						case 7:	//marine or variant of marine
							if(AvP.Network == I_No_Network)
							{
								switch (agc->sub_type)
								{
									case 0:	//pulse rifle
									case 5:	//pistol marine
									case 10: //smartgun
									case 20://grenade launcher
									case 50://flamethrower
									case 60://sadar
									case 70://Minigun
										Load_HNPC[HNPC_Marine]=TRUE;
										if(!Load_HNPC[HNPC_Civilian])
										{
											//noncombatant marines become civilians
											if(MarineIsNomcombatant(agc))
											{
												Load_HNPC[HNPC_Civilian]=TRUE;											
			
											}
										}
										break;
	
	
									case 30://shotgun 1
									case 31://shotgun 2
									case 32://shotgun 3
									case 40://pistol 1
									case 41://pistol 2
									case 80://Molotov
									case 90://Scientist1
									case 91://Scientist2
									case 100://civilian flamer
									case 110://civilian unarmed
									case 120://android
										Load_HNPC[HNPC_Civilian] =TRUE;
										break;
		
									
									default:
										Load_HNPC[HNPC_Marine]=TRUE;
										break;
								}
							}
							break;
						case 8:
							Load_HNPC[HNPC_Pretorian]=TRUE;
							break;
						case 9:
							if(AvP.Network == I_No_Network)
								Load_HNPC[HNPC_SentryGun]=TRUE;
							break;
						default:
							break;
					}
					
				
				}
			}
			else
			{
				//see if generator is a multiplayer start position
				if(agc->flags & AVPGENFLAG_MULTIPLAYERSTART)
				{
					continue;
				}
				
				//this is a generator , look to see what it generates
				AVP_Generator_Extended_Settings_Chunk* setting=agc->get_extended_settings();
				if(setting)
				{
					BOOL all_zero=TRUE;
					if(AvP.Network == I_No_Network)
					{
						if(setting->weights->PulseMarine_Wt ||
						   setting->weights->PistolMarine_Wt ||
						   setting->weights->FlameMarine_Wt ||
						   setting->weights->SmartMarine_Wt ||
						   setting->weights->SadarMarine_Wt ||
						   setting->weights->GrenadeMarine_Wt ||
						   setting->weights->MinigunMarine_Wt)
						{
							Load_HNPC[HNPC_Marine]=TRUE;
							all_zero=FALSE;
						}
						if(setting->weights->ShotgunCiv_Wt ||
						   setting->weights->PistolCiv_Wt ||
						   setting->weights->FlameCiv_Wt ||
						   setting->weights->UnarmedCiv_Wt ||
						   setting->weights->MolotovCiv_Wt)
						{
							Load_HNPC[HNPC_Civilian]=TRUE;
							all_zero=FALSE;
						}
					}
					
					if(setting->weights->Alien_Wt)
					{
						Load_HNPC[HNPC_Alien]=TRUE;
						all_zero=FALSE;
					}
					if(setting->weights->PredAlien_Wt)
					{
						Load_HNPC[HNPC_PredAlien]=TRUE;
						all_zero=FALSE;
					}
					if(setting->weights->Praetorian_Wt)
					{
						Load_HNPC[HNPC_Pretorian]=TRUE;
						all_zero=FALSE;
					}

					if(all_zero)
					{
						//all the weightings are zero , use the default badguy
						Load_HNPC[DefaultGeneratorEnemy]=TRUE;
					}


				}
				else
				{
					//no extended generator data , use the default badguy
					Load_HNPC[DefaultGeneratorEnemy]=TRUE;
				}
			}
		}
	}
	
	List<LoadedNPC> newnpcs;

	for(i=0;i<HNPC_Last;i++)
	{
		if(Load_HNPC[i])
		{
			LoadedNPC tempnpc(HNPC_FileNames[i]);
			if (tempnpc.IsValid())
			{
				newnpcs.add_entry(tempnpc);
			}
		}
	}
	#if 1
	if(AvP.PlayerType==I_Predator || Load_HNPC[HNPC_Predator])
	{
		//need to load the disk hierarchy
		LoadedNPC tempnpc("disk.rif");
		if (tempnpc.IsValid())
		{
			newnpcs.add_entry(tempnpc);
		}

	}

	if(AvP.PlayerType==I_Marine || Load_HNPC[HNPC_Marine])
	{
		//need to load the mdisk hierarchy
		LoadedNPC tempnpc("mdisk.rif");
		if (tempnpc.IsValid())
		{
			newnpcs.add_entry(tempnpc);
		}

	}
	#endif
	
	
	// see what we already have, unloading what we don't need, and ensuring we don't load a npc twice
	for (LIF<LoadedNPC> i_loaded_npc(&loaded_npcs); !i_loaded_npc.done(); )
	{
		if (newnpcs.contains(i_loaded_npc()))
		{
			newnpcs.delete_entry(i_loaded_npc());
			i_loaded_npc.next();
		}
		else
		{
			LoadedNPC tounload(i_loaded_npc());
			tounload.Unload();
			i_loaded_npc.delete_current();
		}
	}
	
	if(!KeepMainRifFile)
	{
		//at this point we no longer need the main level rif file
		unload_rif(h);
	}
	
	// load the new ones, adding them to the main list
	int NumToLoad=newnpcs.size();
	int NumLoaded=0;
	
	if(Load_HNPC[HNPC_Marine] || Load_HNPC[HNPC_Civilian] || AvP.PlayerType==I_Marine)
	{
		LoadMarineScreamSounds();
	}
	if(Load_HNPC[HNPC_Predator] ||AvP.PlayerType==I_Predator)
	{
		LoadPredatorScreamSounds();
	}
	if(Load_HNPC[HNPC_Alien] || Load_HNPC[HNPC_PredAlien]|| Load_HNPC[HNPC_Pretorian] || AvP.PlayerType==I_Alien)
	{
		LoadAlienScreamSounds();
	}
	if(Load_HNPC[HNPC_AlienQueen])
	{
		LoadQueenScreamSounds();
	}
	
	for (LIF<LoadedNPC> i_newnpc(&newnpcs); !i_newnpc.done(); i_newnpc.next())
	{
		LoadedNPC toload(i_newnpc());
		toload.Load(PBAR_NPC_START+(PBAR_NPC_INTERVAL*NumLoaded)/NumToLoad,PBAR_NPC_INTERVAL/NumToLoad);
		loaded_npcs.add_entry(toload);
		NumLoaded++;
	}
	Set_Progress_Bar_Position(PBAR_NPC_START+PBAR_NPC_INTERVAL);

	if(KeepMainRifFile)
	{
		Env_Chunk = old_env_chunk; // pop Env_Chunk
	}
	else
	{
		Env_Chunk=0;
	}
}