Thread Tools
Old January 6, 2001, 18:52   #31
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
quote:

Originally posted by Harlan on 01-06-2001 04:31 PM
Alpha,
If its like CTP1, any file that starts with a number can be changed, but you have to change that number too. So if it was the Units.txt, add three new units and then add three to that start number.

Luckily, many files now no longer use that number, which is great, cos it was a real pain to keep that straight.



I was just making a joke If I had more time, I'd have sat down with the SLIC doc and be doing it myself. But since coding and analyzing crappy code is what I do all day, I mostly just want to have fun when I play. unfortunately, I just cant turn off all those "what if" thoughts

I really wish they had gotten rid of all the size limitations. Most have really bogged their computers down when they had unlimited everything. Of course, definitions of more of the fields would be helpful. Been playing with the Ai to see if I can maximize its aggressiveness without being reckless.
------------------
History is written by the victor.
[This message has been edited by Alpha Wolf (edited January 06, 2001).]
Alpha Wolf is offline  
Old January 6, 2001, 20:16   #32
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
Now I am embaressed. I did that in a hurry before I left on holiday. I am aware (now) that this is simply a function that return the cities food prod.

Anyway today I will see what I can learn, cause I have 12 hours and onthing planned.
heardie is offline  
Old January 6, 2001, 21:06   #33
Bluevoss
Prince
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 2000
Location: Orlando, Florida
Posts: 326
What I would like to see (outside of normal disasters) are some disasters political in nature. Say that your happyness drops 5-10 points in every city, and any city that drops into unrest has a good chance of going barbarian. This might be considered a civil war, the death of a powerful ruler, or something.

I think this would be good, since it would give us a reason to keep building all those theaters and stuff that dont seem to make a differnce.

Outside of that, does anyone know how to increase the unhappyness due to overcrowding?

Thanks,



------------------
Bluevoss-
Bluevoss is offline  
Old January 6, 2001, 21:59   #34
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
quote:

Originally posted by Bluevoss on 01-06-2001 08:06 PM
What I would like to see (outside of normal disasters) are some disasters political in nature. Say that your happyness drops 5-10 points in every city, and any city that drops into unrest has a good chance of going barbarian. This might be considered a civil war, the death of a powerful ruler, or something.

I think this would be good, since it would give us a reason to keep building all those theaters and stuff that dont seem to make a differnce.

Outside of that, does anyone know how to increase the unhappyness due to overcrowding?

Thanks,




in const.txt, REVOLUTION_LEVEL 60. By increasing this number you can make cities revolt more often. I suspect from your questions that you are playing on the easier levels. The more difficult levels require some attention to happines. You might also avoid building happiness wonders.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 6, 2001, 23:37   #35
Radical_Manuvr
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 2000
Location: Maryland, USA
Posts: 80
AW,

Looking at the 4th post on this thread it appears you want an 80% chance of some type of natural disaster to occur every turn. Is that correct? I suppose that is the easy part anyway and could be modified by anyone to have x% chance of the disaster routine on each turn once the other code is written. I'm pretty sure I can get a randomly placed bombardment for the earthquakes. The drought/great weather part seems as though it may be more complicated, but I'll give it a shot. I doubt I could do the tidal wave thing and honestly won't even try. I remember reading something about changing terrain could have unpredictable or undesirable results so I'm not going to mess with that.
Radical_Manuvr is offline  
Old January 7, 2001, 01:23   #36
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
Radical_Manuvr that would be good if you got to work on the bombardemnt functioons. I will create some simplle framework, like messageboxes and the like, adn determing what disaster occurs. Then you/we can simply insert the functions into the code and get it running.

And if i get that all done, I'll also have a go at bombarding but i doubt that i will.

Good Luck!
heardie is offline  
Old January 7, 2001, 01:29   #37
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
RE: To do food production
Drought: Create a building that decrease food by 25%
IMPROVE_DROUGHT {
DefaultIcon ICON_IMPROVE_GRANARY
Description DESCRIPTION_IMPROVE_GRANARY
EnableAdvance ADVANCE_AGRICULTURE
ProductionCost 0
Upkeep 0
FoodPercent -0.25
}
Surplus: Create building increase by 25%
IMPROVE_SURPLUS {
DefaultIcon ICON_IMPROVE_GRANARY
Description DESCRIPTION_IMPROVE_GRANARY
EnableAdvance ADVANCE_AGRICULTURE
ProductionCost 0
Upkeep 0
FoodPercent 0.25
}

