Custom Command Posts (FAQ)

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

FragMe!
Gametoast Staff
Gametoast Staff
Posts: 2244
Joined: Sat May 13, 2006 12:34 am
Projects :: Not sure keep changing my mind.
Games I'm Playing :: F1 and SWBF
xbox live or psn: No gamertag set
Location: Origin name GT_FragMe
Contact:

Re: Custom Command Posts

Post by FragMe! »

Teancum wrote:Been doing more research as to how team colors get set. I found something in ifs_freeform_main.lua in assets/shell that tipped me off. Now I'm just trying to get it to work on a per-game basis

TSTc_con.lua:
Hidden/Spoiler:
unction 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"}



--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:Start()

EnableSPHeroRules()

-- set up team colors
-- precomputed colors
local colorWhite = { r=255, g=255, b=255 }
local colorBlue = { r=180, g=40, b=180 }
local colorRed = { r=255, g=186, b=0 }

self.teamColor = {}
-- absolute colors: 0=nuetral 1=friendly, 2=enemy
self.teamColor[1] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }
self.teamColor[2] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }

end
Does it look like I'm referencing anything weird?
Quickly threw those lines into a conquest lua, didn't change anything and got a non CTD sev 3 error about trying to call and gobal setting or something, trying to go by memmory, did do some other looking, would those lines work in the conquest lua in the scripts directory (not the mode scripts but the other ones)
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Custom Command Posts

Post by Maveritchell »

FragMe! wrote:
Teancum wrote:Been doing more research as to how team colors get set. I found something in ifs_freeform_main.lua in assets/shell that tipped me off. Now I'm just trying to get it to work on a per-game basis

TSTc_con.lua:
Hidden/Spoiler:
unction 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"}



--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:Start()

EnableSPHeroRules()

-- set up team colors
-- precomputed colors
local colorWhite = { r=255, g=255, b=255 }
local colorBlue = { r=180, g=40, b=180 }
local colorRed = { r=255, g=186, b=0 }

self.teamColor = {}
-- absolute colors: 0=nuetral 1=friendly, 2=enemy
self.teamColor[1] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }
self.teamColor[2] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }

end
Does it look like I'm referencing anything weird?
Quickly threw those lines into a conquest lua, didn't change anything and got a non CTD sev 3 error about trying to call and gobal setting or something, trying to go by memmory, did do some other looking, would those lines work in the conquest lua in the scripts directory (not the mode scripts but the other ones)
I did some looking last night too, and I'm not sure that "teamColor" has any meaning as far as conquest goes. Inferring from the freeform scripts it came in, that color corresponds to menu screens and not ingame anything.
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Custom Command Posts

Post by Teancum »

True, but teamColor is defined in the exe, and it drives all of the HUD colors in the .hud files, so it's definitely something that gets used. I only found one instance of teamColor in the exe, so unless there's a weird array hidden somewhere in there then the colors are defined elsewhere. I scoured all resource files with a hex editor trying to find references of it, but only found it in the shell, that's why I'm trying to override it in LUA (I realize that it's probably not called anywhere and thusly it says "precomputed colors" in the LUA).

Oh, and I realized that I should have used this instead of self. Figured that out later on.

I know I can dynamically change the CP color via the gametype_conquest lua, but it's sortof superfluous if we can't actually specify whole team colors. It would only be good for non-aligned locals (like Tuskens on Tatooine).
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Custom Command Posts

Post by Yodakid »

Tryed this code:
Hidden/Spoiler:
-- set up team colors
InitTeamColor = function(this)
-- precomputed colors
local colorWhite = { r=255, g=155, b=255 }
local colorBlue = { r=132, g=26, b=55 }
local colorRed = { r=255, g=102, b=32 }

-- if AI versus team 2...
this.teamColor = {}
if not this.teamController[1] and this.teamController[2] then
-- swapped colors: 1=red, 2=blue
this.teamColor[1] = { [0] = colorWhite, [1] = colorRed, [2] = colorBlue }
this.teamColor[2] = { [0] = colorWhite, [1] = colorRed, [2] = colorBlue }
else
-- absolute colors: 1=blue, 2=red
this.teamColor[1] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }
this.teamColor[2] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }
end
end,


GetTeamColor = funktion(this, team)
local color = this.teamColor[this.playerTeam][team]
return color.r, color.g, color.b
end
But I got an munge error that said something about unexpected symbols near '=' at this line:
Hidden/Spoiler:
GetTeamColor = funktion(this, team)
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: Custom Command Posts

Post by Fiodis »

Maybe you spelt "function" with a "k"?
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Custom Command Posts

Post by Yodakid »

Hmm, I just copied it from another .lua but I'll try it out.

EDIT: It still gives me this error:
Hidden/Spoiler:
C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\TES\TESc_con.lua:46: unexpected symbol near `='
ERROR[scriptmunge scripts\TES\TESc_con.lua]:Could not read input file.ERROR[scriptmunge scripts\TES\TESc_con.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
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: Custom Command Posts

Post by Fiodis »

Well, from what I know about error logs, the "46" is the line of the LUA with the problem. Counting the code you showed us, I see 25 lines.
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Custom Command Posts

Post by Yodakid »

Hidden/Spoiler:
--
-- 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 = 1;
CIS = 2;
DRO = 3;
-- These variables do not change
ATT = REP;
DEF = CIS;
BAA = DRO


function ScriptPostLoad()
ReadDataFile("dc:movies\\ingama.mvs")
ScriptCB_PlayInGameMovie("ingama.mvs","lopmon01")

-- set up team colors
InitTeamColor = function(this)
-- precomputed colors
local colorWhite = { r=255, g=155, b=255 }
local colorBlue = { r=132, g=26, b=55 }
local colorRed = { r=255, g=102, b=32 }

-- if AI versus team 2...
this.teamColor = {}
if not this.teamController[1] and this.teamController[2] then
-- swapped colors: 1=red, 2=blue
this.teamColor[1] = { [0] = colorWhite, [1] = colorRed, [2] = colorBlue }
this.teamColor[2] = { [0] = colorWhite, [1] = colorRed, [2] = colorBlue }
else
-- absolute colors: 1=blue, 2=red
this.teamColor[1] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }
this.teamColor[2] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }
end
end,


GetTeamColor = function(this, team)
local color = this.teamColor[this.playerTeam][team]
return color.r, color.g, color.b
end


--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"}



--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, teamBAA = BAA,
textATT = "game.modes.con",
textBAA = "game.modes.con3",
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:Start()

EnableSPHeroRules()

end
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Custom Command Posts

Post by Teancum »

Open it in Notepad, hit CTRL + G, then type 46 to go to line 46.
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Custom Command Posts

Post by Yodakid »

Well, it is this line: GetTeamColor = function(this, team)
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Custom Command Posts

Post by Teancum »

I'm pretty sure that's because team is undefined. You haven't told it what team is. But I'm not 100% sure on that since I'm not really clear on how LUA declares everything.
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: Custom Command Posts

Post by [RDH]Zerted »

Yodakid wrote:
Hidden/Spoiler:
-- set up team colors
InitTeamColor = function(this)
-- precomputed colors
local colorWhite = { r=255, g=155, b=255 }
local colorBlue = { r=132, g=26, b=55 }
local colorRed = { r=255, g=102, b=32 }

-- if AI versus team 2...
this.teamColor = {}
if not this.teamController[1] and this.teamController[2] then
-- swapped colors: 1=red, 2=blue
this.teamColor[1] = { [0] = colorWhite, [1] = colorRed, [2] = colorBlue }
this.teamColor[2] = { [0] = colorWhite, [1] = colorRed, [2] = colorBlue }
else
-- absolute colors: 1=blue, 2=red
this.teamColor[1] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }
this.teamColor[2] = { [0] = colorWhite, [1] = colorBlue, [2] = colorRed }
end
end
,


GetTeamColor = function(this, team)
local color = this.teamColor[this.playerTeam][team]
return color.r, color.g, color.b
end
Basically you are doing MyVariable = 4, 5 which isn't valid syntax. Should MyVariable have the value four or five? You do use commas in the event callbacks because those are really parameters to a function: EventFunction(ResultFunction, FilterString).

If you don't understand what I'm saying, just remove the red comma.

I'm sorry I'm not helping you guys out on this. I only have Ubuntu on my laptop and haven't been able to get swbf2 running on it yet. If I ever get it working under linux, I'll get back to modding. I don't know what you guys expect to do by just creating tables with values in them. You still have to tell the game to do something with your teamColor tables. If you expected the game to call some type of InitTeamColor() function like it calls ScriptPostLoad() (I don't think it does so, but I don't know for sure), then at the very least you have to move them outside of ScriptPostLoad().

You can try using IFObj_fnSetColor() or ScriptCB_IFObj_SetColor(), but CPs aren't directly IFObjs. You will need to access the .cp part of the CP object.
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Custom Command Posts

Post by Teancum »

Changing the CP color is easy in gametype_conquest -- it's all of the other colors that's the problem. That's why we need to directly access the teamColor global variable.
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: Custom Command Posts

Post by [RDH]Zerted »

Teancum wrote:...we need to directly access the teamColor global variable.
I am saying that there is no such thing, at least from a Lua stand point. The FakeConsole's Print Nested Globals command prints out every global variable and its value. It doesn't show a color table, only the ScriptCB functions the game uses to get the colors for the stat screens and the like.

Has anyone tried ODF values such as?:
Color = "255 100 50 alliance"
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Custom Command Posts

Post by Teancum »

Well, it's there, I don't know what to tell you. It's referenced in the exe, in the Galactic Conquest luas, and the HUD files reference teamColor repeatedly. It's there, and it's used many times. All I'm trying to find out is if we can re-reference it from the exe to override the defaults.
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Custom Command Posts

Post by Yodakid »

Hmm, tryed a few codes and now I got this:
Hidden/Spoiler:
Message Severity: 2
C:\Battlefront2\main\RedEngineFL\movie\RedMovie.cpp(450)
WARNING : Unable to inherit from movie property 0x6556f7f7

(none):0: attempt to call global `SetTeamColor' (a nil value)
Witch causes a CTD.
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Custom Command Posts

