Author Topic: Natural Disasters..  (Read 2628 times)

Offline xamlit

  • Full Member
  • ***
  • Posts: 160
Natural Disasters..
« on: April 03, 2005, 03:40:27 AM »
Okay... Lets open this can of worms. Is there any way that I can have a  earthquake occur in any section of the map at certain intervals of time?

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Natural Disasters..
« Reply #1 on: April 03, 2005, 06:30:08 AM »
Yes; use timers:

Quote
CreateTimeTrigger(1,0,2000,"Quake");
...

void Quake()
{
  TethysGame::SetEarthquake(32+TethysGame::GetRand(128),TethysGame::GetRand(128),1);
}
This will create an earthquake in a 128x128 map at a random location, every 20 ticks.
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline xamlit

  • Full Member
  • ***
  • Posts: 160
Natural Disasters..
« Reply #2 on: April 03, 2005, 03:15:15 PM »
How do I set a specifc location?
 

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Natural Disasters..
« Reply #3 on: April 03, 2005, 03:48:57 PM »
TethysGame::SetEarthquake(x+31,y-1,magnitude)

magnitude=1 is a small quake, anything over 2 will kill almost any building at the epicenter.

[EDIT] There is a (+31,-1) offset in co-ordinates. Don't ask why: just calculate it that way: if you want a quake at (1,1) set it in code to occur at (32,0)
« Last Edit: April 03, 2005, 03:51:04 PM by Eddy-B »
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Mez

  • Hero Member
  • *****
  • Posts: 648
Natural Disasters..
« Reply #4 on: April 05, 2005, 12:26:22 PM »
Is that because the disaster can occur off the map?

i.e. a tornado can spin in from the edge of the map, or the epicenter of the quake can be off the edge of the map so the edge only recieves a smaller shock?

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
Natural Disasters..
« Reply #5 on: April 05, 2005, 02:03:35 PM »
Actually, the +31 -1 stuff is used almost everywhere.

It's because the game adds padding regions to the sides of the map (If I remember right, they're used for blight expansion, letting units exit off the edges, etc) and the mission designer could also use them to hide things that will be used later, like units, possibly even whole bases =)

So in effect (0,0) is probably still a real place on the map, but not visible to the user.
(31,-1) is the upper left corner of the player-visible map.

We haven't documented the padding regions at all, they seem to be different for different map sizes if I remember right. The best way to find out whether they're usable is to just test. If it doesn't work the game will crash trying to do something in that part of the map.

World maps, I'm not sure if they have left-right padding. I don't think they do. They might have top-bottom padding though.

Just play around with it if you're really interested in putting stuff outside the map.

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
Natural Disasters..
« Reply #6 on: April 05, 2005, 02:29:52 PM »
And if you dont want to add the number when placeing mines use:
Code: [Select]
	{ XYPos( 15,  8), mapMiningBeacon, 0, 1, 1},

Offline zigzagjoe

  • Hero Member
  • *****
  • Posts: 626
Natural Disasters..
« Reply #7 on: April 21, 2005, 08:07:04 PM »
How would one go about making a volcano?

i have:

TethysGame::SetLavaSpeed(10);
TethysGame::SetEruption(163, 136, 0);

and a script that setslavapossible on all volcaninc tiles.

problem is: i get nada

it is announced, but nothing else happenes.

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
Natural Disasters..
« Reply #8 on: April 21, 2005, 08:14:41 PM »
Eddy-B the volcano expert to the rescue.. !

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Natural Disasters..
« Reply #9 on: April 21, 2005, 08:38:50 PM »
Well, from what I hear, Eddy has more advanced code than I do for setting lava flows, but essentially you can do it by calling GameMap::SetLavaPossible for each tile the lava can flow to.

Here is some sample code I used to clone the lava flow from CES1.dll (Colony, Eden Startship). I got the coordinates of the volcano from a disassembled view of the DLL, hence why all the coordinates are listed in hex.


Code: [Select]
	// Set animated mouth of volcano
GameMap::SetTile(LOCATION(0x32, 0xB8), 0x474);
GameMap::SetTile(LOCATION(0x32, 0xB9), 0x47E);

// Allow lava at initial eruption point
GameMap::SetLavaPossible(LOCATION(0x32, 0xBA), 1);
// Set eruption point
TethysGame::SetEruption(0x32, 0xBA, 0x96 /* Lava spread speed? (set after the eruption has occured) */);


The first two lines of code set the animation usually found on volcanos. The next line of code ensures lava can flow on the actual eruption point. (Otherwise it tends to never appear, even though you get the eruption warning.) The last line actually starts the eruption. Note how the last parameter controls the spread speed. It needs to be fairly large for it to be noticable. Also, when the eruption occurs, whatever lava spread speed was set before is overwritten. It appears to be one global value used by all volcanos.
« Last Edit: April 21, 2005, 08:39:25 PM by Hooman »

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Natural Disasters..
« Reply #10 on: April 22, 2005, 01:14:41 PM »
To add to Hooman: the 3rd param in SetEruption is the speed at wich the lava will spread out: set it 1 and it'll go a snail's pass, set to too 200 for example, and you got 2 seconds to get out of the way !

As for LavaPossible: This function (SetAllLava) sets LavaPossible for all dark-gray tiles, including the edges. Just call the function from your InitProc().
Be advised that IF you call it at some other time in your DLL, it won't setLavaPossible to any modified tiles, i.e. tiles that are dozed, or have a crater, or rubble, or whatever!

Code: [Select]
// SetAllLava:
// dark lavarock: 1D7-1F8
// edges: 22F-25E

void SetAllLava()
{
LOCATION size(1024,1024);
int x,y,tile;

size.Clip();    // just a simple way to get the correct mapsize
for (y=0; y<size.y; ++y)
{
  for (x=31; x<size.x; ++x)
  {
   tile=GameMap::GetTile(LOCATION(x,y));
   if (((tile>=0x22F) && (tile<=0x25E)) || ((tile>=0x1D7) && (tile<=0x1F8)))
    GameMap::SetLavaPossible(LOCATION(x,y),true);
  }
}
}
« Last Edit: April 23, 2005, 12:08:23 PM by Eddy-B »
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz