Author Topic: Free Units and Invincible Units  (Read 4260 times)

0 Members and 1 Guest are viewing this topic.

Free Units and Invincible Units
Hello. First I would like to say great job with MCO ! I have enjoyed playing through this game repeatable times with all the new improvements coming out. I've just finished getting through all the campaigns using 424 and other then some non-repeatable crashes and some stupid AI (namely desert fox and lasko's legion) was impressed with all the content provided.

So now I've started creating my own maps with the mission editor. I've found some good guides on the internet on how to use the editor. Due to some previous experience with MC1 I've also got a good handle on purchase files, salvage files and the mission.fit files (even a fair knowledge of ABL - but I can't find the "mymission.abl" files, I'll assume they are stuffed into the .pak, and I have not found a decent extractor program yet)

The problems I've come across however is how to do the following two things:
---------
Create a "free unit" for the player, be that a mech or vehicle. In one mission I would like to give the player a free Repair Truck, in another a free mech + pilot. Not an allied unit following a warrior brain, an actual controllable unit by the player, added to the player roster.

EDIT :: Found this buried in the forums;

"Old MC2 way - place mech at the spot you want and set it to team1 (player). Then damage that mech (hit "D" key). - Or change the f Damage value in the mission.fit for this warrior to 1.0- In mission when your force get visual on that mech it will be added to your force. In 304 you will have to make sure that the pilot is in all purchase files from there to the rest of the campaign. In latest version of MCO, it will be automatically added to your pilot roster (it is compatible with old version)."

 - This works perfectly for mechs+pilot but does not work for vehicles
 - If the unit is a mech and is set to team2 (enemy) this adds the unit at full health, with "No Pilot"
        - ready to be captured/salvaged by salvage craft support option and "spare" pilot

EDIT 2 :: Have found a way to add the repair truck using a combination of Hidden Secondary Objective and the below warrior brain:
Code: [Select]
//----------------------------------------------------------------------------------------
// Captureable Unit Warrior Brain for Mech Commander Omnitech
// Created by RustyDios 12 / Feb / 15
//----------------------------------------------------------------------------------------
// The original was copied from the null_order warrior brain
// CREATED:10/14/98   BY:Mike Lee
// This is a 'Do nothing' warrior brain that defects to the player side when captured
// Useful for things like mobile artillery, minelayers and repair trucks
// Basically giving the player a free unit, should they find and capture it
//----------------------------------------------------------------------------------------
module RD_UWB_RT : integer;
//----------------------------------------------------------------------------------------
const
#include_ "OConst.abi"
#include_ "UnitConst.abi"
type
var
static integer Order1Status; // Defines Order1
static boolean ImYours; // Sets a check for not doing this repeatably
//----------------------------------------------------------------------------------------
// Initialise Warrior Brain. This code is run Once only and sets up the unit behaviour
//----------------------------------------------------------------------------------------
function Init;
code
//include_ "UBInit.abi" - the only thing in UBInit.abi is the below line, why include a whole file for one line?
defaultBrain;

// OrderStatus, this sets up the unit to only do the startup routine  once
Order1Status = INCOMPLETE;

SetEngageRadius(0); // Don't engage anything
  IdentifySensorContactsOFF; // Don't call out sensor contacts
MoveToEngageOFF; // Don't move
StopFighting; // Don't fight
ReturnFireOFF; // Don't fight if attacked

ImYours = FALSE; // Open the captured loop check
endfunction;
//----------------------------------------------------------------------------------------
// Main Code
//----------------------------------------------------------------------------------------
code

//Initialize Orders Library
initOrders;

if (TRUE) then
// Order1 - ie the do nothing set up
if (Order1Status == INCOMPLETE) then
SetEngageRadius(0);
Order1Status = SUCCESS;
endif;
endif;

// Check to see if we have been captured or not
// possibly useless loop because we change the brain file ?
if (ImYours == FALSE) then

// Objective 0 is set in the mission editor as a Secondary Hidden objective
// It is the first objective in the list (so it becomes Objective0 in the mission.fit)
// The success condition is Specific Enemy Unit is Captured (this unit)

if (checkObjectiveStatus(0) == SUCCESS) then
ImYours = TRUE;
AddMoverToPlayer(GetID, 0, 0);
SetBrain(GetID, "pbrain");
endif;
endif;

return(1);
//--------------------------------------------------------------------------------------------
endmodule.


EDIT 3 :: Have found a way to perform this function without the need for a silly hidden objective to be set. Only the warriorbrain in the mission.fit needs changing, also an added bonus is this is working for *any* vehicle without a weapon (Tested it with MobileHQ, MobileTurretControl, RepairTruck, Minelayer, MOG, Ambulance, TroopTransport, RPHoverTruck etc).
  You can check the vehicle settings in the data/objects folder to see if it has a weapon or not. If the vehicle has a weapon all looks to be working but the capture command is crossed out, because the command is only valid if no "enemy weapons are near the object to be captured". I have not yet figured a way to PowerDown a vehicle or set the weapon state to not active.
Code: [Select]
//----------------------------------------------------------------------------------------
// Captureable Unit Warrior Brain for Mech Commander Omnitech
// Created by RustyDios 12 / Feb / 15
// RustyDios_UniversalWarriorBrain_FreeSupportUnit
//----------------------------------------------------------------------------------------
// The original was copied from the null_order warrior brain
// CREATED:10/14/98   BY:Mike Lee
// This is a 'Do nothing' warrior brain that defects to the player side when captured
// Useful for things like mobile HQ's, minelayers and repair trucks
// Basically giving the player a free unit, should they find and capture it
//----------------------------------------------------------------------------------------
module RD_UWB_FSU : integer; //does NOT need to be unique for each vehicle!
//----------------------------------------------------------------------------------------
const
#include_ "OConst.abi"
#include_ "UnitConst.abi"
type
var
static integer Order1Status; // Defines Order1
static boolean ImYours; // Sets a check for not doing this repeatably
static char[255] DisplayMessage; // Defines a message string to display on capture

//----------------------------------------------------------------------------------------
// Initialise Warrior Brain. This code is run Once only and sets up the unit behaviour
//----------------------------------------------------------------------------------------
function Init;
code
//----------------------------------------------------------------------------------------
//**You Can Edit This ** This is a pop up message that displays when the unit is captured
// Change the text between the quotation marks below -- " EDIT IN HERE  " ---
// You have 255 characters to use (as defined in the above variable block)
//----------------------------------------------------------------------------------------
DisplayMessage =
" MechWarrior Report -

Commander, a new unit and its crew have agreed to work for us until our mission is complete,

or they are dead. "
;
//----------------------------------------------------------------------------------------
// **End Editable Section **
//----------------------------------------------------------------------------------------

//include_ "UBInit.abi",the only thing in UBInit.abi is the below line
// why include a whole file for one line?
DefaultBrain;

// OrderStatus, this sets up the unit to only do the startup routine once
Order1Status = INCOMPLETE;

SetEngageRadius(0); // Don't engage anything
  IdentifySensorContactsOFF; // Don't call out sensor contacts
MoveToEngageOFF; // Don't move
StopFighting; // Don't fight
ReturnFireOFF; // Don't fight if attacked
SetWillHelp(FALSE); // Don't go to help our mates

SetCapturable(GetID,TRUE); // Sets the unit to be capturable
ImYours = FALSE; // Open the captured loop check

endfunction;
//----------------------------------------------------------------------------------------
// Main Code
//----------------------------------------------------------------------------------------
code
//Initialize Orders Library
initOrders;

// Order1 - ie the do nothing set up
if (TRUE) then
if (Order1Status == INCOMPLETE) then
SetEngageRadius(0);
Order1Status = SUCCESS;
endif;
endif;

