Mission 10 Event File
Руководства
/
Mission 10 Event File
Обновлено 3 years ago от Merric

--IMPORTS

import("ScarUtil.scar")


--GLOBAL VARIABLES

function SetResearchLevel(level)

Restrict_SpaceMarines( g_Player1, level )

Player_RestrictResearch( g_Player1, "marine_librarian_research_1" )
Player_RestrictResearch( g_Player1, "marine_librarian_research_2" )

end


--GAME SETUP

function OnGameSetup() -- globals g_Player1 = Setup_Player(0, "$331100", "space_marine_race", 1) g_Player2 = Setup_Player(1, "$331104", "chaos_marine_race", 2) g_Player3 = Setup_Player(2, "$331102", "chaos_marine_race", 2) g_Player4 = Setup_Player(3, "$331106", "chaos_marine_race", 2)

	g_chaos_dead = 0
	g_objcomplete = 0

end

-- this will only get called after loading a game function OnGameRestore() g_Player1 = World_GetPlayerAt(0) g_Player2 = World_GetPlayerAt(1) g_Player3 = World_GetPlayerAt(2) g_Player4 = World_GetPlayerAt(3) end

function CheatClosing()

Util_StartNIS( EVENTS.NIS_Closing )

end


--ON INITIALIZATION

--OnInit should be used for pregame functions, things that should happen before the player officially enters the world. --Despawn Reserve Units, Set Groups and Start commands for persistent behaviors.

function OnInit()

-- FADE BLACK
EventCue_Enable(false)
Fade_Start( 0, false )	
W40k_Letterbox( true, 0 )	
		
-- MUSIC
SetupMusicPlaylist()

-- DIFFICULTY LEVEL
SetDifficultyLevel( Difficulty_Get() )	

-- RESEARCH
SetResearchLevel( 10 )

-- AI	
Cpu_EnableAll(false)

-- NIS
EGroup_ForceAddOn( "eg_IsadorHQ", "chaos_hq_addon_1" )
EGroup_ForceAddOn( "eg_IsadorHQ", "chaos_hq_addon_2" )
SGroup_AddLeaders("sg_NIS01_ChaosBTPosSquad")
SGroup_DeSpawn("sg_Isador")
SGroup_DeSpawn( "sg_NIS02_AllObjects")
SGroup_DeSpawn( "sg_NIS02_Isador_Begging" )
SGroup_DeSpawn( "sg_NIS02_Gabriel_executioner" )
SGroup_DeSpawn("sg_NIS02_TacMarines")
SGroup_DeSpawn( "sg_PlayersStartingSquads" )
EGroup_DeSpawn("eg_PlayersBase" )
Util_StartNIS( EVENTS.NIS_Opening ) 	
Rule_Add( Rule_InitAfterNIS )

-- OBJECTIVES
OBJ_PRIMARY_KILLISADOR = { title_id = 330000, short_desc_id = 330002, help_tip_id = 330004 }
OBJ_SECONDARY_DESTROYCHAOS = { title_id = 330010, short_desc_id = 330012, help_tip_id = 330014 }

-- ALL OTHER STUFF
SetCommanderPowerSword( g_Player1 )		

end

-- This registers your init function with scar. This call has to be made after the defintion -- of the function and it must be called in global scope (global scope means not in any function -- or table) Scar_AddInit(OnInit)


-- GAME STATE

-- this controls the game state, ensures flow is properly controlled etc

-- this function starts all our rules running once the NIS is complete function Rule_InitAfterNIS() if Event_IsRunning( EVENTS.NIS_Opening ) == false then

	SGroup_ReSpawn("sg_Isador")

	-- reenable the AI
	Cpu_EnableAll( true )
	
	SetupAI()			
	
	-- track characters
	Rule_AddInterval(Rule_TrackCharacters,10)

	-- kill isador
	Rule_Add( Rule_IsadorDead )
	
	-- spawn a bloodthirster to lay the smack down
	g_bloodthirsteractive = false
	Rule_AddInterval( Rule_BloodthirsterEnabled, 600 )
	Rule_AddInterval(Rule_CheckBloodthirster,1)
	Rule_AddInterval(Rule_BloodthirsterSeenByPlayer,1)
	
	Rule_AddInterval( Rule_DestroyChaos, 2 )
	
	Rule_Remove( Rule_InitAfterNIS )
	
	Util_ObjectiveCreate( OBJ_PRIMARY_KILLISADOR, true )
	Util_ObjectiveCreate( OBJ_SECONDARY_DESTROYCHAOS, true )
	
	Rule_AddInterval( Rule_StartClosingNIS, 1 )
	
	Rule_AddInterval(Rule_PlayerLoses,1)
	
	Util_Autosave( "$331050")		
	
end

end

-- call this with an interval to ensure the mission ends function Rule_GameOver()

World_SetGameOver() 

end

-- this function detects if the player has lost their base and has no servitors left function Rule_PlayerLoses()