Can that work?

Then all we do is create them, and then after x amount of turns remove them.

Is that right?
heardie is offline  
Old January 7, 2001, 01:42   #38
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
quote:

Originally posted by Radical_Manuvr on 01-06-2001 10:37 PM
AW,

Looking at the 4th post on this thread it appears you want an 80% chance of some type of natural disaster to occur every turn. Is that correct? I suppose that is the easy part anyway and could be modified by anyone to have x% chance of the disaster routine on each turn once the other code is written. I'm pretty sure I can get a randomly placed bombardment for the earthquakes. The drought/great weather part seems as though it may be more complicated, but I'll give it a shot. I doubt I could do the tidal wave thing and honestly won't even try. I remember reading something about changing terrain could have unpredictable or undesirable results so I'm not going to mess with that.


being that turns represent so many years, I figure theres a reasonable chance that somewhere in the world a disaster would happen almost every turn. alot of them will be in unpopulated areas or quakes so small that they dont do much damage. Would it be easy just to do weather every turn and to put out a message only when its really bad/good? Just randomly increase/decrease food levels worldwide since from one year to the next crop outputs vary, sometimes drastically.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 7, 2001, 01:45   #39
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
quote:

Originally posted by heardie on 01-07-2001 12:29 AM
RE: To do food production
Drought: Create a building that decrease food by 25%
IMPROVE_DROUGHT {
DefaultIcon ICON_IMPROVE_GRANARY
Description DESCRIPTION_IMPROVE_GRANARY
EnableAdvance ADVANCE_AGRICULTURE
ProductionCost 0
Upkeep 0
FoodPercent -0.25
}
Surplus: Create building increase by 25%
IMPROVE_SURPLUS {
DefaultIcon ICON_IMPROVE_GRANARY
Description DESCRIPTION_IMPROVE_GRANARY
EnableAdvance ADVANCE_AGRICULTURE
ProductionCost 0
Upkeep 0
FoodPercent 0.25
}

Can that work?

Then all we do is create them, and then after x amount of turns remove them.

Is that right?


That sure sounds like it could work. Then all SLIC would have to do is go thru the cities and add droughts occasionally. But can we auctually track what turn an improvement was built so we know when to kill it?

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 7, 2001, 01:47   #40
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
In case I forget, thanks for all the help guys

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 7, 2001, 07:26   #41
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
And everyone (drumroll) here is some cool code

Alpha I thought about that too(tracking improvements) and here is what i came up with:

have a variable say isDrought - and default it to -1.
When we have a drought set it to three and then decrement it bu 1 each turn. when it gets to zero remove the improvment and set it to -1. Too easy. Anyway the code that can be added to mine is:
1+2. Drought/Good Weather Building
I can't work out how to add a building to a city. anyone?
3. Add a earthquake code.

I also took the liberty to add floods as a natural disaster as there is already a flood function.

Enough rambling lets post some crappy code
Code:
#include "msg.slc"
HandleEvent(BeginTurn) 'FirstTurn' pre
{
	Message (g.player, 'StartMessage'); //Message when you start a game
	DisableTrigger('FirstTurn')
}

HandleEvent(BeginTurn) 'EveryTurn' pre 
{
	int_t DisasterType;
	int_t FloodStrength;
	
	int_t isDrought; //Used to determing whether we are is drought, or something else.
	isDrought = -1;
	//The next will do two checks. If it is greater than zero, decrement.
	//If it is 0 then destroy all the 'Drought' buildings and set it to -1
	if (isDrought > 0) {
		isDrought = isDrought - 1;
	}
	
	elseif (isDrought == 0) {
		isDrought = -1;
		Message (g.player, 'DroughtEnd'); //Message when drought ends
	}

	
	int_t isWeather; //Used to determing whether we are is drought, or something else.
	isWeather = -1;
	//The next will do two checks. If it is greater than zero, decrement.
	//If it is 0 then destroy all the 'Drought' buildings and set it to -1
	if (isWeather > 0) {
		isWeather = isWeather - 1;
	}
	
	elseif (isWeather == 0) {
		isWeather = -1;
		Message (g.player, 'WeatherEnd'); //Message when good wheather ends
	}

	
	//Start the disaster code here
	
	DisasterType = random (10);
	if (DisasterType == 1)
	{
		Message (g.player, 'DroughtBegin'); 
		//Create the building 'Drought'
		for(m = 0; m <= player.cities; m = m + 1){
			//Insert Building Code here
		} 
		isDrought = 3;  //Three turns of drought
	}
	
	if (DisasterType == 2)
	{
		Message (g.player, 'WeatherBegin');  
		//Create the building 'GoodWeather'
		for(m = 0; m <= player.cities; m = m + 1){
			//Insert Building Code here
		} 
		isWeather = 3;  //Three turns of weather
	}

	if (DisasterType == 3 | | DisasterType == 4 | | DisasterType == 5 | | DisasterType == 6)
	{
		Message (g.player, 'Earthquake'); 
		//Do the Earthquake Stuff
	}
	
	if (DisasterType == 7 | | DisasterType == 8)
	{
		Message (g.player, 'Flood'); 
		FloodStrength = Random(3) + 1
		Flood(FloodStrength);
	}
}
I havent yet tested this(its not ready) so there may be careless spelling errors, missing ';'s, etc.

Alsoo I think this (part of it, anyway) should just be for large random disasters. I was thinking that up the top I could just at a
if(random(10)==1) then
and then there is only a 1/10 chance of anything occuring at all.

What do you think?

Radical_Manuvr got any code for me?
heardie is offline  
Old January 7, 2001, 09:54   #42
Radical_Manuvr
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 2000
Location: Maryland, USA
Posts: 80
I just started on the earthquake stuff. Determined how to indicate the random location based on map size so it will work with any map, but I've only spent an hour on it so far so. Haven't tested yet either and I'm not sure how long it will take me.

Question about using building for the +/- food. If this is a human player, what's to stop them from selling the building? I don't have another method for the +/- food at this point but just thought I would throw that out.

To add a building I didn't find a nice easy way, maybe someone else knows of one. Here are the functions I think you need to do it.

VOID ClearBuildQueue(city)
Remove all items from the build queue of the given city. Example:

city_t tmpCity;

int_t i;



for(i = 0; i < player[0].cities; i = i + 1) {

GetCityByIndex(player[0], i, tmpCity);

if(CityisValid(tmpCity)) {

ClearBuildQueue(tmpCity)

}

}

//clears the build queues of all of player[0]’s cities

VOID AddBuildingToBuildList(city, buildingType)
Add the building type to the end of the city’s queue. Example:

if(!city[0].buildqueuelength) {

AddBuildingToBuildList(city[0], BuildingDB(IMPROVE_CITY_WALLS));

}

//if the city is not building anything, it will put the improvement City Walls into its build queue.


2 events that may help

BuildFront(city_t)
Try to build the first thing in a city's queue

OR

BuyFront(city_t)
Rush buy an item in a city

BuildFront is probably better. It may not require gold since it looks like BuyFront does. The above set of functions and events may require you to determine the gold a player has, how much the rush buy costs and add enough gold using AddGold(city).

I haven't tried the event below but it may work nice and clean. Since int_t is integer I suppose you have to know the index number of the building you want to add. Hopefully this will work.

CreateBuilding(city_t, int_t)
Create a building


For getting rid of the building


VOID DestroyBuilding(city, building)
Remove the specified building from the city.

Example:

DestroyBuilding(city[0], BuildingDB(IMPROVE_SILO));


Back to work on the quakes. Later
Radical_Manuvr is offline  
Old January 7, 2001, 09:58   #43
Radical_Manuvr
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 2000
Location: Maryland, USA
Posts: 80
Forgot to add that the flood function or event (forgot which it is) is like the global warming disaster. As far as I know that would affect all coasts and possibly swamps (if it works like CTP1) anywhere on the map not just those near a random epicenter.
Radical_Manuvr is offline  
Old January 7, 2001, 10:02   #44
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:52
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
heardie:
Here's how to add a building:
CreateBuilding(tmpCity, BuildingDB(IMPROVE_DROUGHT));

Radical:
Here's how to prevent sales:
Code:
EventHandler(SellBuilding) 'SellBuilding' pre {
int_t	type;
	type = value[0];
	if (type = BuildingDB(IMPROVE_DROUGHT)) {
		return STOP;
	}
}

Locutus is offline  
Old January 7, 2001, 14:03   #45
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
quote:

Originally posted by Radical_Manuvr on 01-07-2001 08:58 AM
Forgot to add that the flood function or event (forgot which it is) is like the global warming disaster. As far as I know that would affect all coasts and possibly swamps (if it works like CTP1) anywhere on the map not just those near a random epicenter.


Thats one of the reasons I avoided the existing flooding criteria. Assuming that it would flood ALL areas and i was also worried about the rerouting of rivers that happened on the first global warming (i assume its similiar in ctp2 also).

IF i get my work project done today, i want to slap some of these great ideas from you and Locutus in my game and try them out.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 7, 2001, 15:26   #46
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:52
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Important correction: to add a building one should use the code:
Event:CreateBuilding(tmpCity, BuildingDB(IMPROVE_DROUGHT));
So with 'Event:' in front of the eventname. I don't know how that could fallen away. To destroy it the function DestroyBuilding will work, as Radical mentioned earlier.

To get non-global floods, you could use the Terraform function. My suggestion would be: check all squares in a 3 tile radius (or something similar) and if a tile is swamp, plain or grassland either adjacent to sea or with a river running through it, terraform it to beach/shallow water (whatever turns out to work best), do the same for all squares adjacent to it. (To get an adjacent tile, use a for loop and GetNeighbor). If a tile is of any other terraintype or doesn't have a river or sea near it, check the next tile. A good way to cycle through tiles could be to use a double for-loop with MakeLocation that has variables x and y(which range from location.x - 3 to location.x + 3, similar for y) as arguments, which come from the for-loops.
Locutus is offline  
Old January 7, 2001, 15:32   #47
Radical_Manuvr
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 2000
Location: Maryland, USA
Posts: 80
I've got part of the earthquake stuff working.

So far if it's centered on a city it may destroy a building depending on the size quake. Also depends on if the building is there or not. It may try to destroy a building that isn't built yet in which case nothing happens. If it's level 8 (highest) you'll lose city walls. That can be easily changed by anyone to something else or deleted.

Random tiles surrounding the epicenter may lose tile improvements.

Random units in or around the epicenter will lose hitpoints. At this point I don't have them getting killed. I have it tied to the scale of the quake but if their hit points are less than 8 I'm not taking hitpoints because they ended up with negative hitpoints in some cases and weird stuff started happening.

All this works with me specifying a location I know is a city. I'm working on the random location part but it's been crashing so far. I haven't tried with specifying a location say one tile from a city to see what happens. Probably gonna break for a while and watch some football. I'll post what works later today even if I don't get the random location part working. Maybe someone else can get that. I was trying to make it so this would work with any size map automatically. It may turn out that you just have to edit scenario.txt and plug in your map size.

I'm trying to use GetMapHeight () and GetMapWidth ()
I'm not sure if a variable goes between the () or not. I'm crashing with nothing between the (). Hopefully Locutus or someone else can answer before I get back to it later.
Radical_Manuvr is offline  
Old January 7, 2001, 15:38   #48
Alpha Wolf
Chieftain
 
Local Time: 09:52
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 02:26 PM
To get non-global floods, you could use the Terraform function. My suggestion would be: check all squares in a 3 tile radius (or something similar) and if a tile is swamp, plain or grassland either adjacent to sea or with a river running through it, terraform it to beach/shallow water (whatever turns out to work best), do the same for all squares adjacent to it. (To get an adjacent tile, use a for loop and GetNeighbor). If a tile is of any other terraintype or doesn't have a river or sea near it, check the next tile. A good way to cycle through tiles could be to use a double for-loop with MakeLocation that has variables x and y(which range from location.x - 3 to location.x + 3, similar for y) as arguments, which come from the for-loops.