// Check to see if we have been captured or not
// possibly useless loop because we change the brain file ?
if (ImYours == FALSE) then
// this REPLACES old MCG ABL "if (isCaptured(PartID) == 500) then"
// check alignment of unit, 500 = Player_Force, (501 = Clan_Force, 502 = Allied_Force)
if (objectSide(GetID) == 500) then
ImYours = TRUE; // Close the capturing check
SetTextMsg(1,DisplayMessage,1); // Displays the message entered above
AddMoverToPlayer(GetID, 0, 0); // add the unit to player roster
SetBrain(GetID, "pbrain"); // change the unit brain to control by player
endif;
endif;

return(1);
//--------------------------------------------------------------------------------------------
endmodule.
---------
Also I have set a "Resource Depot" guarded heavily by various turret towers and a few vehicle units. The turret controls are a little way away and relatively unguarded. You can just storm the place (with the mechs available to the player at this time) but will take heavy casualties. The smarter option is to capture the turret tower for extra support. However if the player does this, the first thing the turrets do is target and destroy the 4 resource trucks (which are really the only reason to head there in the first place). Is there a way to make the resource trucks either a) invincible or b) non-targetable options.

I've tried changing the active, exists and damaged flags in the mission.fit with no combinations being successful. I've tried changing the commander ID and the Team ID (both cases the turrets open fire and destroy the trucks immediately).

EDIT 3 :: I've changed the units from "real" trucks to "static prop" trucks. This works, the only major drawback is that they are visible on the map, regardless of Player location, Line of sight or sensor ranges (ie; they are effectively mini-resource buildings). Is there a function that sets the alignment of an actual vehicle to neutral? (I tried using objectchangesides(getID,-1)  )

Any help would be greatly appreciated. Many thanks in advance.
« Last Edit: February 25, 2015, 09:49:19 am by RustyDios »

 

Offline magic

  • Moderator
  • 211
Re: Free Units and Invincible Units
Thank you RustyDios.

If you dont plan to move those trucks why not using Resource Truck prop from menu bar - objects-vehicle props.

Prop objects are static, neutral and wont be targeted.

Every mission from my Exodus and MW2 Mercs campaigns has "MyMission.ABL" file - for example A_0_1.ABL...
It is not created by the editor when you save the mission, you will have to use one of the existing files from any other mission, rename to your mission name and then open MyMission.FIt and go to the bottom of the file.

Find:
st ScenarioScript = "M0101"

Remove "M0101" with "MyMission" (without ".ABL" extension). This will tell your mission to use "MyMission.ABL" as main mission ABL file.

M0101.ABL is default (do nothing) mission ABL file that is auto-assigned to any new mission and can be found in data/missions folder.

 
Re: Free Units and Invincible Units
Thank you RustyDios.

If you dont plan to move those trucks why not using Resource Truck prop from menu bar - objects-vehicle props.

