Home » MODDING HQ 1.13 » v1.13 Feature Requests » [Feature Code Outline] Communications Logistics Model (CLM) (Minor/Optional Difficulty Addition)
[Feature Code Outline] Communications Logistics Model (CLM)[message #340273]
|
Fri, 27 March 2015 20:44
|
|
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
// JA2Options.ini Entry:
// ; Requires a squadleader/>50 leadership/IMP merc to have a laptop in inventory to utilize laptop.
// ; Or to be in sectors with the following facilities:
// ; - Military Headquarters - Research Facility - Small Airport
// ;
// ; Requires a squadleader/>50 leadership/IMP merc to be in sector or have radio for subordinate mercs to move as squad in distant sector.
// ; Requires subordinate mercs to have a radio in order to move as a squad without a leader merc in sector.
// ; Subordinate mercs can move individually by going to sector edge (travel as squad disabled).
// ; Subordinate mercs without leader or radio may move freely within town sector as squad.
// ; Except for sectors with the following facilities:
// ; SAM Site - Rebel Hideout - Military HQ - Airport - Harbor/Port
// ;
// Communications_Logistics_Difficulty = FALSE
// LAPTOP:
// 1. If any leader/IMP player mercenary does -not- have a laptop in inventory, the laptop is
// not accessible (display 'OK' dialog error message with: '404: Internet Not Found')
// 1a. This condition does not apply as long as current game time is <= the first 48 hours after arriving in Arulco.
// 2. If any leader/IMP mercenary is in a sector with the following facilities, allow laptop use:
// - Small Airport ( <ubIndex>4</ubIndex> )
// - Research Facility ( <ubIndex>15</ubIndex> )
// - Military Headquarters ( <ubIndex>7</ubIndex> )
// SUBORDINATION/LEADERSHIP/IMP:
// Leader Merc - Any IMP created merc, any merc with deputy/squadleader trait, any merc with >50 leadership, any merc >=6 rank
// Any merc who has 'Radio Operator' trait and is in same sector with a Leader Merc and has a radio in inventory.
// Subordinate Merc - Any merc not meeting above conditions.
// Subordinate Merc Squad - Any merc squad without leader merc in sector or radio in inventory connecting them to leader merc.
// Rules:
// 1. Subordinate mercs cannot move outside of town sectors as a group/strategic travel.
// 2. Subordinate mercs may move as a single merc by using map edge. ('Selected Merc' only)
// 3. Subordinate mercs in a squad must have a radio to use strategic travel or ('All Mercs in Squad')
// (( Yes, this includes during combat when the radio operator is killed. ))
// 4. Subordinate mercs in a squad must have a leader merc to use strategic travel or ('All Mercs in Squad')
// 5. Subordinate mercs may use ('All Mercs in Squad') while in town sector.
// Exceptions:
// a. SAM Site
// b. Rebel Hideout (wildfire facility)
// c. Military Headquarters
// d. Small Airport
// e. Harbor/Port (Wildfire facility)
Psuedo code outline:
Toggle Spoiler
// Needed variable declarations for Communications_Logistics_Difficulty option:
// ##<type>## designated unknown function or variable type
bool COMMUNICATIONS_Difficulty_Option = FALSE;
bool COMMUNICATIONS_allowLaptop = TRUE;
//Leader mercs
vector<##mercs##> COMMUNICATIONS_currentLeaderMercs;
vector<string> COMMUNICATIONS_leaderMercSectors;
vector<bool> COMMUNICATIONS_leaderHasRadio;
//Subordinate Mercs w/radio
vector<string> COMMUNICATIONS_subordinatesWithRadio;
//Radio Operators
vector<##mercs##> COMMUNICATIONS_radioOperators;
vector<string> COMMUNICATIONS_radioOperatorsSectors;
vector<bool> COMMUNICATIONS_radioOperatorHasRadio;
//Exceptions
vector<int> COMMUNICATIONS_exceptionalFacilityTypesLaptop (4, 15, 7);
vector<int> COMMUNICATIONS_exceptionalFacilityTypesRadio (4, 10, 7, 41, 24);
//Define radio item number
int COMMUNICATIONS_radioItemNumber = 1697;
int COMMUNICATIONS_laptopItemNumber = 1021;
// Process:
// 1. Populate vectors with current information.
// (Independent function)
// 2. If any leader merc in sector or subordinate with radio in sector
// or leader with radio or radio operator in leader squad with radio
// allow use of strategic squad move.
// (Run on attempt to move Squad in strategic)
// Begin populate vectors
if(Communications_Difficulty_Option)
{
vector<##mercs##> tempV1 (##getArrayofCurrentMercs##)
int iMax1 = tempV1.size();
int tempI1 = 0;
do
{
if((tempV1[tempI1].##has trait <squadleader>##) || ((tempV1[tempI1].##get leadership##()) >= 50) || ((tempV1[tempI1].##get exp level##()) >= 6) || ( ((tempV1[tempI1].##get prof id##()) >= 51) && ((tempV1[tempI1].##get prof id##()) <= 56) && ((tempV1[tempI1].##get prof id##()) >= 192) && ((tempV1[tempI1].##get prof id##()) <= 194) ))
{
COMMUNICATIONS_currentLeaderMercs.push_back(tempV1[tempI1]);
}
if((tempV1[tempI1].##count <COMMUNICATIONS_radioItemNumber> in inventory##()) >= 1)
{
}
}
while(tempI1 <= iMax1);
}
//////////////////////////////////////
/////// Unfinished, ///////////////
////// Will Continue Later ///////////
////////// Out 2 Lunch ///////////////
//////////////////////////////////////
Report message to a moderator
|
|
|
|
Re: [Feature Code Outline] Communications Logistics Model (CLM)[message #340279 is a reply to message #340273]
|
Sat, 28 March 2015 11:43
|
|
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
|
|
|
|
Goto Forum:
Current Time: Thu Apr 18 15:22:50 GMT+3 2024
Total time taken to generate the page: 0.01315 seconds
|