Unit-Spawning Objective

Mods that are being worked on. You can post your teaser here.
Post Reply
User avatar
Secg
Half Track L2
Half Track L2
Posts: 200
Joined: Sat Jun 10, 2017 12:28 am
United States of America

Unit-Spawning Objective

Post by Secg »

A while back, TommyCD1 intructed me how to write objectives to spawn units at all player starting point.

1st, extract all files from any .x map

2nd, open game.cfg, for each team, add an objective object's reaper ID

Code: Select all

    Objectives()
    {
      ReaperId(1001); // This is the Objective Object's ReaperId, which must be unique
    }
3rd, open objects.cfg, for each team, create an objective object with corresponding ReaperId number

Code: Select all

CreateObject("objective_start_team1", 1001)
{
  ObjectiveObj()
  {
    Condition();
  }
}
4th, use Notepad++ to create another .cfg file (say objective_start.cfg) and include it in the map's types.cfg

Code: Select all

#include "objective_start.cfg"
5th, in that objective_start.cfg, create one object type for each objective object belonging to each team, like thus:

Code: Select all

CreateObjectType("objective_start_team1", "Objective")
{
  GameObj();
  ObjectiveObj()
  {
    Condition("TRUE"); // This is the condition
    Action() // This is the outcome when the condition is met
    {
      SpawnObjects()
      {
        Region("team1");
        Direction(-90);
        Formation("Basic");
        AddType("army.unit.vikki");
      }
      SpawnObjects()
      {
        Region("team1");
        Direction(-90);
        Formation("Basic");
        AddType("army.unit.riff");
      }
      SpawnObjects()
      {
        Region("team1");
        Direction(-90);
        Formation("Basic");
        AddType("army.unit.thick");
      }
      SpawnObjects()
      {
        Region("team1");
        Direction(-90);
        Formation("Basic");
        AddType("army.unit.scorch");
      }
      SpawnObjects()
      {
        Region("team1");
        Direction(-90);
        Formation("Basic");
        AddType("army.unit.shrap");
      }
      SpawnObjects()
      {
        Region("team1");
        Direction(-90);
        Formation("Basic");
        AddType("army.unit.shrap");
      }
      SpawnObjects()
      {
        Region("team1");
        Direction(-90);
        Formation("Basic");
        AddType("army.unit.bullseye");
      }
    }
  }
}
However, NO :( extra unit is spawned. I wonder where I did wrong idk ?
Last edited by Secg on Wed Jul 31, 2019 8:35 pm, edited 1 time in total.
ImageImage
User avatar
Magnos
Half Track
Half Track
Posts: 61
Joined: Sun Dec 16, 2018 1:27 pm
Egypt

Re: Unit-Spawning Objective

Post by Magnos »

You can use

Code: Select all

 placement.cfg
instead of using an Objective for spawn or use the studio to edit

Code: Select all

object.cfg
the

Code: Select all

placement.cfg
is Connected to the

Code: Select all

sides/Army.cfg
here's the normal

Code: Select all

placement.cfg
File

Code: Select all

///////////////////////////////////////////////////////////////////////////////
//
// Pandemic Studios
//
// Generic Type Placement
//

// Generic name, direction, distance, orientation
Place("unit.sarge", 270, 8, 0);
Place("unit.builder", 90, 8, 0);
and the Default

Code: Select all

army.cfg
too

Code: Select all

///////////////////////////////////////////////////////////////////////////////
//
// Pandemic Studios
//
// Side Configuration
//

CreateSide("army")
{
  Description("#game.side.army.description");

  Mappings()
  {
    Add("unit.sarge", "army.unit.sarge");
    Add("unit.builder", "army.unit.bulldozer");
    Add("unit.grunt", "army.unit.grunt");
  }
  Network(1);
}
From army.cfg you see that it accept only 3 objects
Sarge,Bulldozer,Grunt (in normal doubles it summons sarge and bulldozer this way)

you can add the grunt to begin with Default units (sarge&Bulldozer) by adding it to the placement file

Code: Select all

Place("unit.grunt", 90, 8, 0);
you can also edit it's offset (90, 8, 0)
if you want more grunts then you have to add more 4 lines
You can add as many as you want, and then copy this placement file to the map folder
the default placement file for normal maps is exist in ..\base\ , editing it will cause different data and kick!
just make a new copy for your map and move it to the map folder
as for army.cfg, the most really bad thing that you have to make an UnExtractable Setup with winrar (you can use setup factory)
to setup army.cfg on player game
(if the user played with edited army.cfg a normal map everything is okay except for deleting the first three defaut, so just add on it without deleting)

if you still want to use objective you can extract my map (ndfm sea) there are lots to learn from this map!
https://www.youtube.com/watch?v=-IbPN6RgoBc
User avatar
Secg
Half Track L2
Half Track L2
Posts: 200
Joined: Sat Jun 10, 2017 12:28 am
United States of America

Re: Unit-Spawning Objective

Post by Secg »

Magnos wrote: Wed Jul 31, 2019 4:34 pm
Greetings, Magnos!

I've independently come up with the same solution as yours and it does work (so credits to us both =D> ). I can even change the Sarge's type to whatever unit or building I want, even the dreaded Acid Gun >:) .

Still, the reason I use objectives instead of modding the sides > army.cfg is because:
  • This solution only works when people not only download my map, but also replace their original army.cfg < sides with my modded army.cfg < sides. If all playyer have not the same modded army.cfg < sides, that will cause dis-syncing online (y'know, not all downloaders read the mapmaker's readme.txt :| ).
ImageImage
User avatar
Secg
Half Track L2
Half Track L2
Posts: 200
Joined: Sat Jun 10, 2017 12:28 am
United States of America

Unit-Spawning Objective - Problem solved

Post by Secg »

Finally, the objectives successfully made the game spawn units. Apparently, I just need to make sure that: my objectives' ReaperIDs are truly unique (because a prop may have the same ReaperID as an objective).
ImageImage
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest