Announcement

Collapse
No announcement yet.

any suggestions? (slic)

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

  • any suggestions? (slic)

    Im currently having my first experience programming slic, the goal is to remove that silly bug with internet wonder and computer centers still being build, when done it should work for all that type of wonders.
    here is what it does for now:

    HandleEvent(BeginTurn) 'WonderLookup' post {
    int_t i;
    int_t inetplayer;
    city_t tmpCity;

    inetPlayer = WonderOwner(WonderDB(WONDER_INTERNET));

    if(inetPlayer != -1) {
    //remove computer center from inetPlayer buildlists
    for( i = 0 ; i < PlayerCityCount(inetPlayer); i = i + 1 ){
    GetCityByIndex(inetPlayer, i, tmpCity);
    KillBuildingFromBuildList(tmpCity, BuildingDB(IMPROVE_COMPUTER_CENTER));
    }
    }
    }

    as you can see it identifies the player that owns the wonder (if any) each turn and then procedes to remove all computer centers from the build lists of all cities the player own. it works for human players and AI alike.
    i could really use a couple of tips on how to prevent computer center from appearing on the build lists at all.
    but as it is now it should still prove usefull, i hate going trough all my build lists and manually removing buildings when i build such a wonder.


  • #2
    I'm way ahead of you, kaan, you're reinventing the wheel. I already fixed that bug for the MedMod a few weeks ago (and in a much more elegant way too, if I may say so myself). Check out the MM2_scenario.slc file for my solution.

    It looks like you could be a good SLIC coder though, we could use more people like you on these forums...
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

    Comment


    • #3
      hmmm, ill look it up.
      meanwhile look at my solution to the problem, its a bit bulky but ill slimm it down later.

      HandleEvent(BeginTurn) 'WonderLookup' post {
      // general vars
      int_t i;
      int_t hasrunonce;
      int_t adv;
      city_t tmpCity;

      // vars for internet fix
      int_t B;
      int_t inetPlayer;
      int_t oldInetPlayer;

      // vars for national shield fix
      int_t C;
      int_t shieldPlayer;
      int_t oldShieldPlayer;

      // vars for central matter decompiler fix
      int_t D;
      int_t compPlayer;
      int_t oldCompPlayer;

      // vars for hagnia sophia fix
      int_t E;
      int_t hagnPlayer;
      int_t oldHagnPlayer;

      if(hasrunonce != 0){
      oldInetPlayer = -2;
      oldShieldPlayer = -2;
      oldCompPlayer = -2;
      oldHagnPlayer = -2;
      hasrunonce = 0;
      }

      inetPlayer = WonderOwner(WonderDB(WONDER_INTERNET));
      adv = AdvanceDB(ADVANCE_BUGFIX_B);

      if(inetPlayer == -1 && oldInetPlayer != -2){
      // see if wonder has been destroyed, then clean up
      RemoveAdvance(oldInetPlayer, AdvanceDB(ADVANCE_BUGFIX_B));
      oldInetPlayer = -2;
      }

      if(inetPlayer != -1 && inetPlayer != oldInetPlayer) {
      // see if a new player has the wonder, then sell buildings
      // then remove building from lists and clean up
      B = 0;
      for( i = 0 ; i < Cities(inetPlayer); i = i + 1 ){
      GetCityByIndex(inetPlayer, i, tmpCity);
      if(CityHasBuilding(tmpCity, "IMPROVE_COMPUTER_CENTER")){
      B = B + 1200;
      }
      }
      AddGold(inetPlayer, B);
      if(oldHagnPlayer != -2){
      RemoveAdvance(oldInetPlayer, adv);
      }
      GrantAdvance(inetPlayer, adv);
      oldInetPlayer = inetPlayer;
      }

      shieldPlayer = WonderOwner(WonderDB(WONDER_NATIONAL_SHIELD));
      adv = AdvanceDB(ADVANCE_BUGFIX_C);

      if(shieldPlayer == -1 && oldShieldPlayer != -2){
      // see if wonder has been destroyed, then clean up
      RemoveAdvance(oldShieldPlayer, AdvanceDB(ADVANCE_BUGFIX_C));
      oldShieldPlayer = -2;
      }

      if(shieldPlayer != -1 && shieldPlayer != oldShieldPlayer) {
      // see if a new player has the wonder, then sell buildings, then remove building from lists and clean up
      C = 0;
      for( i = 0 ; i < Cities(shieldPlayer); i = i + 1 ){
      GetCityByIndex(shieldPlayer, i, tmpCity);
      if(CityHasBuilding(tmpCity, "IMPROVE_FORCEFIELD")){
      C = C + 5000;
      }
      }
      AddGold(shieldPlayer, C);
      if(oldHagnPlayer != -2){
      RemoveAdvance(oldShieldPlayer, adv);
      }
      GrantAdvance(shieldPlayer, adv);
      oldShieldPlayer = shieldPlayer;
      }

      compPlayer = WonderOwner(WonderDB(WONDER_CENTRAL_MATTER_DECOMPI LER));
      adv = AdvanceDB(ADVANCE_BUGFIX_D);

      if(compPlayer == -1 && oldCompPlayer != -2){
      // see if wonder has been destroyed, then clean up
      RemoveAdvance(oldCompPlayer, AdvanceDB(ADVANCE_BUGFIX_D));
      oldCompPlayer = -2;
      }

      if(compPlayer != -1 && compPlayer != oldCompPlayer) {
      // see if a new player has the wonder, then sell buildings, then remove building from lists and clean up
      D = 0;
      for( i = 0 ; i < Cities(compPlayer); i = i + 1 ){
      GetCityByIndex(compPlayer, i, tmpCity);
      if(CityHasBuilding(tmpCity, "IMPROVE_MATTER_DECOMPILER")){
      D = D + 2250;
      }
      }
      AddGold(compPlayer, D);
      if(oldHagnPlayer != -2){
      RemoveAdvance(oldHagnPlayer, adv);
      }
      GrantAdvance(compPlayer, adv);
      oldCompPlayer = compPlayer;
      }

      hagnPlayer = WonderOwner(WonderDB(WONDER_HAGIA_SOPHIA));
      adv = AdvanceDB(ADVANCE_BUGFIX_E);

      if(hagnPlayer == -1 && oldHagnPlayer != -2){
      // see if wonder has been destroyed, then clean up
      RemoveAdvance(oldHagnPlayer, AdvanceDB(ADVANCE_BUGFIX_E));
      oldHagnPlayer = -2;
      }

      if(hagnPlayer != -1 && hagnPlayer != oldHagnPlayer) {
      // see if a new player has the wonder, then sell buildings, then remove building from lists and clean up
      E = 0;
      for( i = 0 ; i < Cities(hagnPlayer); i = i + 1 ){
      GetCityByIndex(hagnPlayer, i, tmpCity);
      if(CityHasBuilding(tmpCity, "IMPROVE_SHRINE")){
      E = E + 135;
      }
      }
      AddGold(hagnPlayer, E);
      if(oldHagnPlayer != -2){
      RemoveAdvance(oldHagnPlayer, adv);
      }
      GrantAdvance(hagnPlayer, adv);
      oldHagnPlayer = hagnPlayer;
      }
      }

      Comment


      • #4
        hmmmmm an unducumentet function call with a very long "case of" (switch, whatever its called in your local programming language).
        very nice :-)

        a note to the above,
        i have added to buildings.txt :
        ObsoleteAdvance ADVANCE_BUGFIX_"X"
        for those building that apply
        and added techs to advance.txt as follows

        ADVANCE_BUGFIX_A {

        Prerequisites ADVANCE_BUGFIX_F

        Cost 36272
        Icon ICON_ADVANCE_QUANTUM_MECHANICS
        Branch 0
        Age AGE_ONE
        GLHidden
        }

        ADVANCE_BUGFIX_B {

        Prerequisites ADVANCE_BUGFIX_A

        Cost 36272
        Icon ICON_ADVANCE_QUANTUM_MECHANICS
        Branch 0
        Age AGE_ONE
        GLHidden
        }

        ADVANCE_BUGFIX_C {

        Prerequisites ADVANCE_BUGFIX_A

        Cost 36272
        Icon ICON_ADVANCE_QUANTUM_MECHANICS
        Branch 0
        Age AGE_ONE
        GLHidden
        }

        ADVANCE_BUGFIX_D {

        Prerequisites ADVANCE_BUGFIX_A

        Cost 36272
        Icon ICON_ADVANCE_QUANTUM_MECHANICS
        Branch 0
        Age AGE_ONE
        GLHidden
        }

        ADVANCE_BUGFIX_E {

        Prerequisites ADVANCE_BUGFIX_A

        Cost 36272
        Icon ICON_ADVANCE_QUANTUM_MECHANICS
        Branch 0
        Age AGE_ONE
        GLHidden
        }

        ADVANCE_BUGFIX_F {

        Prerequisites ADVANCE_BUGFIX_A

        Cost 36272
        Icon ICON_ADVANCE_QUANTUM_MECHANICS
        Branch 0
        Age AGE_ONE
        GLHidden
        }

        Comment


        • #5
          Well, it's undocumented but it's frequently used in the official Activision scenario's, so you could easily have known about it. There's a lot more to learn about SLIC from examples of the code (the Activision scenarios, the MedMod, the Diplomod, etc) than from the documentation.

          What *are* you trying to do with that enourmous chunk of code? It seems like you're giving whoever owns the building-wonders a special advance and as soon as the wonder changes owner, you give the new owner a certain amount of money for every accompanying wonder-building he owns. What's the advance good for? Why give money to the new owner? If you're trying to sell the buildings it would be much better to actually destroy the building as well using the event DestroyBuilding or do it differently altogether by calling the event SellBuilding, which takes the money-part out of your hands altogether. In that case, the code would look something like this:

          Code:
          		for( i = 0 ; i < Cities(inetPlayer); i = i + 1 ){
          			GetCityByIndex(inetPlayer, i, tmpCity); 
          			if(CityHasBuilding(tmpCity, "IMPROVE_COMPUTER_CENTER")){
          				Event:SellBuilding(tmpCity, BuildingDB(IMPROVE_COMPUTER_CENTER));
          			}
          		}
          And the AddGold and B variable could be left out entirely. Note that I didn't test this and that I'm not sure if this is actually your intention, but I *think* it does what you're looking for.
          Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

          Comment


          • #6
            thats exacly what that piece of code is used for :-) thanks for pointing the actual procedure out.

            the key to the fix is as you noted the "bugfix" advances. they refer only to themselves and dont appear in great library, so the player wont notice them unless they cheat.
            these advances makes the computer center (or whatever) obsolete.
            if we take the internet example then the timeline is as follows

            this is only a crude model of my script, but a picture can sometimes say more than a thousand words ;-)

            klaus

            Comment


            • #7
              Ah, it seems like we have another RRose user (right?) in the house I think you just scared away any non-CS students and non-ITers that might have been following this thread

              Ok, now I get it. But in that case you're probably better off with my solution: that keeps the units out of the buildqueues as well but without all the hassle, a simple if-clause does the trick there. But of course, you already wrote this so I can see how you might want to keep it, it seems like it would work just as well as my solution.
              Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

              Comment


              • #8
                As we say in school, RRR (Rational Rose Rules), and those non techies were scared long time ago ;-)

                assuming that both solutions works equally well, and only playtesting will show that, the only difference between the two scripts could be effeciency and since that is impossible to determine without the .exe source then we will never know. but most likely is that an undocumentet feature from activision has been tested to be efficient, then again, what did they really test before shipping ;-)

                I also admit that your solution is much more elegant and easyer to use for most people.

                klaus kaan
                [This message has been edited by kaan (edited March 29, 2001).]

                Comment

                Working...
                X