Mods and Rulesets

Protect HQ Example File (7.2)

This is the protecthq_types.cfg file that comes with Army Men RTS:

//////////////////////////////////////////////////////////////////////////////
//
// Copyright Pandemic Studios
//
// Army Men RTS
//


// This is just the check at the start. It's a separate objective
// so that you don't get your ally 3min base messages. It isn't renamed
// because some maps have protecthq.check forced instead of using a
// ruleset. Bad mapmakers! (or alternatively, bad studio!)


CreateObjectType("protecthq.check", "Objective")
{
  // Do I NOT have a fully-constructed HQ?
  Condition("HaveType")
  {
    Type("army.building.hq1")
    {
      Operator("==");
      Amount(0);
    }
  }
  Action()
  {
    Cmd("sound.player.clear");
    Cmd("exec music_common_list.cfg");
    Cmd("sound.player.play");

    // objective
    DisplayObjective("Add","dobj_base",0)
    {
      Text("#mods.ruleset.protecthq.objective2");
    }

    // Light the fuse
    NewObjective("protecthq.timer");
    // tell everybody about it
    TriggerTeamRadio("3minself");


    // Check to see if they start building a hq
    NewObjective("protecthq.build");

    // Is this us ?
    If("@@.engine.name", "==", "*@.engine.name")
    {
      // Display the time
      Cmd("iface.activate protecthq_timer");
    }

    // Add a display objective
    DisplayObjective("Add", "buildHQ")
    {
      Text("#mods.ruleset.protecthq.objective");
    }
  }
}
//
// This is the real one :)
// See the above objective for the start version of this


CreateObjectType("protecthq.checkgame", "Objective")
{
  // Do I NOT have a fully-constructed HQ?
  Condition("HaveType")
  {
    Type("army.building.hq1")
    {
      Operator("==");
      Amount(0);
    }
  }
  Action()
  {
    // Light the fuse
    NewObjective("protecthq.timer");
    // tell everybody about it
    TriggerTeamRadio("3min");


    // Check to see if they start building a hq
    NewObjective("protecthq.build");

    // Is this us ?
    If("@@.engine.name", "==", "*@.engine.name")
    {
      // Display the time
      Cmd("iface.activate protecthq_timer");
    }

    // Add a display objective
    DisplayObjective("Add", "buildHQ")
    {
      Text("#mods.ruleset.protecthq.objective");
    }
  }
}


CreateObjectType("protecthq.timer", "Objective")
{
  // Tick down the timer and when it finishes, boom
  Condition("Timer")
  {
    Time(180);
    Var("@.timeleft");
  }
  Action()
  {
    // Remove the timer
    If("@@.engine.name", "==", "*@.engine.name")
    {
      // Remove the time
      Cmd("iface.deactivate protecthq_timer");
    }

    // Ensure no one can give this team any units
    KnockOut();

    // Destroy all the players units
    SelfDestruct();
  }
}

CreateObjectType("protecthq.build", "Objective")
{
  // Do I NOT have a fully-constructed HQ?
  Condition("HaveType")
  {
    Type("army.building.hq1")
    {
      Operator(">");
      Amount(0);
    }
  }

  Action()
  {
    // Blow out the fuse
    ObjectiveAbandoned("protecthq.timer");

    // Remove the timer
    If("@@.engine.name", "==", "*@.engine.name")
    {
      // Remove the time
      Cmd("iface.deactivate protecthq_timer");
    }

    // We have to keep checking for the hq, so use the game check, not the start check
    NewObjective("protecthq.checkgame");

    // Remove the display objective
    DisplayObjective("Remove", "buildHQ");

    // Reset the time
    Op("@.timeleft", "=", 180);
  }
}

// 3min messages
ConfigureRadioEvent("3min")
{
  Messages()
  {
    GameMessage::Self("3min.self");
    GameMessage::Ally("3min.ally", "#player");
  }
}

ConfigureRadioEvent("3minself")
{
  Messages()
  {
    GameMessage::Self("3min.self");
  }
}

ConfigureGameMessage("3min.self")
{
  Interval();
  Sound()
  {
    Type("Sound::Primary");
    Add("protecthq_hq.wav");
  }
  Message()
  {
    Type("Message::Console");
    Add("#mods.ruleset.protecthq.3minself");
//    Add("You have 3 minutes to build a HQ");
  }
}

ConfigureGameMessage("3min.ally")
{
  Interval();
  Sound()
  {
    Type("Sound::Primary");
    Add("protecthq_hq.wav");
  }
  Message()
  {

    Type("Message::Console");
    Add("#mods.ruleset.protecthq.3minally");
    //Add("Your ally, {1:s}, has 3 minutes to build a HQ");
  }
}