This this the same concept i'd use to see if a tile has a river so i can build a dam on it as a tile improvement?

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 7, 2001, 17:05   #49
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:52
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Radical, post what you have, even if it doesn't work (the random part). I'll have a look at it. I got mapsize-independent location-generators working for CtPI and if needed I'll do it again for CtPII.

Alpha,
Yeah, I suppose that's possible. What effect should a dam have anyway?
[This message has been edited by Locutus (edited January 07, 2001).]
Locutus is offline  
Old January 7, 2001, 19:58   #50
Alpha Wolf
Chieftain
 
Local Time: 09:52
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 04:05 PM
Radical, post what you have, even if it doesn't work (the random part). I'll have a look at it. I got mapsize-independent location-generators working for CtPI and if needed I'll do it again for CtPII.

Alpha,
Yeah, I suppose that's possible. What effect should a dam have anyway?
[This message has been edited by Locutus (edited January 07, 2001).]


I figured dams were early power generators, so they'd production. Figured it would give me another option for some forst tiles since this is were I like to build and i cant put farms or mines there. Then a wonder like TVA or Hoover would double that effect.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 7, 2001, 20:03   #51
Radical_Manuvr
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 2000
Location: Maryland, USA
Posts: 80
AW, please type your email address so I can send you the files. I'll post here but figured it would be eaiser for you if I sent them. I'll also send to Locutus and Herdie if his addy is here. Your addy came up strange when I clicked on the email icon.
Radical_Manuvr is offline  
Old January 7, 2001, 20:18   #52
Radical_Manuvr
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 2000
Location: Maryland, USA
Posts: 80
Still didn't get random location to work. It just crashes with no msg when I include the lines for that. It may be that it's putting the location off the map. Perhaps limiting to between 3 and max x-4 would fix it. Same with y. Anyway, this works for a certain location, whatever is in tmpXloc, tmpYloc. I commented out the last random part I tried to get to work.

I was using huge map size for testing it so it may not work with other sizes. Put a city in the location, add some bldgs, and units all around and in the city and see what happens. Pretty cool, IMHO. It works at locations other than cities as well. I probably have some unnecessary stuff in this but it works (except the random part) anyway. Never claimed to be a programmer. I planned to add a msg and maybe have a city lose a pop if the epicenter was a city, but this is what's done for now.

scenario.slc

/////////////////////////////////////////////////////////////////////////////////////
// Script for the earthquake disaster mod 1.0 //
// last update 01-07-2001 by Charles Rothermel Apolyton name Radical_Manuvr //
/////////////////////////////////////////////////////////////////////////////////////


//////////////////////
// Global variables //
//////////////////////

int_t humanPlayer; // The human player number
int_t tmpYloc;
int_t tmpXloc;
int_t turnCount; // Number of turns elapsed
int_t turnMax; // Turns until scenario ends
location_t disasterLoc;
location_t disasterLoc2;

#include "EQ_func.slc" // Functions

//////////////
// Handlers //
//////////////

//---------------------------------
// Stuff to do when the game starts
//-----------------------------------

HandleEvent(BeginTurn) 'EQStart_F' pre {
int_t tmpPlayer;
if(IsHumanPlayer(player[0])) {
humanPlayer = player[0];

turnMax = 600; // if turnCount reaches turnMax, the game ends
turnCount = 0; // number of turns elapsed
// tmpXloc = 64; // max x for huge map, if using different size enter max x here
// tmpYloc = 128; // max y for huge map, if using different size enter max y here
// tmpXloc = GetMapWidth();
// tmpYloc = GetMapheight();
DisableTrigger('EQStart_F');
}
}

//-----------------------
// Stuff to do every turn
//-------------------------

