Page 1 of 1

locals not spawning ingame what am i missing in my lua ?

Posted: Sat Jul 20, 2019 3:17 pm
by wsa30h
Hidden/Spoiler:
[code]--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("setup_teams")

-- REP Attacking (attacker is always #1)
REP = 2;
imp = 1;
-- These variables do not change
ATT = REP;
DEF = imp;


function ScriptPostLoad()


--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1"}
cp2 = CommandPost:New{name = "cp2"}
cp3 = CommandPost:New{name = "cp3"}
cp4 = CommandPost:New{name = "cp4"}
cp5 = CommandPost:New{name = "cp5"}
cp6 = CommandPost:New{name = "cp6"}
cp7 = CommandPost:New{name = "cp7"}





--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF,
textATT = "game.modes.con",
textDEF = "game.modes.con2",
multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)
conquest:AddCommandPost(cp7)


conquest:Start()
SetUberMode(1);
SetPlayerTeamDifficultyHard(20)
SetEnemyTeamDifficultyHard(20)
SetTeamAggressiveness(rep, 3.7)
SetTeamAggressiveness(IMP, 3.7)
EnableSPHeroRules()

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()
ReadDataFile("dc:ingame.lvl")
ReadDataFile("ingame.lvl")


SetMaxFlyHeight(130)
SetMaxPlayerFlyHeight (130)

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\\bf2.lvl;geo1cross")
ReadDataFile("dc:sound\\\df3.lvl;df2cw")
ReadDataFile("SIDE\\rep.lvl",
"rep_inf_ep3_rifleman",
"rep_inf_ep3_rocketeer",
"rep_inf_ep2_engineer",
"rep_inf_ep2_sniper",
"rep_inf_ep2_rocketeer_chaingun",
"rep_inf_ep2_jettrooper_training",
"rep_hover_barcspeeder",
"rep_walk_oneman_atst",
"rep_hover_fightertank",
"rep_hero_obiwan",
"rep_walk_atte")
ReadDataFile("SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_rocketeer",
"imp_inf_engineer",
"imp_inf_sniper",
"imp_inf_officer_hunt",
"imp_inf_dark_trooper_hunt",
"imp_hover_speederbike",
"imp_walk_atst",
"imp_hero_darthvader",
"imp_hover_fightertank",
"imp_walk_atat")
ReadDataFile("SIDE\\all.lvl",
"all_inf_rifleman")
ReadDataFile("SIDE\\cis.lvl",
"cis_inf_rifleman",
"cis_inf_rocketeer",
"cis_inf_sniper")
ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_laser",
"tur_bldg_tower")

SetupTeams{
rep = {
team = REP,
units = 65,
reinforcements = 600,
soldier = { "rep_inf_ep3_rifleman",120, 220},
assault = { "rep_inf_ep3_rocketeer",5, 6},
engineer = { "rep_inf_ep2_engineer",5, 6},
sniper = { "rep_inf_ep2_sniper",5, 12},
officer = {"rep_inf_ep2_rocketeer_chaingun",5, 6},
special = { "rep_inf_ep2_jettrooper_training",5, 6},

},
imp = {
team = imp,
units = 65,
reinforcements = 600,
soldier = { "imp_inf_rifleman",120, 220},
assault = { "imp_inf_rocketeer",5, 6},
engineer = { "imp_inf_engineer",5, 6},
sniper = { "imp_inf_sniper",5, 6},
officer = {"imp_inf_officer_hunt",5, 6},
special = { "imp_inf_dark_trooper_hunt",5, 6},
}
}

SetHeroClass(imp, "imp_hero_darthvader")
SetHeroClass(REP, "rep_hero_obiwan")

-- Local Stats
SetTeamName(3, "all")
SetUnitCount(3, 7)
AddUnitClass(3, "all_inf_soldier", 7)
SetTeamAsEnemy(3, DEF)
SetTeamAsEnemy(DEF, 3)
SetTeamAsEnemy(ATT,3)
SetTeamAsEnemy(3,ATT)
SetTeamName(4, "rebels")
AddUnitClass(4, "cis_inf_rifleman",10)
AddUnitClass(4, "cis_inf_rocketeer",1)
AddUnitClass(4, "cis_inf_sniper",1)
SetUnitCount(4, 12)
SetTeamAsEnemy(4, ATT)
SetTeamAsEnemy(ATT, 4)

