Announcement

Collapse
No announcement yet.

Mod Idea

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

  • #31
    Thanks Locutus.

    Can I ask you to look at this quickly please. Any reason why it won't work?

    int_t CTC_PLAYER_COUNT;

    HandleEvent(BeginTurn) 'AOM_CivTraits' pre {
    int_t livePlayers;
    int_t i;
    int_t j;
    int_t tmpPlayer;
    city_t tmpCity;

    if (g.year == 10){

    CTC_PLAYER_COUNT= preference("NumPlayers");

    for (i=0;i if (IsPlayerAlive(i)){
    tmpPlayer = player[i];
    if (PlayerCivilization(i)==CivlizationIndex("AMERICANS")){
    for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1){
    GetCitybyIndex(tmpPlayer,j, tmpCity);
    if(CityHasBuilding(tmpCity,"IMPROVE_CAPITOL")){
    Event:CreateWonder(tmpCity, WonderDB(Wonder_SCIENCE_A));
    }
    }
    }
    elseif (PlayerCivilization(i)==CivlizationIndex("JAPANESE")){
    for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1){
    GetCitybyIndex(tmpPlayer,j, tmpCity);
    if(CityHasBuilding(tmpCity,"IMPROVE_CAPITOL")){
    Event:CreateWonder(tmpCity, WonderDB(Wonder_MILITARY_A));
    }
    }
    }
    }

    }
    }
    }

    Thanks again.

    Comment


    • #32
      Well, for one thing, this line is a little messed up:

      Code:
      for (i=0;i if (IsPlayerAlive(i)){
      I think you meant to say:

      Code:
      for (i=0; i <= CTC_PLAYER_COUNT; i = i + 1){
      	if (IsPlayerAlive(i)){
      You probably hit the delete key a couple of times without realizing it I'm not sure if this was a mistake you made when writing this code or just when posting it here (I suspect the latter), but it certainly wouldn't run like this.



      Another mistake you made is this:

      tmpPlayer = player[i];

      player[4] is NOT the 4th player in your current game, which I think you assumed. Player[4] is just a variable that needs to be given a value before it can be used. Player[0] is always given a value by the BeginTurn event: it's filled with the player who's turn it is. Player[1], player[2], etc... are all empty and meaningless in case of a BeginTurn event (actually, they're not empty as SLIC doesn't support 'empty' players, they're 0 -- the Barbarian player), though you can put a value in it yourself if you want to, just like you can with tmpPlayer or any other variable. If you want to access player 4, you can just use '4'. So this:

      tmpPlayer = i;

      would get the job done (or you could just use 'i' and get rid of 'tmpPlayer' altogether). So the working code should look like this:

      Code:
      int_t CTC_PLAYER_COUNT;
      
      HandleEvent(BeginTurn) 'AOM_CivTraits' pre {
      int_t livePlayers;
      int_t i;
      int_t j;
      int_t tmpPlayer;
      city_t tmpCity;
      
      	if (g.year == 10){
      		CTC_PLAYER_COUNT= preference("NumPlayers");
      		for (i=0; i <= CTC_PLAYER_COUNT; i = i + 1){
      			if (IsPlayerAlive(i)){
      				tmpPlayer = i;
      				if (PlayerCivilization(i)==CivlizationIndex("AMERICANS")){
      					for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1){
      					GetCitybyIndex(tmpPlayer,j, tmpCity);
      					if(CityHasBuilding(tmpCity,"IMPROVE_CAPITOL")){
      						Event:CreateWonder(tmpCity, WonderDB(Wonder_SCIENCE_A));
      					}
      				} elseif (PlayerCivilization(i)==CivlizationIndex("JAPANESE")){
      					for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1){
      						GetCitybyIndex(tmpPlayer,j, tmpCity);
      						if(CityHasBuilding(tmpCity,"IMPROVE_CAPITOL")){
      							Event:CreateWonder(tmpCity, WonderDB(Wonder_MILITARY_A));
      						}
      					}
      				}
      			}
      		}
      	}
      }
      That being said, your code can probably be simpified so that you don't even need to do that. I suspect you didn't realize that there's already a variable player.capital, so you don't really have to manually scan all cities for a capitol building. Using the player.capital variable saves a lot of work and also makes the execution of the code much more efficient. The only possible downside would be that I'm not sure what would happen in case a player doesn't have a capital (probably nothing, as in your code). So a more efficient version of the code would be this:

      Code:
      int_t CTC_PLAYER_COUNT;
      
      HandleEvent(BeginTurn) 'AOM_CivTraits' pre {
      int_t livePlayers;
      int_t i;
      int_t j;
      int_t tmpPlayer;
      city_t tmpCity;
      
      	if (g.year == 10){
      		CTC_PLAYER_COUNT= preference("NumPlayers");
      		for (i=0; i <= CTC_PLAYER_COUNT; i = i + 1){
      			if (IsPlayerAlive(i)){
      				if (PlayerCivilization(i)==CivlizationIndex("AMERICANS")){
      					Event:CreateWonder(player[i].capital, WonderDB(Wonder_SCIENCE_A));
      				} elseif (PlayerCivilization(i)==CivlizationIndex("JAPANESE")){
      					Event:CreateWonder(player[i].capital, WonderDB(Wonder_MILITARY_A));
      				}
      			}
      		}
      	}
      }

      Yet there might be even more we can do to improve your code: if I understand correctly, this code should give a unique wonder to each civ (or at least a number of civs) at the start of the game. To make sure every civs gets its wonder, you wait until turn 10 before giving these wonders, as not everyone founds their city in the first turn. However, what if by some freak accident some civ doesn't found their first city within the first 10 turns? They'll miss their wonder... Also, now players will have to go 10 turns without their wonder (which might be just what you want, but odds are you don't).

      A more elegant way to do the same thing, would be to run the code when a city is founded, not at the begin of the turn. That would simplify things even further:

      Code:
      int_t AOM_TRAITS_GIVEN[];	// keep track of to which players traits have been given (index is player)
      
      HandleEvent(CreateCity) 'AOM_CivTraits' post {
      int_t	tmpPlayer;
      city_t	tmpCity;
      	tmpPlayer = player[0];				// the player who created the city
      	tmpCity = city[0];				// the city that was just created
      
      	if (AOM_TRAITS_GIVEN[tmpPlayer] == 0) {		// if traits have not been given yet...
      		if (PlayerCivilization(tmpPlayer)==CivlizationIndex("AMERICANS")){
      			Event:CreateWonder(tmpCity, WonderDB(Wonder_SCIENCE_A));
      		} elseif (PlayerCivilization(tmpPlayer)==CivlizationIndex("JAPANESE")){
      			Event:CreateWonder(tmpCity, WonderDB(Wonder_MILITARY_A));
      		}
      		AOM_TRAITS_GIVEN[tmpPlayer] = 1;	// only do this for the first city of each player
      	}
      }
      (Disclaimer: all of this code is untested, no guarantees given)

      BTW, next time you post SLIC code, please put it between [ code ], [ /code ] tags (without the spaces), that makes it a little easier to read
      Last edited by Locutus; October 29, 2004, 08:56.
      Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

      Comment


      • #33
        Many thanks Locutus, from an amateur to a professsional.

        Currently working with two fingers and a thumb on my right hand bandaged due to a freak accident last Tuesday, sometimes don't notice the typos and it was a copy and paste error.

        I was wondering about the createcity event instead, partly for the reason you said but mainly because I expect the createWonder line will delete accrued production in that city at turn 10. Thats what happened with the createBuilding command.

        Now just need a DestroyWonder Code if a capital is captured otherwise the capturing civ will become far too powerful.

        I have already created and loaded the wonders.txt with 44 extra wonders (1 for each player) and the game did not reject it. I am sure I read somewhere that there appears to be no limit to wonders. I can refine it further by having a wonder specific for each player, e.g. ROMAN_A for the Romans that may give a couple of traits.

        One complaint I have seen is that every player is the same in CTP2. Same units, governments, techs etc.

        Code:
        HandleEvent(CaptureCity) 'MM2_DestroyBuildsOnCapture' pre {
        	city_t tmpcity;
        Just checking to see if this is what you meant. Aha, thats it, it works.

        I think this would do the job.
        Code:
        HandleEvent(CaptureCity) 'AOM_DestroyWondersOnCapture' pre {
        	city_t tmpcity;
        	int_t i;
        int_t j;
        
        	tmpcity = city[0];
        	if(CityIsValid(tmpcity)) {
        		for(i = 0; i < 44; i = i + 1) {
        		j= i + 46;	
        		DestroyWonder(tmpcity, j);
        			
        		}
        	}
        }
        46 being the number of normal wonders.

        Comment


        • #34
          Thanks muchely again.

          Comment


          • #35
            Originally posted by stankarp
            Currently working with two fingers and a thumb on my right hand bandaged due to a freak accident last Tuesday, sometimes don't notice the typos and it was a copy and paste error.
            Ouch, I'm sorry to hear that, I hope it's nothing serious.

            I was wondering about the createcity event instead, partly for the reason you said but mainly because I expect the createWonder line will delete accrued production in that city at turn 10. Thats what happened with the createBuilding command.
            Interesting, that's new for me, will have to remember that...

            I have already created and loaded the wonders.txt with 44 extra wonders (1 for each player) and the game did not reject it. I am sure I read somewhere that there appears to be no limit to wonders.
            Hmm, in theory CtP2 is only supposed to support 64 wonders, I'm surprised to hear you didn't have any trouble with that. You should certainly test all wonders carefully (especially those near the end of your wonders.txt file).

            Maybe it went okay because you only call the extra wonders through SLIC, you can't actually build them the regular way.

            I think this would do the job.
            Yeah, in theory that looks fine, but I think there may actually not be a DestroyWonder function. I could be wrong, but I can't find it anywhere in the docs. Never realized that until now...
            Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

            Comment


            • #36
              Originally posted by Locutus
              You probably hit the delete key a couple of times without realizing it I'm not sure if this was a mistake you made when writing this code or just when posting it here (I suspect the latter), but it certainly wouldn't run like this.
              HTML tags again on the for-loop < .
              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


              • #37
                Originally posted by Locutus
                That being said, your code can probably be simpified so that you don't even need to do that. I suspect you didn't realize that there's already a variable player.capital, so you don't really have to manually scan all cities for a capitol building. Using the player.capital variable saves a lot of work and also makes the execution of the code much more efficient. The only possible downside would be that I'm not sure what would happen in case a player doesn't have a capital (probably nothing, as in your code). So a more efficient version of the code would be this:
                The only problem with player.Capital is that it doesn't returns a city_t or an int_t it just returns the name of the city in other words just a string, you can use for your message boxes. The same is true for player.LargestCity.

                Originally posted by stankarp
                I have already created and loaded the wonders.txt with 44 extra wonders (1 for each player) and the game did not reject it. I am sure I read somewhere that there appears to be no limit to wonders.
                Actual it is the way arround there is a wonder limit. Well you can fill the database with more than 64 wonders, and you can build them all in your cities, but as soon as the wonders over the limit are build they disappear from the city, because they aren't saved.

                -Martin
                Civ2 military advisor: "No complaints, Sir!"

                Comment


                • #38
                  HTML tags again on the for-loop < .
                  Ah, yes, that would explain it.

                  Oh well, fair punishment for not using the code tag
                  Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                  Comment


                  • #39
                    Originally posted by Martin Gühmann
                    The only problem with player.Capital is that it doesn't returns a city_t or an int_t it just returns the name of the city in other words just a string, you can use for your message boxes. The same is true for player.LargestCity.
                    How much does that suck? I mean, the documentation even says (bolding mine):

                    The player's capital city (assign to a city variable first to use, e.g. myCapital = player[0].capital)
                    We should definitely change that in AE, if we haven't already...
                    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                    Comment


                    • #40
                      Code:
                      for(i=0;i
                      
                      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


                      • #41
                        Well, fair punishment for inadequate use of whitespace then
                        Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                        Comment


                        • #42
                          stankarp it sounds like you are creating a lot of cool SLIC. Maybe the mod section needs to be updated, or atleast we should have a place to store all these slic files to allow modders places to grab SLIC "templates" that they need...
                          Formerly known as "E" on Apolyton

                          See me at Civfanatics.com

                          Comment


                          • #43
                            Originally posted by Locutus
                            How much does that suck? I mean, the documentation even says (bolding mine):

                            The player's capital city (assign to a city variable first to use, e.g. myCapital = player[0].capital)


                            We should definitely change that in AE, if we haven't already...
                            Well this does the the wished effect:

                            Code:
                            class PlayerSymbol_Capital : public SlicStructMemberData {
                            	DEF_MAKECOPY(PlayerSymbol_Capital);
                            	BOOL GetText(MBCHAR *text, sint32 maxLen) const {
                            		sint32 pl;
                            		BOOL res = m_parent->GetDataSymbol()->GetPlayer(pl);
                            		Assert(res);
                            		if(pl>=0 && plm_capitol->GetName(), maxLen);
                            			return TRUE;
                            		}
                            		return FALSE;
                            	}
                            #if !defined(ACTIVISION_ORIGINAL)
                            	BOOL GetCity(Unit &city) const {
                            		sint32 pl;
                            		BOOL res = m_parent->GetDataSymbol()->GetPlayer(pl);
                            		Assert(res);
                            		if(pl>=0 && plm_capitol->m_id);
                            			return TRUE;
                            		}
                            		return FALSE;
                            	}
                            #endif
                            };
                            So now you can not only retrieve the city's name but also the city itsself directly.

                            So now just wonder why we had to introduce another player.government builtin, if you can overload the builtins so easily.

                            -Martin
                            Civ2 military advisor: "No complaints, Sir!"

                            Comment


                            • #44
                              Phew, havn't seen this sort of activity in slic land for a long time.

                              With a bit of luck, the Wonders will be created by slic on the turn the player capital is founded, and prevented by "enableadvance SUBNEURAL_ADVANCE" from being available to other players. So the net effect is that players only get one new wonder each, and if there were 12 players, thats 12 new wonders which takes me up to a total of 58.
                              Yeah, in theory that looks fine, but I think there may actually not be a DestroyWonder function. I could be wrong, but I can't find it anywhere in the docs. Never realized that until now...
                              In a quick look I also could not find the destroybuilding function either, but it is there in the capturecity.slc. So I am taking a punt.

                              Tested it, the punt did not work. No function as you said. I gather "WonderRemoved" triggers on a Wonder becoming obsolete?

                              So it has to be the DisbandCity function. This could be a bit tricky. The code would have to-
                              -Record the size of the city, its name, what buildings survived capturecity.slc and what wonders were there lower than wonder no 47.
                              -Reduce city size, disband city(disband size is 6 but slic may override this).
                              -recreate city, add pops, createbuildings, create wonders.

                              The use of arrays is where I fall down with my lack of experience as I assume the details would have to be saved in a temporary array.

                              Any chance of some help on this one?

                              Thanks in advance if anyone can help.

                              The other choice would be to just disband the city, give the capturing player a blob of gold and a couple of nomads as compensation.

                              One thing I am not sure of, if you capture a wonder does the effect of that wonder transfer to you. I rarely capture wonders but I do seem to recall that the ownership details in the wonderlist in rankings do not change. ie, the player name. The city changes colour to your blue, but the player name doesnt. Suppose a quick check would be to capture Lighthouse of Alexandria and see if your ships move faster. Shall do that report back.

                              Also, a wonder given through cheat mode does not show up on the wonderlist, it does in city inventory.

                              Comment


                              • #45
                                Further testing has established the following.
                                1) Wonders given in cheat mode do not appear in the wonder list in the rankings section, however, the effect is given to the player.
                                2) Wonders captured by capturing the enemy city, the name of the city where the wonder is built changes to the new player but the player (player who built it) remains as per the builder.
                                3) Captured wonders DO extend effects to the new owner.

                                Comment

                                Working...
                                X