Problem with Objectives

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
MasterSkywalker
Major
Major
Posts: 501
Joined: Mon Apr 17, 2006 1:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Problem with Objectives

Post by MasterSkywalker »

I'm making a campaign Naboo map now, and I got one big problem here: My objectives are scripted and fine, but when I start the game, I do end up beeing IMP and all, but the problem is, none of the objectives work. I just stand there, the locals do attack me, but thats all. Also absolutely NO AI spawned. Here is my LUA (Objective part)

Code: Select all

--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

    ScriptCB_DoFile("setup_teams")
    ScriptCB_DoFile("ObjectiveConquest")
    ScriptCB_DoFile("ObjectiveAssault")
    ScriptCB_DoFile("MultiObjectiveContainer")
    ScriptCB_DoFile("ObjectiveCTF")
    ScriptCB_DoFile("Ambush")
    ScriptCB_SetGameRules("campaign")
	ScriptCB_SetSpawnDisplayGain(0.2, 0.5) 

	--  Empire Attacking (attacker is always #1)
    local ALL = 2
    local IMP = 1
    --  These variables do not change
    local ATT = 1
    local DEF = 2
    
function ScriptPostLoad()
	-- Here goes all objective related information.
	-- Q: Should It be possible to play Rebels?

	SetAIDifficulty(0, 2, "hard")
	
	AddAIGoal(3, "Deathmatch", 100)
	
	EnableSPScriptedHeroes()

-- Objective 1 Stuff -- Capture Gungan Lookout

    Objective1CP = CommandPost:New{name = "CP3"}
    Objective1 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level.hoth.c.1", popupText = "level.hoth.c.pop.1"}
    Objective1:AddCommandPost(Objective1CP)
    
    Objective1.OnStart = function(self)
      SetObjectTeam("CP6", 1)
      --objectiveSequence.delayNextSetTime = 0.5
      AICanCaptureCP("CP3", ATT, false)
      ActivateRegion("trigger2")
      RespawnObject("CP3")
      Objective1.defendGoal2 = AddAIGoal(ATT, "Defend", 3000, "CP3");
      Objective1.defendGoal1 = AddAIGoal(DEF, "Defend", 300, "CP3");
    end
    
    Objective1.OnComplete = function(self)
      ShowMessageText("game.objectives.complete", ATT)
	  SetProperty("CP3", "SpawnPath", "Local_Spawn")
	  DeleteAIGoal(Objective1.defendGoal2)
	  DeleteAIGoal(Objective1.defendGoal1)
	  Ambush("rebels2", 8, 5)
	  ATT_ReinforcementCount = GetReinforcementCount(ATT)
	  SetReinforcementCount(ATT, ATT_ReinforcementCount + 50)
      Rebels2Goal = AddAIGoal(5, "Defend", 3000, "ShieldGen")
    	if self.winningTeam == DEF then
    		ScriptCB_SndPlaySound("HOT_obj_09")
    	else
    		--play the win sound
	    	ScriptCB_SndPlaySound("HOT_obj_13")
	    	ScriptCB_PlayInGameMusic("imp_hot_objComplete_01")
	    	 -- Music Timer -- 
		 music01Timer = CreateTimer("music01")
		SetTimerValue(music01Timer, 33.0)
				              
			StartTimer(music01Timer)
			OnTimerElapse(
				function(timer)
				ScriptCB_StopInGameMusic("imp_hot_objComplete_01")
				ScriptCB_PlayInGameMusic("imp_hot_amb_action_01")
				DestroyTimer(timer)
			end,
			music01Timer
                        )
	    end
    end
    

--Objective 2 Stuff- Assault
    
    ShieldGen = Target:New{name = "ShieldGen"}
    Objective2 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF, text = "level.OIU.c.2", popupText = "level.OIU.c.pop.2", AIGoalWeight = 0.0}
    Objective2:AddTarget(ShieldGen)
    
    Objective2.OnStart = function(self)
    	--objectiveSequence.delayNextSetTime = 0.5
    	SetProperty("ShieldGen", "MaxHealth", 120000.0)
 		SetProperty("ShieldGen", "CurHealth", 120000.0)
        SetAIDamageThreshold("ShieldGen", 0.2)
        
        --GOALS--
    	Objective2.defendGoal1 = AddAIGoal(DEF, "Defend", 30, "ShieldGen")
    	Objective2.defendGoal2 = AddAIGoal(DEF, "Deathmatch", 100)
    	Objective2.defendGoal3 = AddAIGoal(ATT, "Destroy", 100, "ShieldGen")
    	--Objective2.defendGoal3 = AddAIGoal(ATT, "Deathmatch", 300)
    	Rebels2Goal = AddAIGoal(5, "Defend", 3000, "ShieldGen")
    	
     	--Objective2.dmGoal1 = AddAIGoal(DEF, "Deathmatch", 500)

     end
     
     Objective2.OnComplete = function(self)
     	ShowMessageText("game.objectives.complete", ATT)
     	ATT_ReinforcementCount = GetReinforcementCount(ATT)
     	SetReinforcementCount(ATT, ATT_ReinforcementCount + 50)
     	
     	-- DELETING GOALS--
     	DeleteAIGoal(Objective2.defendGoal1)
     	DeleteAIGoal(Objective2.defendGoal2)
     	DeleteAIGoal(Objective2.defendGoal3)
     	
    	if self.winningTeam == DEF then
    		ScriptCB_SndPlaySound("HOT_obj_09")
    	else
    		--play the win sound
	    ATT_ReinforcementCount = GetReinforcementCount(ATT)
        SetReinforcementCount(ATT, ATT_ReinforcementCount + 50)
	    end
    end
	  
function StartObjectives()     
    objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 12.0}
    
    objectiveSequence:AddObjectiveSet(Objective1)
    objectiveSequence:AddObjectiveSet(Objective2)
    objectiveSequence:Start()
		end
	end
And the mungelog also gave me this error:
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to perform arithmetic on a nil value
stack traceback:
(none): in function `AddCommandPost'
(none): in function `ScriptPostLoad'
Thanks in advance,
Soul -- Merry Christmas!!
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

RE: Problem with Objectives

Post by [RDH]Zerted »

AddAIGoal(3, "Deathmatch", 100) --who is team 3? edit: or is that defined in the other section?

Somewhere, you have a CP name typo or a typo in a CP releated variable name.
Post Reply