--temp until you rescript this mission
AddAIGoal(1,"Conquest",100);
AddAIGoal(2,"Conquest",100);
AddAIGoal(3,"Conquest",100);
--temp until you rescript this mission
-- Level Stats
-- ClearWalkers()
AddWalkerType(0, 4) -- special -> droidekas
AddWalkerType(1, 4) -- 1x2 (1 pair of legs)
AddWalkerType(2, 1) -- 1 atats with 2 leg pairs each
AddWalkerType(3, 3) -- 3 attes with 3 leg pairs each
AddWalkerType(1, 8) -- ATSTs
local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("CommandWalker", 4)
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:KOR\\KOR.lvl", "KOR_conquest")
ReadDataFile("dc:KOR\\KOR.lvl", "KOR_conquest")
SetDenseEnvironment("false")
SetDefenderSnipeRange(500)



-- Sound

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

voiceSlow = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "imp_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", "imp_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "gcw_music")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\geo.lvl", "geo1")
OpenAudioStream("sound\\geo.lvl", "geo1")
OpenAudioStream("sound\\geo.lvl", "geo1_emt")

SetBleedingVoiceOver(REP, REP, "rep_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(REP, imp, "rep_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(imp, REP, "imp_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(imp, imp, "imp_off_com_report_us_overwhelmed", 1)

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

SetAmbientMusic(all, 1.0, "all_geo_amb_start", 0,1)
SetAmbientMusic(all, 0.8, "all_geo_amb_middle", 1,1)
SetAmbientMusic(all, 0.2, "all_geo_amb_end", 2,1)
SetAmbientMusic(imp, 1.0, "imp_geo_amb_start", 0,1)
SetAmbientMusic(imp, 0.8, "imp_geo_amb_middle", 1,1)
SetAmbientMusic(imp, 0.2, "imp_geo_amb_end", 2,1)

SetVictoryMusic(all, "all_geo_amb_victory")
SetDefeatMusic (all, "all_geo_amb_defeat")
SetVictoryMusic(imp, "imp_geo_amb_victory")
SetDefeatMusic (imp, "imp_geos_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.613493, -0.007088, 0.789616, 0.009122, -203.110870, 2.347373, 227.966812);
AddCameraShot(0.731491, -0.195120, -0.631264, -0.168385, 93.467842, 21.624365, 146.393112);
AddCameraShot(-0.175554, 0.013309, -0.981563, -0.074414, 31.551453, 14.149174, 253.044556);
end[/code]

Re: locals not spawning ingame what am i missing in my lua ?

Posted: Sun Jul 21, 2019 7:20 am
by Sporadia
I can't see the problem is in the mission lua. The most likely problem is that the map KOR doesn't have the initial teams for the CPs set how you want to them. The proper way to fix it is to open the map in ZeroEditor and set all the CPs to have the team you want at the start of a game. There are probably more detailed explanations around in the ZeroEditor section of the sticky.


But, since I've never done any map making and I know ZeroEditor takes some messing around with to even get working, I also know an alternative lua solution. Put this at the bottom of ScripPostLoad() and you can use it overrule the map's settings and set up which command posts belong to which teams:
Hidden/Spoiler:
[code]
SetProperty (cp1, "Team", ATT)
SetProperty (cp2, "Team", ATT)
SetProperty (cp3, "Team", 3)
SetProperty (cp4, "Team", 4)
SetProperty (cp5, "Team", 3)
SetProperty (cp6, "Team", DEF)
SetProperty (cp7, "Team", DEF)[/code]
You can also delete CPs with KillObject(cp1), bring them back with RespawnObject(cp1), make them invisible with SetProperty(cp1, "hideCPs", true), or make them impossible to capture by removing the capture region with SetProperty(cp1, "CaptureRegion", 0). To give the capture region back you need to know what the region is called, and I don't remember if removing a capture region uses 0 or "0" tbh, but it's one of those two. Best examples of this stuff is in campain mission lua like Coruscant. The lua stuff's designed for changing CP properties mid mission more than setting them up, but if it works it works.

Re: locals not spawning ingame what am i missing in my lua ?

Posted: Sun Jul 21, 2019 1:40 pm
by wsa30h
thanks i actually fixed it.