Announcement

Collapse
No announcement yet.

Need help with basic slic functions

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

  • Need help with basic slic functions

    IF this is already posted somewhere, let me know, but I think it'd be good to have a basic reference point for some commonly used functions in slic. I've learned a little by checking out the scenario file in certain cenarios but if someone could do a walk through them I'd be glad.
    1) making a unit, building or wonder civ specific
    2) making a unit building or wonder city specific
    3) creating custom victory conditions
    4)Setting alliances
    5) creating General type units, that are replaced as they die
    6) creating wonder enabled units or improvements
    7) adding messages that appear when you start
    can anybody help with at least sum of these???? Me and many others (im sure) would greatly appreciate it.

    [This message has been edited by Chris B (edited January 26, 2001).]
    "It is ridiculous claiming that video games influence children. For instance, if Pac-Man affected kids born in the 80's we should by now have a bunch of teenagers who run around in darkened rooms and eat pills while listening to monotonous electronic music."

  • #2
    For setting alliances you will need to use LogregardEvent() and SetTrust() functions first to make nations like each other. Then you will have to manually make an alliance or pact from within the game. This is very annoying since there is no function to create an alliance from within the slic coding.

    For messages when a game starts, thats complicated, very complicated in fact. Go download my dawn of a new millenium scenario beta thats over at omnigods site. Check out scenario.slc and follow it from there, but it provides an excellent example of how to setup individual messages for each nation.

    Comment


    • #3
      Okay thiis will be a bit brief, sorry.

      1+2. You can use 'CreateUnit' or Event: CreateBuiliding for these.

      See the file Slic2Func in Apolyton's modification section for the required variables.

      3. The way I do it is with 'if' statments.
      If you have a scenario and you need 7 cities, than everytime youo take a city, make 'citysTaken = citysTaken + 1". Then evveryturn check if 'citysTaken' == 7 and if it does they win.

      4. Kormer explained that.

      5. Create the unit in units.txt. Then too make it replalced when he dies, i would check the alexander code and borrow some of that, because that happens there.

      6. Check
      IfWonderBuilt(is that a function??) and if it is allow the unit to be built.(Maybe??)

      7. Messages at start?
      scenario.slc
      Code:
      HandleEvent(BeginTurn) 'Your_Function' pre 
      {
      	Message (g.player, 'YourMessage');
      	DisableTrigger('Your_Function');
      }
      msg.slc
      Code:
      messagebox 'YourMessage' {
      	Show();
      	Title(ID_TITLE);
      	Text(ID_TEXT
      	Button(ID_EXIT) 
      		{
      			Kill();
      		}
      }
      scen_str.txt
      Code:
      ID_TITLE "Your title here"
      ID_TEXT  "  You message heree"
      and in scenario.slc you must #include "msg.slc"


      hope that helps

      Comment


      • #4
        sure does, but how do you include message.slc?
        "It is ridiculous claiming that video games influence children. For instance, if Pac-Man affected kids born in the 80's we should by now have a bunch of teenagers who run around in darkened rooms and eat pills while listening to monotonous electronic music."

        Comment


        • #5
          quote:

          Originally posted by Chris B on 01-28-2001 08:51 AM
          sure does, but how do you include message.slc?

          Code:
          #include "message.slc"

          Comment


          • #6
            I still dont understand how to make a unit available to only one civ or city
            "It is ridiculous claiming that video games influence children. For instance, if Pac-Man affected kids born in the 80's we should by now have a bunch of teenagers who run around in darkened rooms and eat pills while listening to monotonous electronic music."

            Comment


            • #7
              That can be done
              HandleEvent(StartBuilding(or similar) 'StartBuilding_f' pre

              if city[0] == 'The city youu want'{
              return CONTINUE;
              else
              return STOP;
              }

              This assumes you know what city it is. There is probably a better way too

              Comment


              • #8
                Making a unit/building/wonder civ-specific or wonder dependent: (1, 2, 6)

                Very simple actually. I'm surprised to see none of the other SLICers know this, I explained it several times already. Not that I mind explaining it again (only good for my postcount ), but still...

                To do any of these things, you should use the mod_* functions. So to make a unit civ-specific, use this:

                Code:
                int_f mod_CanCityBuildUnit(city_t theCity, int_t theUnit) {
                city_t	tmpCity;
                int_t	tmpUnit;
                	tmpUnit = theUnit;
                	tmpCity = theCity;
                
                	if (tmpUnit == UnitDB(UNIT_SAMURAI)) {	// if samurai
                		if (PlayerCivilization(tmpCity.owner) == CivilizationIndex("JAPANESE")) {
                			return 1;		// japanese can build it
                		} else {
                			return 0;		// other civs can't
                		}
                	} elseif (tmpUnit == UnitDB(UNIT_MARINE)) {	// if marine
                		if (PlayerCivilization(tmpCity.owner) == CivilizationIndex("AMERICANS")) {
                			return 1;		// americans can build it
                		} elseif (PlayerCivilization(tmpCity.owner) == CivilizationIndex("ENGLISH")) {
                			return 1;		// english can build it
                		} else {
                			return 0;		// other civs can't
                		}
                	// } elseif (... -> etc. until all civ specific units have been treated
                	} else {				// if other unit
                		return 1;			// everyone can always build it
                	}
                }
                Here's another example for making buildings wonder enabled:

                Code:
                int_f mod_CanCityBuildBuilding(city_t theCity, int_t theBuilding) {
                city_t	tmpCity;
                int_t	tmpBuilding;
                	tmpBuilding = theBuilding;
                	tmpCity = theCity;
                
                	if (tmpBuilding == BuildingDB(IMPROVE_BROKERAGE)) {	// if brokerage
                		if (PlayerHasWonder(tmpCity.owner, WonderDB(WONDER_LONDON_EXCHANGE)) {
                			return 1;	// civ with London Exchange can build it
                		} else {
                			return 0;	// other civs can't
                		}
                	// } elseif (... -> etc. until all wonder enabled buildings have been treated
                	} else {				// if other building
                		return 1;			// everyone can always build it
                	}
                }
                You can do similar things for specific cities and many other conditions. Simply replace the if-conditions with whatever you need. If you have cities in variables, ala the Alexander the Great scenario, you can simply check if current city is city in variable: 'if (LondonCity == tmpCity) {' or 'if (LondonLoc == tmpCity.location) {'. If you don't have the cities in variables, use more generic techniques, like 'if (player[0].capital == tmpCity) {' (once you set player[0] to tmpCity.owner) or 'if (CityIsNamed(tmpCity, "Amsterdam")) {'. Though in this case you should keep in mind that people might rename cities or relocate the capital.

                For wonders you can use mod_CanCityBuildWonder and for advances mod_CanPlayerHaveAdvance (where the city argument is replaced by a player argument). Check out the various Activision scenarios for more examples.

                Victory conditions (3) can get pretty complicated, but heardie gave a nice and simple example. Have a look at the existing scenarios for more examples and try a few things yourself. If there are specific things that you can't get done, post those here. But victory conditions in general is not specific enough, the possibilities are endless.

                Setting alliances (4): Kormer explained that, but you can also do it without SLIC if you prefer that. Replace the diplomacy files by a version that makes the AI really, really like and trust you when you give him your map or gold or whatever. Then give him your map or some gold a couple of times and ask for any treaty you want. After you set everything you needed to set (possibly by repeating this process a couple of times while using a different version of the diplo files every time), replace the diplomacy files with the original ones again.

                Generals (5): like others said, check out the Alexander and other scenarios for that. Search all SLIC files for the text 'general' and you should find all general related code (keep in mind though that the existing code still has some unresolved bugs that Harlan and his team (including yours truly) are working on).

                Messages (7): Heardie explained that.
                [This message has been edited by Locutus (edited January 30, 2001).]
                Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                Comment


                • #9
                  That is much easier. I never knew how the _Mod functions worked, because they arent called in any triggers, so I never bothered to look at them, but tnow I see there use

                  Comment


                  • #10
                    I can code the actual functions but i cant figure out how to trigger them. Your examples make perfect sense to me but WHEN do you call them? The IFs are easy, but I cant ever get anything to actually work so I must not be triggering them right.

                    ------------------
                    History is written by the victor.

                    Comment


                    • #11
                      You don't need to call them, the game calls them automaticly every time the build-window is opened and every time the AI makes a decision on what to build in a certain city. The way to look at these functions is that they overload (or 'overwrite') existing functions of the game engine that are always called to determine what can and can't be built.

                      If you can't get your code to work you must be doing something else wrong. If you post or email me (an example of) your code, I'll have a look at it and tell you what goes wrong.
                      Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                      Comment


                      • #12
                        alright. tonite i tried creting a message for a scenario
                        i put #include mesage.slc in scenario and made a message in the file as well as a msg_str, but when it loaded it said message.slc was not in an the asset tre. It also said there was a syntax error in scenario.slc

                        herez what i put in scenario.slc:
                        // Scenario script for The Communists Have Come

                        #include "message.slc"

                        HandleEvent(BeginTurn) 'Show()' pre
                        {
                        Message (g.player, 'Intro');
                        DisableTrigger('ID_EXIT');
                        }

                        also, should message be a wordpad doc or a txt dod. i have it as a txt doc.
                        Thanx 2 anyone who helps.
                        -CB
                        "It is ridiculous claiming that video games influence children. For instance, if Pac-Man affected kids born in the 80's we should by now have a bunch of teenagers who run around in darkened rooms and eat pills while listening to monotonous electronic music."

                        Comment


                        • #13
                          [quote]Originally posted by Locutus on 01-31-2001 05:35 AM
                          You don't need to call them, the game calls them automaticly every time the build-window is opened and every time the AI makes a decision on what to build in a certain city. The way to look at these functions is that they overload (or 'overwrite') existing functions of the game engine that are always called to determine what can and can't be built.
                          quote]

                          this is good to know. I've been adding more wonders that give buildings and I really dont want to AI to keep building those buildings. Its a waste of prod and support costs. I'd also like for the human player buildings that are redundant due to wonders, to be in another color in the build list or even in the built buildings under the city. Is this possible? Can the AI be told to sell a building? I didnt see that listed under the functions, or maybe I just missed it.

                          I'm still annoyed my previous SLIC attempts dont work on my new machine, but do work on my old one...grrrrrrrrrrrr I've tried every change I could think of but got screwy results every time.

                          ------------------
                          History is written by the victor.

                          Comment


                          • #14
                            Chris,
                            I'm getting the impression you didn't understood messages correctly. I think what you're trying to do is the following:

                            In file scenario.slc:
                            Code:
                            // Scenario script for The Communists Have Come
                            
                            #include "message.slc"
                            
                            HandleEvent(BeginTurn) 'ShowMessage' pre {
                            	Message(g.player, 'Intro');
                            	DisableTrigger('ShowMessage');
                            }
                            In file message.slc:
                            Code:
                            // Scenario messages for The Communists Have Come
                            
                            Messagebox 'Intro' {
                            	Show();
                            	Text(ID_EXIT);
                            }
                            In file msg_str.txt:
                            Code:
                            EXIT		"Put message here"
                            What this does is show the message "Put message here" to the first player in the first turn and after that this code is never executed again (not sure if the first player is human or barbarian but replacing g.player with 1 will always send the message to player 1, i.e. normally the human player). Is this what you wanted or am I misinterpreting your intentions?

                            What goes wrong in your current set up is that the file message.slc doesn't even exist. The idea is that you not only put that line in scenario.slc but also actually create the file and put all messagecode in there. Alternatively you could just put all SLIC code (HandleEvent and Messagebox) in 1 file (scenario.slc), nothing wrong with that either. All files in CtP2 are regular text files (txt), Word documents (doc) aren't used by the game.

                            AW,
                            I guess I wasn't clear enough about that. The mod_* functions are executed when the AI makes his build orders as well, the AI has an event that's equivilant to the 'human event' of opening the build-manager. So the changes you make in these mod_* functions apply to humans as well as AIs. If you don't want the AI to build certain things, use a condition like IsHumanPlayer. I don't think you can edit the colors in the build manager, but maybe if you dig really deep in the ldl files you might be able to figure out a way (though noone has ever really done that before, so you'd be boldy going where no man has gone before... ). Yes, the AI can be told to sell buildings using SLIC: there's a SellBuilding event that can probably be called with 'Event:SellBuilding();', but I didn't actually try yet.
                            Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                            Comment

                            Working...
                            X