Home » MODDING HQ 1.13 » v1.13 Feature Requests » [Feature Code Outline] Communications Logistics Model (CLM) (Minor/Optional Difficulty Addition)
music66.png  [Feature Code Outline] Communications Logistics Model (CLM)[message #340273] Fri, 27 March 2015 20:44 Go to next message
RunAwayScientist is currently offline RunAwayScientist

 
Messages:85
Registered:September 2001
This is an outline of an optional addition I'd like to make to the code. I'm posting it here first, however, to see if anyone who is already familiar with the backend wishes to tackle this or offer up some of the locations of the pertinent code required to make these changes/conditions.


Outline is as follows:


Comments Section
Toggle Spoiler



Psuedo code outline:
Toggle Spoiler

Report message to a moderator

Corporal 1st Class
Re: [Feature Code Outline] Communications Logistics Model (CLM)[message #340279 is a reply to message #340273] Sat, 28 March 2015 11:43 Go to previous message
Flugente

 
Messages:3509
Registered:April 2009
Location: Germany
Hmm. I see no need for all that vector business or that complicated profile check. What you basically want are two functions:

  • a function that tells you whether the laptop can be accessed, and
  • a function that tells you whether mercs in sector (x, y) can be ordered to move in the strategic map


Have a look at BOOLEAN CanGiveStrategicMilitiaMoveOrder( INT16 sMapX, INT16 sMapY ); this will likely give you a few hints. Basically, whenever you want to fire up the laptop/want to know whether mercs can be ordered, do sth. like this (somewhat pseudo-code):

BOOLEAN  CanWeDoStuff(INT16 sMapX, INT16 sMapY)
{
  // check for options
  if ( !option )
     return TRUE;
  
  // check for special facilities that allow this wherever our mercs are
  if ( facilityisproperlystaffedandwhatnot )
    return TRUE;

  // loop over all our mercs and see whether one allows us to do stuff
  SOLDIERTYPE *pSoldier = NULL;
  UINT32 uiCnt = 0;
  UINT32 lastid = gTacticalStatus.Team[OUR_TEAM].bLastID;
  for ( uiCnt = gTacticalStatus.Team[OUR_TEAM].bFirstID, pSoldier = MercPtrs[uiCnt]; uiCnt <= lastid; ++uiCnt, ++pSoldier )
  {
    // check whether we exist, are active, are alive... perhap also for not sleeping or whatever you like...
    if ( pSoldier && pSoldier->bActive && pSoldier->stats.bLife >= OKLIFE )
    {
      // check whether we are in the same (surface) for sector
      // you could also check for town sectors, or distance to other sectors... see CanGiveStrategicMilitiaMoveOrder(...) for reference
      if ( sMapX == pSoldier->sSectorX && sMapY == pSoldier->sSectorY && !pSoldier->bSectorZ )
      {
         // more checks for traits, stats, items...
      }
    }
  }

  // well, too bad
  return FALSE;
}
If you want to check for the laptop, note that hardcoding numbers is very, very bad and should never be done (the first ~300 items are an exception, as they are vanilla items referenced in way too many places). Simply add a new itemflag and assign that to the laptop item.

As to where to check for this... laptop will be easier, as there is likely just one location initialising start of the thing (there is an ini option that speeds up laptop loading times, that shouldn't be too far away). As for ordering mercs around - perhasp it might be easiest to inject the check into the code that selects a squad when selecting it.

[Updated on: Sat, 28 March 2015 11:46]




I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.

Report message to a moderator

Captain

Previous Topic: [Feature request] Externalizing lock pick difficulty
Next Topic: Request: AI fix \ Taunts fix \ visible fix
Goto Forum:
  


Current Time: Thu Apr 18 15:22:50 GMT+3 2024

Total time taken to generate the page: 0.01315 seconds