Prop objects are static, neutral and wont be targeted.
- I was thinking of doing this route. Would they need any extra scripting or do the vehicle prop resource trucks work as expected after just being placed in the editor?
Every mission from my Exodus and MW2 Mercs campaigns has "MyMission.ABL" file - for example A_0_1.ABL...
It is not created by the editor when you save the mission, you will have to use one of the existing files from any other mission, rename to your mission name and then open MyMission.FIt and go to the bottom of the file.
Find:
st ScenarioScript = "M0101"
Remove "M0101" with "MyMission" (without ".ABL" extension). This will tell your mission to use "MyMission.ABL" as main mission ABL file.
M0101.ABL is default (do nothing) mission ABL file that is auto-assigned to any new mission and can be found in data/missions folder.
Found that line in the mission.fit already, was wondering what it was used for. I didn't realise it was for a generic mission.abl. (MCG Editor used to create a .fit and .abl for every map created).
 Is there a master list of functions/commands can be used in the mission.abl ? ... I've found Cmunsta's old MCG ABL Scripting reference but have already noted that several functions differ from MC2/MCO (such as SetIsCaptureable(partID) and  IsCaptured(PartID) :boolean return: ....

It would be helpful to know what can and cannot be scripted into a mission at a glance down list instead of digging through the many mission.abl 's.

--------------
I've found the following on the forums so far;

if (checkObjectiveStatus(INT) == SUCCESS) then // not on the forums but it does work
SetBrain(getID, "BrainFileNameString")
GetID // Gets the ID of the current object
objectchangesides(PartID, teamID); // use GetID for the partID,, teamID - (0= Player, 2= Friends; 1 or 3= Foe)
addmovertoplayer(PartID, teamID, commanderID); // use GetID for the partID,, commanderID = 0, player is 0 for Single player.
teleporttopoint(PartID, position);  // use GetID for the partID,, position is worldposition or real[3] xyz co-ords
togglesensorstrike;
toggleartillerypiece;
toggleairstrike;
togglerepairtruck;
togglesalvagecraft;
addresourcepoints(inmissionrespointsToAdd);
addmoney(outmissioncbillsToAdd);
settxtbuildingname(BuildingIDfromEditor, "NewBuildingNameString");

So what else is out there ?

-- Many thanks in advance, all help is well appreciated :)
« Last Edit: February 12, 2015, 12:06:09 pm by RustyDios »

 
Re: Free Units and Invincible Units
I Have found a way to perform the free support unit on capture function without the need for a silly hidden objective to be set. Only the warriorbrain in the mission.fit needs changing, also an added bonus is this is working for *any* vehicle without a weapon (Tested it with MobileHQ, MobileTurretControl, RepairTruck, Minelayer, MOG, Ambulance, TroopTransport, RPHoverTruck etc).
  You can check the vehicle settings in the data/objects folder to see if it has a weapon or not. If the vehicle has a weapon all looks to be working but the capture command is crossed out, because the command is only valid if no "enemy weapons are near the object to be captured". I have not yet figured a way to PowerDown a vehicle or set the weapon state to not active. If this coulod be done then I'm sure this code/brain would work for ANY unit... ... ...
Code: [Select]
//----------------------------------------------------------------------------------------
// Captureable Unit Warrior Brain for Mech Commander Omnitech
// Created by RustyDios 12 / Feb / 15
// RustyDios_UniversalWarriorBrain_FreeSupportUnit
//----------------------------------------------------------------------------------------
// The original was copied from the null_order warrior brain
// CREATED:10/14/98   BY:Mike Lee
// This is a 'Do nothing' warrior brain that defects to the player side when captured
// Useful for things like mobile HQ's, minelayers and repair trucks
// Basically giving the player a free unit, should they find and capture it
//----------------------------------------------------------------------------------------
module RD_UWB_FSU : integer; //does NOT need to be unique for each vehicle!
//----------------------------------------------------------------------------------------
const
#include_ "OConst.abi"
#include_ "UnitConst.abi"
type
var
static integer Order1Status; // Defines Order1
static boolean ImYours; // Sets a check for not doing this repeatably
static char[255] DisplayMessage; // Defines a message string to display on capture

//----------------------------------------------------------------------------------------
// Initialise Warrior Brain. This code is run Once only and sets up the unit behaviour
//----------------------------------------------------------------------------------------
function Init;
code
//----------------------------------------------------------------------------------------
//**You Can Edit This ** This is a pop up message that displays when the unit is captured
// Change the text between the quotation marks below -- " EDIT IN HERE  " ---
// You have 255 characters to use (as defined in the above variable block)
//----------------------------------------------------------------------------------------
DisplayMessage =
" MechWarrior Report -

Commander, a new unit and its crew have agreed to work for us until our mission is complete,

or they are dead. "
;
//----------------------------------------------------------------------------------------
// **End Editable Section **
//----------------------------------------------------------------------------------------

//include_ "UBInit.abi",the only thing in UBInit.abi is the below line
// why include a whole file for one line?
DefaultBrain;

// OrderStatus, this sets up the unit to only do the startup routine once
Order1Status = INCOMPLETE;

SetEngageRadius(0); // Don't engage anything
  IdentifySensorContactsOFF; // Don't call out sensor contacts
MoveToEngageOFF; // Don't move
StopFighting; // Don't fight
ReturnFireOFF; // Don't fight if attacked
SetWillHelp(FALSE); // Don't go to help our mates

