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 }
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)
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 2:09 pm
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 }
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.
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 2:58 pm
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).
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 7:20 pm
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)
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 7:23 pm
by Fiodis
Maybe you spelt "function" with a "k"?
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 7:32 pm
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
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 7:39 pm
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.
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 7:43 pm
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
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 8:31 pm
by Teancum
Open it in Notepad, hit CTRL + G, then type 46 to go to line 46.
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 8:35 pm
by Yodakid
Well, it is this line: GetTeamColor = function(this, team)
Re: Custom Command Posts
Posted: Thu Feb 26, 2009 10:08 pm
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.
Re: Custom Command Posts
Posted: Sat Feb 28, 2009 1:25 pm
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.
Re: Custom Command Posts
Posted: Sat Feb 28, 2009 2:11 pm
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.
Re: Custom Command Posts
Posted: Sat Feb 28, 2009 11:11 pm
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"
Re: Custom Command Posts
Posted: Sat Feb 28, 2009 11:55 pm
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.
Re: Custom Command Posts
Posted: Sun Mar 08, 2009 5:05 pm
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.
Re: Custom Command Posts
Posted: Sun Mar 08, 2009 8:49 pm
by Teancum
What does your LUA look like?
Re: Custom Command Posts
Posted: Tue Mar 10, 2009 6:15 pm
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
Re: Custom Command Posts
Posted: Tue Mar 10, 2009 8:36 pm
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.
Re: Custom Command Posts
Posted: Tue Mar 10, 2009 11:16 pm
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.