Page 1 of 1

Problem with mission scripting

Posted: Fri Oct 16, 2009 5:18 am
by [Skirata]Darman[M]
Hey GT Starkillermarek made me a misson script for my map but everytime I start, the map dissapears. The satelite shot shows nothing and I can't spawn becase the mini map is empty and no commandpost is shown.

errorlog:
Hidden/Spoiler:
Message Severity: 3
C:\Battlefront2\main\Battlefront2\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'
Hidden/Spoiler:
Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `AddAIGoal' (number expected, got nil)
stack traceback:
[C]: in function `AddAIGoal'
(none): in function `ScriptInit'
can someone help me?

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 5:21 am
by mswf
Well, some seem pretty obvious:
1. Your lua is not loading command posts.
3. There is a problem with the AI goals

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 5:25 am
by [Skirata]Darman[M]
Yeah, tell me something new.

I know the problem, but don't know how to fix it.
Where do I have to srite down the command posts in a mission script?
why does the map dissapear?

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 5:34 am
by Darth_Spiderpig
Can you please post your LUA?

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 5:36 am
by [Skirata]Darman[M]
of course:
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--


-- load the gametype script
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("Ambush")
ScriptCB_DoFile("setup_teams")

-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
WOK = 3;
MAN = 4;
-- These variables do not change
ATT = REP;
DEF = CIS;


function ScriptPostLoad()

SetAIDifficulty(0, 2, "hard")
AllowAISpawn(ATT, true)
AllowAISpawn(DEF, true)
AllowAISpawn(WOK, false)
AllowAISpawn(MAN, false)
ScriptCB_SetGameRules("campaign")

onfirstspawn = OnCharacterSpawn(
function(character)
if character == 0 then
ShowPopup("level.geo1.hints.hints")
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
BeginObjectivesTimer()
ScriptCB_EnableCommandPostVO(0)

end
end)

KillObject ("cp3")
KillObject ("zem_cp_droiddisspenser3")
KillObject ("zem_cp_droiddisspenser2")
KillObject ("zem_cp_droiddisspenser1")
KillObject ("zem_cp_droiddisspenser")
PlayAnimation("gunship3")

--Destroy the turrets
Objective1= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.firsttext", popupText = "level.FMB.pop.firstpopuptext"}

Dclass = TargetType:New{classname = "tur_bldg_spa_imp_recoilles", killLimit = 2}
Objective1:AddTarget(Dclass)

Objective1.OnStart = function(self)
Objective1.Dclass_cpGoal1 = AddAIGoal(ATT, "Follow", 100, 0)
Objective1.Dclass_cpGoal2 = AddAIGoal(DEF, "Destroy", 100, 0)
end

Objective1.OnComplete = function(self)
DeleteAIGoal(Objective1.Dclass_cpGoal2)
AllowAISpawn(WOK, true)
AddAIGoal(WOK, "Deathmatch", 100)
PlayAnimation("Laatc")
PlayAnimation("Laatc2")
PlayAnimation("center")
PlayAnimation("gunship1")
end



--Kill the droid thingys
Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.secondtext", popupText = "level.FMB.pop.secondpopuptext"}

Dclass = TargetType:New{classname = "zem_cp_droiddisspenser", killLimit = 2}
Objective2:AddTarget(Dclass)

Objective2.OnStart = function(self)
Objective2.Dclass_cpGoal2 = AddAIGoal(DEF, "Deathmatch", 100)
end

Objective2.OnComplete = function(self)

end



--Destory the tantive console
Dobjekt = Target:New{name = "tan4_prop_Console1"}
Dobjekt.OnDestroy = function(self)

end

Objective3 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.thirdtext", popupText = "level.FMB.pop.thirdpopuptext"}
Objective3:AddTarget(Dobjekt)


Objective3.OnStart = function(self)


end

Objective3.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
PlayAnimation("dooright")
PlayAnimation("doorleft")
PlayAnimation("door1")
RespawnObject("cp3")
RespawnObject("zem_cp_droiddispenser3")

end




--Capture cp 3
Objective4CP = CommandPost:New{name = "cp3"}
Objective4 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level,FMB.fourthtext", popupText = "level.FMB.pop.fourthpopuptext", AIGoalWeight = 0}
Objective4:AddCommandPost(Objective4CP)

Objective4:AddHint("level.geo1.hints.capture_cp")

Objective4.OnStart = function(self)
AICanCaptureCP("cp3", ATT, false)
AICanCaptureCP("cp3", DEF, true)

end

Objective4.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
SetProperty("cp3", "Team", 1)
SetProperty("cp3", "CaptureRegion", "")

end



--objective: assault
Dobjekt = Target:New{name = "pol1_prop_control_console"}
Dobjekt.OnDestroy = function(self)

end

Objective5 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.5text", popupText = "level.FMB.pop.5popuptext"}
Objective5:AddTarget(Dobjekt)


Objective5.OnStart = function(self)


end

Objective5.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)

end



--objective: assault
Dobjekt = Target:New{name = "zem_cp_droiddisspenser3"}
Dobjekt.OnDestroy = function(self)

end

Objective6 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.6text", popupText = "level.FMB.pop.6popuptext"}
Objective6:AddTarget(Dobjekt)


Objective6.OnStart = function(self)


end

Objective6.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
RespawnObject("zem_cp_droiddispenser2")
RespawnObject("zem_cp_droiddispenser1")
RespawnObject("zem_cp_droiddispenser")

end




--Go to the region
Objective7 = ObjectiveGoto:New{TeamATT = ATT, TeamDEF = DEF,
text = "level.FMB.7text", popupText = "level.FMB.pop.7popuptext",
regionName = "goto1", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}

Objective7:AddHint("level.geo1.hints.movement")
Objective7:AddHint("level.geo1.hints.obj_markers")
Objective7:AddHint("level.geo1.hints.review_objectives")
Objective7:AddHint("level.geo1.hints.sprint")


Objective7.OnStart = function(self)
MapAddEntityMarker("goto1", "hud_objective_icon_circle", 3.0, 1, "YELLOW", true)

end

Objective7.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
MapRemoveEntityMarker("goto1")
AllowAISpawn(MAN, true)

end



--Kill the mandalorian
Objective8= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.8text", popupText = "level.FMB.pop.8popuptext"}

Dclass = TargetType:New{classname = "cis_hero_jangofett", killLimit = 1}
Objective8:AddTarget(Dclass)

Objective8.OnStart = function(self)

end

Objective8.OnComplete = function(self)

end



end



function BeginObjectivesTimer()
beginobjectivestimer = CreateTimer("beginobjectivestimer")
OnTimerElapse(BeginObjectives, beginobjectivestimer)
SetTimerValue(beginobjectivestimer, 3)
StartTimer(beginobjectivestimer)
end

function BeginObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4}
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective3)
objectiveSequence:AddObjectiveSet(Objective4)
objectiveSequence:AddObjectiveSet(Objective5)
objectiveSequence:AddObjectiveSet(Objective6)
objectiveSequence:AddObjectiveSet(Objective7)
objectiveSequence:AddObjectiveSet(Objective8)

objectiveSequence:Start()

end


---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------
function ScriptInit()


--tell the game to load our loading image
ReadDataFile("dc:Load\\common.lvl")

ReadDataFile("ingame.lvl")


SetMaxFlyHeight(100)
SetMaxPlayerFlyHeight (100)

SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo

ReadDataFile("sound\\yav.lvl;yav1cw")
ReadDataFile("dc:SIDE\\rep.lvl",
"rep_inf_ep2_rifleman",
"rep_inf_ep2_rocketeer",
"rep_inf_ep2_engineer",
"rep_inf_ep2_sniper",
"rep_inf_ep2_jettrooper",
"rep_fly_gunship",
"rep_inf_covert_ops",
"rep_hover_fightertank")
ReadDataFile("dc:SIDE\\cis.lvl",
"cis_inf_rifleman",
"cis_inf_rocketeer",
"cis_inf_engineer",
"cis_inf_sniper",
"cis_inf_officer",
"cis_inf_marine",
"cis_hero_jangofett",
"cis_hover_aat")
ReadDataFile("dc:SIDE\\wok.lvl",
"rep_inf_ep3_marine",
"rep_inf_ep3_pilot")


ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_laser",
"tur_bldg_tower")

SetupTeams{
rep = {
team = REP,
units = 5,
reinforcements = 150,
soldier = { "rep_inf_ep2_rifleman",1, 2},
assault = { "rep_inf_ep2_rocketeer",1, 2},
engineer = { "rep_inf_ep2_sniper",1, 2},
sniper = { "rep_inf_ep2_engineer",1, 2},
special = { "rep_inf_ep2_jettrooper",1, 2},

},
cis = {
team = CIS,
units = 82,
reinforcements = 1000,
soldier = { "cis_inf_rifleman",9, 55},
assault = { "cis_inf_rocketeer",1, 6},
engineer = { "cis_inf_engineer",1, 6},
sniper = { "cis_inf_marine",1, 6},
officer = {"cis_inf_officer",1, 10},
},
man = {
team = MAN,
units = 1,
reinforcements = 0,
soldier = {"cis_hero_jangofett", 1, 1},
}
}


SetHeroClass(CIS, "cis_hero_darthmaul")
SetHeroClass(REP, "rep_inf_covert_ops")

SetTeamName(3, "locals")
SetTeamIcon(3, "all_icon")
AddUnitClass(3, "rep_inf_ep3_marine",40)
AddUnitClass(3, "rep_inf_ep3_pilot",1)

SetUnitCount(3, 41)
AddAIGoal(WookieTeam, "Deathmatch", 100)
SetTeamAsFriend(ATT,3)
SetTeamAsFriend(3,ATT)
SetTeamAsEnemy(DEF,3)
SetTeamAsEnemy(3,DEF)

SetTeamAsEnemy(MAN, REP)
SetTeamAsEnemy(REP, MAN)
SetTeamAsFriend(CIS, MAN)
SetTeamAsFriend(MAN, CIS)
SetTeamName(4, "Mandalorian")


-- Level Stats
-- ClearWalkers()
AddWalkerType(0, 4) -- special -> droidekas
AddWalkerType(1, 0) -- 1x2 (1 pair of legs)
AddWalkerType(2, 0) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 0) -- 3x2 (3 pairs of legs)
local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 32)
SetMemoryPoolSize("EntityFlyer", 32)
SetMemoryPoolSize("EntityHover", 32)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("EntitySoundStream", 4)
SetMemoryPoolSize("EntitySoundStatic", 32)
SetMemoryPoolSize("MountedTurret", 32)
SetMemoryPoolSize("Navigator", 128)
SetMemoryPoolSize("Obstacle", 1024)
SetMemoryPoolSize("PathNode", 1024)
SetMemoryPoolSize("SoundSpaceRegion", 64)
SetMemoryPoolSize("TreeGridStack", 1024)
SetMemoryPoolSize("UnitAgent", 128)
SetMemoryPoolSize("UnitController", 128)
SetMemoryPoolSize("Weapon", weaponCnt)

SetSpawnDelay(10.0, 0.25)
--ReadDataFile("dc:FMB\\FMB.lvl", "FMB_con")
ReadDataFile("dc:FMB\\FMB.lvl", "FMB_con")
SetDenseEnvironment("false")

-- Local Stats
--SetTeamName(3, "locals")
--SetTeamIcon(3, "all_icon")
--AddUnitClass(3, "rep_inf_ep3_marine", 40)
--AddUnitClass(3, "rep_inf_ep3_pilot", 1)
--SetUnitCount(3, 7)
--SetTeamAsEnemy(3,DEF)
--SetTeamAsFriend(3,ATT)

-- Sound

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")

voiceSlow = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)

voiceQuick = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "cw_music")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\yav.lvl", "yav1")
OpenAudioStream("sound\\yav.lvl", "yav1")
OpenAudioStream("sound\\yav.lvl", "yav1_emt")

SetBleedingVoiceOver(REP, REP, "rep_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(REP, CIS, "rep_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, REP, "cis_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, CIS, "cis_off_com_report_us_overwhelmed", 1)

SetOutOfBoundsVoiceOver(2, "cisleaving")
SetOutOfBoundsVoiceOver(1, "repleaving")

SetAmbientMusic(REP, 1.0, "rep_yav_amb_start", 0,1)
SetAmbientMusic(REP, 0.8, "rep_yav_amb_middle", 1,1)
SetAmbientMusic(REP, 0.2, "rep_yav_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "cis_yav_amb_start", 0,1)
SetAmbientMusic(CIS, 0.8, "cis_yav_amb_middle", 1,1)
SetAmbientMusic(CIS, 0.2, "cis_yav_amb_end", 2,1)

SetVictoryMusic(REP, "rep_yav_amb_victory")
SetDefeatMusic (REP, "rep_yav_amb_defeat")
SetVictoryMusic(CIS, "cis_yav_amb_victory")
SetDefeatMusic (CIS, "cis_yav_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--SetSoundEffect("BirdScatter", "birdsFlySeq1")
--SetSoundEffect("WeaponUnableSelect", "com_weap_inf_weaponchange_null")
--SetSoundEffect("WeaponModeUnableSelect", "com_weap_inf_modechange_null")
SetSoundEffect("SpawnDisplayUnitChange", "shell_select_unit")
SetSoundEffect("SpawnDisplayUnitAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplaySpawnPointChange", "shell_select_change")
SetSoundEffect("SpawnDisplaySpawnPointAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplayBack", "shell_menu_exit")


--OpeningSateliteShot
AddCameraShot(0.405418, 0.018834, -0.912953, 0.042412, 156.734161, 6.037713, 180.226318);

AddCameraShot(0.405418, 0.018834, -0.912953, 0.042412, 156.734161, 6.037713, 180.226318);
AddCameraShot(0.405418, 0.018834, -0.912953, 0.042412, 156.734161, 6.037713, 180.226318);
end

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 6:03 am
by mswf
See? Your lua isn't loading those elemantary things. Take a look at a stock (campaign) script to look where you have to ad them.

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 6:12 am
by Darth_Spiderpig
Right, i see some cps in there, but only as objective thingy. They aare loaded nowhere.


How many cp's do you have?


EDIT:
You should add them this way:
Hidden/Spoiler:
SetProperty ("CP","team",DEF)
SetProperty ("CP1","team",DEF)
SetProperty ("CP2","team",DEF)
SetProperty ("CP3","team",DEF)
SetProperty ("CP4","team",DEF)
SetProperty ("CP5","team",DEF)

note:If it's DEF or ATT depends of the Side which own them :mrgreen:

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 6:26 am
by [Skirata]Darman[M]
for the first objective I've got one cp for ATT and three (they are droid dispenser named cp1, cp6 and cp4 for DEF)

where should I write down those lines you posted?

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 6:28 am
by Darth_Spiderpig
I think here:
Hidden/Spoiler:
[quote="mswf"]function(character)
if character == 0 then
ShowPopup("level.geo1.hints.hints")
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
BeginObjectivesTimer()
ScriptCB_EnableCommandPostVO(0)

Here I believe :mrgreen:

end
end)[/quote]

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 6:43 am
by [Skirata]Darman[M]
thanks, I try it

EDIT
sorry doesn't work
same error no map no satelite shot no cp's

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 6:47 am
by Darth_Spiderpig
:x :?

Always I try to help somebody it doesn't work :cry:

Re: problem with mission scripting

Posted: Fri Oct 16, 2009 3:40 pm
by AceMastermind
I'm not about to debug your entire LUA since you should have been testing it for errors as you went along but these parts look like they need attention according to the 2 errors you posted:
[Skirata]Darman[M] wrote:AddAIGoal(WookieTeam, "Deathmatch", 100)
[Skirata]Darman[M] wrote:ReadDataFile("dc:FMB\\FMB.lvl", "FMB_con")

Re: Problem with mission scripting

Posted: Sun Oct 18, 2009 5:01 pm
by [RDH]Zerted
Yeah, your WookieTeam is nil. Maybe you meant WOK? After fixing that, remunge and test it out.