Random Event

Have modding questions or discovered something new? Post here.
Post Reply
User avatar
j3rry
Map Maker
Map Maker
Posts: 121
Joined: Thu Oct 11, 2018 5:43 am
Location: Central Russia
Russia

Random Event

Post by j3rry »

Hello.

I need a help.
Can I force random event in a ruleset? I am trying to make spawn of some random units. It could be 10 Grunts, 6 Machinegunners or 2 Half-tracks for example. So I need to know the way of making random spawns.

Here is the code:

Code: Select all

SpawnObjects()
    {
      Formation("Box");
      Direction(0);
      Region("@.engine.name");
      AddType("army.unit.grunt");
      AddType("army.unit.machinegunner");
      AddType("army.unit.halftrack");
    }
Last edited by j3rry on Thu Jan 06, 2022 7:17 am, edited 1 time in total.
User avatar
TommyCD1
Moderator
Moderator
Posts: 1146
Joined: Tue Jun 04, 2013 8:55 am
Location: East Coast
Contact:
United States of America

Re: Random Event

Post by TommyCD1 »

In order to have a random event occur, you'd need to use the random objective action.

Normally you'd use this to call a new objective:

Code: Select all

    NewObjective("objective_example1");
        NewObjective("objective_example2");
            NewObjective("objective_example3");
However, you'd should rather use this to choose randomly between objectives:

Code: Select all

    NewRandomObjective()
    {
      Add("objective_example1", 30);
      Add("objective_example2", 10);
      Add("objective_example3", 60);
    }
You should add each new objective you want to be pooled for random selection, with the numbers on the right being each objectives weight which should ideally add up to 100.

Although keep in mind that when doing this, Army Men RTS does not use true randomness, and you may be able to discern a pattern after enough play time.
I may not make the best maps, or be the best player, but I put a lot of time, effort, and care into my stuff. That counts for something, right? No.
Image
"Can we order a pizza?"
GameRanger ID: 913974
User avatar
j3rry
Map Maker
Map Maker
Posts: 121
Joined: Thu Oct 11, 2018 5:43 am
Location: Central Russia
Russia

Re: Random Event

Post by j3rry »

Thank you.

I will keep that in mind.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests