Page 1 of 1

New to Modding the game, really confused

Posted: Sun Jun 04, 2017 8:35 am
by Templarfreak
So, I'm trying to add a new unit. Simply a generic flamethrower guy, based off of Scorch obviously, but when I add

Code: Select all

Constructor("army.building.barracks1");
To the unit it does not add them into the Barracks' build card. However, it seems like I can properly change what buildings an existing unit can be build at. I changed the Constructor line on the Bazooka soldier to be built at the Garage and that properly changed. Here is all of the code, in case someone wants to look at it:

Code: Select all

///////////////////////////////////////////////////////////////////////////////
//
// Pandemic Studios
//

#include "fx_army_unit_scorch.cfg"
#includeonce "fx_grunt_damage.cfg"

// UNIT
CreateObjectType("army.unit.flame", "Unit")
{
  GameObj()
  {
    ThinkInterval(1);
    IdleTask("Tasks::UnitIdle");
    Properties()
    {
      Add("Filter::Army");
      Add("Filter::Biological");
      Add("Filter::Unit");
      Add("Filter::Weapon");
      Add("Filter::Transportable");
    }
  }

  MapObj()
  {
    GodFile("army_scorch.god");
    PhysicsModel("Walker");
    TractionType("ground");
    GrainSize(1);
	
    TypeDisplay()
    {
      Image()
      {
        Image("if_game_portraits.tga", 210, 210, 42, 42);
        Mode("Centre");
      }
    }

    ArmourClass("infantry");
    HitPoints(200);

    GenericFX()
    {
      Add("UnitObj::ActivelyOnTeam", "flameidle");
      Add("Weapon::Fire", "weapon.flame.fire");
      Add("MapObj::AddToMap", "damage.grunt");
      Add("MapObj::Death", "death.infantry");
      Add("Restore::Target::Process", "restore-small");
      Add("MapObj::AddToMap2", "restore-small-puff");
      Add("Wounded::Start", "herowound");
      // Add("UnitObj::Engine", "water.ripple");
    }
    ShadowFile("army_grunt-shadow.tga");
    RotateShadow(0); // default is 1

  }

  UnitObj()
  {
    TopSpeed(40);
    TurnSpeed(8640); // was1440);
    SeeingRange(65);
    ResponseEvents()
    {
      Add("Attack")
      {
        Add("army.unit.scorch_attack-0.wav");
        Add("army.unit.scorch_attack-1.wav");
      }
      Add("Attacked")
      {
        Add("army.unit.scorch_attacked-0.wav");
      }
      Add("Move")
      {
        Add("army.unit.scorch_move-0.wav");
        Add("army.unit.scorch_move-1.wav");
        Add("army.unit.scorch_move-2.wav");
      }
      Add("Select")
      {
        Add("army.unit.scorch_select-0.wav");
        Add("army.unit.scorch_select-1.wav");
        Add("army.unit.scorch_select-2.wav");
      }
      Add("Spotted")
      {
        Add("army.unit.scorch_spotted-0.wav");
      }
    }
    Constructor("army.building.barracks1");
    ConstructionTime(30);
    CreateSource("resource.blob.infantry1");
    CommandCost(1);
    ResourceCost()
    {
      Add("Plastic", 200);
      Add("Electricity", 25);
    }
    Prereqs()
    {
      Add("army.building.barracks2");
    }

    CommandCost(1);

    Weapon("army.weapon.flame");
  }
}

// WEAPON
CreateWeaponType("army.weapon.flame")
{
  Style("Instant");

  MaxRange(48);

  HorizAngle(90);
  HorizSeparation(5);
  VertAngle(90);
  VertSeparation(45);

  Delay(0.3);
  LeadAngle(1);
  Speed(200);


  Damage()
  {
    Amount(15);

    Effective("infantry", 100%);
    Effective("vehicle", 50%);
    Effective("structure", 50%);
    Effective("flyer", 0%);
    Effective("mine", 50%);
  }

  FirePoints()
  {
    Add("HP-fire");
  }
}
EDIT: There appears to have been some map-specific shenanigans going on. I had to modify the map in order to make the unit appear in the map I was using to test, which was one of the Great Battle maps. The Multiplayer Maps don't seem to have this same weird coding convention that the Gardens map does though, I think.

Re: New to Modding the game, really confused

Posted: Sun Jun 04, 2017 1:09 pm
by TommyCD1
If you place a new unit into the barracks, remember that the barracks already has a full build menu. Try hovering over it and scrolling down on your mousewheel to reveal the new unit.

Re: New to Modding the game, really confused

Posted: Sun Jun 04, 2017 9:49 pm
by Templarfreak
I've already messed with the UI a lot, expanded the build menu to be a 3x4 area. The only issue I have now is that English.dat file. Is there any documentation on how to edit it?

The only things I can figure out about it is that for most strings there is 2 bytes before the "Name" of the string. The first one determines how many bytes come after the name and the second determines how many bytes long the name is then it ends in a null. Then usually the byte after the null determines how long the string is, but that isn't always consistent. But knowing this still doesn't make it possible to edit or add strings unfortunately so something about the header must keep track of how many strings there are or the filesize or something but that's a bit too complicated for me to figure out on my own.

Re: New to Modding the game, really confused

Posted: Sun Jun 04, 2017 11:42 pm
by TommyCD1
Anything that isn't compiled in an .x file or found in a .cfg file I'd have no idea how to work with. And as far as I know no one has ever edited the english.dat file.

Re: New to Modding the game, really confused

Posted: Mon Jun 05, 2017 12:39 am
by Templarfreak
It seems easy enough if you're an adept hacker, what I've managed to find out took like 30 minutes to an hour of browsing through the file with a Hex Editor and I only have the most rudimentary understanding of what I was actually doing Lol.

I'm like 99% certain that for the most part this is the pattern a lot of the strings follow:

04 06 66 6C 61 6D 65 00 0E 00 01 00 46 6C 61 6D 65 74 68 72 6F 77 65 72 04 07

04 06 means that the name of the string is 6 bytes long and the next 4 bytes are info on the string itself. The 6 bytes are 66, 6C, 61, 6D, 65, and 00 which converted from hex to text is "flame " with a null/space at the end. The next byte after the null/space contains the length of the string itself, which is 0E. 0E is 14, meaning the string itself is 14 bytes long. Those 14 bytes, 46, 6C, 61, 6D, 65, 74, 68, 72, 6F, 77, 65, 72, 04, and 07 correspond to the actual string itself which converts from hex to characters which becomes Flamethrower and 2 bytes after it which are apart of the next string name/string to determine its name length and how many bytes to read after it.

Re: New to Modding the game, really confused

Posted: Tue Apr 16, 2019 12:38 pm
by unikc
Just simply add your new unit example:
1.obj_unit_grunt2.cfg (your new unit cfg file)
2.open obj_army.cfg/types.cfg
3.add your obj_unit_grunt2.cfg by typing like this
(just copy include.....grunt...[in obj_army/types.cfg] and change ...... grunt to .....grunt2.cfg

Re: New to Modding the game, really confused

Posted: Fri Apr 19, 2019 8:05 pm
by Magnos
u have to edit types.cfg
add #include filename.cfg
so amrts.exe will read it :)