So here's some code I could use some help cleaning up.
It's all for testing purposes right now and it's a little lengthy...
This code creates a Volcano at one of 7 pre-selected locations, randomly at Mark 11. Actually spreading Lava I'll declare all at once, and I hope to use this structure of code, or a similar structure for other events.
Before Init_Proc
void VolA()
{
// Start a south volcano animation
SouthFlowAni(70 + 31, 37 - 1);
// Start the eruption on it's way in 1 mark
Trigger &timeTrigger = CreateTimeTrigger(true, true, 100, "EruptionA");
return;
}
void VolB()
{
// Start a south volcano animation
SouthFlowAni(80 + 31, 37 - 1);
// Start the eruption on it's way in 1 mark
Trigger &timeTrigger = CreateTimeTrigger(true, true, 120, "EruptionB");
return;
}
void VolC()
{
// Start a south volcano animation
SouthFlowAni(90 + 31, 37 - 1);
// Start the eruption on it's way in 1 mark
Trigger &timeTrigger = CreateTimeTrigger(true, true, 130, "EruptionC");
return;
}
void VolD()
{
// Start a south volcano animation
SouthFlowAni(100 + 31, 37 - 1);
// Start the eruption on it's way in 1 mark
Trigger &timeTrigger = CreateTimeTrigger(true, true, 140, "EruptionD");
return;
}
void VolE()
{
// Start a south volcano animation
SouthFlowAni(110 + 31, 37 - 1);
// Start the eruption on it's way in 1 mark
Trigger &timeTrigger = CreateTimeTrigger(true, true, 150, "EruptionE");
return;
}
void VolF()
{
// Start a south volcano animation
SouthFlowAni(120 + 31, 37 - 1);
// Start the eruption on it's way in 1 mark
Trigger &timeTrigger = CreateTimeTrigger(true, true, 160, "EruptionF");
return;
}
void VolMid()
{
// Start a south volcano animation
SouthFlowAni(130 + 31, 37 - 1);
// Start the eruption on it's way in 1 mark
Trigger &timeTrigger = CreateTimeTrigger(true, true, 170, "EruptionMid");
return;
}
void (*volcanos[7])() = { VolA, VolB, VolC, VolD, VolE, VolF, VolMid };
In Init_Proc
(*volcanos[TethysGame::GetRand(7) % 7])();
After Init_Proc
SCRIPT_API void EruptionA()
{
// Mark where the lava can flow
// (do this anytime before the eruption, including from InitProc)
GameMap::SetLavaPossible(LOCATION(70+ 31, 39 - 1), true);
GameMap::SetLavaPossible(LOCATION(70 + 31, 40 - 1), true);
GameMap::SetLavaPossible(LOCATION(70 + 31, 41 - 1), true);
// Start the lava flowing (... in about 10 marks)
// At this point, the earliest disaster warning will sound
TethysGame::SetEruption(70 + 31, 39 - 1, 200);
TethysGame::SetLavaSpeed(150);
}
SCRIPT_API void EruptionB()
{
// Mark where the lava can flow
// (do this anytime before the eruption, including from InitProc)
GameMap::SetLavaPossible(LOCATION(80 + 31, 39 - 1), true);
GameMap::SetLavaPossible(LOCATION(80 + 31, 40 - 1), true);
GameMap::SetLavaPossible(LOCATION(80 + 31, 41 - 1), true);
// Start the lava flowing (... in about 10 marks)
// At this point, the earliest disaster warning will sound
TethysGame::SetEruption(80 + 31, 39 - 1, 200);
TethysGame::SetLavaSpeed(150);
}
SCRIPT_API void EruptionC()
{
// Mark where the lava can flow
// (do this anytime before the eruption, including from InitProc)
GameMap::SetLavaPossible(LOCATION(90 + 31, 39 - 1), true);
GameMap::SetLavaPossible(LOCATION(90 + 31, 40 - 1), true);
GameMap::SetLavaPossible(LOCATION(90 + 31, 41 - 1), true);
// Start the lava flowing (... in about 10 marks)
// At this point, the earliest disaster warning will sound
TethysGame::SetEruption(90 + 31, 39 - 1, 200);
TethysGame::SetLavaSpeed(150);
}
SCRIPT_API void EruptionD()
{
// Mark where the lava can flow
// (do this anytime before the eruption, including from InitProc)
GameMap::SetLavaPossible(LOCATION(100 + 31, 39 - 1), true);
GameMap::SetLavaPossible(LOCATION(100 + 31, 40 - 1), true);
GameMap::SetLavaPossible(LOCATION(100 + 31, 41 - 1), true);
// Start the lava flowing (... in about 10 marks)
// At this point, the earliest disaster warning will sound
TethysGame::SetEruption(100 + 31, 39 - 1, 200);
TethysGame::SetLavaSpeed(150);
}
SCRIPT_API void EruptionE()
{
// Mark where the lava can flow
// (do this anytime before the eruption, including from InitProc)
GameMap::SetLavaPossible(LOCATION(110 + 31, 39 - 1), true);
GameMap::SetLavaPossible(LOCATION(110 + 31, 40 - 1), true);
GameMap::SetLavaPossible(LOCATION(110 + 31, 41 - 1), true);
// Start the lava flowing (... in about 10 marks)
// At this point, the earliest disaster warning will sound
TethysGame::SetEruption(110 + 31, 39 - 1, 200);
TethysGame::SetLavaSpeed(150);
}
SCRIPT_API void EruptionF()
{
// Mark where the lava can flow
// (do this anytime before the eruption, including from InitProc)
GameMap::SetLavaPossible(LOCATION(120 + 31, 39 - 1), true);
GameMap::SetLavaPossible(LOCATION(120 + 31, 40 - 1), true);
GameMap::SetLavaPossible(LOCATION(120 + 31, 41 - 1), true);
// Start the lava flowing (... in about 10 marks)
// At this point, the earliest disaster warning will sound
TethysGame::SetEruption(120 + 31, 39 - 1, 200);
TethysGame::SetLavaSpeed(150);
}
SCRIPT_API void EruptionMid()
{
// Mark where the lava can flow
// (do this anytime before the eruption, including from InitProc)
GameMap::SetLavaPossible(LOCATION(130 + 31, 39 - 1), true);
GameMap::SetLavaPossible(LOCATION(130 + 31, 40 - 1), true);
GameMap::SetLavaPossible(LOCATION(130 + 31, 41 - 1), true);
// Start the lava flowing (... in about 10 marks)
// At this point, the earliest disaster warning will sound
TethysGame::SetEruption(130 + 31, 39 - 1, 200);
TethysGame::SetLavaSpeed(150);
}
It works, and it works fine... just lengthy.
Thoughts?
EDIT: so I just read some of Mcshay's smartlava post, I am way behind on good lava I think... This code is terrible...
DOUBLE EDIT: So I have changed this code just a little, and adjusted it too watch whats going on. It randomly pics a location to dump the lava, but it always starts a mark 11, animation shows up at Mark 1, lava at 11 everytime. Damn...