Thread Tools
Old December 28, 2000, 00:30   #1
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
creating natural disasters via SLIC????
i was looking at the SLIC flags, and started wondering if we could use them to simulate natural occurances. IF random locations are possible, we could have that spot get hit with an bombardment to simulate an earthquake, or plaque. Since bombardment can kill population and destroy buildings, a strong earthquake might consist of several bombardments. If nothing exists at the randomly selected location, nothing would happen. Also, a random weather number could give global food bonuses some years, and droughts in others.

Since my SLIC knowledge is limited, i figured i'd throw it out to those who have used it more.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old December 28, 2000, 20:24   #2
Depp
Prince
 
Depp's Avatar
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Stockholm, Sweden
Posts: 399
Since you can change land you can write a sliccode that can grow mountains and such anywhere on map, and adding beaches where you need them. Could be pretty cool.
Depp is offline  
Old December 28, 2000, 20:50   #3
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
[Note: I have not yet looked at SLIC this is all pseudo code]

Okay 1st you should create random locations on the map.
If the map was 100x100 to create a random location you could use this (in Pseudo Code - I'll post how to do it in slick [hopefully] once Ii get back from a holiday)

CreateRandomNo(1-100) -> Store it in variable i
CreateRandomNo(1-100) -> Store in variable j
Variable TempLoc = [i,j]

Now say you wanted 10 locations. A for loop should doo that

Creat loop from 1 - 10 -> Variable m
{
CreateRandomNo(1-100) -> Store it in variable i
CreateRandomNo(1-100) -> Store in variable j
Variable TempLoc[m]=[i,j]
}

Maybe that could work for random locations. The first should work, but I don't know about the second. If the second one didnt owork you could just do the first one x amount of times, and cjust change the name of the temploc varibale.

Hope you understand, and I hope someone can convert my pseudo into SLIC
heardie is offline  
Old December 28, 2000, 22:25   #4
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
Good idea of writing it out in psuedo code. Here's what i was thinking:

pick an event (drought, great weather, quake, plague,none)

if drought (10%)
global decrease in food

if great weather (10%)
global increase in food production

if quake (40%)
determine richter factor (1 to 7)
bombard location richter times (if city only)
determine 1 tile radius around epicenter and bombard those tiles richter/2 times (if city only)

if plague (20%)
bombard location 3 times (if city or army to simulate deaths)
determine 1 tile radius around center and bombard those tiles 2 times (if city or army to simulate deaths)
if any of the tiles are a city
infect it (gives plague a chance to spread)

that leaves 20% when nothing happens. And the majority of quakes and plagues wont hit anything and cause no damage unless the radius is enlarged

It seems that this should be doable.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old December 29, 2000, 04:17   #5
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
Okay, this code is to find a random location, and also for me to learn SLIC. I have come across a problem which ill describe at the end.
scenario.slc
Code:
#include "msg.slc"
int_t i;
int_t j;
int_t no_of_disasters;
int_t x;
int_t temp_locx[];
int_t y;
int_t temp_locy[];

HandleEvent(BeginTurn) 'DStart_F' pre 
{
	Message (1, 'AGStartA');
}

HandleEvent(BeginTurn) 'DEachTurn_F' post 
{
	if (random(3) == 1)
	{
		i = random(20);
		j = random(20);
		no_of_disasters = 2; //Change the '2' to how many natural disasters you want
		for(x = 0; x < no_of_disasters; x = x + 1) 
		{
			temp_locx[x] = i; //x value
		}

		for(y = 0; y < no_of_disasters; y = y + 1) 
		{
			temp_locy[y] = j; //y value
		}
	}
}
msg.slc
Code:
messagebox 'AGStartA' {
	Show();
	Title(ID_AG_START_TITLE);
	Text(ID_AG_START_A);
	Button(ID_AG_BUTTON_NEXT) 
		{
			Kill();
		}
}
scen_str
Code:
AG_BUTTON_NEXT		 	"Next->"
AG_START_TITLE	"Natural Disasters"
AG_START_A	"Made by heardie"
Now why doesn't this display a messagebox when the game loads?
Do I need to call 'DStart_F'
[This message has been edited by heardie (edited December 29, 2000).]
heardie is offline  
Old December 29, 2000, 04:41   #6
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
thats a good ideas Alpha. when I get back on the 7th ill try and implement them. If its not done by then!
heardie is offline  
Old December 29, 2000, 06:12   #7
skorpion59
Prince
 
Local Time: 03:52
Local Date: October 31, 2010
Join Date: May 1999
Location: Tulsa, Oklahoma, USA
Posts: 716
For the messagebox problem, this will do it.

Scenario.slc:
Code:
//just run once when the game starts

HandleEvent(BeginTurn) 'DonStartGame' post {

	if(IsHumanPlayer(player[0])) {
		Message (g.player, 'DonTurn0');
		DisableTrigger('DonStartGame');
	}
}

messagebox 'DonTurn0' {
	Show();
	Title(ID_DON_TURN_0_TITLE);
	Text(ID_DON_TURN_0);
}
Scen.str:
Code:
DON_TURN_0_TITLE "Natural Disasters"
DON_TURN_0 "\nMade by Heardie"
skorpion59 is offline  
Old December 29, 2000, 11:05   #8
wheathin
Prince
 
wheathin's Avatar
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Apr 1999
Location: home
Posts: 601
What happens if the chosen location is ocean? You could add a check that makes sure that the disasters only hit land.

Also, for droughts, would it be possible to have it actually change terrain - replace plains with deserts, for example? If so, you could add a mini-ice age/el nino trigger with similar effect.

Finally, with the bombarding, will that also destroy tile improvements? If not, maybe that should be an additional effect of the disasters.
wheathin is offline  
Old December 29, 2000, 12:35   #9
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
I had actually thought about those options also. Like if the quake was just offshore, to flood flatlands, or if it was a mountain, for it to be a volcano. But at that point I hadnt read too much about SLIC yet so didnt want to get too complicated. I figured quakes would destroy mines, road/rail, but farms and adv farms wouldnt be that affected by some ground shaking. I figured it would take quite a few years of drought to turn land bad or good years to turn desert into plains, so I didnt know how realistic those options would be. Altho natural disasters seem to happen alot, the big world changing ones are rare.

I'm glad I'm not the only one that thinks this is viable

------------------
History is written by the victor.
Alpha Wolf is offline  
Old December 30, 2000, 12:04   #10
Matthew Watson
Settler
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 2000
Location: Edinburgh, Scotland
Posts: 4
quote:

Originally posted by wheathin on 12-29-2000 10:05 AM
What happens if the chosen location is ocean? You could add a check that makes sure that the disasters only hit land.



Maybe it could represent a tsunami - the code could search for all swamps within a certain radius and turn them into sea.
Matthew Watson is offline  
Old December 31, 2000, 01:11   #11
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 Matthew Watson on 12-30-2000 11:04 AM
Maybe it could represent a tsunami - the code could search for all swamps within a certain radius and turn them into sea.


I had figured any flatland would be hit by the tital wave.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old December 31, 2000, 15:19   #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:52
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Instead of using bombardment to destroy things, it might be better to use manually destroy buildings (using DestroyBuilding), damage or kill units (using KillUnit or DamageUnit) or destroy terrain improvements (using CutImprovements) or change terrain (using KillTile or Terraform), change citysize (using KillPop or MakePop), etc. This gives you much more control over what happens and you could even come up with things that reduce the effects of these disasters.

One thing though, it's not possible to increase or decrease food or production through SLIC. The only workaround for this that I know is to create and destroy special city-improvements for this purpose (e.g. a city improvement called Drought that decreases food in a city with 10% or a building called great weather that gives 10% extra food in the city). It's not pretty but as far as I see there's no other solution to this.
[This message has been edited by Locutus (edited December 31, 2000).]
Locutus is offline  
Old December 31, 2000, 17:03   #13
Cyrius
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Nov 2000
Location: Minneapolis, MN, USA
Posts: 71
Clever... very clever...keep up the work on this guys, sounds fascinating! I'd love to include random weather in my games, it would help spice things up.
Cyrius is offline  
Old December 31, 2000, 18:59   #14
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
part of the fun of adding disasters would be their unpredictability of damage. Once you start specific coding, wouldnt you lose that randomness? Plus even in this day, look at the damage that has been done in Californian quakes, which I guess has the most stringest building codes for surviving quakes. By using bombardment, you never know which buildings might be destroyed or how many if any population is killed. My personal preference is to keep as much totally random as possible, altho I understand that may not be everyones opinion.

If we cant do weather via SLIC, how about randomly generated wonders. WONDER_DROUGHT that reduces global food, or WONDER_GREAT_WEATHER that increases it?

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 1, 2001, 14:55   #15
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
Well, randomness isn't a problem since SLIC has a Random function. If a quake happened in or near a city you could specify the chance a building is destroyed (even make this specific for certain types or buildings or whatever) and cycle through all buildings and wonders in the city and use the Random function to test if it would be destroyed or not. This is just as unpredicable as the bombardment function, but much more tweakable (e.g. you could make a Bank much more likely to survive than a Factory or whatever).

One problem with the wonder/advance I forgot to mention is that there is a max of 64 buildings & wonders, so you can only have so much of these events. Also, the disadvantage of using a Wonder instead of a building is that you can only have one at a time, which might be undesirable (but sometimes it might not matter, so it's still useful but only when no more than one at a time is needed).
Locutus is offline  
Old January 1, 2001, 15:20   #16
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-01-2001 01:55 PM
Well, randomness isn't a problem since SLIC has a Random function. If a quake happened in or near a city you could specify the chance a building is destroyed (even make this specific for certain types or buildings or whatever) and cycle through all buildings and wonders in the city and use the Random function to test if it would be destroyed or not. This is just as unpredicable as the bombardment function, but much more tweakable (e.g. you could make a Bank much more likely to survive than a Factory or whatever).



Ah, now I understand. Yes, that would be more preferrable to bombardment. i had thought you meant that if there was a quake and the city has a bank then to destroy it. I didnt realize that you could cycle thru the buildings in a city and give it a percentage that it would be destroyed. We could have a building called IMPROVEMENT_BUILDING_CODE that would minimize the damage.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 4, 2001, 16:25   #17
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
Well, problem is that I'm already working almost full-time on Harlan's scenario and the code for the MedMod, so I don't have much time right now (it will get much worse when college starts again). And even if I had more time, I'm still working on some decent SLIC documentation as well, which has precedence over this, so I won't be able to do much about this for at least the next two-three weeks (probably longer). I was kind of hoping someone else would pick this up. (If you'd dig into the archives you'd find so many SLIC ideas it would take one guy several years to turn it all into code, even if he's working 8 hours a day, so we definately need more people going into SLIC.)
Locutus is offline  
Old January 4, 2001, 16:59   #18
Harlan
Apolytoners Hall of Fame
 
Local Time: 01:52
Local Date: October 31, 2010
Join Date: Aug 2005
Location: Berkeley, CA, USA
Posts: 1,053
Locutus,
When you say there are a max of 64 buildings and wonders, is that something you know for sure or are you assuming that's how it was in CTP1 and its probably the same in CTP2? Also, do you know of any limits to the number of advances?
Harlan is offline  
Old January 4, 2001, 17:20   #19
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
Would I be safe in assuming that any file whose first line is the number of entries probably has a limit? Any cases where this isnt true?

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 4, 2001, 17:29   #20
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
Harlan,

Unless Mr Ogre is a pathelogical lie-er(sp?) I'm fairly sure of that 64 limit on buildings and wonders AFAIK there's no limit on advances or units though (and IIRC Mr Ogre confirmed that).

Alpha,

I don't know, that might actually be the case, it never occured to me that there might actually be a system
Locutus is offline  
Old January 4, 2001, 20:07   #21
colorme
Warlord
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Nov 2000
Posts: 122

Guys, this is great. But I hope the idea is to restrict all disasters to the human. We don't want to overload the AI's already weak brain do we?
colorme is offline  
Old January 4, 2001, 20:32   #22
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
my AI's brain aint weak anymore. Disasters affect anyone. Whole cities have been wiped out by disasters, so if a civ is by chance hurt, it'll have to bounce back.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 4, 2001, 22:33   #23
Radical_Manuvr
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Dec 2000
Location: Maryland, USA
Posts: 80
Great idea AW and additions from others. If I decide to "borrow" it for a scenario I'm working on, I'll be happy to post working code. I'm in the very early stages though, so hopefully someone will beat me to it.
Radical_Manuvr is offline  
Old January 4, 2001, 23:27   #24
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
Thanks. i figured its doable but i've been spending so much time improving the AI that I havent had a chance to practise SLIC. I'm also hoping someone will have the time to try this.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 5, 2001, 01:43   #25
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
Have you had a chance to try any of the disaster coding? If you can get it started, I probably can test asd debug it. Its the initial how to set it up in SLIC that I'm not very good at.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 6, 2001, 07:05   #26
heardie
Prince
 
heardie's Avatar
 
Local Time: 20:52
Local Date: October 31, 2010
Join Date: Aug 1999
Posts: 684
I'm back now, and ready to code. I hope you dont mind me asking 1 million questions though, eventually. That sucks if you cant change the cities food production, now I need to learn how to make a building. I thought I was so smart too:

Code:
for(m = 0; m <= player.cities; m = m + 1) 
		{
			CityFoodDelta(city[m]) = .75 * CityFoodDelta(city[m])
		}
Oh Well!
heardie is offline  
Old January 6, 2001, 09:54   #27
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,
Well, at least it's original Most people would try to use variables to change in-game values (something like city[0].netcitygold = 2 * city[0].netcitygold), never saw anyone using functions for it before

One other thing to be aware of is that SLIC only works with whole numbers, everything after the dot will simply be cut off, so even if your example trigger would have worked, it would have made the CityFoodDelta 0. If you want to say x = .75 * x, you'll have to say x = (x * 3) / 4, or something like that.
Locutus is offline  
Old January 6, 2001, 12:47   #28
Alpha Wolf
Chieftain
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
Now I know why I'm leaving the SLIC coding to you guys. ZOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMMMMMMM MM

------------------
History is written by the victor.
Alpha Wolf is offline  
Old January 6, 2001, 15:06   #29
colorme
Warlord
 
Local Time: 09:52
Local Date: October 31, 2010
Join Date: Nov 2000
Posts: 122


On Slic mathematics, my observation is that if something in a command is not an integer, Slic may simply ignore that command (it won't complain)! I don't know if that's a fact, but that was the effect I seemed to be getting.
colorme is offline  
Old January 6, 2001, 17:31   #30
Harlan
Apolytoners Hall of Fame
 
Local Time: 01:52
Local Date: October 31, 2010
Join Date: Aug 2005
Location: Berkeley, CA, USA
Posts: 1,053
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.
Harlan 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