Page 1 of 1

Giving units the ability to call in Airstrikes/Paratroopers/Magnyfying glass

Posted: Sat Mar 11, 2017 10:28 pm
by Arisen
I had too much fun with this one.


Again, another idea I got from Company of heroes, I was trying to give infantry the ability to build barricades, but just as i test I used the bombing run first.

So, to do this you have to go into the config file of the bombing run obj.army.bombingrun

go to the entry that says "unit constructor" and change it from the radio operator to sarge


Constructor("army.unit.sarge");



then go to sarges config and add this underneath the create unit entry

GameObj()
{
ThinkInterval(1);
IdleTask("Tasks::UnitConstructor");
Properties()
{



it should look like this


// UNIT
CreateObjectType("army.unit.sarge", "Unit")
{
GameObj()
{
ThinkInterval(1);
IdleTask("Tasks::UnitConstructor");
Properties()
{

if you add this to the "Add" section then sarges icon will appear always next to the bulldozer.
Add("Client::FacilityBar");



I tried to give sarge the ability to build units, but when I try to build the unit i get an error that says memory access violation. So I will have to do some more poking around before Sarge can start magically poofing grunts! But, it's a start :D




Image

Re: Giving units the ability to call in Airstrikes/Paratroopers/Magnyfying glass

Posted: Sun Mar 12, 2017 12:59 am
by TommyCD1
Yes, while this idea is fun to play with, it's very dangerous in practice. The reason that the radio operator, or any unit that builds, does not attack is because the game's idle process for Tasks::UnitConstructor does to take weapons into account. Which sound fine, but Sarge will only attack if told to or while moving. Also if Sarge dies while constructing, the game crashes.

And units cannot build other units. This is because their models (.god files) do not contain the correct hard points for units. These hard points are used to tell the newly built unit where to spawn, where to walk, and where to exit the building. The points are called OP-EXIT-POST, OP-EXIT1, and OP-EXIT2.

Also, you can post code with the correct formatting using the code button when writing a post as such.
code.png
code.png (3.31 KiB) Viewed 973 times
code.png
code.png (3.31 KiB) Viewed 973 times

Code: Select all

  GameObj()
  {
    ThinkInterval(1);
    IdleTask("Tasks::UnitConstructor");
    Properties()
    {
      Add("Filter::Army");
      Add("Filter::Biological");
      Add("Filter::Unit");
      Add("Filter::Weapon");
      Add("Filter::Heroes");
      Add("Filter::Transportable");
      Add("Client::FacilityBar");
      Add("Client::ForceNameDisplay");
    }
  }

Re: Giving units the ability to call in Airstrikes/Paratroopers/Magnyfying glass

Posted: Sun Mar 12, 2017 10:20 pm
by Arisen
TommyCD1 wrote: Sun Mar 12, 2017 12:59 am Yes, while this idea is fun to play with, it's very dangerous in practice. The reason that the radio operator, or any unit that builds, does not attack is because the game's idle process for Tasks::UnitConstructor does to take weapons into account. Which sound fine, but Sarge will only attack if told to or while moving. Also if Sarge dies while constructing, the game crashes.

And units cannot build other units. This is because their models (.god files) do not contain the correct hard points for units. These hard points are used to tell the newly built unit where to spawn, where to walk, and where to exit the building. The points are called OP-EXIT-POST, OP-EXIT1, and OP-EXIT2.

Also, you can post code with the correct formatting using the code button when writing a post as such.
code.png

Code: Select all

  GameObj()
  {
    ThinkInterval(1);
    IdleTask("Tasks::UnitConstructor");
    Properties()
    {
      Add("Filter::Army");
      Add("Filter::Biological");
      Add("Filter::Unit");
      Add("Filter::Weapon");
      Add("Filter::Heroes");
      Add("Filter::Transportable");
      Add("Client::FacilityBar");
      Add("Client::ForceNameDisplay");
    }
  }
Cool, could I make sarge build other buildings? :COFE:

Re: Giving units the ability to call in Airstrikes/Paratroopers/Magnyfying glass

Posted: Sun Mar 12, 2017 10:26 pm
by TommyCD1
Yes, but you face the same problems as explained previously, where as sarge has a problem shooting and crashes the game.