SetCapturable(GetID,TRUE); // Sets the unit to be capturable
ImYours = FALSE; // Open the captured loop check

endfunction;
//----------------------------------------------------------------------------------------
// Main Code
//----------------------------------------------------------------------------------------
code
//Initialize Orders Library
initOrders;

// Order1 - ie the do nothing set up
if (TRUE) then
if (Order1Status == INCOMPLETE) then
SetEngageRadius(0);
Order1Status = SUCCESS;
endif;
endif;

// Check to see if we have been captured or not
// possibly useless loop because we change the brain file ?
if (ImYours == FALSE) then
// this REPLACES old MCG ABL "if (isCaptured(PartID) == 500) then"
// check alignment of unit, 500 = Player_Force, (501 = Clan_Force, 502 = Allied_Force)
if (objectSide(GetID) == 500) then
ImYours = TRUE; // Close the capturing check
SetTextMsg(1,DisplayMessage,1); // Displays the message entered above
AddMoverToPlayer(GetID, 0, 0); // add the unit to player roster
SetBrain(GetID, "pbrain"); // change the unit brain to control by player
endif;
endif;

return(1);
//--------------------------------------------------------------------------------------------
endmodule.

Original post updated with the new information.
« Last Edit: February 25, 2015, 09:48:28 am by RustyDios »

  

Offline magic

  • Moderator
  • 211
Re: Free Units and Invincible Units
Check version.txt file in your MechCommanderOmnitech install folder.

It has descriptions of all new ABL commands I made, among all other changes...

And we had modified file with all available ABL commands, just have to find it...

 
Re: Free Units and Invincible Units
Wow! I knew from playing multiple times that a lot of work has gone into MCO changing/tweaking/improving it from Stock MC2.... but that file really highlights all the great work that has been achieved , since 28/01/2011.

I think I opened this thread by giving my thanks for this awesome modification to a well loved game. I don't think I can ever say thank you enough.

EDIT :: Where on a vehicle are the weapons stored? I could try using the "destroymechbodylocation(MechID, locationID);" to disable the weapons so things like the AeroSpotter could be captured (to then set airstrikes and maybe sensorprobes to active)...
Could you design a function that damages things by ComponentID  ?

So far I've figured out a way to "capture" things with weapons by proxy. You instead capture a Mobile HQ (non-weapon unit) in the mission.abl and once that's done it transfers control of "units under it's command" (And it works for anything from Mobile artillery to SwarmLRM Trucks !!). I'm working on making into a brainfile similar to above for easy drop into a mission.fit (no need to create an entire mission.abl) .... Although, the way I see it AeroSpotters are in themselves a style of mobile HQ for air units.. so it just doesn't seem right to do it like this for the AeroSpotter.... ...

I could use the "by proxy" idea to make it so that when an airfield HQ/Building is captured those options become available... ... ...
Hmm, seem to have idea's flowing out of my head now I've started to make my own missions....
.... which by the way... where/how can we share user made content ?
« Last Edit: February 13, 2015, 08:07:39 pm by RustyDios »

 

Offline magic

  • Moderator
  • 211
Re: Free Units and Invincible Units
RustyDios,

we have a private group here and if you want I can give you access. Its very quiet now...
And FTP access, for sharing within group.

Are you are interested?

About changes , since 28/01/2011, that is only a half of it, I lost the file with previous changes when my hard disk died...
It was not kept within release...

About Resource Trucks, there was a trick  to prevent enemies shooting at them, I cant remember.

Vehicles have their weapons definition in <vehicle_name.fit> file in objects folder. Should be in the turret since only turret has weapon nodes.
I will think about new "destroyweapon" function.
« Last Edit: February 14, 2015, 04:06:05 am by magic »

 
Re: Free Units and Invincible Units
Yes that sounds interesting so i could upload my campaign when I've finished making it.

This is the mission.abl for being able to capture a MobileHQ and four units under its command;
Code: [Select]
//*********************************************************************************

module rdmap2 : integer;

