Page 1 of 1

Add vehicle via lua [Solved]

Posted: Sat Mar 01, 2014 7:34 am
by Anakin
Hi,

i want to add vehicles to Hoth cw. So i looked in the hoth.ldx file and found this:

Code: Select all

GameMode("conquest")
{
	Layer(8);
	Layer(9);
}
So i looked above what layer 8 and 9 are called:

Code: Select all

Layer("Conquest", 8, 0)
{
	Description("");
}

Layer("CPs", 9, 0)
{
	Description("");
}
And in the CPs.lyr i found this:
Hidden/Spoiler:
[code]
Object("VehicleSpawn_11", "com_item_vehicle_spawn", 949314973)
{
ChildRotation(-0.222, 0.000, -0.975, 0.000);
ChildPosition(-527.000, 0.000, 82.000);
SeqNo(949314973);
Team(2);
NetworkId(-1);
Label("VehicleSpawn_11");
Layer(9);
ControlZone("CP5");
SpawnCount("1");
SpawnTime("45.0");
ExpireTimeEnemy("20.0");
ExpireTimeField("40.0");
DecayTime("10.0");
ClassNeutral("");
ClassAllATK("");
ClassCISATK("");
ClassImpATK("");
ClassRepATK("");
ClassLocATK("");
ClassHisATK("");
ClassAllDEF("all_fly_snowspeeder");
ClassCISDEF("");
ClassImpDEF("");
ClassRepDEF("");
ClassLocDEF("");
ClassHisDEF("all_fly_snowspeeder");
ClassLocals("");
}
[/code]
And the same for VehicleSpawn_12, VehicleSpawn_13, VehicleSpawn_14.

So i set up my lua like this:
Hidden/Spoiler:
[code]
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

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

ReadDataFile("dc:common.lvl")
ReadDataFile("common.lvl")
-- Empire Attacking (attacker is always #1)
REP = 2
CIS = 1
CLONES = 3
-- These variables do not change
ATT = 1
DEF = 2

---------------------------------------------------------------------------
-- 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 ScriptPostLoad()

AddDeathRegion("fall")
DisableBarriers("atat")
DisableBarriers("bombbar")

--CP SETUP for CONQUEST
-- SetProperty("shield", "MaxHealth", 222600.0)
-- SetProperty("shield", "CurHealth", 222600.0)
SetObjectTeam("CP3", 1)
SetObjectTeam("CP6", 1)
KillObject("CP7")

EnableSPHeroRules()

cp1 = CommandPost:New{name = "CP3"}
cp2 = CommandPost:New{name = "CP4"}
cp3 = CommandPost:New{name = "CP5"}
cp4 = CommandPost:New{name = "CP6"}
-- cp5 = CommandPost:New{name = "CP7"}

conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, textATT = "game.modes.con", textDEF = "game.modes.con2", multiplayerRules = true}

conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
-- conquest:AddCommandPost(cp5)

conquest:Start()

-- KillObject("shield");

SetProperty("CP3", "AllyPath", "CP3_SpawnPath")
SetProperty("CP4", "AllyPath", "CP4_SpawnPath")
SetProperty("CP5", "AllyPath", "CP5_SpawnPath")
SetProperty("CP6", "AllyPath", "CP6_SpawnPath")
SetProperty("CP7", "AllyPath", "CP7_Spawn")

SetProperty("VehicleSpawn_11", "ClassRepDEF", "all_fly_snowspeeder")
SetProperty("VehicleSpawn_12", "ClassRepDEF", "all_fly_snowspeeder")
SetProperty("VehicleSpawn_13", "ClassRepDEF", "all_fly_snowspeeder")
SetProperty("VehicleSpawn_14", "ClassRepDEF", "all_fly_snowspeeder")

end

function ScriptInit()
ReadDataFile("dc:Load\\RCM_Load.lvl")

if(ScriptCB_GetPlatform() == "PS2") then
StealArtistHeap(1024*1024) -- steal 1MB from art heap
end

-- Designers, these two lines *MUST* be first.
--SetPS2ModelMemory(4500000)
SetPS2ModelMemory(3300000)

SetMemoryPoolSize("ParticleTransformer::SizeTransf", 2500)
SetMemoryPoolSize("ParticleTransformer::ColorTrans", 3000)
SetMemoryPoolSize("ParticleTransformer::PositionTr", 2500)
SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",30) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",500) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",500) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",500) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",400) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",4000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",88) -- should be ~1x #combo
SetMemoryPoolSize("Music", 70)

local screenWidth, screenHeight = ScriptCB_GetScreenInfo()

