Author Topic:  MCG coding  (Read 710 times)

1 Aug 17

Read 710 times

Offline Mech

  • Members
  • Rookie
  • *

i've been attempting to understand and confirm the use of the functions shown by CMunsta....here's a few scraps of code that i've checked so far.

   

Code: [Select]
    //setObjectDamage(Mech_Bay_021024000,var);

    //setObjectDamage(Mech_Bay_021026000,GetObjectDamage(Mech_Bay_021024000));
    
    //CallStrike(508, -1, 1476.0, 478.0, -1.0, TRUE);

    //CallStrikeEx(507,-1,1476.0, 478.0,-1.0,TRUE,5.0);


*************************************************************************

the first example sets the damage amount of a designated building. The value may be incremented over time until the building is destroyed (0 = no damage to 100 = destroyed).

the second example shows that the damage amount of the first building may be applied to another building too.

eg: creation of splash-zone effect.

3rd and 4th examples are 2 variants of the same thing. One includes a time factor between strikes.

Both appear to require positioning of the strike point near to CLAN? movers otherwise the action fails and an error sound is given.


*************************************************************************

Using Cmunsta's "Giving In-Mission Drop Groups" example ex8.


Find Mystique effect.

Unit powers up when you approach and joins your team.


Code: [Select]
      var
            static integer Ally;

function init;

       code
            Ally = GetVehicleID(PLAYER_FORCE,1,0);

endfunction;

       code
            if ((distancetoobject(PLAYER_FORCE,Ally) < 35) and (GetObjectActive(Ally) == 0)) then
                 SetObjectActive(Ally, TRUE);
            endif;




"found" units can "find" other units too, since they all become part of the team.

*************************************************************************

"In-Mission Drop Groups" 

can be Mobile Artillery that fire upon your command when given the .Fit file st ObjectProfile PV21150 instead of PV21100.

2 Aug 17

Reply #1

Offline RizZen

  • Moderator
  • Veteran
  • *

Great due to my limited time amount I would like to see more of that. Will make mission creation easier ^^

2 Aug 17

Reply #2

Offline Mech

  • Members
  • Rookie
  • *

cool

will add what i can and will be doing that mostly with working code examples if possible.

here's another bit.

********************************************************************************************
update for Cmunstas' CBG2(rev0.3)
********************************************************************************************

ObjectStatus(integer ObjectID) : integer;

********************************************************************************************
********************************************************************************************
list of return values found in OConst.abi 

OBJECT_STATUS_NORMAL = 0;
OBJECT_STATUS_DISABLED = 1;
OBJECT_STATUS_DESTROYED = 2;
OBJECT_STATUS_STARTING_UP = 3;
OBJECT_STATUS_SHUTTING_DOWN = 4;
OBJECT_STATUS_SHUTDOWN = 5;
OBJECT_STATUS_WITHDRAWN = 6;
OBJECT_STATUS_INVISIBLE = 7;

********************************************************************************************
********************************************************************************************

example usage
********************************************************************************************


Code: [Select]
    //OBJECT_STATUS_NORMAL = 0
    if (ObjectStatus(Mech_Bay_021024000) ==0) then

          //slowly damage mechbay1
          setObjectDamage(Mech_Bay_021024000,incrementing variable);

          //alter value to show a delayed value on healthbar of mechbay2
          //setObjectDamage(Mech_Bay_021026000,incrementing variable - 20);

    else

          //OBJECT_STATUS_DESTROYED = 2
          // mechbay1 is destroyed after the incrementing value reaches 100
          if  (ObjectStatus(Mech_Bay_021024000) ==2) then

                 //get value from mechbay1 and apply to mechbay2
                 //value is equal to 100 causing "destroyed state"
                 //setObjectDamage(Mech_Bay_021026000,GetObjectDamage(Mech_Bay_021024000));

                 //make a value eg: 2 * 10 = 20 taken from returned value of object state of mechbay1
                 //and apply it to mechbay2 to show percentage on health bar 20/100
                 setObjectDamage(Mech_Bay_021026000,ObjectStatus(Mech_Bay_021024000)*10);

                 //just set the value that equates to destruction
                 //setObjectDamage(Mech_Bay_021026000,100);

          endif;

      endif;


********************************************************************************************
nb: the mechbay names/numbers "ObjectID Handles" are specified in the STR.ABI file of an example mission.
      incrementing variable is run in a function like the playbetty example.

********************************************************************************************
********************************************************************************************

3 Aug 17

Reply #3

Offline Mech

  • Members
  • Rookie
  • *

not sure now if all those return values are working

OBJECT_STATUS_NORMAL = 0;
OBJECT_STATUS_DISABLED = 1; ??
OBJECT_STATUS_DESTROYED = 2;
OBJECT_STATUS_STARTING_UP = 3; ??
OBJECT_STATUS_SHUTTING_DOWN = 4; ??
OBJECT_STATUS_SHUTDOWN = 5;
OBJECT_STATUS_WITHDRAWN = 6; ??
OBJECT_STATUS_INVISIBLE = 7; ??

0, 2 and 5 are fine but i get a 3 "starting up" when i check on a unit thats been ordered to withdraw. haven't been able to get a 6 "withdrawn" or 7 "invisible" yet, although that's what also happens to a unit that withdraws.

i shot a mech in the leg until it was lame but it didn't return a "disabled" 1 value.

here's some code that performs an action of powering up or powering down an enemy mech depending on whether you approach or move away.
Code: [Select]
//     Powerup and Powerdown (for mission ABL file)

//------------------------------------------------------------------
//     Variable Declarations
//------------------------------------------------------------------
            static integer Turkina;
//------------------------------------------------------------------
//     Init Function
//------------------------------------------------------------------
            Turkina = GetVehicleID(CLAN_FORCE,0,1);
//------------------------------------------------------------------
//     Main Code
//------------------------------------------------------------------
            //Turkina GetVehicleID == 896
            //Turkina GetTerrainObjectPartID == 54848

            //if (Turkina == 896) then
                  //setObjectDamage(Mech_Bay_015382000,Turkina/10);
            //endif;
 
            if (ObjectStatus(Turkina) == 5) and (distancetoobject(PLAYER_FORCE,Turkina) < 50) then
                  SetObjectActive(Turkina, TRUE);
                  SelectWarrior(GetPilotID(Turkina));
                  OrderPowerUp;
            else
                 if  (ObjectStatus(Turkina) == 0) and (distancetoobject(PLAYER_FORCE,Turkina) > 50) then
                      SelectWarrior(GetPilotID(Turkina));
                      OrderPowerDown;
                 endif;
            endif;
at the start are some values i was able to find the hard way showing the numbers assigned to a turkina for its VehicleID and its GetTerrainPartID.
« Last Edit: 3 Aug 17 by Mech »

3 Aug 17

Reply #4

Offline RizZen

  • Moderator
  • Veteran
  • *

Did you check if these are in abl library? There is a library containing all available commands - only these should work.

3 Aug 17

Reply #5

Offline Mech

  • Members
  • Rookie
  • *

which one is that?

i've got the MCG extracted files, do you mean its one of the ABL files in the MISSION.FST folder?

there's several clan brains there that seem to use that list of "object status" i was looking at.

example cbrain01.abl

OBJECT_STATUS_NORMAL = 0;
OBJECT_STATUS_DISABLED = 1;
OBJECT_STATUS_DESTROYED = 2;
OBJECT_STATUS_STARTING_UP = 3;
OBJECT_STATUS_SHUTTING_DOWN = 4;
OBJECT_STATUS_SHUTDOWN = 5;

*********************************************

some code to make an enemy APC become active or non active due to player force proximity.

APC will display a mouseover message of "APC" or "No Crew" if its active or not.
Code: [Select]
//      APC :  Active = Crewed / Inactive = No Crew (for mission ABL file)

//------------------------------------------------------------------
//     Variable Declarations
//------------------------------------------------------------------
            static integer APC;
//------------------------------------------------------------------
//     Init Function
//------------------------------------------------------------------
            APC = GetVehicleID(CLAN_FORCE,0,0);
//------------------------------------------------------------------
//     Main Code
//------------------------------------------------------------------
            if (ObjectStatus(APC) == 0) and (distancetoobject(PLAYER_FORCE,APC) < 50) then
                  SetObjectActive(APC, true);
            else
                 if  (ObjectStatus(APC) == 0) and (distancetoobject(PLAYER_FORCE,APC) > 50) then
                      SetObjectActive(APC, false);
                 endif;
            endif;
« Last Edit: 3 Aug 17 by Mech »

3 Aug 17

Reply #6

Offline RizZen

  • Moderator
  • Veteran
  • *

Nope, there is another file containing all available abl commands. When I remember right it's a csv file. But I'm not sure...

Have a look here also:
http://www.hard-light.net/forums/index.php?topic=89196.0
« Last Edit: 3 Aug 17 by RizZen »

3 Aug 17

Reply #7

Offline Mech

  • Members
  • Rookie
  • *

 i saw that page recently, wasn't sure how much of it applied to MCG  since it seemed to be in relation to the omnitech upgrade? of MC2. "List of ALL NEW (or fixed) ABL COMMANDS"

btw, i like mc2 as well, but at the moment am focused on MCG since i found Cmunstas' stuff after making another map recently and thinking about trying to extend the capabilities of the editor again.

this is a rough list i've been using, hopefully there'll be some more "commands?, orders?, functions?" to add.
« Last Edit: 3 Aug 17 by Mech »

3 Aug 17

Reply #8

Offline Mech

  • Members
  • Rookie
  • *

VehicleID();
GetVehicleID();

**********************

VehicleIDs numbered according to SORT ORDER of team, type and weight?


1 Player controlled Inner Sphere Lance/s and player controlled Allies of Inner Sphere first?
2 then Clan?
3 then uncontrolled Allies of Inner Sphere?

***********************************************************************

(Commander0) player control

player team - group 0?

1st unit = 512 - player controlled active lance?
2nd unit = 513 -  "                 "                    "
3rd unit = 514 -  "                 "                    "
4th unit = 515 -  "                 "                    "
5th unit = 516 -  "                 "                    "
6th unit = 517 -  "                 "                    "
7th unit = 518
8th unit = 519
9th unit = 520
10th unit = 521
11th unit = 522
12th unit = 523

player team - group1 - player controlled allies ("in mission drop group") via fit file editing

13th unit = 524 (heaviest mech) Atlas
14th unit = 525 (lightest mech) Firestarter
15th unit = 526 (heaviest vehicle) Alacorn
16th unit = 527 (lightest vehicle) Savannah
17th unit = 528
18th unit = 529
etc

***********************************************************************

(Commander1)

enemy - group 0

1st unit = 896 (heaviest mech) Masakari
2nd unit = 897 (mid mech) hunchback
3rd unit = 898 (lightest mech) Cougar
4th unit = 899 (heaviest vehicle) Shrek
5th unit = 900 (lightest vehicle) Pegasus
6th unit = 901
7th unit = 902
8th unit = 903
9th unit = 904
10th unit = 905
11th unit = 906
12th unit = 907

enemy - group 1

13th unit = 908
14 unit = 909
15
16
etc

***********************************************************************

(Commander2) non player controlled allies

allied - group 0

1st unit = 1280 (heaviest mech) Thor
2nd unit = 1281 (mid mech) Loki
3rd unit = 1282 (lightest mech) Uller
4th unit = 1283 (heaviest vehicle) Rommel
5th unit = 1284 (lightest vehicle) Swiftwind
6th unit = 1285
7th unit = 1286
8th unit = 1287
9th unit = 1288
10th unit =1289
11th unit = 1290
12th unit = 1291

allied - group 1

13th unit = 1292
14th unit = 1293
15
etc

**********************

see misconst.abi for abbreviated listings.

        //------------------
        // GENERIC PARTS
        //------------------
        PLAYER_VEHICLE0_LANCE0       = 512;
        PLAYER_VEHICLE1_LANCE0       = 513;
        PLAYER_VEHICLE2_LANCE0       = 514;
        PLAYER_VEHICLE3_LANCE0       = 515;
        PLAYER_VEHICLE0_LANCE1       = 524;
        PLAYER_VEHICLE1_LANCE1       = 525;
        PLAYER_VEHICLE2_LANCE1       = 526;
        PLAYER_VEHICLE3_LANCE1       = 527;
        etc

*********************************************************************

if the sort order is understood, all movers can be known beforehand by number.
these are constants created according to the set up by the person that makes the mission.

**********************
« Last Edit: 8 Aug 17 by Mech »

4 Aug 17

Reply #9

Offline Mech

  • Members
  • Rookie
  • *

ObjectTypeID();

object type id for allied and enemy units and buildings.

if the unit is part of the allied team then it doesn't matter if its a mech or a vehicle, it will always return -1.

            //(ObjectTypeID(Atlas) ==-1)
            //(ObjectTypeID(Firestarter) ==-1)

            //(ObjectTypeID(Alacorn) ==-1)
            //(ObjectTypeID(Savannah) ==-1)


if its an enemy mech it will return a 2 digit number which may be listed somewhere, or may be generated on the spot?

            //(ObjectTypeID(Masakari) ==58)
            //(ObjectTypeID(Hunchback) ==17)
            //(ObjectTypeID(Cougar) == 53)


if its an enemy vehicle it will return the number seen in the Tedlds.csv file of the editor.

            //(ObjectTypeID(Shrek) == 470)
            //(ObjectTypeID(Pegasus) == 471)


if its a building it will also return the number seen in the Tedlds.csv file of the editor.

            //(ObjectTypeID(Mech_Bay_015384000) ==633)

