Scripting (Solved)

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
MandeRek
Sith Master
Sith Master
Posts: 2766
Joined: Tue Oct 02, 2007 10:51 am
Projects :: Battlefront Zer0
Games I'm Playing :: SWTOR
xbox live or psn: No gamertag set
Location: Ghosting around GT
Contact:

Scripting (Solved)

Post by MandeRek »

Well, I'm making a script with 1 objective.. Which is kill Artel Darc (cis_hero_arteldarc)

Ingame, no pop-up screen, objective, artel darc, or geonosian at all!

Someone an idea? I think i'm starting to understand scripting, but i've missed an essential part for sure!
Hidden/Spoiler:
[code]--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

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

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



function ScriptPostLoad()
ScriptCB_SetGameRules("campaign")-- Here you can see a script being used; The script to define the gameRules(of wich I don't really know what they do EXACTLY)
SetAIDifficulty(0, 0, "medium")-- I'd say this influences the dumbness of the A.I. to compensate for difficult maps.
DisableAIAutoBalance()--Help requested on explaining this


onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
BeginObjectives()
end
end)


--This is the main objective: destroy Artel Darc

Objective1= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.zer.objectives.campaign.killartel", popupText = "level.zer.objectives.long.killartel"}

JediKiller = TargetType:New{classname = "cis_hero_arteldarc", killLimit = 1}
Objective1:AddTarget(JediKiller)

Objective1.OnStart = function(self)
AddAIGoal(ATT, "Deathmatch", 1000)
AddAIGoal(DEF, "Deathmatch", 1000)
SetClassProperty("cis_hero_arteldarc", "MaxHealth", "3300.0")
SetClassProperty("cis_hero_arteldarc", "AddHealth", "120.0")
MapAddEntityMarker("cis_hero_arteldarc", "hud_objective_icon", 3.0, ATT, "YELLOW", true, true, true)
end

Objective1.OnComplete = function(self)
ScriptCB_SndPlaySound("UTA_obj_34")
ShowMessageText("game.objectives.complete", ATT)
end
--That was the main objective.. I guess

SetProperty("CP1", "CaptureRegion", "no_region")
SetProperty("CP2", "CaptureRegion", "no_region")
SetProperty("CP3", "CaptureRegion", "no_region")
SetProperty("CP4", "CaptureRegion", "no_region")
SetProperty("CP5", "CaptureRegion", "no_region")

SetClassProperty("jed_master_01", "PointsToUnlock", 6)
SetClassProperty("cis_inf_droideka", "PointsToUnlock", 6)

end

function BeginObjectives()
--This creates the objective "container" and specifies order of objectives, and gets that running
-- objectiveSequence = MultiObjectiveContainer:New{}
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4.5}
objectiveSequence:AddObjectiveSet(Objective1)
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()
-- Designers, these two lines *MUST* be first.
SetPS2ModelMemory(4100000)
ReadDataFile("ingame.lvl")
ReadDataFile("dc:ingame.lvl")
ReadDataFile("dc:Load\\gna.lvl")

SetMemoryPoolSize("Music", 36)

SetTeamAggressiveness(CIS, 1.0)
SetTeamAggressiveness(REP, 1.0)

ReadDataFile("sound\\uta.lvl;uta1cw")
ReadDataFile("SIDE\\geo.lvl",
"gen_inf_geonosian")
ReadDataFile("dc:SIDE\\mher2.lvl",
"cis_hero_arteldarc")

ReadDataFile("SIDE\\cis.lvl",
"cis_inf_droideka")

ReadDataFile("SIDE\\jed.lvl",
"jed_knight_01",
"jed_master_01")


-- Level Stats

ClearWalkers()
SetMemoryPoolSize("EntityWalker", -1)
AddWalkerType(0, 3) -- 8 droidekas (special case: 0 leg pairs)
AddWalkerType(2, 2) -- 2 spider walkers with 2 leg pairs each
AddWalkerType(3, 2) -- 2 attes with 3 leg pairs each
SetMemoryPoolSize("Aimer", 70)
SetMemoryPoolSize("BaseHint", 200)
SetMemoryPoolSize("CommandWalker", 1)
SetMemoryPoolSize("EntityFlyer", 4)
SetMemoryPoolSize("EntityHover", 12)
SetMemoryPoolSize("EntityLight", 50)
SetMemoryPoolSize("MountedTurret", 12)
SetMemoryPoolSize("Obstacle", 338)
SetMemoryPoolSize("PathNode", 100)

SetSpawnDelay(10.0, 0.25)

SetupTeams{

rep = {
team = REP,
units = 32,
reinforcements = -1,
sniper = { "jed_knight_01",10},
engineer = { "jed_master_01",5},


},
cis = {
team = CIS,
units = 40,
reinforcements = -1,
soldier = { "geo_inf_geonosian",30},
engineer = { "cis_hero_arteldarc",8},

}
}


-- Attacker Stats
--SetUnitCount(ATT, 32)
--SetReinforcementCount(ATT, 250)
--teamATT = ConquestTeam:New{team = ATT}
--teamATT:AddBleedThreshold(21, 0.75)
--teamATT:AddBleedThreshold(11, 2.25)
--teamATT:AddBleedThreshold(1, 3.0)
--teamATT:Init()
--SetTeamAsEnemy(ATT,3)

-- Defender Stats
--SetUnitCount(DEF, 25)
--SetReinforcementCount(DEF, 250)
--teamDEF = ConquestTeam:New{team = DEF}
--teamDEF:AddBleedThreshold(21, 0.75)
--teamDEF:AddBleedThreshold(11, 2.25)
--teamDEF:AddBleedThreshold(1, 3.0)
--teamDEF:Init()
SetTeamAsFriend(DEF,3)

