Announcement

Collapse
No announcement yet.

Slic

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

  • #46
    Hi Ben,

    Can you see why my code above does not work, something to do with the declarations again.

    Thanks if you can help.

    Comment


    • #47
      Phew, problem figured out. I recommend anyone who wants to write slic should seek a medical opinion first, it is very, very frustrating.

      The problem is that, I am 99% sure, you cannot build a building in a city in the turn the city is created. I eventually added a getcitybyindex loop to my code and still did not get a building, then had a thought and created cities on successive turns. The city created the previous turn then got the building.

      Comment


      • #48
        Try destroying a building and moding settlers to make it on city creation.

        Hint: look at urban planers unit entry.
        "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
        The BIG MC making ctp2 a much unsafer place.
        Visit the big mc’s website

        Comment


        • #49
          Thanks Big Mc,

          However, that will involve a different settler type for each wonder that provides buildings, and restricitng that unit ala med mod or AG scenario to the player with the wonder. Then you would need one nomad type for each possible combination of wonders, eg,

          has VOK but not HG and HW, or has HG but not HW and VOK, etc, etc, etc.

          I now have it all worked out except that the last city built by the wonder owner does not have the building, since its lev 1, plenty of time to build the buildings and its not critical to that city that is does not have the wonder.

          The reason why I persevered with this is I am sure that building effect supplied by a wonder, does not mean the city has the building if you do a hasbuilding check, such as in the disaster code.

          Comment


          • #50
            Code:
                TOTAL_COST=((NUM_OBS_UNITS)*PER_UNIT_UPDATE_COST[UPDATE_TYPES_ARRAY[UPDATE_TYPES_INDEX]]);
                if (TOTAL_COST <= Playergold(player[0]) && (NUM_OBS_UNITS ==1) ){
                           //special case: slightly different message and text
            	 
            	 message(player[0], 'ObsUnitsCostOKand1unit');    	     
                }
                elseif (TOTAL_COST <= PlayerGold(player[0]) && (OBS_UNIT_ARRAY.# >1) ){
            	 
            	 message(player[0], 'ObsUnitsCostOK');    	     
                }
                else {
            	 message(player[0], 'ObsUnitsCostNotEnoughGold');
                }
                
            }
            I found the updater only address gold, should I just copy this code for PW and the iron score or do they have to be all together?
            Formerly known as "E" on Apolyton

            See me at Civfanatics.com

            Comment


            • #51
              That depends. From what I remember of the code, the messages called above lead into the main updating sequence. If you simply copied that for PW and resource points, it would try and update three times, horrible things would happen.

              What I think you need to do is to work out before that block of code the total cost in gold, PW and iron points (and this will probably involve two more arrays similar in form and function to PER_UNIT_UPDATE_COST[]), work out if any of the three resources (gold, pw, iron) are too small to do the whole lot, and then message accordingly. If two (or all three) resources are too small, you'll have to message the player using the least one I guess.
              The good news is that you might be able to hijack the existing messages once you have worked that out, using variable string text to tell the player which resource is limited, and then use the same updater code.
              If none of the three things are limited, you need the code to go into the "enough gold" loop. And of course, alll the messages will have to be changed to tell the player how much public works he's putting into the updating so that he/she can tell the code when to stop.
              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


              • #52
                Very Quick Question

                Does reloadslic reset global variables?

                Comment


                • #53
                  E,

                  this bit of code searches the map for a particular tile_imp belonging to the each player.

                  if(IsHumanPlayer(player[0])){ // once each player-cycle. This means that AI players will get gold early, but
                  // it saves scanning the map 8 times
                  for(i=0; i < GetMapWidth(); i = i + 1){
                  for(j=0; j < GetMapHeight(); j = j + 1){
                  MakeLocation(tmpLoc,i,j); // scan map for locations
                  if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_OUTPOST))){ // if it's a outpost
                  if(CellOwner(tmpLoc)){ // and owned
                  AddGold(CellOwner(tmpLoc),10); // gift some gold
                  }
                  if(CellOwner(tmpLoc)){
                  if (HasGood(tmpLoc)>=0){
                  AddGold(CellOwner(tmpLoc),10);
                  }
                  }

                  Note, it does not have the right number of "}" at the end of code, its copy and paste job from part of a 30 page code.

                  Comment


                  • #54
                    Forgot, adds 10 gold for the tile_imp and another 10 gold if there is a good there.

                    Comment


                    • #55
                      Yeah, but an easier way to do that, since you only need to check city radii would be to do as HasGood call first, which identifies if you even need to scan the city, and then use BlueO's or Pedrunn's city-radius scanning pattern to check for the tile improvement.

                      Yes, reloadslic does reset globals.
                      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


                      • #56
                        Hi Ben,

                        Any idea how to maintain a separate in game score that wont reset with reloadslic. I have set up a system that adds to a global variable when-
                        a) a capital is captured,
                        b) a AI is killed.
                        c) a wonder is built
                        then once per 100 turns, adds that value to a score worked out on number and size of cities. This gives a score and an appropriate message to the human player and displays the score.

                        The problem, if I have to reloadslic for the occassional crash, the score resets to 0.

                        Comment


                        • #57
                          Actually, I figured out how to do it, as long as local variables are not reset to 0 with a reloadslic.

                          Instead of simply having a line
                          score = score +25;
                          in each part of code where I want the score to increase, replace it with a function that simply adds 25 to a variable inside the function then writes it to the global variable. That way if the global variable is reset, it gets updated next time the score function is run.

                          So the simple question is, do local variables reset to 0 with reloadslic?

                          Comment


                          • #58
                            Answered my own question with a test, local variables do reset with reloadslic, even inside a function.

                            So back to Ben for any ideas. Sigh.

                            Comment


                            • #59
                              Don't reloadslic.
                              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


                              • #60
                                Immortal Wombat "Don't reloadslic. "

                                Wish it was that easy but I am getting an ocasional crash betwen turns 200-300. Its a bit wierd, will start keeping a record of them, but the ones where I have to reloadslic almost always seem to be the same AI player, think its no 5. I get an occasional other one but I think thats a windows thing, I am on Directx 9 now and suspect that might cause it.

                                I have worked out a way to calculate the score from scratch each time, using a tilimprovement check , a visible wonder check from a map scan, then a wonder check for other wonders. The trick was capturing enemy capitals and killing an AI. So I created a monument for each one, which is built when you achieve that, then the map scan picks it up. Havn't quiet perfected the code that places the monument following the event.

                                Thats really testing my limited skill.

                                Comment

                                Working...
                                X