//--------------------------------------------------------
// Mission Name: rdmap2
// Created: 14/02/15
//--------------------------------------------------------

//------------------------------------------------------------------
//     Constant Definitions
//------------------------------------------------------------------
const
          #include_ "misconst.abi"

//------------------------------------------------------------------
//     Type Definitions
//------------------------------------------------------------------
type

//------------------------------------------------------------------
//     Variable Declarations
//------------------------------------------------------------------
var

static integer ScenarioResult;
eternal real gametime;
static real nextsecond;
eternal boolean GeneralAlarm;
static boolean PlayPASound;
static boolean PlayGASound;
eternal integer GeneralAlarmCounter;
boolean PerimeterBreach;

//------------------------------------------------
// Mission Specific Variables
//------------------------------------------------

static integer[12] UnitList; // defines an array to hold vehicle ID's

static boolean GotaHQ; // Sets a check for not repeating this once captured

static integer MobileHQ; // defines the MobileHQ UnitID by editor SquadID
static integer Unit1; // defines a unit under the MHQ command by editor SquadID
static integer Unit2; // defines a unit under the MHQ command by editor SquadID
static integer Unit3; // defines a unit under the MHQ command by editor SquadID
static integer Unit4; // defines a unit under the MHQ command by editor SquadID


//------------------------------------------------------------------
//     Init Function    (automatically run first time through)
//------------------------------------------------------------------
function init;
code

ScenarioResult = PLAYING;
NextSecond = 1.0;
GeneralAlarmCounter = -1;
GeneralAlarm = FALSE;
PlayPASound = FALSE;
PlayGASound = FALSE;

//------------------------------------------------
// Mission Specific initializations
//------------------------------------------------

//Airstrikes, sensors, copters, artillery, minelayers, repair trucks & salvage craft have all been disabled in the editor/mission.fit

//----------------------------------------------------------------------------------------
//**You Can Edit This **  This lists the squadID's for the units under a Mobile HQ's control
//----------------------------------------------------------------------------------------

MobileHQ = 4; // The editor SquadID for the MobileHQ
Unit1 = 5; // The editor SquadID for a unit under command from this HQ
Unit2 = 6; // The editor SquadID for a unit under command from this HQ
Unit3 = 7; // The editor SquadID for a unit under command from this HQ
Unit4 = 8; // The editor SquadID for a unit under command from this HQ

//----------------------------------------------------------------------------------------
// **End Editable Section **
//----------------------------------------------------------------------------------------

GotaHQ = FALSE; // Open the captured loop check

// Here we convert the given SquadID's into Part/VehicleID's and set the MHQ to be capturable
GetUnitMates(MobileHQ,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
MobileHQ = UnitList[0]; // Assigns the VehID to this name
SetCapturable(MobileHQ,TRUE); // Sets the unit to be capturable
GetUnitMates(Unit1,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
Unit1 = UnitList[0]; // Assigns the VehID to this name
GetUnitMates(Unit2,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
Unit2 = UnitList[0]; // Assigns the VehID to this name
GetUnitMates(Unit3,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
Unit3 = UnitList[0]; // Assigns the VehID to this name
GetUnitMates(Unit4,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
Unit4 = UnitList[0]; // Assigns the VehID to this name

endfunction;
//------------------------------------------------------------------
//     Main Code
//------------------------------------------------------------------
code

//------------------------------------------------
// Debug Window Game Clock Second Counter
// Note:  This is used by some ingame functions.
// I think it's used by the mission timer and if there are any perimeter towers
//------------------------------------------------
// Used by many functions as a general time counter
gametime = gettime;
If (gametime >= nextsecond) Then
nextsecond = gametime + 1;
If (GeneralAlarm) then
GeneralAlarmCounter = GeneralAlarmCounter + 1;
endif;
endif;
// Plays a general alert at some point
if ((PlayGASound) and (NextSecond == gametime + 1)) then
playSoundEffect(GENERAL_ALARM_SOUND);
endif;
// Loops playing the perimeter breach sound if there is one in the map
if (PlayPASound) then
playSoundEffect(PERIMETER_ALARM_SOUND);
endif;

PerimeterBreach = FALSE;

//---------------------------------------
// Mission Specific Code
//---------------------------------------

if (GotaHQ == FALSE) then // If the HQ is not captured ...
if (objectside(MobileHQ) == 500) then // when it is captured...on the player side 500, 501 = enemy, 502 = ally

addmovertoplayer(MobileHQ, 0, 2); // set this unit to the player team, ally commander
addmovertoplayer(Unit1, 0, 0); // set this unit to the player team, player commander
addmovertoplayer(Unit2, 0, 0); // set this unit to the player team, player commander
addmovertoplayer(Unit3, 0, 0); // set this unit to the player team, player commander
addmovertoplayer(Unit4, 0, 0); // set this unit to the player team, player commander

SetBrain(Unit1, "pbrain"); // make the unit repond to player commands
SetBrain(Unit2, "pbrain"); // make the unit repond to player commands
SetBrain(Unit3, "pbrain"); // make the unit repond to player commands
SetBrain(Unit4, "pbrain"); // make the unit repond to player commands

// Alert the player by pop-up message that some units have come directly into thier command
SetTextMsg(1," MechWarrior Report -

Commander, the units under command from this MobileHQ have agreed to work for us until our mission is complete,

or they are dead. ",1);

GotaHQ = TRUE; // Close the loop
endif;
endif;
//---------------------------------------
// END SCENARIO
//---------------------------------------

if (getMissionStatus <> PLAYING) then
//Just set scenarioResult to 9999 here and you're all set!!
endif;

//---------------------------------------
return (ScenarioResult);
//---------------------------------------
endmodule.
//******************************************************************

It works very well. I don't understand why it won't work as a warriorbrain;
Code: [Select]
//----------------------------------------------------------------------------------------
// Captureable Unit Warrior Brain for Mech Commander Omnitech
// Created by RustyDios 12 / Feb / 15
// RustyDios_UniversalWarriorBrain_FreeSupportUnit
//----------------------------------------------------------------------------------------
// The original was copied from the null_order warrior brain
// CREATED:10/14/98   BY:Mike Lee
// This is a 'Do nothing' warrior brain that defects to the player side when captured
// Useful for units with weapons by proxy
// Basically giving the player a free lance, should they find and capture the MHQ
// To use this brain the MHQ should be initially set to the ally team in the editor
//
// By default this brain assumes that SquadID's 1,2,3 are the player dropzone locations
// 4 is actually this unit
// and 5,6,7,8 are the units under it's command
//----------------------------------------------------------------------------------------
fsm RD_UWB_MHQ; //does NOT need to be unique for each vehicle in map
// but you will need to have multiple file copies if you have more then one MHQ in one map
// with different squad ID's under it's command
//----------------------------------------------------------------------------------------

var
static integer Order1Status; // Defines Order1
static boolean GotaHQ; // Sets a check for not doing this once captured
static boolean HQDead; // Sets a check for not checking if dead, once dead

static integer[12] UnitList; // defines an array to hold vehicle ID's
static integer MobileHQ; // defines the MobileHQ UnitID by editor SquadID
static integer Unit1; // defines a unit under the MHQ command by editor SquadID
static integer Unit2; // defines a unit under the MHQ command by editor SquadID
static integer Unit3; // defines a unit under the MHQ command by editor SquadID
static integer Unit4; // defines a unit under the MHQ command by editor SquadID

//----------------------------------------------------------------------------------------
// Initialise Warrior Brain. This code is run Once only and sets up the unit behaviour
//----------------------------------------------------------------------------------------
function Init;
code
//----------------------------------------------------------------------------------------
//**You Can Edit This **  This lists the squadID's for the units under this units control
//----------------------------------------------------------------------------------------

MobileHQ = 4; // The editor SquadID for the MobileHQ
Unit1 = 5; // The editor SquadID for a unit under command from this HQ
Unit2 = 6; // The editor SquadID for a unit under command from this HQ
Unit3 = 7; // The editor SquadID for a unit under command from this HQ
Unit4 = 8; // The editor SquadID for a unit under command from this HQ

//----------------------------------------------------------------------------------------
// **End Editable Section **
//----------------------------------------------------------------------------------------

//include_ "UBInit.abi",the only thing in UBInit.abi is the below line
// why include a whole file for one line?
//DefaultBrain;

// OrderStatus, this sets up the unit to only do the startup routine once
Order1Status = INCOMPLETE;

SetEngageRadius(0); // Don't engage anything
  IdentifySensorContactsOFF; // Don't call out sensor contacts
MoveToEngageOFF; // Don't move
StopFighting; // Don't fight
ReturnFireOFF; // Don't fight if attacked
SetWillHelp(FALSE); // Don't go to help our mates

SetCapturable(GetID,TRUE); // Sets the unit to be capturable
GotaHQ = FALSE; // Open the captured loop check

// Here we convert the given SquadID's into VehicleID's
GetUnitMates(MobileHQ,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
MobileHQ = UnitList[0]; // Assigns the VehID to this name
GetUnitMates(Unit1,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
Unit1 = UnitList[0]; // Assigns the VehID to this name
GetUnitMates(Unit2,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
Unit2 = UnitList[0]; // Assigns the VehID to this name
GetUnitMates(Unit3,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
Unit3 = UnitList[0]; // Assigns the VehID to this name
GetUnitMates(Unit4,UnitList); // Gets the Vehicle ID from the editor SquadID and stores it in the list array
Unit4 = UnitList[0]; // Assigns the VehID to this name

endfunction;
//----------------------------------------------------------------------------------------
// Main Code
//----------------------------------------------------------------------------------------
state start;
code
//Initialize Orders Library
initOrders;

// Order1 - ie the do nothing set up
if (TRUE) then
if (Order1Status == INCOMPLETE) then
SetEngageRadius(0);
Order1Status = SUCCESS;
endif;
endif;

if (GotaHQ == FALSE) then // If the HQ is not captured ...
if (objectside(MobileHQ) == 500) then // when it is captured...on the player side 500, 501 = enemy, 502 = ally

addmovertoplayer(MobileHQ, 0, 2); // set this unit to the ally commander, so this doesn't get done again!
addmovertoplayer(Unit1, 0, 0); // set this unit to the player commander
addmovertoplayer(Unit2, 0, 0); // set this unit to the player commander
addmovertoplayer(Unit3, 0, 0); // set this unit to the player commander
addmovertoplayer(Unit4, 0, 0); // set this unit to the player commander

SetBrain(Unit1, "pbrain"); // make the unit repond to player commands
SetBrain(Unit2, "pbrain"); // make the unit repond to player commands
SetBrain(Unit3, "pbrain"); // make the unit repond to player commands
SetBrain(Unit4, "pbrain"); // make the unit repond to player commands

// Alert the player by pop-up message that some units have come directly into thier command
SetTextMsg(1," MechWarrior Report -

Commander, the units under command from this MobileHQ have agreed to work for us until our mission is complete,

or they are dead. ",1);

GotaHQ = TRUE; // Close the loop
endif;
endif;


endstate;
//--------------------------------------------------------------------------------------------
endfsm.

It does work, but both the MobileHQ AND the first unit go direct to the ally commander, the other three units go to the player ?!? Any Ideas?

I've also put together a list of all the ABL commands, see the separate thread.

And I believe the trick to not get people/enemy/computer ai/turrets to not target resource trucks was in the command "SetPotentialContact(PartID,Integer)" .... but I can't find any of my old MCG scripts that used it, and can't get it working in MCO... ...
« Last Edit: February 24, 2015, 05:24:00 pm by RustyDios »

 

Offline magic

  • Moderator
  • 211
Re: Free Units and Invincible Units
When you use addMoverToPlayer command, you dont need objectChangeSides at all.

 
Re: Free Units and Invincible Units
Cool. Updated the above posts to remove the ObJectChangeSides lines...