HandleEvent(BeginTurn) 'EQEachTurn_F' post {
city_t tmpCity;
int_t i;
int_t tmpPlayer;
int_t tmpRichter; // Richter scale simulator
int_t tmpDestroy; // used to determine which building to destroy
int_t tmpnumberUnits;

tmpPlayer = player[0];
// tmpXloc = Random(63); // -1 from map size since random starts at 0
// tmpYloc = Random(127); // -1 same

tmpXloc = 29;
tmpYloc = 75;

if (tmpPlayer == 1) {
turnCount = turnCount + 1; // increment turn counter
if (turnCount > turnMax) {
if (humanPlayer == 1) {
Event:GiveMap(2,1); // this is temporary just need something here
}
} // temp for testing take out later
MakeLocation(disasterLoc, tmpXloc, tmpYloc);
tmpRichter = Random(8); // random number from 0-8
tmpDestroy = Random(52); // random number from 0-52
GetCityByLocation(disasterLoc, tmpCity);

if (CityIsValid(tmpCity)) { // if a city exists at the epicenter
tmpnumberUnits = UnitsInCell(disasterLoc); // number of units in cell
if (tmpnumberUnits > 0) {
QuakeDamage (disasterLoc, tmpnumberUnits, tmpRichter);
}
for (i = 0; i < tmpRichter; i = i + 1) {
GetRandomNeighbor(disasterLoc, disasterLoc2); // find a random tile one tile from epicenter
Event:CutImprovements(disasterLoc2); // destroy tile improvements if found
tmpnumberUnits = UnitsInCell(disasterLoc2); // number of units in cell
if (tmpnumberUnits > 0) {
QuakeDamage (disasterLoc2, tmpnumberUnits, tmpRichter);
}
}
if (tmpRichter > 5) { // if quake is 6, 7, or 8 a building will be destroyed if it exists
// if the building doesn't exist nothing happens to buildings
if (tmpDestroy == 0 | | tmpDestroy == 1) { // 2 in 52 chance
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_VR_AMUSEMENT_PARK));
} elseif (tmpDestroy == 2) { // 1 in 52 chance
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ACADEMY));
} elseif (tmpDestroy == 3) { // 1 in 52 chance from here down
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_AIRPORT));
} elseif (tmpDestroy == 4) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ANTI_BALLISTIC_MISSILES));
} elseif (tmpDestroy == 5) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_AQUA_FILTER));
} elseif (tmpDestroy == 6) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_AQUEDUCT));
} elseif (tmpDestroy == 7) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ARCOLOGIES));
} elseif (tmpDestroy == 8) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ARENA));
} elseif (tmpDestroy == 9) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BALLISTA_TOWERS));
} elseif (tmpDestroy == 10) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BANK));
} elseif (tmpDestroy == 11) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BASCILICA));
} elseif (tmpDestroy == 12) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BATTLEMENTS));
} elseif (tmpDestroy == 13) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BAZAAR));
} elseif (tmpDestroy == 14) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BEHAVIORAL_MOD_CENTER));
} elseif (tmpDestroy == 15) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BODY_EXCHANGE));
} elseif (tmpDestroy == 16) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BROKERAGE));
} elseif (tmpDestroy == 17) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CAPITOL));
} elseif (tmpDestroy == 18) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CITY_WALLS));
} elseif (tmpDestroy == 19) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_COMPUTER_CENTER));
} elseif (tmpDestroy == 20) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CORNUCOPIC_VAT));
} elseif (tmpDestroy == 21) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CORRECTIONAL_FACILITY));
} elseif (tmpDestroy == 22) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_COURTHOUSE));
} elseif (tmpDestroy == 23) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_DRUG_STORE));
} elseif (tmpDestroy == 24) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_E_BANK));
} elseif (tmpDestroy == 25) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ECO_TRANSIT));
} elseif (tmpDestroy == 26) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FACTORY));
} elseif (tmpDestroy == 27) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FLAK_TOWERS));
} elseif (tmpDestroy == 28) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FOOD_SILO));
} elseif (tmpDestroy == 29) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FORCEFIELD));
} elseif (tmpDestroy == 30) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FUSION_PLANT));
} elseif (tmpDestroy == 31) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_GAIA_COMPUTER));
} elseif (tmpDestroy == 32) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_GRANARY));
} elseif (tmpDestroy == 33) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_HOSPITAL));
} elseif (tmpDestroy == 34) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_INCUBATION_CENTER));
} elseif (tmpDestroy == 35) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_MATTER_DECOMPILER));
} elseif (tmpDestroy == 36) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_MICRO_DEFENSE));
} elseif (tmpDestroy == 37) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_MILL));
} elseif (tmpDestroy == 38) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_MOVIE_PALACE));
} elseif (tmpDestroy == 39) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_NANITE_FACTORY));
} elseif (tmpDestroy == 40) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_NUCLEAR_PLANT));
} elseif (tmpDestroy == 41) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_OIL_REFINERY));
} elseif (tmpDestroy == 42) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ORBITAL_LABORATORY));
} elseif (tmpDestroy == 43) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_POWER_SATELLITE));
} elseif (tmpDestroy == 44) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_PUBLIC_TRANSPORTATION));
} elseif (tmpDestroy == 45) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_PUBLISHING_HOUSE));
} elseif (tmpDestroy == 46) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_RECYCLING_PLANT));
} elseif (tmpDestroy == 47) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ROBOTIC_PLANT));
} elseif (tmpDestroy == 48) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_SECURITY_MONITOR));
} elseif (tmpDestroy == 49) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_SHRINE));
} elseif (tmpDestroy == 50) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_TELEVISION));
} elseif (tmpDestroy == 51) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_THEATER));
} elseif (tmpDestroy == 52) {
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_UNIVERSITY));
}
if (tmpRichter == 8) { // if quake is 8, city walls will be destroyed if they exist
// at this magnitude something should go
DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CITY_WALLS));
}
}
} else { // no city at epicenter
Event:CutImprovements(disasterLoc); // destroy tile improvements if found at epicenter
tmpnumberUnits = UnitsInCell(disasterLoc); // number of units in cell
if (tmpnumberUnits > 0) {
QuakeDamage (disasterLoc, tmpnumberUnits, tmpRichter);
}
for (i = 0; i < tmpRichter; i = i + 1) {
// the higher the Richter number the more likely a tile improvement will be destroyed
// can be up to 8 tile improvements destroyed surrounding epicenter
GetRandomNeighbor(disasterLoc, disasterLoc2); // find a random tile one tile from epicenter
Event:CutImprovements(disasterLoc2); // destroy tile improvements if found
tmpnumberUnits = UnitsInCell(disasterLoc2); // number of units in cell
if (tmpnumberUnits > 0) {
QuakeDamage (disasterLoc2, tmpnumberUnits, tmpRichter);
}
// possible that it will use the same tile 8 times or other combos, ex. 1 twice, another once, another 3 times
// losing all tile impr. around epicenter should be rare
}
}
}
}

EQ_func.slc


///////////////
// Functions //
///////////////

// Damages all units in location
void_f QuakeDamage (location_t tmpLoc, int_t tmpNum, int_t tmpNum2)
{
int_t i;
unit_t tmpUnit;

for (i = 0; i < tmpNum; i = i + 1) {
GetUnitFromCell(tmpLoc, i, tmpUnit);
if (tmpUnit.hp > 8) {
DamageUnit(tmpunit, tmpNum2); // Subtract tmpNum2 hit points from the specified unit
}
}
}

Radical_Manuvr is offline  
Old January 7, 2001, 23:32   #53
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
quote:

Originally posted by Radical_Manuvr on 01-07-2001 07:03 PM
AW, please type your email address so I can send you the files. I'll post here but figured it would be eaiser for you if I sent them. I'll also send to Locutus and Herdie if his addy is here. Your addy came up strange when I clicked on the email icon.


CTPAlphaWolf@aol.com

When I setup that account on aol i set it up as CTP Alpha Wolf forgetting that the email address would freak out on the spaces. Took me a few days of harrassing poor Dan and Mark in order to figure out that my actual email address didnt have the spaces. Now I'm afraid to touch it in my profile....LOL

I think i remember seeing that buildings are assigned a number as its read into the database. If so, you can just do a loop thru the number of buildings and would save a ton of code.

Something like:

