Page 1 of 1

Space Battle Scripting Problem

Posted: Mon Mar 20, 2006 5:15 pm
by xwingguy
The map freezes in the loading screen and I believe that I basically messed up my code somewhere, but I don't where. I just need a second opinion on it.

common script

Code: Select all

ScriptCB_DoFile("setup_teams")

--  Republic Attacking (attacker is always #1)
ALL = 1
IMP = 2
--  These variables do not change
ATT = 1
DEF = 2

function SetupUnits()
    ReadDataFile("SIDE\\all.lvl",
        "all_inf_pilot",
        "all_inf_marine",
        "all_fly_xwing_sc",
        "all_fly_ywing_sc",
        "all_fly_awing",
        "all_fly_gunship_sc",
        "all_veh_remote_terminal")
     ReadDataFile("SIDE\\imp.lvl",
        "imp_inf_pilot",
        "imp_inf_marine",
        "imp_fly_tiefighter_sc",
        "imp_fly_tiebomber_sc",
        "imp_fly_tieinterceptor",
        "imp_fly_trooptrans",
        "imp_veh_remote_terminal")
        
    ReadDataFile("SIDE\\tur.lvl",
        "tur_bldg_spa_all_beam",
        "tur_bldg_spa_all_recoilless",
        "tur_bldg_spa_all_chaingun",
        "tur_bldg_spa_all_guided_rocket",
        "tur_bldg_spa_imp_beam",
        "tur_bldg_spa_imp_recoilless",
        "tur_bldg_spa_imp_chaingun",
        "tur_bldg_chaingun_roof")
end

myTeamConfig = {
     all = {
        team = ALL,
        units = 32,
        reinforcements = -1,
        pilot    = { "all_inf_pilot",26},
        marine   = { "all_inf_marine",6},
    },

    imp = {
        team = IMP,
        units = 32,
        reinforcements = -1,
        pilot    = { "imp_inf_pilot",26},
        marine   = { "imp_inf_marine",6},
    }
}



ScriptCB_DoFile("LinkedTurrets")
function SetupTurrets() 
    --ALL turrets
    turretLinkageALL = LinkedTurrets:New{ team = ALL, mainframe = "all-defense", 
		turrets = {"all_turr_1", "all_turr_2", "all_turr_3", "all_turr_4", "all_turr_5", "all_turr_6", 
					"all_turr01", "all_tur02", "all_tur3", "all_tur4", "all_tur5", "all_tur6", "all_tur7",
					"all_tur8"} }
    turretLinkageALL:Init()
    
    function turretLinkageALL:OnDisableMainframe()
        ShowMessageText("level.spa.hangar.mainframe.atk.down", IMP)
        ShowMessageText("level.spa.hangar.mainframe.def.down", ALL)
        
        BroadcastVoiceOver( "IOSMP_obj_20", IMP )
        BroadcastVoiceOver( "AOSMP_obj_21", ALL )
    end
    function turretLinkageALL:OnEnableMainframe()
        ShowMessageText("level.spa.hangar.mainframe.atk.up", IMP)
        ShowMessageText("level.spa.hangar.mainframe.def.up", ALL)
        
        BroadcastVoiceOver( "IOSMP_obj_22", IMP )
        BroadcastVoiceOver( "AOSMP_obj_23", ALL )
    end
   
    --IMP turrets
    turretLinkageIMP = LinkedTurrets:New{ team = IMP, mainframe = "imp-defense", 
		turrets = {"imp_turr_1", "imp_turr_2", "imp_turr_3", "imp_turr_4", "imp_turr_5", "imp_turr_6",
					"spa1_prop_imp_ship_turret21", "spa1_prop_imp_ship_turret22", "spa1_prop_imp_ship_turret23", "spa1_prop_imp_ship_turret24", "spa1_prop_imp_ship_turret10", "spa1_prop_imp_ship_turret1", "spa1_prop_imp_ship_turret20", "spa1_prop_imp_ship_turret2" } }
    turretLinkageIMP:Init()

    function turretLinkageIMP:OnDisableMainframe()
        ShowMessageText("level.spa.hangar.mainframe.atk.down", ALL)
        ShowMessageText("level.spa.hangar.mainframe.def.down", IMP)
        
        BroadcastVoiceOver( "IOSMP_obj_21", IMP )
        BroadcastVoiceOver( "AOSMP_obj_20", ALL )
    end
    function turretLinkageIMP:OnEnableMainframe()
        ShowMessageText("level.spa.hangar.mainframe.atk.up", ALL)
        ShowMessageText("level.spa.hangar.mainframe.def.up", IMP)
        
        BroadcastVoiceOver( "IOSMP_obj_23", IMP )
        BroadcastVoiceOver( "AOSMP_obj_22", ALL )
    end
end

-- adjust extents to fit cap ship
function ScriptPreInit()
   SetWorldExtents(2650)
   ScriptPreInit = nil
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()
   
  -- Designers, this line *MUST* be first!
    ReadDataFile("ingame.lvl")
   
    SetMinFlyHeight(-1800)
    SetMaxFlyHeight(1800)
    SetMinPlayerFlyHeight(-1800)
    SetMaxPlayerFlyHeight(1800)
    SetAIVehicleNotifyRadius(100)
    
    ReadDataFile("sound\\spa.lvl;spa1gcw")
     ScriptCB_SetDopplerFactor(0.4)
     ScaleSoundParameter("tur_weapons",   "MinDistance",   3.0);
     ScaleSoundParameter("tur_weapons",   "MaxDistance",   3.0);
     ScaleSoundParameter("tur_weapons",   "MuteDistance",   3.0);
     ScaleSoundParameter("Ordnance_Large",   "MinDistance",   3.0);
     ScaleSoundParameter("Ordnance_Large",   "MaxDistance",   3.0);
     ScaleSoundParameter("Ordnance_Large",   "MuteDistance",   3.0);
     ScaleSoundParameter("explosion",   "MaxDistance",   5.0);
     ScaleSoundParameter("explosion",   "MuteDistance",  5.0);
         
    SetupUnits()
    SetupTeams(myTeamConfig)

    --  Level Stats
    ClearWalkers()
    local weaponCnt = 250
    local guyCnt = 32
    SetMemoryPoolSize("Aimer", 190)
    SetMemoryPoolSize("AmmoCounter", weaponCnt)
    SetMemoryPoolSize("BaseHint", 89)
    SetMemoryPoolSize("Combo::DamageSample", 0)
    SetMemoryPoolSize("CommandFlyer", 3)
    SetMemoryPoolSize("SoldierAnimation", 180)
    SetMemoryPoolSize("EnergyBar", weaponCnt)
    SetMemoryPoolSize("EntityCloth", 0)
    SetMemoryPoolSize("EntityDroid", 0)
    SetMemoryPoolSize("EntityDefenseGridTurret", 0)
    SetMemoryPoolSize("EntityFlyer", 32)
    SetMemoryPoolSize("EntityLight", 115)
    SetMemoryPoolSize("EntityRemoteTerminal", 36)
    SetMemoryPoolSize("FLEffectObject::OffsetMatrix", 180) //this was one line before posting it here.
    SetMemoryPoolSize("MountedTurret", 56)
    SetMemoryPoolSize("EntityPortableTurret", 20)
    SetMemoryPoolSize("Navigator", guyCnt)
    SetMemoryPoolSize("Obstacle", 135)
    SetMemoryPoolSize("PathNode", 80)
    SetMemoryPoolSize("PathFollower", guyCnt)
    SetMemoryPoolSize("TentacleSimulator", 0)
    SetMemoryPoolSize("TreeGridStack", 240)
    SetMemoryPoolSize("UnitAgent", 65)  -- guyCnt*2
    SetMemoryPoolSize("UnitController", 65)
    SetMemoryPoolSize("Weapon", weaponCnt)

    SetSpawnDelay(10.0, 0.25)
    
    -- do any pool allocations, custom loading here
    if myScriptInit then
        myScriptInit()
        myScriptInit = nil
    end
    
    ReadDataFile("dc:SED\\spa_sky.lvl", "end")

    ReadDataFile("dc:SED\\SED.lvl", myGameMode)
    
    SetDenseEnvironment("false")

    SetParticleLODBias(15000)

    --  Sound Stats
    local voiceSlow = OpenAudioStream("sound\\global.lvl", "spa1_objective_vo_slow")
    AudioStreamAppendSegments("sound\\global.lvl", "all_unit_vo_slow", voiceSlow)
    AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_slow", voiceSlow)
    AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)
    
    local voiceQuick = OpenAudioStream("sound\\global.lvl", "imp_unit_vo_quick")
    AudioStreamAppendSegments("sound\\global.lvl", "all_unit_vo_quick", voiceQuick)    
    
    -- OpenAudioStream("sound\\spa.lvl",  "spa1_objective_vo_slow")
    -- OpenAudioStream("sound\\global.lvl",  "global_vo_slow")
    OpenAudioStream("sound\\global.lvl",  "gcw_music")
    OpenAudioStream("sound\\spa.lvl",  "spa")
    OpenAudioStream("sound\\spa.lvl",  "spa")
    
    SetBleedingVoiceOver(ALL, ALL, "all_off_com_report_us_overwhelmed", 1)
    SetBleedingVoiceOver(ALL, IMP, "all_off_com_report_enemy_losing",   1)
    SetBleedingVoiceOver(IMP, ALL, "imp_off_com_report_enemy_losing",   1)
    SetBleedingVoiceOver(IMP, IMP, "imp_off_com_report_us_overwhelmed", 1)
    
    SetLowReinforcementsVoiceOver(ALL, ALL, "all_off_defeat_im", .1, 1)
    SetLowReinforcementsVoiceOver(ALL, IMP, "all_off_victory_im", .1, 1)
    SetLowReinforcementsVoiceOver(IMP, IMP, "imp_off_defeat_im", .1, 1)
    SetLowReinforcementsVoiceOver(IMP, ALL, "imp_off_victory_im", .1, 1)
    
    SetOutOfBoundsVoiceOver(ALL, "allleaving")
    SetOutOfBoundsVoiceOver(IMP, "impleaving")
    
    SetAmbientMusic(ALL, 1.0, "all_spa_amb_start",  0,1)
    SetAmbientMusic(ALL, 0.99, "all_spa_amb_middle", 1,1)
    SetAmbientMusic(ALL, 0.1,"all_spa_amb_end",    2,1)
    SetAmbientMusic(IMP, 1.0, "imp_spa_amb_start",  0,1)
    SetAmbientMusic(IMP, 0.99, "imp_spa_amb_middle", 1,1)
    SetAmbientMusic(IMP, 0.1,"imp_spa_amb_end",    2,1)
    
    SetVictoryMusic(ALL, "all_spa_amb_victory")
    SetDefeatMusic (ALL, "all_spa_amb_defeat")
    SetVictoryMusic(IMP, "imp_spa_amb_victory")
    SetDefeatMusic (IMP, "imp_spa_amb_defeat")
    
    SetSoundEffect("ScopeDisplayZoomIn",  "binocularzoomin")
    SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
    --  SetSoundEffect("BirdScatter",         "birdsFlySeq1")
    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 
    SetAttackingTeam(IMP)
    -- Internal Alliance hangar
    -- this shot is bad, needs to be fixed
    AddCameraShot(-0.049495, 0.003922, -0.995646, -0.078892, 24.992880, -22.995819, -1025.940186);
    --Flag shot
    AddCameraShot(0.546201, 0.047743, 0.833116, -0.072822, 402.610260, -105.474068, -55.044727);
    --Internal Imperial hangar
    AddCameraShot(0.988295, -0.091070, 0.121873, 0.011230, 33.932011, 10.868500, 1567.624146);
    -- Imperial ship overall
    AddCameraShot(-0.380690, 0.021761, -0.922940, -0.052756, 1351.167236, 188.651230, -10.971837);
    -- Alliance ship overall
    AddCameraShot(0.941014, -0.051715, 0.333887, 0.018349, 1053.546143, 188.651230, -51.276745);


    AddDeathRegion("deathregion1")
    
    AddDeathRegion("deathregion2")
    AddDeathRegion("all-engine1")
    AddDeathRegion("all-engine2")
    AddDeathRegion("all-engine3a")
    AddDeathRegion("all-engine3b")
    AddDeathRegion("all-engine4a")
    AddDeathRegion("all-engine4b")
    AddDeathRegion("all-engine5")
    AddDeathRegion("all-engine6")
    AddDeathRegion("imp-engine1")
    AddDeathRegion("imp-engine2")
    AddDeathRegion("imp-engine3")
    AddDeathRegion("all-hangara-sqm")
    AddDeathRegion("all-hangarb-sqm")
    AddDeathRegion("imp-hangara-sqm")
    AddLandingRegion("all-CP1Con")
    AddLandingRegion("all-cp2_con")
    AddLandingRegion("imp-CP1Con")



function destallengine1()
        RemoveRegion("all-engine1")

end

    
function destallengine2()
        RemoveRegion("all-engine2")
	  
end
    
function destallengine3()
        RemoveRegion("all-engine3a")
	  RemoveRegion("all-engine3b")
	   
end
    
function destallengine4()
        RemoveRegion("all-engine4a")
	  RemoveRegion("all-engine4b")
	end
    
function destallengine5()
        RemoveRegion("all-engine5")
	  end
  
function destallengine6()
        RemoveRegion("all-engine6")
	end

function destimpengine1()
        RemoveRegion("imp-engine1")
	  
end
function destimpengine2()
        RemoveRegion("imp-engine2")
	  end

function destimpengine3()
        RemoveRegion("imp-engine3")
	 end

OnObjectKillName(destalengine1, "all_drive_1")
OnObjectKillName(destallengine2, "all_drive_2")
OnObjectKillName(destallengine3, "all_drive_3")
OnObjectKillName(destallengine4, "all_drive_4")
OnObjectKillName(destallengine5, "all_drive_5")  
OnObjectKillName(destallengine6, "all_drive_6")
OnObjectKillName(destimpengine1, "imp_drive_1")
OnObjectKillName(destimpengine2, "imp_drive_2")
OnObjectKillName(destimpengine3, "imp_drive_3")


end

Posted: Mon Mar 20, 2006 5:19 pm
by xwingguy
assualt file

Code: Select all

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("SEDg_cmn")

ScriptCB_DoFile("ObjectiveSpaceAssault")
ScriptCB_DoFile("LinkedShields")
ScriptCB_DoFile("LinkedDestroyables")

myGameMode = "SED_GCW-Assault"
 
function ScriptPostLoad()
    SetupObjectives()
    
    SetupShields()
    SetupDestroyables()
    SetupTurrets()
	
    AddAIGoal(ALL, "Deathmatch", 100)
    AddAIGoal(IMP, "Deathmatch", 100)
	
	DisableSmallMapMiniMap()
end

function SetupObjectives()
	assault = ObjectiveSpaceAssault:New{
		teamATT = IMP, teamDEF = ALL, 
		multiplayerRules = true
	}
	
	local impTargets = {
		engines		= {"all_drive_1", "all_drive_2", "all_drive_3", "all_drive_4", "all_drive_5", "all_drive_6"},
		lifesupport	= "all-life-ext",
		bridge		= "all-bridge",
		comm		= "all-comms",
		sensors		= "all-sensors",
		frigates		= "all-frigate",
		internalSys	= { "all-life-int", "all-engines" },
	}
	
	local allTargets = {
		engines		= { "imp_drive_1", "imp_drive_2", "imp_drive_3" },
		lifesupport	= "imp-life-ext",
		bridge		= "imp-bridge",
		comm		= "imp-comms",
		sensors		= "imp-sensors",
		frigates		= "imp-frigate",
		internalSys	= { "imp-life-int", "imp-engines" },
	}
	
	assault:SetupAllCriticalSystems( "imp", impTargets, true )
	assault:SetupAllCriticalSystems( "all", allTargets, false )
	
	assault:Start()
