Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (dr_panther, AndrewAMD, Ayumi, TedMar), 1,033 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
The Ultimate Dynamic Light Script #41245
02/19/05 12:57
02/19/05 12:57
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
In its current form, this script REQUIRES any version of 3DGS with the stencil shadow feature. Even if you set the "castToggle" to "on", you'll need to be sure to set the "cast" flag of each entity whose shadow should be influenced by these lights to "on", as well. Also, make sure the "shadow_stencil" flag is set to "on" to enable stencil shadows or none of the shadow eyecandy will work to begin with.

I guess if you take out the "cast" part, at the beginning, it should work with older versions of A6. I don't know if there are any other instructions that are native to A6 only, but if not then you can use it with A5 after removal of those shadows sections. Possible candidates are "vec_dist" and "sleep". You can substitute "sleep" with "waitt"(for conversion purposes, sleep(1) is equal to waitt(16)) and you can probably figure out an alternative for "vec_dist" if it isn't a part of A5's instruction set.

This script should fulfill your every need except movement.

Code:

var killSwitch = 0; //0 = all lights active, 1 = all lights inactive
define range, skill1; //lightrange for this light
define rangeModifier, skill2; //used for random lightrange calculation...if random lights used, DO NOT set to 0 or script will crash
define redColor, skill3; //red color for this light
define greenColor, skill4; //green color for this light
define blueColor, skill5; //blue color for this light
define distToggle, skill6; //distance to toggle on/off lightrange...uses vec_dist(player.x, my.x)
define startDelay, skill7; //if > 0 then light object is invisible for this value in seconds at level start
//only use with constant blinking lights..unexpected results may occur with random blinkers
//this will only take affect if beginOn is true
define shortDelay, skill8; //shorter of two delays for blink
define longDelay, skill9; //longer of two delays for blink
//make short/long delays equal for a true constant light
//for example: 2 sec. on, 2 sec. off

define castToggle, flag1; //on = influence stencil shadow
define beginOn, flag2; //on = light object will be visible at level start unless startDelay > 0
//off = light object invisible at level start
define alwaysOn, flag3; //on = light is always on regardless of player's position from lightsource
define randomColorRange, flag4; //on = light will always be a random color and lightrange
//off = light is constant color & lightrange
define blink, flag5; //on = light will blink; off = light will not blink
define randBlink, flag6; //on = light will blink at a random rate if true...blink must be true
define localSwitch, flag7; //on = light is on; off = light is off



Code:

// uses: range, rangeModifier, redColor, greenColor, blueColor, distToggle
// uses: startDelay, shortDelay, longDelay, castToggle, beginOn, alwaysOn
// uses: randomColorRange, blink, randBlink, localSwitch
action dynamicLight //assign to a dynamic light entity
{
while(player == null) { wait(1); }
var tempShortDelay;
var tempLongDelay;
my.passable = on;
if(my.castToggle == on) //light will influence stencil shadows
{
my.cast = on;
}
else
{
my.cast = off;
}
while(1)
{
if(killSwitch == 0 && my.localSwitch == on)
{
if(my.beginOn == on) //light object is visible at level start, unless startDelay > 0
{
if(my.startDelay > 0) //useful for scrolling lights on marquees
{ //should ONLY be used with constant blinkers
sleep(my.startDelay); //you may experience unexpected results if you use with random blinkers
}
my.invisible = off;
}
else
{
my.invisible = on; //light object is invisible at level start
}
if((vec_dist(player.x, my.x) < my.distToggle && my.alwaysOn == off) ||
(my.alwaysOn == on)) //distance based and non-distance based/always on lights
{
if(my.randomColorRange == on) //random color and range
{
my.lightrange = max(random(my.range), my.range/my.rangeModifier); //make sure rangeModifier > 0
if(my.lightrange == 0) { my.lightrange = 1; }
my.red = int(random(my.redColor));
if(my.red == 0) { my.red = 1; }
my.green = int(random(my.greenColor));
if(my.green == 0) { my.green = 1; }
my.blue = int(random(my.blueColor));
if(my.blue == 0) { my.blue = 1; }
}
else //constant color and range
{
my.lightrange = my.range;
my.red = my.redColor;
my.green = my.greenColor;
my.blue = my.blueColor;
}
if(my.blink == on) //light will blink with 2 separate delays
{
if(my.randBlink == on) //random blinking
{
tempShortDelay = random(my.shortDelay);
if(tempShortDelay == 0) { tempShortDelay = 0.1; }
sleep(tempShortDelay); //shorter delays
my.lightrange = 0;
if(my.beginOn == on) //light object is now invisible
{
my.invisible = on;
}
tempLongDelay = random(my.longDelay);
if(tempLongDelay == 0) { tempLongDelay = 0.1; }
sleep(tempShortDelay + tempLongDelay); //longer delays
}
else //constant blinking
{
sleep(my.shortDelay); //shorter delays
my.lightrange = 0;
if(my.beginOn == on) //light object is now invisible
{
my.invisible = on;
}
sleep(my.longDelay); //longer delays
my.startDelay = 0; //zero out so it won't delay again
//after initial delay at level start..
//..only applies to constant blinkers
}
}
}
else //player is > my.distToggle from lightsource..turn light off and make object invisible
{
my.lightrange = 0;
my.invisible = on;
}
}
else
{
my.lightrange = 0;
my.invisible = on;
}
wait(1);
}
}




