Announcement

Collapse
No announcement yet.

Script.slc Question

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

  • Script.slc Question

    I was looking through the LOTR code, and noticed there's a LOTR_script.slc file in both the \Scenarios\War of the Ring\scen000x\default\gamedata and in the \ctp2_data\default\gamedata\ files, which one is actually used?
    "

  • #2
    Another SLIC question, is there any function which can tell you whether you have recaptured a city? The city recapture event must use it but I can't find it in the Modification directory(or the event.slc file for that matter, I suspect its hard coded).
    "

    Comment


    • #3
      Re: Script.slc Question

      Originally posted by EPW
      I was looking through the LOTR code, and noticed there's a LOTR_script.slc file in both the \Scenarios\War of the Ring\scen000x\default\gamedata and in the \ctp2_data\default\gamedata\ files, which one is actually used?
      Look in gamefile.txt, if that exists in the scenario gamedata folder then that one is used I think. Otherwise it uses the one in the regular gamedata folder, which is modified by modswapper.

      Another SLIC question, is there any function which can tell you whether you have recaptured a city? The city recapture event must use it but I can't find it in the Modification directory(or the event.slc file for that matter, I suspect its hard coded).
      The city recapture feat?

      You can check the first player or civ to recapture any city by checking the recapture feat:

      Code:
      HandleEvent(AccomplishFeat) 'counterfeatTrig' post {
      
          if (PlayerCivilization(player[0]) == CivilizationIndex("Russian") 
              && FeatDB(FEAT_CITY_RECAPTURED)) {
      
      		DisableTrigger('counterfeatTrig');
      	}
      }
      But that feat could be triggered by someone else beforehand and then the code would never be triggered. Unless you made it impossible for others to achieve the feat.
      Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
      CtP2 AE Wiki & Modding Reference
      One way to compile the CtP2 Source Code.

      Comment


      • #4
        Re: Re: Script.slc Question

        Originally posted by Maquiladora
        Look in gamefile.txt, if that exists in the scenario gamedata folder then that one is used I think. Otherwise it uses the one in the regular gamedata folder, which is modified by modswapper.
        Okay, after making some changes to a slc file this seems to be the case

        The city recapture feat?
        I changed the city capture code in the WOTR scenario so you could pay gold to "cleanse" a city captured rather than raze it.
        If it was a city you previously held, I wanted to reduce the fine. This doesn't seem to be possible.
        "

        Comment


        • #5
          Re: Re: Re: Script.slc Question

          Originally posted by EPW

          I changed the city capture code in the WOTR scenario so you could pay gold to "cleanse" a city captured rather than raze it.
          If it was a city you previously held, I wanted to reduce the fine. This doesn't seem to be possible.
          It's definitely possible, but I guess it involves keeping track of the cities you've held, which is beyond my knowledge.

          Hopefully someone else will be able to help you. It might help to post the code too.
          Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
          CtP2 AE Wiki & Modding Reference
          One way to compile the CtP2 Source Code.

          Comment


          • #6
            Here's the code, modified from Martin's KillCityOption.slc:

            Code:
            HandleEvent(CaptureCity) 'MG_NewKillCityOption' post {
                CCityCost = ((1000*city[0].population) + Random(1000));
            	if (city[0].population>1) {
            		if(IsHumanPlayer(player[0])){
            			if(CityIsValid(city[0])) {			    
            				if(CCityCost > PlayerGold(player[0])){
            					message(player[0], 'DestroyCityMSG');
            					city[0] = DestroyCity;
            				}
            				else{
            					message(player[0], 'SaveCityMSG2');
            					city[0] = DestroyCity;
            				}
            			}
            		}
            	}
            }
            
            AlertBox 'DestroyCityMSG' {
            int_t i;
            int_t MGPw;
            int_t MGCitySize;
            location_t MGCityLoc;
            unit_t MGUnit1;
            unit_t MGUnit2;
            location_t MGUnitLoc1;
            location_t MGUnitLoc2;
            city_t MGCity;
            int_t MG_OK1;
            int_t MG_OK2;
            int_t k;
            int_t m;
            army_t MGArmy;
            Title(ID_DESTROY_CITY_TITLE);
            Text(ID_DESTROY_CITY);
            //MessageType("MILITARY");
            DestroyCity = city[0];
            //player[5] = MG_COwner;
            Show();
            	Button(ID_BLOODBATH) {
            		if(CityIsValid(city[0])) {
            			AddGold(player[0], (city[0].population*25));
            			MGPw = player[0].publicworkslevel;
            			MGPw = MGPw + (city[0].population*25);
            			setPW(player[0], MGPw);
            			ChangeGlobalRegard(player[0], -100, ID_BLOODBATH, 50);
            			Deselect();
            			for (i=city[0].population; i>=0; i=i-1){
            				if(CityIsValid(city[0])) {
            					Event: KillPop(city[0]);
            				}
            			}
            			Kill(); 
            		}
            	}
            }
            
            AlertBox 'SaveCityMSG2' {
            int_t i;
            int_t MGPw;
            int_t RandomDeath;
            Title(ID_SAVE_CITY_TITLE);
            Text(ID_SAVE_CITY2);
            //MessageType("MILITARY");
            DestroyCity = city[0];
            Show();
            	Button(ID_CLEANSE) {
            		if(CityIsValid(city[0]))  {
            			AddGold(player[0], -(CCityCost));
            			RandomDeath = (city[0].population) - (Random((city[0].population) / 2));
            			for (i=city[0].population; i>=RandomDeath; i=i-1){
            				if(CityIsValid(city[0])) {
            					Event: KillPop(city[0]);
            				}
            			}
            			Kill();
            		}
            	}
            			
            	Button(ID_BLOODBATH) {
            		if(CityIsValid(city[0])) {
            			AddGold(player[0], (city[0].population*25));
            			MGPw = player[0].publicworkslevel;
            			MGPw = MGPw + (city[0].population*25);
            			setPW(player[0], MGPw);
            			ChangeGlobalRegard(player[0], -100, ID_BLOODBATH, 50);
            			Deselect();
            			for (i=city[0].population; i>=0; i=i-1){
            				if(CityIsValid(city[0])) {
            					Event: KillPop(city[0]);
            				}
            			}
            			Kill(); 
            		}
            	}
            }
            "

            Comment


            • #7
              Re: Re: Re: Script.slc Question

              Originally posted by EPW
              I changed the city capture code in the WOTR scenario so you could pay gold to "cleanse" a city captured rather than raze it.
              If it was a city you previously held, I wanted to reduce the fine. This doesn't seem to be possible.
              As Maq says, to do it for cities you had previously held, you'll need to keep track of cities in an array. If you want to do it for cities that you started with, then there's already arrays for this in the WOTR slic. But then you wouldn't detect cities you captured, lost, and recaptured, or cities which were founded in-game.

              Still, in the former case, the code should be easy enough.

              Hmm.

              Ideally we want a list of player owned cities which is updated whenever we gain one. But, I'm not sure we can add a captured city to the list of cities after the KillCityOption fires and checks we owned it.
              (please note, I haven't written slic for years, so my skills are rusty)
              Code:
              city_t CitiesIHad[];
              HandleEvent(BeginTurn) 'IW_countourcities' pre {
              int_t j; city_t tmpCity;
                if(IsHumanPlayer(player[0])){
                  for(j=0; j < PlayerCityCount(player[0]); j=j+1){
                    GetCitybyIndex(player[0],j, tmpCity);
                    CitiesIHad[j] = tmpCity;
                  }
                }
                DisableTrigger('IW_countourcities');
              }
              
              HandleEvent(CaptureCity) 'IW_newcitycaptured' post {
                if(CityIsValid(city[0]) && IsHumanPlayer(player[0])){ 
                  CitiesIHad[CitiesIHad.#] = city[0];
                }
              }
              HandleEvent(CreateCity) 'IW_newcityfounded' post {
                if(CityIsValid(city[0]) && IsHumanPlayer(player[0])){
                  CitiesIHad[CitiesIHad.#] = city[0];
                }
              }
              HandleEvent(GiveCity) 'IW_mordorgaveyouacitywtf' post {
                if(CityIsValid(city[0]) && IsHumanPlayer(player[0])){
                  CitiesIHad[CitiesIHad.#] = city[0];
                }
              }
              HandleEvent(ConvertCity) 'IW_newconvertedcity' post {
                if(CityIsValid(city[0]) && IsHumanPlayer(player[0])){
                  CitiesIHad[CitiesIHad.#] = city[0];
                }
              }
              Ok, the latter two event handlers are quite unlikely in this case, and I'm not sure that player[0] is who I think it is in them. But, if in the unlikely case that that works, you want to add it to the KillCityOption code. Try including it after the KillCityOption.slc (or in the same file but lower down), so that the newly captured city isn't in the list of owned cities when the Option slc checks it.
              (or if this doesn't work, I seem to recall maybe slic is loaded in backwards, then try including it before).

              If neither of these works, then we can count cities the slightly slower way:

              Code:
              city_t CitiesIHad[];
              HandleEvent(BeginTurn) 'IW_counteveryturn' pre {
                if(IsHumanPlayer[player[0])){
                  for(j=0; j < PlayerCityCount(player[0]); j=j+1){
                    GetCitybyIndex(player[0],j, tmpCity);
                    CitiesIHad[j] = tmpCity;
                  }
                }
              }

              And then whichever of the above works, just add a check to KillCityOption:

              Code:
              // where you have this block:
              Button(ID_CLEANSE) {
                if(CityIsValid(city[0]))  {
                  int_t c; int_t hadit;
                  hadit = 0;
                  for(c=0; c < CitiesIHad.#; c=c+1){
                    if(city[0] == CitiesIHad[c]){
                      hadit = 1;
                    }
                  }
                  if(hadit){ AddGold(player[0], -(CCityCost)/2);  // or whatever
                  } else { AddGold(player[0], -(CCityCost));
                  }
                  RandomDeath = (city[0].population) - (Random((city[0].population) / 2));
                  for (i=city[0].population; i>=RandomDeath; i=i-1){
                    if(CityIsValid(city[0])) {
                      Event: KillPop(city[0]);
                    }
                  }
                  Kill();
                }
              }
              It's just occurred to me that I'm not sure you can have city_t arrays. If this is the case, you'd have to do it by city locations, and then decide whether you want to check that the city you're capturing in that location was the same city as you owned in that location (which might be quite hard), or fudge it (which would be a simple case of replacing city_t CitiesIHad[] with location_t CitiesIHad[], and making most of the instances of "city[0]" into "city[0].location")

              Um. So, that probably won't work, but it should be the gist of it.
              Last edited by Immortal Wombat; April 18, 2008, 03:45.
              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

              Working...
              X