Announcement

Collapse
No announcement yet.

SLIC Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SLIC Question

    Hey everyone I've been lurking round this forum and trying out mods etc for a few weeks now and I've finally decided to join. Anyway I started learning SLIC today thanks to some of the guides here and it's alot easier than it looks but I've a question (and probably will have a load more soon):

    Could somone tell me the expression to use in an if statement when a type of unit is attacked. e.g if an archer is attacked I want x to happen, I just don't know the expression to use in the if () bit.

    Thanks!
    Shores Of Valinor.com - The Premier Tolkien Community -

  • #2
    Well, welcome to the forums, I'm very glad to hear you decided to join and even gladder to see you're interested in SLIC

    The answer to your question is simple. The type of a unit is a unit property and therefore, logically (but unfortunately SLIC isn't always this logical), it is a variable of the unit[0] array. So the expression to use in the if statement would be 'unit[0].type == UnitDB(UNIT_ARCHER)', assuming that you have the unit stored in unit[0].

    Note that in this case (an unit in the attack), the logical event to use is 'Battle' (not sure if any others could be used as well). However, from 'Battle' you can't directly access each and every unit involved, you must use army[0] (the attacking army) instead. So you should use the GetUnitFromArmy function to extract the unit(s) from this army before you can check the type.

    Let me know if you have any more questions, I love to help (especially with simple questions like this one ).
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

    Comment


    • #3
      Welcome to the wonderful world of SLIC

      Using the event (Battle); if you want the defending army, you can't just use the army[0], as that will give the attacking army.

      So...
      You'll have to use the location of the battle (location[0] from the event) and then using a for loop, for the number of units in the cell (UnitsInCell(location[0]) do GetUnitFromCell(location[0], index, tmpUnit)
      This will store each unit in turn in the defending army (at the location being attacked) as tmpUnit. THEN you can check whether it is an archer, and if it is, do the action.

      Pain in the arse, no?
      Concrete, Abstract, or Squoingy?
      "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

      Comment


      • #4
        D'oh! Misread the question, I thought Turambar said attacking...

        Originally posted by Immortal Wombat
        Pain in the arse, no?
        Nah, that's what makes SLIC fun
        Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

        Comment


        • #5
          Originally posted by Locutus
          Nah, that's what makes SLIC fun
          You enjoy pains in your arse?
          Concrete, Abstract, or Squoingy?
          "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

          Comment


          • #6
            Originally posted by Immortal Wombat
            You enjoy pains in your arse?
            No, I enjoy being creative...
            Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

            Comment


            • #7
              Thanks for the responses . I'll try it out soon. I'll probably have a load more questions for you soon anyway.
              Shores Of Valinor.com - The Premier Tolkien Community -

              Comment

              Working...
              X