Announcement

Collapse
No announcement yet.

I want to kill exactly 7 people. Volunteers?

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

  • I want to kill exactly 7 people. Volunteers?

    Ok, now that I have your attention...

    I want to kill exactly 7 (or 7 percent) of my adoring citizens from one my cities using SLIC. Obviously, if I'm feeling less benevolent, I want to be able to edit the SLIC file and change this value to say 351, or whatever strokes my fancy at that time.

    Don't ask me why I want to do this. Let's just say I don’t like their attitudes.

    The bit of the code I'm using at the moment (stolen from IW; Peter Triggs et al - thanks guys ):

    int_t tmpDead;
    int_t tmpCounter;
    city_t tmpCity;

    city[0] = tmpCity;

    tmpDead = city[0].population/10;

    for (tmpCounter = 0; tmpCounter < tmpDead; tmpCounter = tmpCounter + 1) {
    Event:KillPop(tmpCity);
    }

    This doesn't quite do what I'm looking for. Can anybody help?
    If something doesn't feel right, you're not feeling the right thing.

  • #2
    i dont thinck its posible because you are dividing integers. it wont work becase after division the number is rounded up to the nearest hole number so a city with a pop of 15 will lose .5 of the pop more then your 7%.
    "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


    • #3
      That should kill of 10% of the population, though you'd need to put it into an event handler, depending on when you wanted them to die. If it's every turn, you need a handler that fires every turn. For simplicity's sake, if you wanted to do every city, the line:
      Code:
      HandleEvent(BeginCityTurn) 'kill10pcpt' pre{
      // kill stuff code as above
      }
      at the beginning would kill of 10% from every city in the game.

      If you want a specific city (Don't know how you want to choose which one) you'll need either its name or its index. eg. for the capital, use this:

      Code:
      HandleEvent(BeginCityTurn) 'kill10pcpt' pre{
      if(IsHumanPlayer(player[0]))  // the human
            city_t  tmpCity;
            GetCityByIndex(player[0], 0, tmpCity);  // store your capital 
            if(tmpCity == city[0]){
                 // insert kill stuff code here
            }
      }
      }

      If you want to kill 7 citizens, simply use your code, but replace
      Code:
      tmpDead = city[0].population/10;
      with
      Code:
      tmpDead = 7;
      To get 7%, use:
      Code:
      tmpDead = city[0].population*7;
      tmpDead = tmpDead/100;
      Done separately to avoid rounding errors when SLIC tries to do fractions (it can't).

      hope this helps, and is comprehensible
      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
        /me realsies there's a good chance you knew most of that, and are getting rounding errors*
        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


        • #5
          wombat does this mean you are volunteering!
          "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


          • #6
            Thanks Big Mc and IW for your help and suggestions. As always, much appreciated.

            Unfortunately, I still cannot wreak my revenge on exactly 7 lucky individuals. Here’s why:

            * Create a SLIC with the code as suggested, and set tmpDead to 7 (tmpDead = 7;
            * Add the SLIC to script.slc blah-blah-blah;
            * Create a new game;
            * Build a city and cheat it to population size 10 (just so we’re clear - when I say population size, I mean the number below the city name.)

            You should now be the proud owner of a city with 100 000 inhabitants! (Even though I suck at math), the city should grow by: 100 000 + growth - 7;

            Right?

            Wrong. (End the turn.)

            Whoa! The city now has +/-30 000 people! Where have 69 993 folks disappeared to?

            Instead of inflicting my benevolent rule on exactly 7 people - I’ve now slaughtered them and their entire family and all their friends and all their friends’ family and their bank managers and their family and the guy that delivers the paper and his family and the dude that tries to wash your car at a red light and his family and their neighbours and their family and their neighbours’ neighbours and their families and… you get the picture.

            It seems Event:KillPop(tmpCity); doesn’t use the city population, instead, it uses the population number. (If I’ve just said something that everybody else already knew - ignore it.)

            Nevertheless, the question still stands. How do I kill exactly 7 people?
            If something doesn't feel right, you're not feeling the right thing.

            Comment


            • #7


              DoT i sure hope you can sleep easy at night. I suppose you could put it down to a catastrophic government mistake......some experiment gone wrong, either way i wouldn't want to be one of your citizens during this experiment, I have a feeling more may perish
              'The very basis of the liberal idea – the belief of individual freedom is what causes the chaos' - William Kristol, son of the founder of neo-conservitivism, talking about neo-con ideology and its agenda for you.info here. prove me wrong.

              Bush's Republican=Neo-con for all intent and purpose. be afraid.

              Comment


              • #8
                Code:
                (...)
                	for(i=0; i > 7; i = i + 1) {
                		Event:KillPop(tmpCity); 
                	}
                (...)
                or

                Code:
                (...)
                	AddPops(tmpCity, -7);
                (...)
                "Kill a man and you are a murder.
                Kill thousands and you are a conquer.
                Kill all and you are a God!"
                -Jean Rostand

                Comment


                • #9
                  It seems Event:KillPop(tmpCity); doesn’t use the city population, instead, it uses the population number.
                  Yes... 'fraid so.

                  So 7 people rather than 7 pop points? That's much harder. Very little SLIC deals with the actual population. Um...

                  Probably the best way is to plant some sort of tile improvement to fine tune the actual growth of the city. I don't know if it would work properly.

                  Can I ask why you would wish to?
                  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


                  • #10
                    The city now has +/-30 000 people! Where have 69 993 folks disappeared to?
                    I just saw this
                    sorry it is impossibe (I think)
                    "Kill a man and you are a murder.
                    Kill thousands and you are a conquer.
                    Kill all and you are a God!"
                    -Jean Rostand

                    Comment


                    • #11
                      it is possible but only in a msg box.
                      "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


                      • #12
                        how???
                        "Kill a man and you are a murder.
                        Kill thousands and you are a conquer.
                        Kill all and you are a God!"
                        -Jean Rostand

                        Comment


                        • #13
                          very easy indeed but i have to run for the bus now sea you tomorrow after 2.30pm gmt.
                          "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


                          • #14
                            "Kill a man and you are a murder.
                            Kill thousands and you are a conquer.
                            Kill all and you are a God!"
                            -Jean Rostand

                            Comment


                            • #15
                              the title really tight but i dont uderstand anything u guy said

                              Comment

                              Working...
                              X