g_building_exceptions = 
{
	"space_marine_mine_field",
	"space_marine_listening_post",
	"space_marine_turret_bolter"
}

g_unit_exceptions = 
{
	"guard_squad_inquisitor",
	"space_marine_squad_force_commander"
}

if( Player_HasBuildingsExcept(g_Player1, g_building_exceptions) == false ) then
	if( Player_HasSquadsExcept(g_Player1, g_unit_exceptions ) == false ) then
		World_SetTeamWin( g_Player2, "" )
		Rule_AddIntervalEx( Rule_GameOver,5,1 )
		Rule_Remove( Rule_PlayerLoses )
	end
end

end


-- AI

-- this section has all functions regarding to AI

-- stop AI from moving certain units around function SetupAI() Cpu_LockSGroupAcrossPlayers( "sg_Isador" ) Cpu_LockSGroupAcrossPlayers( "sg_Player2_Defense" )

-- stop the ai from building a chaos lord (hes dead!)
Player_RestrictSquad( g_Player2, "chaos_squad_lord" )
Player_RestrictSquad( g_Player2, "chaos_squad_sorcerer" )

Player_RestrictSquad( g_Player3, "chaos_squad_lord" )
Player_RestrictSquad( g_Player3, "chaos_squad_bloodthirster" )
Player_RestrictSquad( g_Player3, "chaos_squad_sorcerer" )

Player_RestrictSquad( g_Player4, "chaos_squad_lord" )
Player_RestrictSquad( g_Player4, "chaos_squad_bloodthirster" )
Player_RestrictSquad( g_Player4, "chaos_squad_sorcerer" )

Player_RestrictResearch( g_Player3, "chaos_bloodthirster_research" )
Player_RestrictResearch( g_Player4, "chaos_bloodthirster_research" )

end


-- CHARACTERS

-- this section keeps track of the characters, and controls losing when they die.

-- keeping track of the characters and keeping them alive. function Rule_TrackCharacters() Util_TrackCharacterAndDropPodIn( g_Player1, "sg_ForceCommander", "space_marine_squad_force_commander", "mk_ForceCommanderDropPodIn" ) Util_TrackCharacterAndDropPodIn( g_Player1, "sg_Inquisitor", "guard_squad_inquisitor", "mk_InquisitorDropPodIn" ) end


-- DIFFICULTY LEVEL

-- the functions here set the difficulty level for the mission. Should be called from OnGameSetup

function SetDifficultyLevel( difficultyLevel )

Difficulty_SetForAll( difficultyLevel )

-- easy
if difficultyLevel == DIFFICULTY_EASY then
	Cpu_SetDifficulty( g_Player2, AD_Standard )
	Cpu_SetDifficulty( g_Player3, AD_Easy )
	Cpu_SetDifficulty( g_Player4, AD_Easy )
-- medium
elseif difficultyLevel == DIFFICULTY_NORMAL then
	Cpu_SetDifficulty( g_Player2, AD_Standard )
	Cpu_SetDifficulty( g_Player3, AD_Standard )
	Cpu_SetDifficulty( g_Player4, AD_Standard )
-- hard
elseif difficultyLevel == DIFFICULTY_HARD then
	Cpu_SetDifficulty( g_Player2, AD_Insane )
	Cpu_SetDifficulty( g_Player3, AD_Hard )
	Cpu_SetDifficulty( g_Player4, AD_Hard )
end

end


-- MUSIC/SOUND

function SetupMusicPlaylist() -- clear the current playlist Sound_PlaylistClear( PC_Music ) -- add tracks to the playlist
Sound_PlaylistAddTrack( PC_Music, "music_EldarTheme" ) Sound_PlaylistAddTrack( PC_Music, "music_evil_isador_theme" ) Sound_PlaylistAddTrack( PC_Music, "music_chant" ) Sound_PlaylistAddTrack( PC_Music, "music_force_commander_theme" ) -- mark these tracks to play randomly Sound_PlaylistSetorder( PC_Music, true ) -- add 5 to 10 seconds silence between tracks Sound_PlaylistSetSilence( PC_Music, 20, 70 ) -- don't play yet

Sound_PlaylistClear( PC_Ambient )
-- add tracks to the playlist    
Sound_PlaylistAddTrack( PC_Ambient, "ambient_wind" )
-- mark these tracks to play randomly
Sound_PlaylistSetorder( PC_Ambient, false )
-- add 5 to 10 seconds silence between tracks
Sound_PlaylistSetSilence( PC_Ambient, 5, 10 )	

end


-- KILL ISADOR

-- quite simple, go ahead and destroy isador

-- isador dead function Rule_IsadorDead() if SGroup_Count( "sg_Isador" ) == 0 and Event_IsAnyRunning() == false then

	Util_ObjectiveComplete( OBJ_PRIMARY_KILLISADOR.title_id )
	g_objcomplete = g_objcomplete + 1
	Rule_Remove(Rule_IsadorDead)		
	
	
	
	
end

end

