Adding More than 2 Teams...
by CSMP · in Combat Starter Kit · 01/07/2009 (11:08 pm) · 7 replies
I've been through almost all of the related script files and it seems to keep me with 3 teams max, i have no idea where any team data is in the engine code as i keep seeing comments saying "hardcoded for 2 teams".
Edit: OK, so I've got 3 teams... Only my "Green" team is not showing up green even though i have modified the colored icons and RGB values, the green team does spawn in the green base but the icons and colors do not reflect the team.
Edit: OK, so I've got 3 teams... Only my "Green" team is not showing up green even though i have modified the colored icons and RGB values, the green team does spawn in the green base but the icons and colors do not reflect the team.
#2
I've already made those changes and i still cannot see the green flag and green spawn markers, even though i have those already setup for green.
I can select the green team with the classSelectDLG and i can spawn at a green base but i can not visibly see the green team's color pic/icons on the commMap they only show up as yellow.
01/29/2009 (10:14 am)
Thanks for the help,I've already made those changes and i still cannot see the green flag and green spawn markers, even though i have those already setup for green.
I can select the green team with the classSelectDLG and i can spawn at a green base but i can not visibly see the green team's color pic/icons on the commMap they only show up as yellow.
#3
first you will need to go into commandermap.cc and add support for more than 2 teams.
search for "numTeams", change that to how many teams you want.
search for "mTextureHandle" change its declaration to the same #.
find the constructor for GuiCommanderHud() and update the teamColors[] initialization
find GuiIcon::setBitmap() and extend the cheesy looking cut & paste job (or write a proper loop) -- im NOT a C coder type so I just followed the pattern. Im sure somebody can write a proper loop that references a NumberOfTeams global.
Then go into MissionLoad.cs and add create statements for your new teams:
for (%team=0; %team <= 4; %team++)
{
$TManager.createTeam(%team);
}
go into area_trigger.cs and add functions for your new teams. Make sure the teamIDs match up from TeamManager.cs
function setWhiteTeamOwner(%obj)
{
setInitialOwner(%obj, 3);
}
function setGreenTeamOwner(%obj)
{
setInitialOwner(%obj, 4);
}
Edit classSelectDlg.gui and modify the team picking buttons:
Command = "pickTeam(3);";
Command = "pickTeam(4);";
and finaly, edit your .mis file and set the initial owners for each starting flagpole:
new StaticShape(GreenFlagPole) {
dynamicFunction = "setGreenTeamOwner";
objectiveName = "Green Base";
objectiveNumber = "2";
};
--------------------------------------------------------------------
All the above will get the proper colored icons to display on the commander map and allow you to join an arbitrary team. Although your newly created teammembers wont be able to capture anything.
In order to be able to actually capture stuff, you will need further edits in area_trigger.cs to support an arbitrary number of teams. This is one aspect I wanted to do,but never got around to it.
here are a few function rewrites to get you started:
$MaxTeams=5;
// something entered the trigger. update values
function AreaTrigger::onEnterTrigger(%this,%trigger,%obj)
{
if ( !canUpdateFlags(%obj))
{
return;
}
%teamID = %obj.client.team.teamID;
// If another team is in the trigger, do nothing.
for ( %x=1; %x <= $MaxTeams; %x++)
{
if ( %x != %teamID)
{
if ( %this.teamInZone[%x] > 0 )
return;
}
}
%trigger.teamInZone[%teamID]++;
Parent::onEnterTrigger(%this,%trigger,%obj);
}
// something left the trigger. update values
function AreaTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
%teamID = %obj.client.team.teamID;
%trigger.teamInZone[%teamID]--;
if (%trigger.teamInZone[%teamID] < 0)
{
%trigger.teamInZone[%teamID] = 0;
}
Parent::onLeaveTrigger(%this,%trigger,%obj);
// reset trigger timer when everyone leaves
%sum=0;
for ( %x=1; %x <= $MaxTeams; %x++)
{
%sum += %trigger.teamInZone[%x];
}
if (%sum = 0)
{
%trigger.ticks = 0;
}
}
02/05/2009 (8:35 pm)
ok seems I missed a bunch of changes.first you will need to go into commandermap.cc and add support for more than 2 teams.
search for "numTeams", change that to how many teams you want.
search for "mTextureHandle" change its declaration to the same #.
find the constructor for GuiCommanderHud() and update the teamColors[] initialization
find GuiIcon::setBitmap() and extend the cheesy looking cut & paste job (or write a proper loop) -- im NOT a C coder type so I just followed the pattern. Im sure somebody can write a proper loop that references a NumberOfTeams global.
Then go into MissionLoad.cs and add create statements for your new teams:
for (%team=0; %team <= 4; %team++)
{
$TManager.createTeam(%team);
}
go into area_trigger.cs and add functions for your new teams. Make sure the teamIDs match up from TeamManager.cs
function setWhiteTeamOwner(%obj)
{
setInitialOwner(%obj, 3);
}
function setGreenTeamOwner(%obj)
{
setInitialOwner(%obj, 4);
}
Edit classSelectDlg.gui and modify the team picking buttons:
Command = "pickTeam(3);";
Command = "pickTeam(4);";
and finaly, edit your .mis file and set the initial owners for each starting flagpole:
new StaticShape(GreenFlagPole) {
dynamicFunction = "setGreenTeamOwner";
objectiveName = "Green Base";
objectiveNumber = "2";
};
--------------------------------------------------------------------
All the above will get the proper colored icons to display on the commander map and allow you to join an arbitrary team. Although your newly created teammembers wont be able to capture anything.
In order to be able to actually capture stuff, you will need further edits in area_trigger.cs to support an arbitrary number of teams. This is one aspect I wanted to do,but never got around to it.
here are a few function rewrites to get you started:
$MaxTeams=5;
// something entered the trigger. update values
function AreaTrigger::onEnterTrigger(%this,%trigger,%obj)
{
if ( !canUpdateFlags(%obj))
{
return;
}
%teamID = %obj.client.team.teamID;
// If another team is in the trigger, do nothing.
for ( %x=1; %x <= $MaxTeams; %x++)
{
if ( %x != %teamID)
{
if ( %this.teamInZone[%x] > 0 )
return;
}
}
%trigger.teamInZone[%teamID]++;
Parent::onEnterTrigger(%this,%trigger,%obj);
}
// something left the trigger. update values
function AreaTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
%teamID = %obj.client.team.teamID;
%trigger.teamInZone[%teamID]--;
if (%trigger.teamInZone[%teamID] < 0)
{
%trigger.teamInZone[%teamID] = 0;
}
Parent::onLeaveTrigger(%this,%trigger,%obj);
// reset trigger timer when everyone leaves
%sum=0;
for ( %x=1; %x <= $MaxTeams; %x++)
{
%sum += %trigger.teamInZone[%x];
}
if (%sum = 0)
{
%trigger.ticks = 0;
}
}
#4
02/06/2009 (3:07 pm)
Thanks for the help, I'll be able to test this in a day or two.
#5
02/07/2009 (10:42 am)
Let me know what you find. I had fun writing the team manager and flags code.
#6
Allied would mean can use all the same spawn facilities, vehicles, etc.
So effectively you would have Team 1 vs Team 2A and Team 2B. Or Team 1A and Team 1B vs Team 2A and Team 2B.
Is that a possibility without significant re-factoring?
02/12/2009 (5:50 pm)
Is it feasible to add a structure where you have 3 teams, but 2 of them are allied?Allied would mean can use all the same spawn facilities, vehicles, etc.
So effectively you would have Team 1 vs Team 2A and Team 2B. Or Team 1A and Team 1B vs Team 2A and Team 2B.
Is that a possibility without significant re-factoring?
#7
certianly.
Easy? .. no.
the main issue would be the spawnpoints,as they are hard coded into the commandermap C code to only use 1 teamID per spawnpoint.
The other issue that would come up is one of display. Everyone wants to know what color(s) their allies are. with the hard coded icons, displaying some kind of ally indicator would be difficult at best.
Now if you want to ignore the spawning problem and the display of allies.. then its doable with only script changes. You would need to modify the vehicle code so you can mount your allies vehicle, The repair pads, the ammo drops, and the flag raise/lower code would get even messier.
02/17/2009 (8:12 pm)
Possible?certianly.
Easy? .. no.
the main issue would be the spawnpoints,as they are hard coded into the commandermap C code to only use 1 teamID per spawnpoint.
The other issue that would come up is one of display. Everyone wants to know what color(s) their allies are. with the hard coded icons, displaying some kind of ally indicator would be difficult at best.
Now if you want to ignore the spawning problem and the display of allies.. then its doable with only script changes. You would need to modify the vehicle code so you can mount your allies vehicle, The repair pads, the ammo drops, and the flag raise/lower code would get even messier.
Torque 3D Owner Jon Paynter
look in TeamManager.cs TeamManager::teamData(%teamID)
-- add whatever you want for names
-- take careful note of the numbers in the case statements.
next goto the client/scripts/ui folder. and you will see several iconds with a '0' '1' and '2' suffix (flag0, flag1, flag2).
create new versions of these icons to correspond to your new teams. So if you want a "green" team, look at what the number in the case statement is from TeamManager.cs (in this case 4), and name the files accordingly: flag4, jeep4, player4.
All that is the easy part.
the last part is to change the playGUI to add places for more teams.
-- edit playGUI.gui and add spots to display the scores for your new teams.
-- edit playGUI.cs - ClientCmdSetTeamScores. update the case statement with the Same numbers from TeamManager.cs
-- edit playGUI.cs --ClientCmdUpdateObjective. update the case statement in there with the Same numbers from TeamManager.cs (you will also need new corresponding copies of the BlueTeamPoint and RedTeamPoint images
Let me know if that does the trick for you.