Post by Teancum »

What does your LUA look like?
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Custom Command Posts

Post by Yodakid »

Hidden/Spoiler:
--
-- 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 = 1;
CIS = 2;
DRO = 3;
-- These variables do not change
ATT = REP;
DEF = CIS;
BAA = DRO

SetTeamColor(Red, "100 231 102")
SetTeamColor(Blue, "35 31 201")
SetTeamColor(White, "100 100 19")


function ScriptPostLoad()
ReadDataFile("dc:movies\\ingama.mvs")
ScriptCB_PlayIngameMovie("dc:movies\\ingama.mvs", "lopmon01")



--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"}



--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, teamBAA = BAA,
textATT = "game.modes.con",
textBAA = "game.modes.con3",
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:Start()

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
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: Custom Command Posts

Post by [RDH]Zerted »

You can't just put game function outside of ScriptPostLoad() or ScriptInit() like that. Those SetTeamColor() functions are being run as soon as the game loads the map script and the map script seems to be one of the first things to be loaded. SetTeamColor() doesn't exist at that point in the loading stage.
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: Custom Command Posts

Post by Frisbeetarian »

Up until now, we've just talked about the color of the holo for the command post. I can't imagine that changing the holo ODF would change color of the take over icons that appear under the mini map, so how would we change this? Would having access to, and then changing the teamColor variable change these colors? I figure no one really knows; I'm really just throwing this out there as something into which we should look.
Post Reply