My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: The Ultimate Dynamic Light Script [Re: Orange Brat] #41246
02/19/05 13:16
02/19/05 13:16
Joined: Nov 2004
Posts: 832
United States, Utah
Braxton Offline
Developer
Braxton  Offline
Developer

Joined: Nov 2004
Posts: 832
United States, Utah
Wow, tons better than mine!


"The GREAT LAW: Life is and always will be justly ordered, and that all past experiences, good and bad, were the equitable out working of our evolving, yet unevolved selves" - As A Man Thinketh
Re: The Ultimate Dynamic Light Script [Re: Braxton] #41247
02/19/05 13:18
02/19/05 13:18
Joined: Aug 2004
Posts: 2,215
I
ISG Offline

Expert
ISG  Offline

Expert
I

Joined: Aug 2004
Posts: 2,215
Braxton, you seem suprised

Thanks for this contribution OB


Ground Tactics - Coming Soon
Ground Tactics OFFICIAL WEBSITE
Re: The Ultimate Dynamic Light Script [Re: Braxton] #41248
02/19/05 13:19
02/19/05 13:19
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Sorry for stepping on your script. I had thought about waiting a few days, but I was ready to post it. Here's Braxton's script for those who might want to use it instead:

http://www.conitecserver.com/ubbthreads/showflat.php?Cat=&Number=486436

It's somewhat similar, but not quite as flexible. Still, if that's all you need and script execution time is a factor......


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: The Ultimate Dynamic Light Script [Re: Orange Brat] #41249
02/19/05 13:26
02/19/05 13:26
Joined: Nov 2004
Posts: 832
United States, Utah
Braxton Offline
Developer
Braxton  Offline
Developer

Joined: Nov 2004
Posts: 832
United States, Utah
i am not, just was surprised to see a better one so fast. The only difference between our scripts is that mine is editable in the behavior panel. His is still way better.

I have run into a problem. I can't get it to run... it says 'ultimateDynamicLigh' action not found. so I copy the 'ultimateDynamicLight' script and rename it 'ultimateDynamicLigh'. then when I build and run nothing is different.

BTW Orange Brat - It is ok, you didn't step all over my script. When someones script is better, it is better and you can't argue.


"The GREAT LAW: Life is and always will be justly ordered, and that all past experiences, good and bad, were the equitable out working of our evolving, yet unevolved selves" - As A Man Thinketh
Re: The Ultimate Dynamic Light Script [Re: Braxton] #41250
02/19/05 13:31
02/19/05 13:31
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
I think there might be a length limit for action/function names, since I've run into that problem before. I went ahead and renamed it to "dynamicLight".


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: The Ultimate Dynamic Light Script [Re: Orange Brat] #41251
02/20/05 12:40
02/20/05 12:40

A
Anonymous
Unregistered
Anonymous
Unregistered
A



I think the limit is 15 characters for actions, but I may be wrong.

Re: The Ultimate Dynamic Light Script #41252
02/22/05 12:13
02/22/05 12:13
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Made a small change which will allow you to see the "defined" skill and flag names in WED's behavior panel. Just copy & paste the three "// uses: " lines right before the action and add them to the same spot in your own code. I also changed the red, green, and blue defines to redColor, greenColor, and blueColor. This was done to eliminate any potential conflicts with the built in c-script instructions of the same name.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: The Ultimate Dynamic Light Script [Re: Orange Brat] #41253
02/25/05 22:07
02/25/05 22:07
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline
Senior Developer
Thomas_Nitschke  Offline
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
Hey, this is a nice contribution!
From now on, we don't have to re-invent the wheel all the time
Concerning the character-limits question: As fas as I know, there's still a limit of 8 characters for actions, although the limit fpr functions is much higher. Shame on you, Conitec, the times of DOS are over!


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Re: The Ultimate Dynamic Light Script [Re: Thomas_Nitschke] #41254
02/26/05 05:05
02/26/05 05:05
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Added a light switch toggle. Required a new flag(#7) and an addition to a single line right after the "while". Don't forget to add the flag name to the "uses" section.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Page 1 of 3 1 2 3

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1