How to have 6+ units in your game

Started by Dark_Phantom, October 27, 2018, 08:17:00 AM

Previous topic - Next topic
October 27, 2018, 08:17:00 AM Last Edit: November 23, 2020, 05:57:21 AM by Dark_Phantom
Well I released a video a long time ago that it was possible, and now I'm going the tutorial route with it.  This does require modification of the .exe file, which may leave some of you wary, but all it does is change a hard-coded spawn screen limit from 5 to 6.  If you haven't seen it:
https://youtu.be/jopdQhFSHYY

The three things you have to do are this:
You need a common.lvl builder. (local link needed)
1.) Edit the ifs_pc_spawnselect.lua file and raise numslots accordingly.  If you want one extra unit (6) you raise it by one (to 5, lua generally starts at 1 but in this case starts at 0).  Replace the common.lvl in your game's folder.  Oh yeah and you probably want to do some scripting like above because your units will run off the screen.

2.) Edit/create a mission file for the level you want to use.  Mission.lvl builder here: http://www.swbfgamers.com/index.php?action=downloads;sa=view;down=319
--------->You're going to add a 6th AddUnitClass line to one or both of the teams.

3.)  Have a hex editor, I use PSPad (http://www.pspad.com/).  Find these offsets in the Battlefront.exe:  1A9985 and 1A94B2.  Change the 05 to 06 (or whatever, just remember that 0A in hex is 10, not 10) at both offsets.  If you do not wish to edit your .exe, you can do the same thing in Cheat Engine (Battlefront.exe+offset) and it will only adjust the value while the game is running.

It should work in your game now.  This is online and offline compatible as far as I know.

Notes that you need to read:

  • You NEED Auto Assign for this to work properly.  Units 6 and 7 will be assigned to switching teams and you won't be able to select your unit.
  • The max BF1 can support is 12 units (13 with hero).  However, unless testing, I recommend you limit yourself to 10.  You won't be able to spawn if you do (same cause as above).  Buttons seem to be based on indexing and the spawn screen was never meant for more than 5 units
  • Always make a backup of your .exe
  • Never actually could fix the loadout and unit name mismatch
  • There are other notes I wanted to make but don't remember them.
The BOBclan:  A Rich History


Quote from: Unit 33 on November 29, 2014, 03:44:44 AM'Please, tell me more about the logistics of the design of laser swords being wielded by space wizards' - Some guy on the internet.

Nice work on this!

I wonder if the issue you found was in SWBF2 initially during development, and the 'SetClass' LUA options were added in to circumvent that.
In Progress:

--SWBFEA Demakes
--Star Wars: Battlefront - Anniversary Edition Update 1.3

Completed:
--Star Wars: Battlefront - Anniversary Edition (formerly Star Wars: Battlefront - Legacy)

On Hold:
--Star Wars Battlefront: Elite Squadron For SWBF1
--Phantom Menace Celebration Maps

Yeah! :D I never thought this was possible! :shrug:

By the way, should the 6th unit appear below the rest or next to them in spawn select screen?
AR Clan Discord: https://discord.gg/gmmSm5e | Star Wars: Battlefront - 20th Anniversary (2004-2024)

October 27, 2018, 09:37:06 AM #3 Last Edit: October 27, 2018, 09:40:54 AM by Dark_Phantom
Psych0fred said at one point the spawn screen was done by a third party in Battlefront 1, but in 2 was done in-house.  The max number of units (12) is actually defined.  See here:

[spoiler]
Quote from: Psych0fredYes, theoretically, as long as the rest of the code wasn't dependent on the limit. In BF1 I think it was in SpawnParams.h. That's the file where the limits were set as I've pasted them from that file below. Keep in mind that spawn display screen has a memory restriction so if you load too many different models it wouldn't be able to hold them.



const int PLAYER_TEAMS = 2;   // max number of player teams

const int MAX_TEAMS = 8;       // 0 is neutral, 1 and 2 are player teams, the rest are nonplayer teams

const int MAX_CLASSES = 12;   // max number of classes per team

#ifdef PC

const int TEAM_SIZE = 200;      // allow padding for soldiers, vehicles, dead units (dulicated briefly during spawning)

const int MAX_UNITS = 450;

#else

const int TEAM_SIZE = 40;        // allow padding for soldiers, vehicles, dead units (dulicated briefly during spawning)

const int MAX_UNITS = 64;

#endif

const int MAX_DROIDS = 16;

const int MAX_ENEMIES = TEAM_SIZE;

const int MAX_FLY_UNITS = 20;
[/spoiler]

The rest of this gold mine is a discussion for another post, but you get an idea of what you're working with in regard to maximums.

@Red04 - depends on how you do the scripting.  By default yes.  My code in the video said something akin to "if numSlot = 5 then define new location" which is how you get the nicely laid out screen.  See here:
[spoiler]
Code (lua) Select
local i
for i = 0,numSlots do

local tag = format("SlotUnitName%d",i)

-- this.Info[tag] = NewIFText --the Unit's name/soldiertype/title
-- {
--- x = SlotTextOffsetX, --SlotUnitNameOffsetX , -- center-x position
--- y = SlotYOffset + i * ( boxh + textheight ), -- just touching box below (my height = 32, but is centered)
-- width = barw * 10,
---- font = fontsize,
-- halign = "left",
-- valign = "top",
-- -- textw = barw , -- usable area for text
-- texth = 32,  --boxh ,
-- font = fontsize,
-- string = "UnitTitle",
-- ColorR = 255, ColorG = 255, ColorB = 255, -- white
-- --flashy = 0,
-- rotY = 20,
-- bgleft = "headerbuttonleft",
-- bgmid = "headerbuttonmid",
-- bgright = "headerbuttonright",
--
-- textw = boxw, -- usable area for text
-- }


tag = format("SlotWindow%d",i)
--this.Info[tag] = NewBorderRect
--{
-- ZPos = 190, -- behind most
-- x = SlotUnitNameOffsetX +  65,
-- y = SlotYOffset + i * ( boxh + textheight ) + boxh,
-- width = boxw,
-- height = textheight + boxh,
-- alpha = 128,
--}

if (i<5) then       
this.Info[tag] = NewButtonWindow
{
ZPos = 200,
x=SlotUnitNameOffsetX +  SlotUnitNameOffsetX * 2.5,
y = SlotYOffset + i * ( boxh + textheight +  ScriptCB_GetFontHeight(fontsize)+10 ) + boxh ,
--ScreenRelativeX = 0.0, -- center
--ScreenRelativeY = 0.0,
width = boxw,
height = textheight + boxh,
      ----height=boxh,
titleText = "Debug Build",
rotY = leftsideRot,
font = fontsize
}     
else   
--go bonkers
     this.Info[tag] = NewButtonWindow
{
ZPos = 200,
x=SlotUnitNameOffsetX +  SlotUnitNameOffsetX * 9,
y = SlotYOffset + (i-6) * ( boxh + textheight +  ScriptCB_GetFontHeight(fontsize)+10 ) + boxh ,    ----changed from i-4(5) for fake buttons
--ScreenRelativeX = 0.0, -- center
--ScreenRelativeY = 0.0,
width = boxw,
height = textheight + boxh,
      ----height = boxh,
titleText = "ifs.profile.list",
rotY = -20,
font = fontsize
}
    end

this.Info[tag].bHotspot = 1
this.Info[tag].fHotspotW = boxw
this.Info[tag].fHotspotH = textheight + boxh

this.Info[tag].InfoText = NewIFText  --the equipment/weapon text
    { 
--x = 0, --SlotTextOffsetX ,
--y = 0, --SlotYOffset + i * ( boxh + textheight ) + ScriptCB_GetFontHeight(fontsize) + 30  ,


width = barw * 10,

halign = "hcenter",
valign = "vcenter",
textw = boxw, -- usable area for text
texth = textheight,
font = fontsize,
string = "InfoText",
ColorR = 255, ColorG = 255, ColorB = 255, -- white
--rotY = 20,
flashy = 0,
--x = -boxw,
--y = -textheight,
}

end
[/spoiler]
edit: fixed due to the fact I had 2 fake buttons in there - if anyone wants the fake button code for a player select situation I can post it.
The BOBclan:  A Rich History


Quote from: Unit 33 on November 29, 2014, 03:44:44 AM'Please, tell me more about the logistics of the design of laser swords being wielded by space wizards' - Some guy on the internet.

I've said it before, but I'll say it again: great work on getting this stable! This might change the game for a lot of people's mods!

I wonder if it's possible to 'shrink down' the unit buttons. to all fit on one side if you want to have less than 10 units (IE like SWBF2's 9).

I'm also curious as to whether it's possible to activate the side-selector as it appears in both the console versions and in PC SWBF2 (where you get a menu before the first spawn screen asking whether you want to be on team 1, 2 or be auto-assigned). If we have to disable the spawn-screen side-selector to get this working, getting the pre-spawn side-selector might be a workaround.
In Progress:

--SWBFEA Demakes
--Star Wars: Battlefront - Anniversary Edition Update 1.3

Completed:
--Star Wars: Battlefront - Anniversary Edition (formerly Star Wars: Battlefront - Legacy)

On Hold:
--Star Wars Battlefront: Elite Squadron For SWBF1
--Phantom Menace Celebration Maps

Quote from: Dark_Phantom on October 27, 2018, 08:17:00 AM

1.) ...  If you want one extra unit (6) you raise it by one (to 5, lua starts at 0).
It does?
https://stackoverflow.com/questions/2785704/why-do-lua-arraystables-start-at-1-instead-of-0

I suppose there could be some form of structure that would allow you to refer to something as the 0th index..
If lua object/map is a thing and can have numerical members like javascript can, I guess that makes sense.

SWBF lua  does seem to start from zero.  But SWBF lua is non-standard.  Some features have been stripped out, too, particularly in the area of accessing system functions.
Quote from: Abraham Lincoln. on November 04, 1971, 12:34:40 PM
Don't believe everything you read on the internet

At the very least, SWBF1 starts at 0 :)

Quote from: Giftheck on November 03, 2018, 02:27:08 PM
I've said it before, but I'll say it again: great work on getting this stable! This might change the game for a lot of people's mods!

I wonder if it's possible to 'shrink down' the unit buttons. to all fit on one side if you want to have less than 10 units (IE like SWBF2's 9).

I'm also curious as to whether it's possible to activate the side-selector as it appears in both the console versions and in PC SWBF2 (where you get a menu before the first spawn screen asking whether you want to be on team 1, 2 or be auto-assigned). If we have to disable the spawn-screen side-selector to get this working, getting the pre-spawn side-selector might be a workaround.
Shrinking down the unit buttons can be done - One of my pictures somewhere has an old version of it where I have all ten units in one column.  Sometimes the buttons didn't line up precisely with the highlighting if I remember right.

Getting that side selector working would be amazing!  I'm not going to call it an impossibility, but it seems to me that code lies in whatever "executable" the game has.  Still, it's something to look for in the future.  I hadn't really thought about it - great idea Gistech.
The BOBclan:  A Rich History


Quote from: Unit 33 on November 29, 2014, 03:44:44 AM'Please, tell me more about the logistics of the design of laser swords being wielded by space wizards' - Some guy on the internet.

Quote from: Dark_Phantom on October 27, 2018, 08:17:00 AM
You NEED Auto Assign for this to work properly.  Units 6 and 7 will be assigned to switching teams and you won't be able to select your unit.

In my testing, I've noticed that Unit 6 on Team 1 actually seems to work just fine without Auto Assign enabled:

[spoiler][/spoiler]

Unit 6 on Team 2 does present the Team Switching issue however.

That is odd, surely it should work the same way. Maybe a scripting issue? It might be worth asking psych0fred. I know the spawn screen code was done third-party, but was the ifs_pc_spawnselect script? Maybe he can see something that would point to a resolution.
In Progress:

--SWBFEA Demakes
--Star Wars: Battlefront - Anniversary Edition Update 1.3

Completed:
--Star Wars: Battlefront - Anniversary Edition (formerly Star Wars: Battlefront - Legacy)

On Hold:
--Star Wars Battlefront: Elite Squadron For SWBF1
--Phantom Menace Celebration Maps

Quote from: DylanRocket on November 16, 2018, 05:44:46 PM
In my testing, I've noticed that Unit 6 on Team 1 actually seems to work just fine without Auto Assign enabled:

[spoiler][/spoiler]

Unit 6 on Team 2 does present the Team Switching issue however.
I had not noticed that before - great find!
The BOBclan:  A Rich History


Quote from: Unit 33 on November 29, 2014, 03:44:44 AM'Please, tell me more about the logistics of the design of laser swords being wielded by space wizards' - Some guy on the internet.

Now a question, would this work in multiplayer ?
Also, check out my total conversion for BF1: Ferocious Battlefront
http://www.moddb.com/mods/ferocious-battlefront

RELEASE INCOMING

Yes, this is multiplayer compatible, as long as all clients have it.

AFAIK, you do NOT need the server executable to have this hex edit, just a mission.lua edit.  It would be in a different place in battlefront.exe, regardless, but in my testing it only matters if you pull up the spawnselect screen.
The BOBclan:  A Rich History


Quote from: Unit 33 on November 29, 2014, 03:44:44 AM'Please, tell me more about the logistics of the design of laser swords being wielded by space wizards' - Some guy on the internet.

I think the only issue you would have is the switching teams issue ATM.
In Progress:

--SWBFEA Demakes
--Star Wars: Battlefront - Anniversary Edition Update 1.3

Completed:
--Star Wars: Battlefront - Anniversary Edition (formerly Star Wars: Battlefront - Legacy)

On Hold:
--Star Wars Battlefront: Elite Squadron For SWBF1
--Phantom Menace Celebration Maps

Erh, I'm not complicating my life further more, my mod is stable and I upload it tonight, Battlefront's perfect and balanced as it is, and I'd rather keep my mod KISS, was just curious and therefore asked.  :P
Also, check out my total conversion for BF1: Ferocious Battlefront
http://www.moddb.com/mods/ferocious-battlefront

RELEASE INCOMING