function Rule_StartClosingNIS() if g_objcomplete == 2 then Util_StartNIS( EVENTS.NIS_Closing ) Rule_RemoveAll() Rule_Add( Rule_ClosingNISIsFinished ) end end

-- player wins function Rule_ClosingNISIsFinished() if Event_IsRunning( EVENTS.NIS_Closing ) == false then

	World_SetTeamWin(g_Player1,"youve won")
	Rule_AddIntervalEx( Rule_GameOver, 3, 1 )
	
	Rule_Remove(Rule_ClosingNISIsFinished)
	
end

end


-- KILL CHAOS

-- check for all the enemies being destroyed function Rule_DestroyChaos() g_chaos_dead = 0 g_chaos_building_exceptions = { "chaos_mine_field", "chaos_listening_post", "chaos_turret_bolter" }

g_chaos_unit_exceptions = 
{
	"space_marine_librarian_evil_sp"
}

if( Player_HasBuildingsExcept(g_Player2, g_chaos_building_exceptions) == false ) then
	if( Player_HasSquadsExcept(g_Player2, g_chaos_unit_exceptions ) == false ) then
		g_chaos_dead = g_chaos_dead + 1
	end
end

if( Player_HasBuildingsExcept(g_Player3, g_chaos_building_exceptions) == false ) then
	if( Player_HasSquadsExcept(g_Player3, g_chaos_unit_exceptions ) == false ) then
		g_chaos_dead = g_chaos_dead + 1
	end
end

if( Player_HasBuildingsExcept(g_Player4, g_chaos_building_exceptions) == false ) then
	if( Player_HasSquadsExcept(g_Player4, g_chaos_unit_exceptions ) == false ) then
		g_chaos_dead = g_chaos_dead + 1
	end
end

if g_chaos_dead == 3 then
	Util_ObjectiveComplete( OBJ_SECONDARY_DESTROYCHAOS.title_id )
	g_objcomplete = g_objcomplete + 1
	Rule_Remove( Rule_DestroyChaos )
end	

end


-- BLOODTHIRSTER

-- this keeps track of the bloodthirster function Rule_CheckBloodthirster() local FilterList = function(gID, idx, sID) if (Squad_GetBlueprintName(sID) ~= "chaos_squad_bloodthirster") then SGroup_Remove(gID, sID) end end

SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Bloodthirster"), Player_GetSquads(g_Player2))            
SGroup_ForEach(SGroup_FromName("sg_Bloodthirster"), FilterList)
	
if SGroup_Count( "sg_Bloodthirster" ) > 0 and not g_bloodthirsteractive then
	Cpu_LockSGroupAcrossPlayers( "sg_Bloodthirster" )
	Cmd_StopSquads( "sg_Bloodthirster" )
end

end

function Rule_BloodthirsterEnabled() EnableBT() Rule_Remove(Rule_BloodthirsterEnabled) end

function EnableBT() g_bloodthirsteractive = true SGroup_SetAvgHealth( "sg_Bloodthirster", 1.0 ) --~ Cpu_UnlockSGroupAcrossPlayers( "sg_Bloodthirster" ) Cmd_AttackSGroup( "sg_Bloodthirster", "sg_ForceCommander" ) if not Rule_Exists(Rule_RecreateBloodthirster) then Rule_AddInterval( Rule_RecreateBloodthirster, 600 ) end Rule_AddInterval( Rule_BloodthirsterDisabled, 1 ) end

function Rule_BloodthirsterDisabled() if SGroup_Count( "sg_Bloodthirster" ) == 0 then g_bloodthirsteractive = false Rule_Remove( Rule_BloodthirsterDisabled ) end end

-- after X seconds, if the ai doesnt already have the research or the bloodthirster, give em one to play with function Rule_RecreateBloodthirster() if SGroup_Count( "sg_Bloodthirster" ) > 0 and Player_GetResearchState( g_Player2, "chaos_bloodthirster_research" ) ~= RS_Researching and Player_GetResearchState( g_Player2, "chaos_bloodthirster_research" ) ~= RS_Complete then Player_GrantResearch( g_Player2, "chaos_bloodthirster_research" ) end end

function Rule_BloodthirsterSeenByPlayer() if Player_CanSeeSGroup( g_Player1, "sg_Bloodthirster", false ) then Util_StartIntel( EVENTS.IE_BloodThirster ) if Rule_Exists( Rule_BloodthirsterEnabled ) then Rule_Remove( Rule_BloodthirsterEnabled ) EnableBT() end Rule_Remove(Rule_BloodthirsterSeenByPlayer) end end

Статистика игры
Подписчики
27
Времена
99
Игроки
12
Последние запуски
Уровень: Into the Maw
Уровень: Unholy Ceremony
Уровень: Planet Fall
Последние темы
Опубликовано 5 years ago
games:thread_reply_count
Опубликовано 5 years ago
games:thread_reply_count
Опубликовано 5 years ago
games:thread_reply_count
Опубликовано 7 years ago
games:thread_reply_count
Модераторы