if screenHeight == 1080 and screenWidth == 1920 then
ReadDataFile("dc:HUD\\hud1920x1080.lvl")
ReadDataFile("ingame.lvl")
ReadDataFile("dc:HUD\\hudBmpKill.lvl")
else
ReadDataFile("ingame.lvl")
end



--SetAttackingTeam(ATT)


SetMaxFlyHeight(70)
SetMaxPlayerFlyHeight(70)
SetGroundFlyerMap(1);

ReadDataFile("dc:sound\\rcm.lvl;RCMr")
ReadDataFile("dc:sound\\hot_weapon.lvl;cor1cw")
ReadDataFile("dc:sound\\hot_cw.lvl;hot1cw")



ReadDataFile("SIDE\\all.lvl",
"all_fly_snowspeeder",
"all_walk_tauntaun")

ReadDataFile("SIDE\\cis.lvl",
"cis_hover_stap",
"cis_fly_droidfighter_sc")

ReadDataFile("SIDE\\rep.lvl",
"rep_walk_oneman_atst",
"rep_walk_atte")

ReadDataFile("dc:SIDE\\rep.lvl",
"rep_inf_commando_01_rifleman",
"rep_inf_commando_02_roketeer",
"rep_inf_commando_03_sniper",
"rep_inf_commando_04_engineer",
"rep_inf_commando_05_electronic",
"rep_inf_commando_06_sergeant",
"rep_inf_commando_07_havoc",
"rep_inf_commando_08_elite")

ReadDataFile("dc:SIDE\\cis.lvl",
"cis_inf_b1_rifleman",
"cis_inf_b1_rocketeer",
"cis_inf_b1_sniper",
"cis_inf_sbd",
"cis_inf_magnaguard",
"cis_inf_droideka")

ReadDataFile("dc:SIDE\\mdo.lvl",
"mdo_inf_assassin",
"mdo_inf_officer")

ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_hoth_dishturret",
"tur_bldg_hoth_lasermortar")

ReadDataFile("dc:SIDE\\tnd.lvl",
"tnd_inf_slaver",
"tnd_inf_mercenary")

ReadDataFile("dc:SIDE\\geo.lvl",
"geo_inf_geonosian",
"geo_inf_geonosian_elite")

ReadDataFile("dc:SIDE\\rrl.lvl",
"rrl_inf_ep2_rifleman",
"rrl_inf_ep2_commander",
"rrl_inf_ep2_jettrooper")

TrandoOrMandoOrGeo = math.random(1,9)

if TrandoOrMandoOrGeo < 4 then

SetupTeams{
rep = {
team = REP,
units = 16,
reinforcements = 150,
soldier = { "rep_inf_commando_01_rifleman",9, 25},
assault = { "rep_inf_commando_02_roketeer",1,4},
sniper = { "rep_inf_commando_03_sniper",1,4},
engineer= { "rep_inf_commando_04_engineer",1,4},
officer = { "rep_inf_commando_05_electronic",1,4},
special = { "rep_inf_commando_06_sergeant",1,4},
commander={ "rep_inf_commando_07_havoc", 1, 4},
general = { "rep_inf_commando_08_elite", 1, 2}
},
cis = {
team = CIS,
units = 32,
reinforcements = 300,
soldier = {"cis_inf_b1_rifleman",10, 30},
assault = {"cis_inf_b1_rocketeer",1, 4},
sniper = {"cis_inf_b1_sniper",1, 4},
engineer= {"mdo_inf_assassin",1, 3},
officer = {"cis_inf_sbd",1, 2},
special = {"mdo_inf_officer",1, 2},
commander={"cis_inf_droideka", 1, 2},
general = {"cis_inf_magnaguard", 1, 2}
}
}
end

if TrandoOrMandoOrGeo > 3 and TrandoOrMandoOrGeo < 7 then

SetupTeams{
rep = {
team = REP,
units = 16,
reinforcements = 150,
soldier = { "rep_inf_commando_01_rifleman",9, 25},
assault = { "rep_inf_commando_02_roketeer",1,4},
sniper = { "rep_inf_commando_03_sniper",1,4},
engineer= { "rep_inf_commando_04_engineer",1,4},
officer = { "rep_inf_commando_05_electronic",1,4},
special = { "rep_inf_commando_06_sergeant",1,4},
commander={ "rep_inf_commando_07_havoc", 1, 4},
general = { "rep_inf_commando_08_elite", 1, 2}
},
cis = {
team = CIS,
units = 32,
reinforcements = 300,
soldier = {"cis_inf_b1_rifleman",10, 30},
assault = {"cis_inf_b1_rocketeer",1, 4},
sniper = {"cis_inf_b1_sniper",1, 4},
engineer= {"tnd_inf_mercenary",1, 3},
officer = {"cis_inf_sbd",1, 2},
special = {"tnd_inf_slaver",1, 2},
commander={"cis_inf_droideka", 1, 2},
general = {"cis_inf_magnaguard", 1, 2}
}
}