end

function SetupShields()
    -- ALL Shielded objects    
    local linkedShieldObjectsALL = { "all_ship_1", "all_ship_2",
    							"all-bridge", "all-comms", "all-life-ext", "all-sensors",
    							"all_drive_1", "all_drive_2", "all_drive_3", "all_drive_4", "all_drive_5", "all_drive_6"}
    shieldStuffALL = LinkedShields:New{objs = linkedShieldObjectsALL, controllerObject = "all-shield"}
    shieldStuffALL:Init()
    
    function shieldStuffALL:OnAllShieldsDown() 
        ShowMessageText("level.spa.hangar.shields.atk.down", IMP)
        ShowMessageText("level.spa.hangar.shields.def.down", ALL)
		
		BroadcastVoiceOver( "IOSMP_obj_16", IMP )
		BroadcastVoiceOver( "AOSMP_obj_17", ALL )
    end
    function shieldStuffALL:OnAllShieldsUp() 
        ShowMessageText("level.spa.hangar.shields.atk.up", IMP)
        ShowMessageText("level.spa.hangar.shields.def.up", ALL)
		
		BroadcastVoiceOver( "IOSMP_obj_18", IMP )
		BroadcastVoiceOver( "AOSMP_obj_19", ALL )
    end
    
    
    -- IMP Shielded objects    
    local linkedShieldObjectsIMP = { "imp_ship_1", "imp_ship_4", "imp_ship_5", "imp_ship_6",
    							"imp-bridge", "imp-comms", "imp-life-ext", "imp-sensors",
    							"imp_drive_1", "imp_drive_2", "imp_drive_3", "imp-commandDeck"}
    shieldStuffIMP = LinkedShields:New{objs = linkedShieldObjectsIMP, controllerObject = "imp-shield"}    
    shieldStuffIMP:Init()
    
    function shieldStuffIMP:OnAllShieldsDown() 
        ShowMessageText("level.spa.hangar.shields.atk.down", ALL)
        ShowMessageText("level.spa.hangar.shields.def.down", IMP)
		
		BroadcastVoiceOver( "IOSMP_obj_17", IMP )
		BroadcastVoiceOver( "AOSMP_obj_16", ALL )
    end
	function shieldStuffIMP:OnAllShieldsUp() 
        ShowMessageText("level.spa.hangar.shields.atk.up", ALL)
        ShowMessageText("level.spa.hangar.shields.def.up", IMP)
		
		BroadcastVoiceOver( "IOSMP_obj_19", IMP )
		BroadcastVoiceOver( "AOSMP_obj_18", ALL )
    end
	local linkedShieldFrigIMP = { "imp-frigate" }
	shieldFrigIMP = LinkedShields:New{objs =linkedShieldFrigIMP, addShield = 10, controllerObject = "imp-shield1"}
	shieldFrigIMP:Init()

	local linkedShieldFrigALL = { "all-frigate" }
	shieldFrigALL = LinkedShields:New{objs = linkedShieldFrigALL, addShield = 10, controllerObject = "all-shield1" }
	shieldFrigALL:Init()
end


function SetupDestroyables()
    --ALL destroyables
    lifeSupportLinkageALL = LinkedDestroyables:New{ objectSets = {{"all-life-int"}, {"all-life-ext"}} }
    lifeSupportLinkageALL:Init()
        
    engineLinkageALL = LinkedDestroyables:New{ objectSets = {{"all_drive_1", "all_drive_2", "all_drive_3", "all_drive_4", "all_drive_5", "all_drive_6"}, {"all-engines", "all-fuelreserve"}} }
    engineLinkageALL:Init()
	sensorsLinkageALL = LinkedDestroyables:New{ objectSets = {{"all-sensors"}, {"all-sensors1-int", "all-sensors2-int"}} }
	sensorsLinkageALL:Init()
	commsLinkageALL = LinkedDestroyables:New{ objectSets = {{"all-comms"}, {"all-comms-int"}} }
	commsLinkageALL:Init()
	bridgeLinkageALL = LinkedDestroyables:New{ objectSets = {{"all-bridge"}, {"all-commandmain", "all-command1", "all-command2"}} }
	bridgeLinkageALL:Init()
	hullLinkageALL = LinkedDestroyables:New{ objectSets = {{"all_ship_1"}, {"all_ship_2"}} }
	hullLinkageALL:Init()	    
    --IMP destroyables
    lifeSupportLinkageIMP = LinkedDestroyables:New{ objectSets = {{"imp-life-int"}, {"imp-life-ext"}} }
    lifeSupportLinkageIMP:Init()    
    
    engineLinkageIMP = LinkedDestroyables:New{ objectSets = {{"imp_drive_1", "imp_drive_2", "imp_drive_3"}, {"imp-engines"}} }
    engineLinkageIMP:Init()

    shieldLinkageIMP = LinkedDestroyables:New{ objectSets = {{"imp-shield"}, {"imp_ship_2", "imp_ship_3", "imp-shield-ext"}} }
    shieldLinkageIMP:Init()
	commandLinkageIMP = LinkedDestroyables:New{ objectSets = {{"imp-defense"}, {"imp-commandDeck"}} }
	commandLinkageIMP:Init()	

end
Some of you may know that normally you can't put shields on a frigate. I modified so it does work so that isn't my problem.

Posted: Mon Mar 20, 2006 6:31 pm
by [RDH]Zerted
You can put shields on any object, it just might not look good. I haven't notived a problem yet.

Posted: Mon Mar 20, 2006 8:04 pm
by xwingguy
nmd, but that's not the point, the point is to find the flaw that I can't find!

Posted: Wed Mar 22, 2006 9:39 am
by Emraz
My kingdom for a compiler.....

Posted: Wed Mar 22, 2006 10:01 am
by Teancum
Can you run BF2_modtools.exe? That should tell you.

- OR - if you're running the regular game, when the loading screen freezes, hit ALT + TAB and see if it leaves any fatal error messages.

Posted: Wed Mar 22, 2006 5:43 pm
by xwingguy
My modtools.exe doesn't work because of a missing dll file. If you could point me to a place where I can download binkw32.dll that would be great.

I figured out what crashed it. It's another odf that just doesn't seem to be compatable with space maps for some reason or another.

Posted: Thu Mar 23, 2006 1:28 am
by [RDH]Zerted
Do a search on your computer for the file. It should be in one of your game directores. You can move the mod tools to the game's folder, or you can copy the dll file to a location in your Windows PATH.