well I have some code I found and have been using but there seems to be no way I can set when to have it hit. Is there a way? do I have to use another code or put it somewere else?
TethysGame::SetMeteor(40,40,5);
looks like your ready for some more coding input from us! :D
To start a meteor ,or any other disaster, you need to define a TimeTrigger:
CreateTimerTrigger( 1, 1, time, "function" );
...
SCRIPT_API void function()
{
TethysGame::SetMeteor(40,40,5);
}
where time is the number of game-ticks, and there are 100 ticks in 1 timemark. The timer starts counting from the moment you define it.
So if you want it to have a meteor at mark 30, then use 3000 for time.
Then if you want a tornade to come just 20 marks after the meteor; change it liek this:
CreateTimerTrigger( 1, 1, 3000, "meteor" );
...
SCRIPT_API void meteor()
{
TethysGame::SetMeteor(40,40,5);
CreateTimerTrigger( 1, 1, 2000, "quake" );
}
SCRIPT_API void quake()
{
TethysGame::SetQuake(40,40,1);
}
Please read the file TethysGame.h to look at all possible triggers. i think there's also some help available on the wiki (if it ever comes back online <_< )
The last parameter to the trigger creation function is the name of an exported function from your DLL. That message box pops up if (when OP2 requests your function's address) the Windows API can't find an exported function from your DLL with the name.
You have to make sure you have a function that's properly exported from your DLL with the name you've given to OP2 in the create trigger call.
CreateTimerTrigger( 1, 1, time, "function" );
SCRIPT_API void function()
In those two lines Eddy gave, note the last parameter to CreateTimeTrigger is "function". This MUST match up with the exported function name seen in the second line. The "SCRIPT_API" part tells the compiler this function is to be exported from your DLL (so it can be found when the lookup is done). It is exported using the undecorated function name. In this case it was "function". If you wanted to have a callback named "Meteor", you use this:
CreateTimeTrigger( 1, 1, 300, "Meteor" );
Trigger population = CreateResourceTrigger(1, 1, resColonists, 400, 0, mpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, population, "Have 400 Colonists.");
return 1; // return 1 if OK; 0 on failure
}
SCRIPT_API void Meteor()
{
TethysGame::SetMeteor(40,40,5);
}
I have it that way already. don't I?
CreateTimeTrigger( 1, 0, 300, "Meteor" );
CreateTimeTrigger( 1, 0, 500, "Meteor" );
CreateTimeTrigger( 1, 0, 800, "Meteor" );
SCRIPT_API void Meteor()
{
TethysGame::SetMeteor(40,40,5);
}
That will create 3 meteors, at location (40, 40), at ticks 300, 500, and 800.
The only thing left to do, might be to customize the x and y coordinates? Oh, and I think the last parameter is only really valid for a range of 0-3 or so? (I don't remember exactly). A value outside that range just makes the game randomly select a value within range for you.
The easy way:
CreateTimeTrigger( 1, 0, 300, "Meteor1" );
CreateTimeTrigger( 1, 0, 500, "Meteor2" );
CreateTimeTrigger( 1, 0, 800, "Meteor3" );
SCRIPT_API void Meteor1()
{
TethysGame::SetMeteor(40,40,1);
}
SCRIPT_API void Meteor2()
{
TethysGame::SetMeteor(50,50,1);
}
SCRIPT_API void Meteor3()
{
TethysGame::SetMeteor(60,60,1);
}
Or you could just use random numbers instead of hardcoded locations? Probably better if you use a bit of randomization. How complicated do you want to make this?
To create a disaster more randomly, you can you .... RANDOM !
TethysGame::GetRand(maxvalue) returns a random (integer) value between 0 and maxvalue-1. You can use this for the co-ordinates, as well as the timing:
This creates a meteor at a random location, somewhere in the region (1,10) - (128,41):
TethysGame::SetMeteor(32+TethysGame::GetRand(128),10+TethysGame::GetRand(32),1);
Remember: you have to add 31 to the location, so the first random creates values between 32 and 159 which translates to 1 .. 128.
To start these disasters at a random interval:
CreateTimeTrigger( 1, 0, 300, 800, "Meteor" );
OP2 will start the trigger at a random time somewhere between 300 and 799. Then when it fires, it again creates a random time. It doesnt "store" the result, to use it over and over. If the first trigger starts at mark 4 (=400), this doesnt mean the second WILL start at 8. It CAN, but it is more likely to start at some other time.
I did some tests and I think 2 numbers are were it starts, 2 more are were it ends and and then I think the last two are so. control speed and maybe the randomness path it follows. but I could be wrong. it was not easy seeing what the last 2 did.
TethysGame::SetTornado(Xstart,Ystart,Xend,Yend,?,?);
TethysGame::SetTornado(75,35,75,35,1,3);[/
spirit
Edit: I have tried several ways of getting a Tornado to be random but I can't seem to get anything but a random time. What is the code for random movement?
Check the SDK header files. I think it's in TethysGame.h? Probably something like TethysGame::SetQuake.
I'm just gonna guess at some code and not compile it to test. B) Be sure to correct me when I make a mistake. :o
To setup the trigger (in InitProc usually):
CreateTimeTrigger( 1, 0, 3000, 5000, "RandomTornado" );
The trigger code:
SCRIPT_API void RandomTornado()
{
TethysGame::SetTornado(32 + TethysGame::GetRand(128), TethysGame::GetRand(128),TethyGame::GetRand(100), 0, 0, 0);
}
As for the two unknown paramters, if in doubt, stick in 0s (like I did). If that doesn't work, try -1 for both. (I think the normal DLLs might have used -1 for both). Also, I'm not sure what a reasonable value for the duration is. Experiment and find out. I'll look into it in more detail one of these days. Also, adjust the random x and y range for your level. I assumed a 128x128 map, with vortexes appearing pretty much anywhere. (Might want to double check the bound conditions, or decrease the range a little if you're not sure).