Page 1 of 1

add startposition to the start script

Posted: 22 Aug 2007, 15:03
by BrainDamage
atm it's impossible, not even by making a custom script, to skip a start position (in fixed start positions mode), they'll have to be incrementally filled (with empy AIs if necessary, but the commander will still be spawned) until you'll have reached the position you want to use

a solution could be to add to the team definitions:

Code: Select all

StartPosition=#;
this is intended to be used in singleplayer launching atm, to not break lobby compatibility, when such value won't be defined, it will fall back to standard beahviour (#order = position)

Posted: 22 Aug 2007, 15:18
by Tobi
It could be a new StartposType choose before game (3) next to in-order (0), random (1) and choose in game (2).

That way it is easier to define what should happen if StartPosition is set for only some players: either bail out or fall back to random.

Seems like a useful feature, not in the least for testing start positions as mapper :-)

Posted: 22 Aug 2007, 16:55
by tc-
I'm currently working on SpringLobby's real single player feature (playing with bots online works already). Beeing able to specify startposition will make it much better and more flexible. The current way of selecting start positions make it very difficult to form ally teams the way you want them.

Posted: 22 Aug 2007, 17:22
by AF
I whole heartedly disagree

I think the script should specifically say the exact starting location rather than an index to an array of mapper defined locations.

This way we have maximum flexibility over how starting positions are chosen and can implement anything we want. The original feature request could still be done by simply reading the mapper defined starting positions from the map smf via VFS.

Posted: 22 Aug 2007, 17:58
by tc-
I agree that it would be slightly nicer to set the startpositions by exact position but that can wait, this would be good enugh for most needs. And just because we implement by index first doesn't mean we can't implement it with exact positioning later. Should take it one step at a time so that it doesn't become a powerplant that none wants to implement.

Posted: 22 Aug 2007, 20:49
by tc-
About how long time would it take toimplemet it the way Tobi sugested, assuming you know the Spring source somewhat well?

Posted: 22 Aug 2007, 21:00
by Tobi
My method doesn't exclude AF's one, I didn't define what the Startposition field would be set to after all. (Though two tags, StartPosX and StartPosY would be better for AF's way.)

Either solution should be trivial to implement (2 hours max), just reuse the choose in game code with the default mapwide rectangle, but read the initial positions from the startscript and set everyone to ready immediately (as is done for ordered and random start positions already). It lives in GameSetup.cpp

Posted: 22 Aug 2007, 21:01
by AF
tbh my proposed method shouldnt be very hard, ifnact itd be an easier implementation than the one currently used for map defined positions.

RTS\Game\GameSetup.cpp:

Code: Select all

	file.GetDef(startPosType,"0","GAME\\StartPosType");
	if(startPosType==2){
		for(int a=0;a<gs->activeTeams;++a)
			readyTeams[a]=false;
		for(int a=0;a<gs->activeTeams;++a)
			teamStartNum[a]=a;
		SAFE_NEW CStartPosSelecter();
	} else {
		for(int a=0;a<gs->activeTeams;++a)
			readyTeams[a]=true;
		if(startPosType==0){		//in order
			for(int a=0;a<gs->activeTeams;++a)
				teamStartNum[a]=a;
		} else {								//random order
			std::multimap<int,int> startNums;
			for(int a=0;a<gs->activeTeams;++a)
				startNums.insert(pair<int,int>(gu->usRandInt(),a));	//server syncs these later
			int b=0;
			for(std::multimap<int,int>::iterator si=startNums.begin();si!=startNums.end();++si){
				teamStartNum[si->second]=b;
				++b;
			}
		}
	}
of note:

Code: Select all

	if(startPosType==2){
		for(int a=0;a<gs->activeTeams;++a)
			gs->Team(a)->startPos=float3(startRectLeft[gs->AllyTeam(a)]*gs->mapx*8,-500,startRectTop[gs->AllyTeam(a)]*gs->mapy*8);
	}

Posted: 22 Aug 2007, 21:04
by Tobi
Note that that is old code, I rewrote it quite a bit to make it better readable a while ago.

EDIT: Oh well, already implemented it here. Just need to test it a bit and then you can be the lucky owner of an implemented feature request ;-)

EDIT 2:
Changed by: tvo
Changed at: Wed 22 Aug 2007 22:03:13
Branch: trunk
Revision: 4240

Changed files:

* trunk/Documentation/Spring start.txt
* trunk/rts/Game/GameSetup.cpp
* trunk/rts/Game/GameSetup.h

Comments:

* Add StartPosX and StartPosZ tags to TEAM section of start script (GameSetup),
to be used in combination with the new StartPosType 3 (Choose Before Game).
They are in the range of map coordinates as returned by unitsync.
* Removed the loop that was supposed to initialize the startPos of each team
to the upper left corner of it's start rectangle, because it actually
initialized the startpos to garbage data because gs->mapx and gs->mapy had
not been initialized there yet.
* Add a CGameSetup::StartPosType enumeration so we don't have this mess with
magic numbers in CGameSetup.
* Added a check for startPosType, it is set to 0 (Fixed) if the script sets
it to a value out of range.

Posted: 22 Aug 2007, 22:31
by tc-
Thanks a lot Tobi! :-) I though I would have to wait for it for quite some time or implement it myself :-)

Now I can do my part and implement a nice single player start feature in SpringLobby :-)