Game Development Community

Lightning

by Vladimir Velez · in Torque Game Engine · 10/27/2009 (4:05 pm) · 21 replies

I found a thread here : http://www.garagegames.com/community/forums/viewthread/91857

I want to add lightning to my level, but im not sure how to do what the person posted. Anyone mind helping please? Thanks!
Page «Previous 1 2
#1
10/31/2009 (5:39 pm)
Bump
#2
11/02/2009 (10:53 am)
From the book GPGT...

First you need a datablock:

datablock LightningData(LightningExample)
{
   strikeSound = LightningStrikeSound;
   thunderSounds[0] = ThunderSound0;
   thunderSounds[1] = ThunderSound1;
};

Now create the Lightning object in the World Editor:

new Lightning
{
   position = "0 0 180";
   scale = "100 100 500";
   datablock = LightningExample;
   strikesPerMinute = "90";
   strikeWidth = "0.25";
   chanceToHitTarget = "100";
   strikeRadius = "25";
   boltStartRadius = "100";
   color = "1 1 1 1";
   fadeColor = "0.1 0.1 1.0 1.0";
};

Make sure that the datablock is loaded before you create the lightning object.
#3
11/02/2009 (3:27 pm)
From the book GPGT...??

Erm? :o
#4
11/03/2009 (11:50 am)
Game Programmers Guide to Torque

www.garagegames.com/products/gameprogrammersguide
#5
11/05/2009 (12:05 am)
Heh, gonna make me buy a book to learn how to add what you posted to the engine? =/
#6
11/05/2009 (3:18 am)
I guess you have to buy TGE/A first.
#7
11/05/2009 (8:40 pm)
I have TGE.. W starter fps n all that. along with constructor..

Mind telling me how to add lightning?
#8
11/05/2009 (8:53 pm)
Those examples are script functions, they dont require engine changes. Just drop those 2 code blocks into a script and exec them.
#9
11/07/2009 (10:46 pm)
Mmm, i opened the panel using ~ , tried to add it there, seems i cant.. how else can i?

Edit: Where would i place the 2 cs files? And would i just copy and paste whats there in a txt file and save it as a cs?
#10
11/08/2009 (12:46 am)
yea you use a text editor and just save it as a .cs file.

so in server/scripts make a lightning.cs file and put the first bit of code that thomas posted in it and save it as a .cs file.

then in server/init.cs go down to where it execs the other .cs files and add 'exec("./scripts/lightning.cs");'.

Then open up your mission.mis file, whatever you called it, and down towards the end add the second bit of code that thomas posted.

That's it, if it works, it'll work, if not you should have an error in the console.log.

If you plan to copy what thomas posted, make sure you click view source at the top of each code block, so that it takes the numbers out.
#11
11/08/2009 (9:56 pm)
I did what you posted, the script is in "C:TorqueTGE_1_5_2examplestarter.fpsserverscripts"

I modified my mission and added the 2nd part to the bottom..

No errors in the console but it says " Missing file: ./scripts/lightning.cs! "

It seems all the exec says that.. Even the ones it came with..

// Load up game server support scripts
   exec("./scripts/commands.cs");
   exec("./scripts/centerPrint.cs");
   exec("./scripts/game.cs");
   exec("./scripts/lightning.cs");
#12
11/09/2009 (12:59 am)
double check your spelling of the filename to what you put in the .cs file. Cause if you are execing lightning.cs in the server/init.cs and the file is in server/scripts then all should be ok.
#13
11/09/2009 (1:02 am)
this is in my server for lightining

server\init.cs
exec("./scripts/lightning.cs");

server\scripts\lightning.cs
datablock LightningData(LightningExample)  
{
strikeSound = LightningStrikeSound;
thunderSounds[0] = ThunderSound0; 
thunderSounds[1] = ThunderSound1;
};
#14
11/09/2009 (7:25 am)
It is also possible to execute a script from the console.
Simply type the following:

exec("starter.fps/server/scripts/lightning.cs");

(maybe you have to modify the path depending where your cs is)

And check the console.log for errors!!!
#15
11/09/2009 (8:57 am)
There is a much easier way to get lightning if you own tge 1.5.2

Look in "example/demo/server/scripts/" and copy the environment.cs file to your folder. Then copy the "data/environment" folder to your data folder. Add your lightning from the mission editor.
You already have an environment.cs file in starter.fps, it's just missing the needed lighting code and your data folder is missing the lighting bolts.
#16
11/09/2009 (12:26 pm)
Thanks! got it working XD , now to figure out how to add sound..

Edit: If anyone can show me how to add the sounds for lightning ill be very great full :3
#17
11/09/2009 (2:09 pm)
new AudioDescription(ThunderSoundDesc)
{
   volume = 1.0;
   isLooping = false; //or true
   is3D = false; // or true
   type = $SimAudioType;
}

datablock AudioProfile(ThunderSound0)
{
   filename = "game/data/sound/someSound.ogg";
   description = ThunderSoundDesc;
}

Look at Post #2. There is this line of code...

thunderSounds[0] = ThunderSound0;


One side note: You can use new and datablock. Use new for non-networked things like sounds of the GUI. Otherwise, for the gameplay, use datablock.
#18
11/09/2009 (2:17 pm)
By the way... you can specify up to eight different thunderSounds from

thunderSounds[0]
...
...
thunderSounds[7]
#19
11/09/2009 (5:57 pm)
Um, mind if i ask where to add that? Sorry, im not very oriented with these things..
#20
11/09/2009 (6:07 pm)
That goes wherever your lightning datablock is, either lightning.cs or environment.cs whichever way you used from the above postings. If you add more sounds make sure you define them all or you won't hear all the sounds.

datablock AudioProfile(ThunderSound0)   
{   
   filename = "game/data/sound/someSound0.ogg";   
   description = ThunderSoundDesc;   
} 

datablock AudioProfile(ThunderSound1)   
{   
   filename = "game/data/sound/someSound1.ogg";   
   description = ThunderSoundDesc;   
}
Page «Previous 1 2