BP Logo
Home » MODDING HQ 1.13 » v1.13 Feature Requests » Merc orientation when sector loses focus (My pet peeve since the original game)
icon4.gif  Merc orientation when sector loses focus[message #361438] Fri, 02 October 2020 17:33 Go to next message
Kurt

 
Messages:428
Registered:March 2004
Since always JA2 had the bad habit to forget your mercs' orientation and stance when the sector they are in loses focus.
To add injury to insult, when you come back they are always placed standing, looking towards the map center, so any invading enemy could catch them unawares and get a free turn of target practice...

Yet the game engine does remember their location on the map (most of the times), would it really be that hard to add orientation and stance to that memorized information?

I don't think memory might be a problem, there are only 24 (8x3) possible positions for each merc. Compared to the size and complexity of their inventory, it's almost nothing...
Re: Merc orientation when sector loses focus[message #363488 is a reply to message #361438] Fri, 09 July 2021 03:20 Go to previous messageGo to next message
rasz

 
Messages:38
Registered:August 2006
Its worse than you think, the game actually tracks and saves/loads this information to/from savefile
https://github.com/aimnas/ja2-1.13-source-mirror/blob/d6f07a7ef52b7fe277cd85358dc8e1b9e7bc8cc0/SaveLoadGame.cpp#L1918

BOOLEAN SOLDIERTYPE::Load(HWFILE hFile)
		numBytesRead = ReadFieldByField(hFile, &this->ubDirection, sizeof(ubDirection), sizeof(UINT8), numBytesRead);
...
		numBytesRead = ReadFieldByField(hFile, &this->usAnimState, sizeof(usAnimState), sizeof(UINT16), numBytesRead);


so there must be code somewhere resetting it on purpose every time you unload/load a sector. I dont know here exactly in the code game loads/unloads sectors, and searching for "STANDING" gives back >70 files angry
Re: Merc orientation when sector loses focus[message #363490 is a reply to message #361438] Fri, 09 July 2021 09:44 Go to previous messageGo to next message
ShaDoOoW

 
Messages:65
Registered:April 2009
Location: Czech Republic
Kurt wrote on Fri, 02 October 2020 17:33
Since always JA2 had the bad habit to forget your mercs' orientation and stance when the sector they are in loses focus.]
What does lose focus mean? I never notice my mercs changing direction on their own. Can you post savegame before the issue happens with instruction how to trigger the bug?
Re: Merc orientation when sector loses focus[message #363491 is a reply to message #363490] Fri, 09 July 2021 13:59 Go to previous messageGo to next message
rasz

 
Messages:38
Registered:August 2006
You can only ever have one Tactical sector loaded at any time. If you have two groups of mercs in two separate sectors going down to tactical for one of them unloads the other one resetting all the mercs ubDirection to as Kurt said looking somewhere into the center and usAnimState to STANDING.

EDIT: Soldier Init List.cpp AddPlacementToWorld

Soldier Add.cpp AddSoldierToSectorNoCalculateDirection

BOOLEAN AddSoldierToSectorNoCalculateDirection( UINT8 ubID )
	return( InternalAddSoldierToSector( ubID, FALSE, FALSE, 0, 0 ) );

InternalAddSoldierToSector

			sGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, STANDING, pSoldier->sInsertionGridNo, 7, &ubCalculatedDirection, FALSE );
			if( fCalculateDirection )
				ubDirection = ubCalculatedDirection;
			else
				ubDirection = pSoldier->ubInsertionDirection;
...
		if(gTacticalStatus.uiFlags & LOADING_SAVED_GAME )
			AddSoldierToSectorGridNo( pSoldier, sGridNo, pSoldier->ubDirection, fUseAnimation, usAnimState, usAnimCode );
		else
			AddSoldierToSectorGridNo( pSoldier, sGridNo, ubDirection, fUseAnimation, usAnimState, usAnimCode );

there it is, checks if we are loading a save and sets ubDirection from save, otherwise overrides it with ubCalculatedDirection calculated with
FindGridNoFromSweetSpotWithStructData( pSoldier, STANDING, pSoldier->sInsertionGridNo, 7, &ubCalculatedDirection, FALSE )

to point at soldiers default sInsertionGridNo, I am guessing it is set to center of sector for all mercs

[Updated on: Fri, 09 July 2021 15:27]

Re: Merc orientation when sector loses focus[message #363492 is a reply to message #363491] Fri, 09 July 2021 17:00 Go to previous message
ShaDoOoW

 
Messages:65
Registered:April 2009
Location: Czech Republic
I can confirm this is happening and you found the right place in code too (at least for direction, stance is elsewhere it seems).

Problem is that I don't see any differentiation between entering the sector the first time (and thus choosing starting position from the insertion overlay) and entering the previously loaded sector where soldiers already were again after it was unloaded.

EDIT: ok I fixed this. Commited the fix into SVN. Playtesting will be needed.

[Updated on: Fri, 09 July 2021 17:24]

Previous Topic: Adding new files to "Files"
Next Topic: Kaerar's Guns & Portraits
Goto Forum:
  


Current Time: Fri Jul 23 18:41:58 EEST 2021

Total time taken to generate the page: 0.02380 seconds