end

if TrandoOrMandoOrGeo > 6 then

SetupTeams{
rep = {
team = REP,
units = 16,
reinforcements = 150,
soldier = { "rep_inf_commando_01_rifleman",9, 25},
assault = { "rep_inf_commando_02_roketeer",1,4},
sniper = { "rep_inf_commando_03_sniper",1,4},
engineer= { "rep_inf_commando_04_engineer",1,4},
officer = { "rep_inf_commando_05_electronic",1,4},
special = { "rep_inf_commando_06_sergeant",1,4},
commander={ "rep_inf_commando_07_havoc", 1, 4},
general = { "rep_inf_commando_08_elite", 1, 2}
},
cis = {
team = CIS,
units = 32,
reinforcements = 300,
soldier = {"cis_inf_b1_rifleman",10, 30},
assault = {"cis_inf_b1_rocketeer",1, 4},
sniper = {"cis_inf_b1_sniper",1, 4},
engineer= {"geo_inf_geonosian",1, 3},
officer = {"cis_inf_sbd",1, 2},
special = {"geo_inf_geonosian_elite",1, 2},
commander={"cis_inf_droideka", 1, 2},
general = {"cis_inf_magnaguard", 1, 2}
}
}

end


-- Clones -------------------------
SetTeamName (3, "clone")
AddUnitClass (3, "rrl_inf_ep2_rifleman", 11)
AddUnitClass (3, "rrl_inf_ep2_jettrooper", 5)
AddUnitClass(3, "rrl_inf_ep2_commander",3)
SetUnitCount (3, 15)
AddAIGoal(CLONES, "Deathmatch", 100)
SetTeamAsFriend(3,REP)
SetTeamAsEnemy(3,CIS)
SetTeamAsFriend(REP,3)
SetTeamAsEnemy(CIS,3)
-----------------------------------

-- Level Stats
ClearWalkers()
AddWalkerType(0, 3) -- 0 droidekas
AddWalkerType(1, 5) -- 6 atsts with 1 leg pairs each
AddWalkerType(2, 2) -- 2 atats with 2 leg pairs each

local weaponCnt = 221
SetMemoryPoolSize("Aimer", 80)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 175)
SetMemoryPoolSize("CommandWalker", 2)
SetMemoryPoolSize("ConnectivityGraphFollower", 56)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 60)
SetMemoryPoolSize("EntityFlyer", 10)
SetMemoryPoolSize("EntityLight", 110)
SetMemoryPoolSize("EntitySoundStatic", 16)
SetMemoryPoolSize("EntitySoundStream", 5)
SetMemoryPoolSize("FLEffectObject::OffsetMatrix", 54)
SetMemoryPoolSize("MountedTurret", 30)
SetMemoryPoolSize("Navigator", 70)
SetMemoryPoolSize("Obstacle", 400)
SetMemoryPoolSize("OrdnanceTowCable", 40) -- !!!! need +4 extra for wrapped/fallen cables !!!!
SetMemoryPoolSize("PathFollower", 70)
SetMemoryPoolSize("PathNode", 128)
SetMemoryPoolSize("ShieldEffect", 0)
SetMemoryPoolSize("TreeGridStack", 300)
SetMemoryPoolSize("UnitController", 70)
SetMemoryPoolSize("UnitAgent", 70)
SetMemoryPoolSize("Weapon", weaponCnt)
SetMemoryPoolSize("SoldierAnimation", 700)
SetMemoryPoolSize("RedOmniLight", 145)

ReadDataFile("HOT\\hot1.lvl", "hoth_conquest")
--ReadDataFile("tan\\tan1.lvl", "tan1_obj")
SetSpawnDelay(10.0, 0.25)
SetDenseEnvironment("false")
SetDefenderSnipeRange(170)
AddDeathRegion("Death")


-- Sound Stats

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\\hot.lvl", "hot1gcw")
OpenAudioStream("sound\\hot.lvl", "hot1gcw")

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)

-- SetLowReinforcementsVoiceOver(ALL, IMP, "all_hot_transport_away", .75, 1)
-- SetLowReinforcementsVoiceOver(ALL, IMP, "all_hot_transport_away", .5, 1)
-- SetLowReinforcementsVoiceOver(ALL, IMP, "all_hot_transport_away", .25, 1)

SetLowReinforcementsVoiceOver(REP, REP, "rep_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(REP, CIS, "rep_off_victory_im", .1, 1)
SetLowReinforcementsVoiceOver(CIS, CIS, "cis_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(CIS, REP, "cis_off_victory_im", .1, 1)

SetOutOfBoundsVoiceOver(2, "Repleaving")
SetOutOfBoundsVoiceOver(1, "Cisleaving")

SetAmbientMusic(REP, 1.0, "rep_hot_amb_start", 0,1)
SetAmbientMusic(REP, 0.8, "rep_hot_amb_middle", 1,1)
SetAmbientMusic(REP, 0.2, "rep_hot_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "cis_hot_amb_start", 0,1)
SetAmbientMusic(CIS, 0.8, "cis_hot_amb_middle", 1,1)
SetAmbientMusic(CIS, 0.2, "cis_hot_amb_end", 2,1)

SetVictoryMusic(REP, "rep_hot_amb_victory")
SetDefeatMusic (REP, "rep_hot_amb_defeat")
SetVictoryMusic(CIS, "cis_hot_amb_victory")
SetDefeatMusic (CIS, "cis_hot_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--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")

-- Camera Stats
--Hoth
--Hangar
AddCameraShot(0.944210, 0.065541, 0.321983, -0.022350, -500.489838, 0.797472, -68.773849)
--Shield Generator
AddCameraShot(0.371197, 0.008190, -0.928292, 0.020482, -473.384155, -17.880533, 132.126801)
--Battlefield
AddCameraShot(0.927083, 0.020456, -0.374206, 0.008257, -333.221558, 0.676043, -14.027348)


ReadDataFile("dc:HUD\\hudTxtKill.lvl")
end

[/code]
Look at the end of the ScriptPostLoad() function.

But there are no vehicles ingame. The BF2log says this:
Hidden/Spoiler:
Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(635)
Entity "VehicleSpawn_11" not found

Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(635)
Entity "VehicleSpawn_12" not found

Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(635)
Entity "VehicleSpawn_13" not found

Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(635)
Entity "VehicleSpawn_14" not found
So for some reason there are no VehicleSpawns. Does someone know what i made wrong??

Re: add vehicle via lua

Posted: Sat Mar 01, 2014 7:52 am
by JimmyAngler
To add a vehicle you have to add it to you custom side files. (odf, req, mshs, tga, etc...) Then, open up ZE and browse to the objects tab and hit the browse odf. then, just direct the file to you custom side and find the vehicle odf. Select the odf, and place it in your world!

Re: add vehicle via lua

Posted: Sat Mar 01, 2014 7:56 am
by Anakin
In this case i need to rebuild stock hoth. And that's something i don't want. So the map allread has an vehicle spawn and an region, too. The only thing i need to do is setup the ClassRepDEF after the rep sides are the defeting one. If you read the lua you'll see that this is exactly what i try at the end of the ScriptPostLoad() function. And there are also all requiert files for the vehicle (msh, odf, req, tga,..) after i try to load the stock all_fly_snowspeeder.

Re: add vehicle via lua

Posted: Sat Mar 01, 2014 10:36 am
by Locutus
If had exactly the same issue on the Stargate map.
It seems you can't change the Instance Properties from Vehicle Spawns.
Since spawning vehicles via lua doesn't work either I'm afraid there isn't much you can do.

Re: add vehicle via lua

Posted: Sat Mar 01, 2014 12:14 pm
by Maveritchell
What you should simply do is - instead of rebuilding Hoth - construct an extra custom layer and load it in. Ex:

Code: Select all

     ReadDataFile("dag\\dag1.lvl", "dag1_conquest", "dag1_gcw")
     ReadDataFile("dc:BDT\\dag1.lvl", "dag1_dtOBJ")
In the above example, I loaded in stock Dagobah, but I'd also created an extra .lvl file that had a single layer in it ("dag1_dtOBJ"), which I loaded in after the stock map.

Re: add vehicle via lua

Posted: Sat Mar 01, 2014 12:37 pm
by Anakin
How looks your custom dag1.req file??

Re: add vehicle via lua

Posted: Sat Mar 01, 2014 12:53 pm
by Maveritchell
It loads in only what I need (which in this case was the layer and the path file containing spawnpaths). In your example, you probably only need to load in the layer, since you'd just be placing vehicle spawn objects.
Hidden/Spoiler:
[code]ucft
{
REQN
{
"config"
}

REQN
{
"path"
"dag1"
}
REQN
{
"world"
"dag1_dtOBJ"
}

}[/code]

Re: add vehicle via lua

Posted: Sat Mar 01, 2014 12:55 pm
by Anakin
Thank you very much it works :mrgreen: