Announcement

Collapse
No announcement yet.

Need help making Barrack :-)

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

  • Need help making Barrack :-)

    Well, I think the game would be better if they have barrack. Anyone know how to make improve to do that.
    Better yet, I would love to see a millitary base (title improve) that if a unit station there for a number of turn the unit become veteran. Hope someone know how to do it.

  • #2
    It's simple to add a new building with the text files. Modify buildings.txt document under the Default folder/Gamedata folder, then add corresponding text in any document related with the Great Library.

    The harder part is capturing and altering a graphic for the new building or creating an entirely new one.
    A lot of Republicans are not racist, but a lot of racists are Republican.

    Comment


    • #3
      THERE IS WAY TO DO THAT,THOUGH IT WOULD REQUIERE SLIC FUNCTIONS,AS IS IN THE WW2 SCENERIO,IN THAT SCE ANY UNIT IN A GROUP A GERNERAL IS MADE A VETERAN AS LONG AS IT IS WITH THE GERNERAL.YOU COULD MAKE A SLIC FUNCTION THAT FLAGS THE UNIT AFTER X TURNS,THOUGH THAT WOULD PROBABLY REQUIER THE BARRACKS LOCATION,IN OTHER WORDS PROBABLY ONLY IN A SCENERIO.MIGHT BE A SIMPLER WAY,IN WW2 SLIC THE FILE SAYS IT MAKES THE UNIT A VETERAN FOR THE REST OF THE TURN,MAYBE CHANGE THAT TO 100 TURNS OR WHATEVER,AFTER ALL MOST UNITS BECOME OBSELETE BEFORE THAT ANYWAY.PLAY AROUND WITH THE SLIC AFTER THE TERRAIN IMPROVEMENT IS MADE.

      Comment


      • #4
        Thanks for the advice. I never touch the SLIC before
        may be I will give it a try. What about minefield? If
        other player(or make it easy, everyone) unit move on it, will damage. Do you think that is possible?

        I don't like the infantry unit that much, They should have
        musket unit first then rifile unit. I am looking for a nice
        pic for the infantry and create musket unit using the exsting infantry pic.

        By the way, does anyone know where to get a nice modern unit pics?

        Comment


        • #5
          Both the barracks/military base and the minefield thing can be done through SLIC. For the Barracks you'll need the functions IsVeteran, ToggleBVeteran and CityHasBuilding. For a military base you'll need the veteran functions plus some annual counter-array and for the minefield you'll need DamageUnit (or is it called Damage? I'm not sure). The coding should be fairly straightforward.
          [This message has been edited by Locutus (edited January 06, 2001).]
          Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

          Comment


          • #6
            Locutus, thanks for the advice. May be you can help me
            with this one. I seem to have problem with making button for the tileimp. Do you know anything about it
            such as pic size, max color, background and where to put
            it etc.

            Comment


            • #7
              quote:

              For the Barracks you'll need the functions IsVeteran, ToggleBVeteran and CityHasBuilding.


              Locutus, where is the documentation (such as it is) on SLIC functions? Thanks.

              Comment


              • #8
                quote:

                Originally posted by lago on 01-06-2001 01:16 PM
                Locutus, where is the documentation (such as it is) on SLIC functions? Thanks.

                http://apolyton.net/ctp2/modification/

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

                Comment


                • #9
                  thank you thank you thank you

                  I've been wondering about this for weeks. Didn't look hard enough.

                  Comment


                  • #10
                    Well, I'm only a SLIC guy, don't harass my with questions like that, those only scare me

                    Seriously, I think the pic should go in the regular picture folder (default\graphics\pictures), it should be 16-bit tga. The background color should be pink or purple or whatever it's called (Red 255 Green 0 Blue 255), the size 40x30. Am I a graphics expert? No. Did I steal this info from the WWII scenario? Yes

                    Edit:
                    Is it actually possible to add custom tile improvements to the game? Currently not. It's not possible without being able to change the terrain graphics (those *.til files). Changing the buttons is easy enough, but currently there's no way to change graphics on the actual map.
                    [This message has been edited by Locutus (edited January 06, 2001).]
                    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                    Comment


                    • #11
                      Locutus, well since you are a SLIC guy I have a question for you. I have add a barrack in the game using
                      fort icon and pic. I was trying to use SLIC from ww2 general. edit some to something like this

                      // Turns units near Barrack into Veteran and all other units non Veteran
                      void_f VeteranEffect ()
                      {
                      int_t y;
                      int_t j;
                      unit_t tmpUnit;
                      int_t tmpNum;
                      int_t numUnits;
                      int_t tmpPlayer;

                      for (y = 1; y < 5; y = y + 1) {
                      if (IsPlayerAlive(y)) {
                      player[0] = y;
                      tmpPlayer = player[0];
                      numUnits = player[0].units;
                      }
                      }

                      // Make all Units veterans who share the location of the Generals
                      if (barrack.valid) {
                      tmpNum = GetUnitsAtLocation(barrack.location);
                      for (y = 0; y < tmpNum; y = y + 1) {
                      GetUnitFromCell(barrack.location, y, tmpUnit);
                      ToggleVeteran(tmpUnit, 10);
                      }
                      }

                      }

                      I am new to SLIC, I hope you can help with the barrack slic so we can use it.

                      Comment


                      • #12
                        magma,
                        I'm not sure what you're trying to do here, but let me give you some exaple code. Below is how the barrack code could look like in the classic Civ1/2 way: every new unit built in a city is a veteran when a barrack is present. I get the feeling you may be looking for something different though, so if that is the case, let me know what you *are* looking for and I'll see what I can do. Note that following is untested and may contain a few typos or bugs, but the basic idea *should* work.

                        Code:
                        HandleEvent(CreateUnit) 'BarrackCode' post {	// if a unit is created
                        int_t	tmpUnit;
                        city_t	tmpCity;
                        	tmpUnit = unit[0];	// store the unit that was just built
                        	tmpCity= city[0];	// store the city in which it was built
                        
                        	if (CityIsValid(tmpCity)) {	// if city exits (unit didn't come from ruin or whatever)
                        		if (CityHasBuilding(tmpCity, BuildingDB(IMPROVE_BARRACK)) {	// if city has a barrack
                        			ToggleVeteran(tmpUnit, 1);	// make unit a veteran;
                        		}
                        	}
                        }
                        Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                        Comment


                        • #13
                          My apologics Locutus, I was trying to make a Barrack (Milliatry Base) as a tile imp. The concept is, if unit station there for a period of time (trainning) it will get a vetran status. No expire. But thank for the code you gave
                          it will work too If you like the concept please help.

                          Comment


                          • #14
                            LS: if this thread looks like ****, it's because HTML and SLIC don't go well together. I'll try to fix it a bit but I can't garantuee to keep the code intact and still keep the thread look good.

                            Oh, ok, now I get it. A military base is more complicated: you'll have to keep track of how long a unit has been there and you'll need to track down the actual bases themselves as well. I intended to write you some example code on how to do it but ended up writing all code
                            This will make units train for 6 turns before they turn veteran, assuming they are in their own base and they go to sleep there (since there's no 'train' command). It's not possible with this code to train 3 turns, do something else, and train 3 turns again, you have to train 6 consequetive(sp?) turns. That would make the code even more complicated and someone else may figure out how to do that (hint: requires keeping track of all non-veteran units, not just the ones sleeping in bases). Same disclaimer as usual: not tested, might be buggy.

                            Code:
                            location_t	militaryBaseLocs[];	// array that stores all bases in game
                            int_t	militaryBaseOwners[];		// array that stores all owners of bases
                            int_t	miitaryBaseIndex;		// value that stores how many bases exist/at what index new bases are added
                            unit_t	trainingUnits[];		// array that stores all training units
                            int_t	trainingTimes[];		// array that stores how long these units have been training
                            int_t	trainingIndex;			// value that stores how many units are training/at what index new units are added
                            
                            HandleEvent(ImprovementComplete) 'MilitaryBaseBuilt' post {	// triggers if a tile improvement is built
                            location_t	tmpLoc;
                            int_t	tmpPlayer;
                            int_t	tmpValue;
                            	tmpValue = value[0];	// might have to be value[1], not sure; stores type of improvement
                            	tmpPlayer = player[0];					// stores owner of improvement
                            	tmpLoc = location[0];					// stores location of improvement
                            
                            	if (tmpValue == TerrainImprovementDB(TILEIMP_MILITARY_BASE)) {	// check if type of improvement is military base
                            		militaryBaseLocs[miitaryBaseIndex] = tmpLoc;		// store base
                            		militaryBaseOwners[militaryBaseIndex] = tmpPlayer;	// store owner
                            		militaryBaseIndex = militaryBaseIndex + 1;		// now one more base exists
                            	}
                            }
                            
                            HandleEvent(CutImprovements) 'MilitaryBasePillaged' post {	// triggers if a tile improvement is pillaged
                            location_t	tmpLoc;
                            int_t	i;
                            int_t	j;
                            	tmpLoc = location[0];	// get location of pillage
                            
                            	i = 0;
                            	while (i < militaryBaseIndex) {				// cycle through all military bases
                            		if (militaryBaseLocs[i] == tmpLoc) {		// if the location of this base is same as pillage-location
                            			for (j = i; j < (militaryBaseIndex - 1); j = j + 1) { // go through all remaining bases except the last one
                            				militaryBaseLocs[j] = militaryBaseLocs[j + 1]; // put next base at the position of the current base
                            				militaryBaseOwners[j] = militaryBaseOwners[j + 1]; // do the same for the owners
                            			} // the above two lines overwrite the pillaged base and move all other bases forward in the array
                            			militaryBaseIndex = militaryBaseIndex - 1;	// there's now one less base
                            			i = militaryBaseIndex + 1;		// base is found, no need to look further
                            		} else {					// if this is not the same location as the pillage location
                            			i = i + 1;				// look at the next base
                            		}
                            	}
                            }
                            
                            HandleEvent(SleepUnit) 'UnitTrains' post {	// triggers if a unit goes to sleep
                            int_t	i;
                            unit_t	tmpUnit;
                            	tmpUnit = unit[0];			// store unit
                            
                            	i = 0;
                            	while (i < militaryBaseIndex) {				// cycle through all military bases
                            		if (militaryBaseLocs[i] == tmpUnit.location) {	// if location of base is same location of that of sleeping unit
                            			if (militaryBaseOwners[i] == tmpUnit.owner) { // check if unit is in his own base
                            				if (IsVeteran(tmpUnit)) {		// if unit isn't already veteran
                            					trainingUnits[trainingIndex] = tmpUnit;	// train this unit
                            					trainingTimes[trainingIndex] = 5;	// it takes 6 turns to train a unit 
                            				}					// (countdown from 5 to 0, so 6 turns)
                            				trainingIndex = trainingIndex + 1;	// one more unit training
                            				i = militaryBaseIndex + 1;		// no need to look further, so end cycling through bases
                            			} else {					// if locations are different
                            				i = i + 1;				// look at next base
                            			}
                            		} else {
                            			i = i + 1;
                            		}
                            	}
                            }
                            
                            HandleEvent(WakeUnit) 'UnitStopsTraining' post {		// triggers if a units wakes up
                            int_t	i;
                            int_t	j;
                            unit_t	tmpUnit;
                            	tmpUnit = unit[0];			// store unit
                            
                            	i = 0;
                            	while (i < militaryBaseIndex) {				// cycle through all military bases
                            		if (militaryBaseLocs[i] == tmpUnit.location) {	// if location of base is same location of that of sleeping unit
                            			if (militaryBaseOwners[i] == tmpUnit.owner) { // check if unit is in his own base
                            				j = 0;
                            				while (j < trainingUnitsIndex) { 		// go through all training units
                            					if (tmpUnit == trainingUnits[j]) {	// if this is the unit
                            						for (k = j; k < trainingIndex; k = k + 1) {	
                            							trainingUnits[k] = trainingUnits[k + 1];
                            							trainingTimes[k] = trainingTimes[k + 1];
                            						}
                            						trainingIndex = trainingIndex - 1;	// one less unit training
                            						j = trainingIndex + 1;
                            						i = militaryBaseIndex + 1;		
                            					} else {
                            						j = j + 1;				// no need to look further
                            					}
                            				}
                            			} else {					// if locations are different
                            				i = i + 1;				// look at next base
                            			}
                            		} else {
                            			i = i + 1;
                            		}
                            	}
                            }
                            
                            HandleEvent(BeginTurn) 'TrainingUnitsAnnual' post {	// trigger when a new turn begins for any of the players
                            int_t	i;
                            
                            	if (player[0] == 0) {	// if player is barbarian, this should happen once a year, not x times a year (where x is # of players in the game)
                            		i = 0;
                            		while (i < trainingIndex) {				// cycle through all players
                            			if (trainingTimes[i] != 0) {			// unless training is completed
                            				trainingTimes[i] = trainingTimes[i] - 1; // one year of training completed
                            			} else {					// if training is completed
                            				ToggleVeteran(trainingUnits[i], 1);	// make unit veteran
                            				for (j = i; j < trainingIndex; j = j + 1) {	// go through all remaining units
                            					trainingUnits[j] = trainingUnits[j + 1]; // put next unit at the position of the current one
                            					trainingTimes[j] = trainingTimes[j + 1]; // put next time at the position of the current one
                            				}
                            				trainingIndex = trainingIndex - 1;	// one less unit training
                            			}
                            			i = i + 1;					// look at next unit
                            		}
                            	}
                            }
                            [This message has been edited by Locutus (edited January 07, 2001).]
                            [This message has been edited by Locutus (edited January 07, 2001).]
                            Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                            Comment


                            • #15
                              I definitely want to try this specific code. I was looking for something like that earlier myself. I've always suspected that barbarians are all vets because all things being equal, they tend to kick my butt.

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

                              Comment

                              Working...
                              X