Announcement

Collapse
No announcement yet.

SLIC - Units in City

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

  • #16
    Dreamer,

    What exactly is going on? I don't see any problems with this. I don't know how much you know so I will start at the basics.

    An EyePoint selects and centers on a unit.
    An EyeDropdown supplies a list of EyePoint locations so you can select 1 to apply the EyePoint to (in English, you pick 1 to go to).

    EyePoint Syntax: EyePoint(Location)
    EyeDropdown Syntax: EyeDropdown(StartIndexNumber, ListVariable)
    ListVariable can be any BuiltIn variable that can be used as a list. (Currently that is Unit, City or Discovery. Unit & City provide locations while Discovery provides research items. Hmm, research item huh?)

    If you click on ONLY 1 unit, it automatically selects it. Since this is what EyePoint is for, it has already been done so EyeDropdown does not have to do anything. Thus no list is produced. You can still click on the EyePoint in the AlertBox but you won't be able to tell anything is happening. So just close the box out.

    If you click on 2 or more units, the Alertbox has the normal EyePoint PLUS a dropdown list to the right of that. Clicking on the dropdown list brings up the list of units in that tile. When you click on one of the selections, it selects that unit. Open the dropdown list again, select another units and it selects that one. You can keep doing this until you close the Alertbox.

    Since you are using this to find out how many units are in a stack, you are going to have to put that information in your ID message. If you don't, the users are not going to have any idea what is going on.

    I assume you want it done this way so you can actually see what unit it is, right?


    Now for the bad part.

    You will have to go back to using the spy if you want it done this way. Clicked.Unit won't work on cities, only tiles. When you click on a city, Clicked.City gets activated instead.

    When you decide exactly what you want to do, let me know. If you want to use Clicked.City, we are going to have to merge what you want in with the Clicked.City code I have. Since you weren't interested in my code above, I took Clicked.City into a whole new realm all its own.

    Don

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

    Comment


    • #17
      Dreamer,

      Originally posted by Dreamer on 01-08-2000 02:25 AM
      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.
      Actually, I was planning on doing just that (using clicked.unit) from the beginning, but when you came up with that special.singleattack thing or whatever it was, I thought I'd give that a try first. Right now, all the testing I'm doing I'm doing with unit.sighted, so I'll be sure the trigger triggers at all, I'll worry on making it trigger at the right moment (unit.attacked, clicked.unit, whatever) later. One step at a time is my philosophy in programming (and I can recommend it to anyone).

      About the EyeDropDown, until Don posted his explanation I didn't knew how it worked. It's nowhere in the doc's that I have (that's why I need your's so much, Don) but I think we should be able to get it all to work now Don has explained a few things. I'll keep trying as well, but I still have a project for my study to finish that should have been finished two weeks ago, so I don't have too much time this weekend. If you don't get it to work before I finished my project I'll put all my time in helping you, since I really like this option myself. What would you think of displaying the icons of the units and some statistics (such as health, movementfactor, etc.) instead of a simple dropdownlist? I don't know how to do this yet, but maybe we can find out or someone else knows?

      See ya,

      Locutus

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

      Comment


      • #18
        Locutus,

        Go back and read my last post from 'Now for the bad part'.

        I was editing it at the same time you were posting and you missed that part. I didn't catch you were planning on trying to use Clicked.Unit on a city until I reread it.

        Also, most of the information you mentioned is already in my Clicked.City code. And the new SLIC docs are about done.

        Don
        Don,
        CtPMaps (Hosted by Apolyton)

        Comment


        • #19
          skorpion59,
          Well it all started were I wanted to check no. of units in enemy city, with your help we made it. Regarding the problem to open up Diplomacy Window, I found out that is just a missing string to address the button ID, so is fixed now.

          Later after seeing Locutus script that his idea were to view enemy units in stack not only in city but on the field. Both Locutus and I were thinking of using the EyeDropdown() to list the unit name.

          Now after seeing your message, then I know it is actually passing unit location into the dropdown list. What a bad news, like what Locutus had said "It's nowhere in the doc's that I have (that's why I need your's so much, Don)."

          Locutus,
          You mentioned "What would you think of displaying the icons of the units and some statistics (such as health, movementfactor, etc.)"

          Err....thinking that these is going to be a major one. Anyway, I'll try.

          Comment


          • #20
            All,

            Hurray!!! It works now even in Alertbox(). Locutus, there is nothing much I change in your script just renaming of variable name and changed the trigger container to clicked.unit as example from skorpion59's clicked.city.

            I have included a slaver in the stacked unit during testing and it is shown in the list dropdown. So what you guys think, good or bad?

            Here's the trigger :-
            Code:
            // Check contents of stacked units
            Trigger 'CheckStackContents' when (clicked.unit && (unit.owner != g.player)) {
              Message(g.player, 'CheckStackContentsMessage');
            }
            Alertbox 'CheckStackContentsMessage' {
              SetPlayer(1, unit.owner);
              i = 0;
              u = 4;
              while (i < player.1.totalunits) {
                SetUnitByIndex(3, player.1, i);
                if (unit.3.location == unit.location) {
                  SetUnit(u, unit.3);
                  u = u + 1;
                }
                i = i + 1;
              }
              Text(ID_CHECK_STACK_CONTENTS_MESSAGE);
              EyeDropDown(4, unit);
              Button(ID_BUTTON_CLOSE) {
                Kill();
              }
            }

            Comment


            • #21
              skorpion59,

              With the success of the above ""Stacked Unit Trigger", the "Check City Units Trigger" should be as follows :-
              Code:
              // Check no. of enemy units in city upon clicking
              Trigger 'CheckCityUnits' when (clicked.city && (city.owner != g.player)) {
                cityunits = UnitsInCell(city.location);
                Message(g.player, 'CheckCityUnitsMessage');
              }
              
              Alertbox 'CheckCityUnitsMessage' {
                SetPlayer(1, city.owner);
                i = 0;
                u = 4;
                while (i < player.1.totalunits) {
                  SetUnitByIndex(3, player.1, i);
                  if (unit.3.location == city.location) {
                    SetUnit(u, unit.3);
                    u = u + 1;
                  }
                  i = i + 1;
                }
                Text(ID_CHECK_CITY_UNITS_MESSAGE);
                EyeDropdown(4, unit);
                Button(ID_BUTTON_CLOSE) {
                  Kill();
                }
              }

              Comment


              • #22
                Looking good guys. I always enjoy seeing the fruits of my labor pay off. Apparently, you do to. That is one reason I enjoy programming so much. Of course, then I look at it and say, 'That was easy, why didn't I think of that in the first place'. Oh well, that's life.

                *Hiding my head in shame*
                Now I must apologize to you and anybody following this thread. I had been up 20 hours when I started my last thread so I wasn't quit thinking right. So, to clarify...
                You CAN have multiple triggers triggering off the same trigger. Either by having multiple Clicked.City triggers or by having 1 Clicked.City trigger with multiple MessageBoxes. Sorry about that.


                ------------------
                Don, Apolyton Junkie

                Don,
                CtPMaps (Hosted by Apolyton)

                Comment


                • #23
                  All,

                  Let me pass along another little bit of info. You might already know this but it has bit me before.

                  Variables used in triggers are evaluated according to the 'Lowest Common Denominator' therory. Triggers are associated with 1 variable only and that is the one with the lowest common denominator. No other variables are even looked at until the 'LCD' variable has triggered.

                  Now in English. Say you are checking city.built and unit.built in a trigger. Unit.built is the 'LCD' so this trigger gets placed in the unit.built trigger queue. (It is in no way associated with the city.built trigger queue at this point in time. If you never build a unit, this trigger will never be evaluated. Even if you DO build a city.) Okay, now you go build a unit. It goes through the unit.built queue and comes across this trigger. If the unit.built expression is met, it will then, and only then, evaluate the city.built expression. If both expressions are met, it will now execute this trigger. If both are not met, it will not execute this trigger.

                  Hopefully this will save you some future frustration.

                  ------------------
                  Don, Apolyton Junkie

                  Don,
                  CtPMaps (Hosted by Apolyton)

                  Comment


                  • #24
                    Don,
                    Thanks for pointing that out, I would have never noticed the edited part if you hadn't said it, while it contains some important info. I do think we should include the units present in a city in your clicked.city thing. I will concentrate on the units in the field. Do you have some code on the clicked.city thing already? I'd be interested in seeing that if you have. It doesn't have to be finished or working or anything.
                    I don't have to tell you how glad I am that you've almost finished the docs, I've been whining about it like crazy ever since you first mentioned it.

                    Dreamer,
                    I don't see why the passing of the unit-location into the dropdown list is such bad news. It can still work, take a look at the code under this text. It works now - only the when-clause of the trigger isn't right yet, but I don't think that's much a problem.
                    About the icons and statistics, that is not easy, I know, but with a lot of research and perhaps some help from others with more experience in this area we might get it done. It would be great if we could pull it off, don't you think?

                    Later,

                    Locutus

                    Code:
                    ////////// Check contents of stack //////////
                    // Not the final trigger yet, should be "&& unit.clicked" or something
                    // We'll see about that later
                    Trigger 'CheckStackContents' when (unit.sighted && IsHumanPlayer(g.player) 
                                     && (unit.2.type == UnitType("UNIT_SPY") ) ) { // continued from above
                          Message(g.player, 'CheckStackContentsMessage');
                    }
                    
                    // in this alertbox all units will be checked, if they are at the same location as unit.1, 
                    // 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])
                    Messagebox 'CheckStackContentsMessage' {
                    // why won't this work with an alertbox? Oh well, at least it works...
                          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.owner, i); // temporary unit (see above)
                                if (unit.3.location == unit.1.location) {
                                      SetUnit(number, unit.3); // add tempory unit to array
                                      number = number + 1;
                                }
                                i = i + 1;
                          }
                          Text(ID_CHECK_STACK_CONTENTS_MESSAGE);
                          EyeDropDown(4, unit);
                          // better but tougher alternative: show pics of units
                          Button(ID_BUTTON_CLOSE) {
                                Kill();
                          }
                    }
                    [This message has been edited by Locutus (edited January 08, 2000).]
                    [This message has been edited by Locutus (edited January 08, 2000).]
                    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                    Comment


                    • #25
                      Don't remind me now, remind me when I'm stuck and I've completely forgotten about this
                      Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                      Comment


                      • #26
                        Dreamer,

                        I found some time to try out your trigger and it works great. A few minor issues though:

                        I think we should add a message if there's only one unit. Now the EyeDropDown doesn't appear, which is sort of ugly. This is what happens now:

                        Code:
                           |-----------------------------------------------|
                           |                                               |
                           | This stack contains of the following units:   |
                           |                                               |
                           |                                               |
                           |                                               |
                           |                                               |
                           |-----------------------------------------------|
                        It's a minor thing but still... It can easily be resolved like this (didn't test it, but it can't contain many errors):

                        Code:
                        Trigger 'CheckStackContents' when (clicked.unit && (unit.owner != g.player)) {
                           if (UnitsInCell(unit.location) > 1) {
                              Message(g.player, 'CheckStackContentsMessage');
                           } else {
                              Message(g.player, 'OnlyOneUnit');
                           }
                        }
                        
                        Altertbox 'OnlyOneUnit' {
                           Text(ID_ONLY_ONE_UNIT_MESSAGE);
                           Button(ID_BUTTON_CLOSE) {
                              Kill();
                          }
                        }
                        Besides that I discovered another ugly bug. Once you've clicked on an enemy unit, you must first click on one of your own units before you can click on another enemy stack and see it's contents. I doubt this can be resolved though.

                        Also I think the ability to see the contents of a stack should be limited to spy-like units (Spy, Cyber Ninja, Diplomat, etc.) What do you guys think of this?

                        Later,

                        Locutus

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

                        Comment


                        • #27
                          Locutus,

                          I don't have the problem of clicking own unit before clicking enemy unit. All you need is to left click on any empty tile before clicking next enemy, seems like there is a invisible selected frame there when clicking enemy unit or city, just like when we click on our own unit or city.

                          I think is fair to view enemy stacks without spy etc. I believe the AI do know what units are within our stacks too.

                          Comment


                          • #28
                            The terrain click is required because you have to deselect an object before you can select (click) it. (See Side Note above.)

                            Personally, I don't think you should have to only use a spy to get the info. The computer cheats and knows exactly what we have and where we have it. (Why else does the barbarians mysteriously appear right next to the city with no defenders instead of next to the city with 4 defenders.)

                            From a gamer standpoint, clicking on a stack and getting the info would probably be to powerful. I think the average person would think just the spy should have this ability. At least until the AI learns how to fight and defend better. Hopefully, auto-upgrading the AI Garrison units will make this a moot point.

                            ------------------
                            Don, Apolyton Junkie

                            Don,
                            CtPMaps (Hosted by Apolyton)

                            Comment


                            • #29
                              Originally posted by Dreamer on 01-09-2000 11:20 PM
                              I think is fair to view enemy stacks without spy etc. I believe the AI do know what units are within our stacks too.
                              I wasn't aware of that, well in that case I change my opinion. I guess we could make people choose (with my setup program) if they want to limit the ability to see stack-contents to spy-like units or not.

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

                              Comment


                              • #30
                                Any chance of extending this to the spy plane/spy satelite too? And while your at it, you could include the 'investigate city' function too. This is something I feel is quite a major omission.... It doesn't have to have a 100% chance of success (e.g. as a result of cloud cover etc.), but it should be fairly high.

                                Dan

                                ------------------
                                Just a thought......

                                Just a thought......

                                Comment

                                Working...
                                X