if (tmpRichter > 4) { // if quake is 5, 6, 7, or 8 buildings have a chance to be destroyed
// if the building doesn't exist nothing happens to buildings

for(b = 0; Building.Type[b] <> ""; b = b + 1)
{ //assuming this is how to identify the end of the array
if random(tmpRichter * 3) > 12 {
//chance any building will be destroyed
DestroyBuilding(tmpCity, Building.Type[b])
}
}


Also, depending on how SLIC does there rounding, tmpRichter = Random(8); will most likely give you a range of 0 to 7. Most of the randomizers i've seen over the years simply drop fractional values so getting the 8 would be so rare that in essence it would never happen. However, if SLIC's randomizer rounds then you can get 8 more often.
------------------
History is written by the victor.
[This message has been edited by Alpha Wolf (edited January 07, 2001).]
[This message has been edited by Alpha Wolf (edited January 07, 2001).]
Alpha Wolf is offline  
Old January 7, 2001, 23:38   #54
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
Great work!

I'll force that together with my code and see what happens. This should be good
heardie is offline  
Old January 8, 2001, 00:26   #55
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
What is

#include "EQ_func.slc" // Functions ????


I put the code into scenario.slc but the game crashes on that line.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 8, 2001, 01:14   #56
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
EW_FUNC
Code:
  ///////////////
 // Functions //
///////////////

// Damages all units in location
void_f QuakeDamage (location_t tmpLoc, int_t tmpNum, int_t tmpNum2)
{
int_t	i;
unit_t tmpUnit;

	for (i = 0; i < tmpNum; i = i + 1) {  
		GetUnitFromCell(tmpLoc, i, tmpUnit);
		if (tmpUnit.hp > 8) {	
			DamageUnit(tmpunit, tmpNum2);		// Subtract tmpNum2 hit points from the specified unit
		}
	}
}
heardie is offline  
Old January 8, 2001, 01:17   #57
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
So close to getting this work..
Okay now
I added this

################################################## ##########

IMPROVE_DROUGHT {
DefaultIcon ICON_IMPROVE_GRANARY
Description DESCRIPTION_IMPROVE_GRANARY
EnableAdvance ADVANCE_AGRICULTURE
ProductionCost 0
Upkeep 0
FoodPercent -0.25
}

################################################## ##########

IMPROVE_GREATWEATHER {
DefaultIcon ICON_IMPROVE_GRANARY
Description DESCRIPTION_IMPROVE_GRANARY
EnableAdvance ADVANCE_AGRICULTURE
ProductionCost 0
Upkeep 0
FoodPercent 0.25
}

################################################## ##########

ANd it crashed saying
'buildings.txt:727: Record does not start with name'

not how can I fix this?
heardie is offline  
Old January 8, 2001, 01:42   #58
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
quote:

Originally posted by heardie on 01-08-2001 12:17 AM

'buildings.txt:727: Record does not start with name'

not how can I fix this?


i got that error when i tried to add some wonders to the end of the wonders file. I moved them all to the top and the error went away. Made no other changes.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 8, 2001, 02:59   #59
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
Thanks Alpha. More errors here though and i havent even tried adding radical's eq code.

i dont know how or why but the line

for(m = 0; m <= player.cities; m = m + 1){

is being flagged as an wrror, because 'player is not a structure'. This must work,, shouldnt it?

NOTE: I will be gone most likly till friday from the forums, but when i return I hope to have it all done bar floods
heardie is offline  
Old January 8, 2001, 04:56   #60
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
On a scale of 1 to 10 (expert), my SLIC is about a 2, but that sure looks right to me. I assume that you declared "int_t m"? As I've been trying to implement Rad's code (so far unsuccessfully) I've noticed some of the error messages are misleading. So now when I get an error on a line, I mostly ignore the message itself and concentrate on the entire line. But according to the SLIC doc player.cities is valid.

Oh crud....while i was looking at valid flags I realized that we could code for labor strikes if a city riots and remove a percentage of PW. Someone turn my brain off before I have any more ideas....LOL

We probably want to use the "AddCenter(loc)" to center on the quake also. OMG, the examples show how to make a city immune to riots and revolts. I was so tired when I read thru this stuff the first time that I didnt realize how many things we can do.

And i wonder if we could use SLIC to have the AI build an effective army. Interesting that there is an unit.name but not an army.name. We could have had units join specific armies and when those armies = 12 units, off they go to war, like a blitzkrieg. I wonder how to tell which units are grouped.

whew, i finally switched the brain off for the night or I'll be up all night coming up with new ideas.

------------------
History is written by the victor.
Alpha Wolf 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:52.


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