コード例 #1
0
  //
  // Assign constructors to this base
  //
  void Base::AssignConstructors(const char *tagName)
  {
    processTokens = TRUE;

    // Was a tag specified ?
    if (tagName)
    {
      // Resolve the tag
      TagObj *tag = TagObj::FindTag(tagName);

      if (tag)
      {
        // Iterate the units in the tag
        for (MapObjList::Iterator i(&tag->list); *i; i++)
        {
          // Is it alive
          if (!(*i)->Alive())
          {
            continue;
          }

          // Is this a unit ?
          UnitObj *unit = Promote::Object<UnitObjType, UnitObj>(**i);
          if (!unit)
          {
            continue;
          }

          // Is it on our team ?
          if (unit->GetTeam() != GetObject().GetTeam())
          {
            continue;
          }

          // Is it a constructor ?
          if (!unit->HasProperty(0xDCDE71CD)) // "Ability::Construction"
          {
            continue;
          }

//          LOG_AI(("Assigning constructor [%d] '%s' to base '%s'", unit->Id(), unit->UnitType()->GetName(), GetName()))

          // Add this constructor to the list of idle constructors
          constructorsIdle.Append(unit);
        }
      }
      else
      {
        ERR_CONFIG(("Could not find tag '%s' when assign constructors to base '%s'", tagName, GetName()))
      }
    }
    else
    {
      // Iterate all of the units on this team
      for (NList<UnitObj>::Iterator u(&GetObject().GetTeam()->GetUnitObjects()); *u; u++)
コード例 #2
0
    //
    // Execute
    //
    U32 SelfDestruct::Execute(const U8 *, Player &player)
    {
      // Tell each object to SelfDestruct
      for (UnitObjList::Iterator i(&player.GetSelectedList()); *i; i++)
      {
        // Get the unit
        UnitObj *unit = **i;

        // Ensure it can self destruct
        if (unit->HasProperty(0x54D4152A) && !unit->UnderConstruction()) // "Ability::SelfDestruct"
        {
          unit->SelfDestruct(TRUE, unit->GetTeam());
        }
      }

      return (sizeof (Data));
    }