Author Topic: Delaying Meteors?  (Read 7884 times)

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #25 on: November 05, 2005, 03:31:58 PM »
I noticed that but decided not to try and fix it. Because I would have to make far too many triggers to keep meteors falling throughout the game. So I just left it.
But thanks for explaining how to stop them if I wanted  :)


Spirit
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Delaying Meteors?
« Reply #26 on: November 05, 2005, 04:00:12 PM »
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):
Code: [Select]
  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:
Code: [Select]
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.
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 spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #27 on: November 05, 2005, 04:03:26 PM »
so it will run forever if I use this code?
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Delaying Meteors?
« Reply #28 on: November 05, 2005, 05:54:49 PM »
Quote
Be advised: hooman's code works fine, but creates repeating triggers!
Lol, the horrors of copy-and-pasted code. I wasn't even paying attention to that.

Quote
so it will run forever if I use this code?
Yes. If that second parameter is 0 (bool noRepeat, in the SDK I think) then the trigger will keep firing. For a time trigger, it resets itself to fire after another period of time that you've specified in the initial setup. If you've used the one that specifies a range of time, then it randomly picks a value between those times when it will fire again.

Also, with repeated time triggers like this, you should really use the random time interval one. Otherwise, the player will start to know when to expect meteors, which hardly seems right. Meteors shouldn't be falling in a steady, regular pattern.

And yeah, you should also randomize the location of the meteor impact, unless of course you specifically wanted a meteor to hit a certain area.
 

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #29 on: November 05, 2005, 10:28:51 PM »
Quote
Lol, the horrors of copy-and-pasted code. I wasn't even paying attention to that.


yep   :lol:

The good thing about it is I will never need to be told again  :P


Quote

And yeah, you should also randomize the location of the meteor impact, unless of course you specifically wanted a meteor to hit a certain area.

yea my first Beta tester basicly told me to do so  :P

Spirit
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #30 on: November 05, 2005, 11:25:31 PM »
Anyone know how to make random twisters or does that have to be planed?
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Delaying Meteors?
« Reply #31 on: November 05, 2005, 11:31:54 PM »
You can make random anything. Just use TethysGame::GetRand(int range). It'll return a random integer for you. Do whatever you want based on that integer that you want randomness from. Maybe use one random number for the x coordinate, one random number for the y coordinate. Just make sure the coordinates fall within the confines of the map.

You can also use random times, but the time range trigger works well here anyways. (It calls GetRand internally). Just modify the code Eddy pasted for Meteors at random locations, and change the created disaster to be a Vortex/Tornado. (I hate the inconsistent naming the game always uses  :angry: )

 

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #32 on: November 06, 2005, 12:04:09 AM »
I thought so but when I changed the meteor to tornado.  It would not compile so I guessed that it needs more code or something. I think it said something about Tornado can't use 3 variables
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Delaying Meteors?
« Reply #33 on: November 06, 2005, 03:34:07 AM »
There is a different number of arguments for Tornados. Just add dummy values in, like 0. I think those parameters were added so the Tornado could be made to appear right away. I noticed one of the demo levels that plays at the main menu when you do nothing does this. I suspect they added those extra parameters in just for demo purposes.
 

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Delaying Meteors?
« Reply #34 on: November 06, 2005, 07:23:49 AM »
maybe the direction the tornade will follow ?
has anyone tested these values more in depth ?
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 spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #35 on: November 06, 2005, 08:51:39 AM »
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.  
Code: [Select]
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?
« Last Edit: November 06, 2005, 10:38:56 AM by spirit1flyer »
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Delaying Meteors?
« Reply #36 on: November 06, 2005, 09:08:59 PM »
The last parameter is a boolean value that controls if the Vortex appears right away, or if it's subject to the normal disaster delay (where you get advanced warning). Anyone want to suggest a decent name for it?
int boolAppearImmediately?

Parameter 3 seems to control the duration of the Vortex.

I'm not too sure about the other 2 parameters. I looked where they get copied into the unit class. I know I've seen references to this part of the unit class in some previous work on Vortexes, but I wasn't sure what those memory locations did. I'll let you know once I find out.
« Last Edit: November 06, 2005, 09:10:49 PM by Hooman »

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #37 on: November 06, 2005, 11:08:28 PM »
Quote
Parameter 3 seems to control the duration of the Vortex.
Oh yea I knew that  :blush:  I had just forgot  :P


Do you know the exact code for random vortexs?  I have tried several things but none of them will compile.  
and what is the coding name for earthquakes?  I tried to make one but the compiler said it didn't know what Quake or Earthquake was.


Spirit
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Delaying Meteors?
« Reply #38 on: November 07, 2005, 12:00:52 AM »
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):
Code: [Select]
CreateTimeTrigger( 1, 0, 3000, 5000, "RandomTornado" );

The trigger code:
Code: [Select]
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).
 

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #39 on: November 07, 2005, 01:19:57 AM »
Quote
I'm just gonna guess at some code and not compile it to test.  Be sure to correct me when I make a mistake.

just these two errors,  I don't know how to fix them but atleast its not the error I had  before  :P

Quote
Main.cpp(154) : error C2653: 'TethyGame' : is not a class or namespace name
Main.cpp(154) : error C3861: 'GetRand': identifier not found, even with argument-dependent lookup

I will look and see if I can fix this tomorrow but the chances are 99% that I will just mess it up worse  :P




Quote
Check the SDK header files. I think it's in TethysGame.h? Probably something like TethysGame::SetQuake.
I think I checked there and it didn't work but I don't have time to check and see right now, I will in the morning.

spirit
 
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #40 on: November 08, 2005, 10:55:41 AM »

I have tried everything I can think of but I still get these 2 problems
[/QUOTE]
Main.cpp(154) : error C2653: 'TethyGame' : is not a class or namespace name
Main.cpp(154) : error C3861: 'GetRand': identifier not found, even with argument-dependent lookup
Quote

If anyone can help me or point me in the right direction enough that I can get it fixed. I will be thankfull and I will give you 100 ore

Code: [Select]
CreateTimeTrigger( 1, 0, 3000, 5000, "RandomTornado" ); 


Code: [Select]
 
SCRIPT_API void RandomTornado()
{
TethysGame::SetTornado(32 + TethysGame::GetRand(128), TethysGame::GetRand(128),TethyGame::GetRand(100), 0, 0, 0);
}

spirit
 
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Delaying Meteors?
« Reply #41 on: November 08, 2005, 06:50:19 PM »
Lol, typo.

That should read "TethysGame". Note the "s". That might help solve the next problem as well.
 

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Delaying Meteors?
« Reply #42 on: November 08, 2005, 08:02:37 PM »
I am about to kill something  :P
That was way too easy  :heh:
I will send you the ore in two lump sums  ;)

btw it works now  :P


spirit
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter