Announcement

Collapse
No announcement yet.

SLIC - Units in City

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

  • SLIC - Units in City

    I was day dreaming in the office and came out this trigger and quickly started scripting once I reached home. It is suppose to show the number of combat units in a city.
    Code:
    Trigger 'CheckCityUnits' when (city.selected) {
      cityunits = city.combatunits;
      Message(player, 'CheckCityUnitsMessage');
    }
    
    Alertbox 'CheckCityUnitsMessage' {
      Text(ID_CHECK_CITY_UNITS_MESSAGE);
      Button(ID_BUTTON_CLOSE) {
        Kill();
      }
    }
    The following should be in scen_str.txt
    Code:
    CHECK_CITY_UNITS_MESSAGE "There are [cityunits.value] in the city of [city.name]."
    It was tested and working fine but .... damn!!! I CAN'T CLICK ON THE ENEMY CITY.

    [This message has been edited by Dreamer (edited January 05, 2000).]

  • #2
    Here's another trigger in replacement of the above one. This time it report the no. of units in the city upon entering a enemy city.
    Code:
    Trigger 'CheckCityUnits' when (special.singlecombat && (unit.2.location == city.location)
    && IsHumanPlayer(g.player)) {  // This line is continous of the above.
      cityunits = UnitsInCell(unit.2.location);
      Message(g.player, 'CheckCityUnitsMessage');
    }
    
    Alertbox 'CheckCityUnitsMessage' {
      Text(ID_CHECK_CITY_UNITS_MESSAGE);
      Button(ID_BUTTON_YES) {
        Kill();
      }
      Button(ID_BUTTON_NO) {
        ClearOrders(unit);
        Kill();
      }
    }
    I am still trying a way to get the unit.2.location to check if the units are in a city.

    [This message has been edited by Dreamer (edited January 05, 2000).]

    Comment


    • #3
      Dreamer,

      Wouldn't there be no units in a city when you enter it. If it had units in it, you wouldn't be able to enter it.

      Don
      Don,
      CtPMaps (Hosted by Apolyton)

      Comment


      • #4
        Skorpion59,

        The special.singlecombat will trigger only when 2 parties units start a battle, so if the city does not have any unit in it, this trigger will not happen.

        When there is units in it, the trigger activate and popup and message box telling you the number of units in the city. I'll have an option to choose YES or NO to continue.

        If you choose no, the ClearOrders(unit) will clear the previous order given, but I think you'll lose some movement points for doing that.

        Comment


        • #5
          Dreamer,

          WOW, that is a slick. What a good idea. I have to try this out. Keep up the work.

          Don
          Don,
          CtPMaps (Hosted by Apolyton)

          Comment


          • #6
            Skorpion59,

            Sorry the trigger still not working, if you look closely in the codes (unit.2.location == city.location), there is still no reference to the city.location.

            Need to check the units are in a city location tile.

            Comment


            • #7
              At first I didn't know exactly what you were trying to do, but now I understand (and have the time to respond). I can see one possible solution: check all cities of unit.2 and compare their locations with unit.2.location.
              If this is possible at all (it might be tricky because SLIC by my knowledge doesn't have arrays - apart from city.1, city.2, city.3, etc.) this trigger can also be adapted to check the contents of a stack/city. Instead of displaying the number of cities, just cycle through all player.2's unit's to check if their at unit.2.location and then display them.
              I'll look at this problem of checking all cities as soon as I find the time.

              BTW You can prevent loosing movement-points by using AddMovement(1, unit).

              Locutus

              P.S. These triggers will both probably be very slow, but that doesn't really matter because it's only used by human players, so the player knows what he is waiting for.
              Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

              Comment


              • #8
                Dreamer,

                I really like this option so I modified your code slightly. Nothing like cheating without going into cheat mode.

                This shows how many units are in a city (by single clicking on the city) and then gives you the option to open the Diplomacy screen. It has been thoroughly tested.

                Script.slc code: (with 1st line split to be narrower)
                Code:
                TypeLocation location5;
                Trigger 'CheckCityUnits' when ((IsHumanPlayer(g.player)) 
                    && (clicked.city) && (city.owner != g.player)) {
                    location5 = city.location;
                    cityunits = UnitsInCell(location5);
                    Message(g.player, 'CheckCityUnitsMessage');
                    }
                //
                //
                Alertbox 'CheckCityUnitsMessage' {
                    Text(ID_CHECK_CITY_UNITS_MESSAGE);
                    Button(ID_BUTTON_CLOSE) {
                        Kill();
                        }
                    Button(ID_BUTTON_DIPLOMATIC_MENU) {
                        OpenDiplomacy();
                        Kill();
                        }
                    }
                Scen.str code: (split to be narrower)
                Code:
                CHECK_CITY_UNITS_MESSAGE "There are [cityunits.value]
                 units in the city of [city.name]."
                This is really way to powerful. I'm thinking about putting a counter in so it can only be used every so many rounds. I can modify this to make a version like you started with (only popping up when a battle starts). Also, it could be modified to tell you how many units are in a stack. Like I said, too much power here.

                Side note:
                As is, you have to click on the terrain somewhere (to deselect everything) before you click once on the city. If not, or if you click twice on the city, it automatically opens the Diplomacy menu.

                Don

                UPDATE:
                I guess you will have to narrower your code above to narrow this thread.

                [This message has been edited by skorpion59 (edited January 06, 2000).]
                Don,
                CtPMaps (Hosted by Apolyton)

                Comment


                • #9
                  Hi guys,

                  I've been working on this thing last night as well, but then on another version: here's a crude and untested first try to make a spy unit check a stack/city and show its contents.
                  I've got one question already before I start testing this: Are you sure special.singlecombat works? According to the documentation single.combat involves two single units (so no stacks). If this is true we will have to add | | special.stackedcombat to the when-clause of the trigger.

                  Code:
                  Trigger 'CheckStackContents' when (special.singlecombat && IsHumanPlayer(g.player) 
                  			&& UnitHasFlag(unit.1, VISIBILITY_CAN_SEE_4) ) { // continued from above
                        Message(g.player, 'CheckCityUnitsMessage');
                  }
                  
                  // in this alertbox all units will be checked, if they are at the same location as unit.2, 
                  // then they are added to the unit.array at the first available spot
                  // (he, this actually resembles programming   [img]http://apolyton.net/forums/smile.gif[/img])
                  Alertbox 'CheckStackContentsMessage' {
                        i =  0;
                        number = 4; // 1 stands for inspecting unit (e.g. Spy), 2 for inspected unit 
                  	 // and 3 for temporary unit (see later), so 4 is the first available spot to start with
                        while (i < player.totalunits) {
                              SetUnitByIndex(3, unit.2.owner, i); // temporary unit (see above)
                              if (unit.3.location == unit.2.location) {
                                    SetUnit(number, unit.3); // add temporary unit to array
                                    number = number + 1;
                              }
                              i = i + 1; // (this time it *should* be here and not in an else-clause   [img]http://apolyton.net/forums/smile.gif[/img])
                        }
                        // somehow list unit.4 t/m unit.number
                        Text(ID_CHECK_STACK_CONTENTS_MESSAGE);
                        EyeDropDown(4, unit); // or should it be EyeDropDown(4, unit.type) or something like that?
                        // better but tougher alternative: show pics of units
                        Button(ID_BUTTON_CLOSE) { // or ID_BUTTON_CONTINUE or whatever
                              ClearOrders(unit.1);
                              AddMovement(1, unit.1);
                              Kill();
                        }
                  }
                  I'll work on this today (but first I'll try and perfect the garrison thing, so I can't guarantee to have a working version of it tonight, but I'll try)

                  Locutus
                  [This message has been edited by Locutus (edited January 06, 2000).]
                  Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                  Comment


                  • #10
                    Locutus,
                    You are correct. Singlecombat only works when each player has one unit. That is why I did it differently.

                    I find it amazing that you can do the same thing in so many ways.

                    Dreamer,
                    Have you got any of the SLIC group emails? I have heard from all but you.

                    Don

                    [This message has been edited by skorpion59 (edited January 06, 2000).]
                    Don,
                    CtPMaps (Hosted by Apolyton)

                    Comment


                    • #11
                      WOW!!! you guys are fantastic. I have tested the special.stackedcombat, doesn't trigger even the enemy have two or more units in the same location.

                      I was actually trying these.
                      Code:
                      Trigger 'CheckUnits' when (special.attacked && IsHumanPlayer(g.player)) {
                        u = 3;
                        i = 0;
                        While (i <= player.2.totalunits) {
                          SetUnitByIndex(u, player.2, i);
                          If (unit.[u].location == city.1.location) {
                            u = u + 1;
                            cityunits = UnitsInCell(unit.2.location);
                            Message(g.player, 'CheckUnitsMessage');
                          }
                          i = i + 1;
                        }
                      }
                      Alertbox 'CheckUnitsMessage' {
                        Text(ID_CHECK_UNITS);
                        EyeDropDown(3, unit);
                        Button(ID_BUTTON_YES) {
                          Kill();
                        }
                        Button(ID_BUTTON_NO) {
                          ClearOrders(unit.1);
                          Kill();
                        }
                      }
                      I got syntax error, probably due to unit.[u].location, can't SLIC use array?

                      [This message has been edited by Dreamer (edited January 06, 2000).]

                      Comment


                      • #12
                        He Dreamer,

                        That's exactly what I started with (that unit.[u].location thing. But I thought: that will never work (didn't try it though, maybe unit.u.location will work?) so I changed it to what you see above in my trigger: you must create a temporary unit. In you're case try this (this is, BTW, not tested either but it has a much better change of working IMHO):

                        Code:
                        Trigger 'CheckUnits' when (special.attacked && IsHumanPlayer(g.player)) {
                          u = 4; // one higher because 3 will be temporary unit
                          i = 0;
                          While (i <= player.2.totalunits) {
                            SetUnitByIndex(3, player.2, i);
                            If (unit.3.location == city.1.location) { // compare temporary unit
                                                                      // with city location
                              SetUnit(u, unit.3); // add temporary unit to array
                              u = u + 1;
                              cityunits = UnitsInCell(unit.2.location);
                              Message(g.player, 'CheckUnitsMessage');
                            }
                            i = i + 1;
                          }
                        }
                        Alertbox 'CheckUnitsMessage' {
                          Text(ID_CHECK_UNITS);
                          EyeDropDown(4, unit);
                          Button(ID_BUTTON_YES) {
                            Kill();
                          }
                          Button(ID_BUTTON_NO) {
                            ClearOrders(unit.1);
                            Kill();
                          }
                        }
                        I didn't test your trigger so there could be a dozen other things wrong with it, but it looks sound. I've finished my garrison-code, I send it out to you all, so tonight/tomorrow I will have a look at this one.

                        Locutus
                        Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                        Comment


                        • #13
                          Locutus,

                          I had tested your script, there are a few things not happen during the trigger.

                          First, the special.singlecombat only trigger when both party have only 1 unit each. I tried putting 2 units to the enemy and nothing happen. Later I change to special.attacked, it works but not the followings.

                          Second, the popup message does not show the dropdown listing of units. I only get an eye button in it and clicked got no effect.

                          Third, the messagebox popup while the two units still fights, it doesn't halt the battle and ClearOders(unit.1) does not apply here.

                          Comment


                          • #14
                            Dreamer,

                            I'm working on this right now, you'll here from me. (I'm in a bit of a hurry)
                            Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                            Comment


                            • #15
                              Locutus,

                              Why don't we use clicked.unit for the trigger? Can get the player by using SetPlayer(1, unit.owner). BTW, how does EyeDropdown() works? I modify your codes a bit just to get the dropdown appear and I still see the eye button there doing nothing when clicked.
                              Code:
                              // Check no. of city units when clicked on enemy's city
                              
                              TypeUnit currentunit;
                              Trigger 'CheckUnits' when (clicked.unit && (unit.owner != g.player)) {
                                Message(g.player, 'CheckUnitsMessage');
                              }
                              
                              Alertbox 'CheckUnitsMessage' {
                                SetPlayer(1, unit.owner);
                                i = 0;
                                u = 4;
                                While ( i < player.1.totalunits) {
                                  SetUnitByIndex(3, player.1, i);
                                  If (unit.3.location == unit.location) {
                                    CurrentUnit = unit.3;
                                    SetUnit(u, CurrentUnit);
                                    u = u + 1;
                                  }
                                  i = i + 1;
                                }
                                Text(ID_CHECK_UNITS_MESSAGE);
                                EyeDropDown(4, unit);
                                Button(ID_BUTTON_CLOSE) {
                                  Kill();
                                }
                              }
                              [This message has been edited by Dreamer (edited January 08, 2000).]

                              Comment

                              Working...
                              X