-- Local Stats

--SetTeamName(4, "locals")
--AddUnitClass(4, "rep_inf_jedimale",1)
--AddUnitClass(4, "rep_inf_jedimaleb",1)
--AddUnitClass(4, "rep_inf_jedimaley",1)
--SetUnitCount(4, 3)
--SetTeamAsFriend(4, ATT)

ReadDataFile("dc:GEA\\GEA.lvl", "GEA_conquest")

SetDenseEnvironment("false")
SetMinFlyHeight(-65)
SetMaxFlyHeight(50)
SetMaxPlayerFlyHeight(50)



-- Birdies
--SetNumBirdTypes(1)
--SetBirdType(0.0,10.0,"dragon")
--SetBirdFlockMinHeight(90.0)

-- Sound

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

-- 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(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(1, "repleaving")
SetOutOfBoundsVoiceOver(2, "cisleaving")

SetAmbientMusic(REP, 1.0, "rep_geo_amb_hunt", 0,1)
-- SetAmbientMusic(REP, 0.99, "rep_GEO_amb_middle", 1,1)
-- SetAmbientMusic(REP, 0.1,"rep_GEO_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "cis_geo_amb_hunt", 0,1)
-- SetAmbientMusic(CIS, 0.99, "cis_GEO_amb_middle", 1,1)
-- SetAmbientMusic(CIS, 0.1,"cis_GEO_amb_end", 2,1)

SetVictoryMusic(REP, "rep_geo_amb_victory")
SetDefeatMusic (REP, "rep_geo_amb_defeat")
SetVictoryMusic(CIS, "cis_geo_amb_victory")
SetDefeatMusic (CIS, "cis_geo_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")


--ActivateBonus(CIS, "SNEAK_ATTACK")
--ActivateBonus(REP, "SNEAK_ATTACK")

SetAttackingTeam(ATT)

--OpeningSateliteShot
AddCameraShot(0.896930, -0.191575, -0.389725, -0.083241, -86.631836, 44.870083, 95.218506);

end
[/code]
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Scripting

Post by Fiodis »

Did you use the Mission Scripter? It's very useful, and I would recomend it for a simple objective like this, but it does have some flaws that sneak into scripts. I can't see any off the top of my head, though. I think one is that it types "con" instead of "conquest", but I'm not sure if you use that in your script anywhere....
MandeRek
Sith Master
Sith Master
Posts: 2766
Joined: Tue Oct 02, 2007 10:51 am
Projects :: Battlefront Zer0
Games I'm Playing :: SWTOR
xbox live or psn: No gamertag set
Location: Ghosting around GT
Contact:

Re: Scripting

Post by MandeRek »

Nope, i didn't use that program. Tried it, but this makes more sense to me.. What i did notice, is that the mission scripter adds some more lines when doing an assault. Also about a cp. Still, this is nowhere else writen/scripted/spoken about.. I still hope an experienced scripter can help me with this!
User avatar
Sky_216
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Scripting

Post by Sky_216 »

Add this line:

ScriptCB_DoFile("MultiObjectiveContainer")

that's all i can suggest right now.......
MandeRek
Sith Master
Sith Master
Posts: 2766
Joined: Tue Oct 02, 2007 10:51 am
Projects :: Battlefront Zer0
Games I'm Playing :: SWTOR
xbox live or psn: No gamertag set
Location: Ghosting around GT
Contact:

Re: Scripting

Post by MandeRek »

DUDE! That just did it! :D

Thanks, next time i won't forget it.. This can be locked :angel:

Edit: Before this is locked, 2 more questions.

1: How can i make it this way there's only 1 artel darc in the field?

Code: Select all

       engineer = { "cis_hero_arteldarc",1},
The above doesn't work..

2: How can i set a timer, on 3 minutes, and after those minutes, the att team will lose?
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: Scripting

Post by [RDH]Zerted »

Please people, use Hide tags for long code/quote sections. I keep putting them into a bunch of posts.

For number 2, read the scripting doc. It tells you how to create timers. When your timer is up, use MissionVictory(<team #>) or MissionDefeat(<team #>). Those functions can also take an array of team numbers.
User avatar
Sky_216
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Scripting

Post by Sky_216 »

MandeRek wrote:DUDE! That just did it! :D

Thanks, next time i won't forget it.. This can be locked :angel:

Edit: Before this is locked, 2 more questions.

1: How can i make it this way there's only 1 artel darc in the field?

Code: Select all

       engineer = { "cis_hero_arteldarc",1},
The above doesn't work..

2: How can i set a timer, on 3 minutes, and after those minutes, the att team will lose?
It worked? Good.

For 1, think this'll work
special = { "cis_hero_arteldarc",1, 1},
Extra '1' to set max/min units to 1, and I think special class limits it so the 'max 1' bit appears.

Any other scripting problems for BF0, let me know. Can help you with simpler stuff like this and some of the more complex stuff.
MandeRek
Sith Master
Sith Master
Posts: 2766
Joined: Tue Oct 02, 2007 10:51 am
Projects :: Battlefront Zer0
Games I'm Playing :: SWTOR
xbox live or psn: No gamertag set
Location: Ghosting around GT
Contact:

Re: Scripting

Post by MandeRek »

Okay, both thanks a lot.. Do i have you on Xfire Sky? Because then i'll ask you some things on there ;)

This can be locked now! :)
Post Reply