4 Aug 17

Reply #10

Offline Mech

  • Members
  • Rookie
  • *

it seems like some MCG specific virus is attacking my installation/s of the game.

i think i got it from when i downloaded and tried to run Exodus/Turncoat and the same thing happened with XenocideBengalLancers.

Both affected the brightness setting and froze at the briefing menu.

changing the monitor screen refresh rate seemed to keep the games from freezing or crashing until i attempted to enter a mission. the general result is lock up with the need to reboot.

the problem at first was only affecting those games but now its spread to my own game copy with the effect first being noticed with the loss of the usability of the editor.

now if i try to make a clean install of the game i find that it locks up when i try to go to the purchasing screen.
or if i try to run a test mission.

in all cases, hitting ctrl-alt-dlt would fail to drop the app to the taskbar. instead i can see flickering low res buttons and tabs along the area of the taskbar which are no help. but show the exact same effect that i first noticed from Exodus/turncoat.

i downloaded and ran those games a week or 2 before i came here.
« Last Edit: 4 Aug 17 by Mech »

4 Aug 17

Reply #11

Offline RizZen

  • Moderator
  • Veteran
  • *

I dont think it's virus. My installation of all versions are running clean and without any issues. Maybe you made some changes on system that cause issues?

Edit: May you gimme your system infos? Such like i described here?
« Last Edit: 4 Aug 17 by RizZen »

4 Aug 17

Reply #12

Offline Mech

  • Members
  • Rookie
  • *

i don't believe i made any changes except for running Exodus/turncoat and Xenocide/BengalLancers a few weeks before.

- system ur running (win10 64bit f.e.)

what's f.e?
winxp pro sp3 32bit dual core cpu. e6500 @ 2.93ghz. 3.46gb ram.


- game version ur running (darkest hours full version 2.0d f.e.)

Mechcommander Gold. "Desperate Measures". Cd burnt copy from original copy.


- try to explain exactly the problem

i did a bit.

the problem started when i went to use the editor again (like i had just 5 minutes beforehand) after going through the gui selection process (of map creation or editing) the editor failed to display the workspace to allow mission editing.

this had also happened a week or so ago just before i came here.

back then, i reinstalled MCG and everything seemed okay again except that i noticed the issue with screen brightness had transferred itself from Exodus/turncoat and Xenocide/BengalLancers.

the screen brightness was suddenly too high and i had to set the "preferences" level to 0.

(side note) also, when i look at the pictures on that bug report page they look the same as Exodus/turncoat and Xenocide/BengalLancers. ie: overbright.

now i can't run the MCG gamespace or get a usable product from the editor.

- what game feature u use (original/expansion campaign / solo- / multi-player missions)
attempted to use the editor again. after reinstalling, attempted to use the programme as usual. i find the editor works again after a reinstall but it still crashes the game if i try to run a mission i make.

- what mission / map causes the problem (overview here)
none (all?), it freezes the computer when i try to navigate around the briefing and purchasing menus (same with Exodus/turncoat and Xenocide/BengalLancers).

- awesome help would be screenshots or error reports from game when it crashes
there's no error report. a screenshot probably won't show more than i described, maybe i'll try.

again. i didn't have these problems unitl i downloaded those games and any attempt at installing a new copy of the game (or using any copy anywhere on my hard drive) causes exactly the same effects as seen from those DL games.



(DL'ed Exodus/Turncoat 25/07/17 and XenocideBengalLancers 31/07/17)
« Last Edit: 4 Aug 17 by Mech »

4 Aug 17

Reply #13

Offline Mech

  • Members
  • Rookie
  • *

i found that hitting alt-enter to drop the game to windowed mode prevents the need to reboot (as long as i do that before i do anything that causes it to freeze). i'm then able to use the task manager to "end task" the app when it does freeze up.

here's an error message after the game crashed when i tried to run op1 mission1 (of original campaign).

« Last Edit: 4 Aug 17 by Mech »

5 Aug 17

Reply #14

Offline RizZen

  • Moderator
  • Veteran
  • *

Sorry this doesn´t make sense. I can´t help you. Screenshot would be enough, what should i do with java script? And please upload somewhere else, not dropbox, hate that.

Im impressed you could start and work with editor on XP... - i only can get it to run on windows 98.

Your ingame resolution / Color problems are caused by your individual graphic settings / configuration.

Try to play it without installing like i describe here.

When you had hope using editor to edit existing missions - im sorry to disappoint you. Editor never allowed that. Only creation of new maps - and only in it´s limited limits and content. For doing more it always needed abl scripting.
« Last Edit: 5 Aug 17 by RizZen »