Thread Tools
Old January 5, 2001, 11:26   #1
magma12
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Nov 2000
Location: Bangkok, Thailand
Posts: 20
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.
magma12 is offline  
Old January 5, 2001, 12:19   #2
MrFun
Emperor
 
MrFun's Avatar
 
Local Time: 04:50
Local Date: October 31, 2010
Join Date: Nov 2000
Location: Illinois
Posts: 8,595
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.
MrFun is offline  
Old January 5, 2001, 12:24   #3
jethro
Settler
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Jan 2001
Posts: 13
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.
jethro is offline  
Old January 5, 2001, 15:24   #4
magma12
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Nov 2000
Location: Bangkok, Thailand
Posts: 20
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?
magma12 is offline  
Old January 6, 2001, 09:48   #5
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:50
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
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).]
Locutus is offline  
Old January 6, 2001, 11:43   #6
magma12
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Nov 2000
Location: Bangkok, Thailand
Posts: 20
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.
magma12 is offline  
Old January 6, 2001, 14:16   #7
lago
Guest
 
Posts: n/a
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.
 
Old January 6, 2001, 16:46   #8
Alpha Wolf
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
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.
Alpha Wolf is offline  
Old January 6, 2001, 18:14   #9
lago
Guest
 
Posts: n/a
thank you thank you thank you

I've been wondering about this for weeks. Didn't look hard enough.
 
Old January 7, 2001, 01:53   #10
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:50
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
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).]
Locutus is offline  
Old January 7, 2001, 05:37   #11
magma12
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Nov 2000
Location: Bangkok, Thailand
Posts: 20
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.
magma12 is offline  
Old January 7, 2001, 09:37   #12
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:50
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
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;
		}
	}
}
Locutus is offline  
Old January 7, 2001, 12:24   #13
magma12
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Nov 2000
Location: Bangkok, Thailand
Posts: 20
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.
magma12 is offline  
Old January 7, 2001, 16:51   #14
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:50
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
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).]
Locutus is offline  
Old January 8, 2001, 01:34   #15
Alpha Wolf
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
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.
Alpha Wolf is offline  
Old January 9, 2001, 04:48   #16
magma12
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Nov 2000
Location: Bangkok, Thailand
Posts: 20
Thanks for the code. Hope other will include it in their mod pack.
magma12 is offline  
Old January 16, 2001, 02:07   #17
Alpha Wolf
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
quote:

Originally posted by Locutus on 01-07-2001 08:37 AM
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;
		}
	}
}


OK, i just dont get it. I used this code, which seemed to make sense to me, but it wont work. I even fixed the missing ")" on the CityHasBuilding line. I built the barracks in my town, but the new units created dont appear to be vets (no little flag by unit). Or do they only get the vet flag after a battle? I put the code in the scenario.slc file. Also tried it in script.slc. What am i doing wrong?

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 17, 2001, 06:46   #18
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:50
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Odd, I did make another mistake, but I thought that doing that should give an error message, guess I was wrong. Anyway, try replacing BuildingDB(IMPROVE_BARRACK) with "IMPROVE_BARRACK". It's an old CtP1 function and requires the old CtP1 syntax, I forgot about that.
Locutus is offline  
Old January 17, 2001, 14:34   #19
Alpha Wolf
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
Thanks. Will try it tonight.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 17, 2001, 23:55   #20
Alpha Wolf
Chieftain
 
Local Time: 09:50
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
no luck. it didnt work. again i'm assuming that the flag will show up upon creation and not only after battles.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 18, 2001, 09:02   #21
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:50
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Hmm, very odd. I'll need to look into this more closely when I have the time (which will be a while). It can't be that combat is needed because it works fine in the Alexander scenario, all units stacked with Alex get vet-status, combat experience or not.

One alternative (I have no idea if this will work but it's worth a try) might be to kill the unit immideately when it's created and create a new one of the same type and give that one veteran status, which would look something like this:

(replace "ToggleVeteran(tmpUnit, 1);" with this)
Code:
// if city has barrack {
	tmpType = value[0];	// I think this returns the unittype, but maybe it's value[1]
	tmpLoc = tmpCity.location;
	tmpOwner = tmpCity.owner;
	Event:KillUnit(tmpUnit);
	CreateUnit(tmpOwner, tmpType, tmpLoc, 0, tmpUnit);
	ToggleVeteran(tmpUnit, 1);
Locutus is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 05:50.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team