Note: This forum is merely an archive. It is no longer possible to register or post. - StackOverflow
New Ace of Spades Forums: http://buildandshoot.com/

Dynamic Fog

Finished a script? Pop it in here.

Dynamic Fog

Postby SLoW » Thu Jan 19, 2012 9:46 pm

So I've written a simple little script that allows you to change the color of the fog on a per-map basis. I originally wrote it for my Firestorm map, (because you can't play Firestorm without orange fog) but I'm sure other people might find it useful too.

Code: Select all
import commands

def apply_script(protocol, connection, config):
    class FogProtocol(protocol):
        default_fog = (128, 232, 255)
        def on_map_change(self, name):
            self.set_fog_color(getattr(self.map_info.info, 'fog', self.default_fog))
            protocol.on_map_change(self, name)
    return FogProtocol, connection


To implement, open your map.txt file, and add the following:

Code: Select all
fog = (232, 128, 5)
(and replace the numbers with the RGB color of fog you want.)

Enjoy. :)
Image
User avatar
SLoW
Global Moderator
 
Posts: 560
Joined: Sat Dec 10, 2011 4:35 pm

Re: Dynamic Fog

Postby Enari » Sat Jan 21, 2012 12:44 am

this is awesome!

but could you change it to:
Code: Select all
fog = '232, 128, 5'
Image
User avatar
Enari
Moderator
 
Posts: 595
Joined: Sun Dec 11, 2011 1:15 pm

Re: Dynamic Fog

Postby matpow2 » Sat Jan 21, 2012 4:28 pm

Enari, that wouldn't make sense. The map metadata is basically Python code, so it's better to use native Python types instead of doing silly string parsing.
User avatar
matpow2
Site Admin
 
Posts: 47
Joined: Thu Dec 29, 2011 12:35 pm
Location: Denmark, Odense

Re: Dynamic Fog

Postby Enari » Sun Jan 22, 2012 12:14 am

okey...
Image
User avatar
Enari
Moderator
 
Posts: 595
Joined: Sun Dec 11, 2011 1:15 pm

Re: Dynamic Fog

Postby DaDMaR » Mon Jan 30, 2012 10:06 pm

SLow
I am certainly not a programer, so please explain for myself and others..............
How is the first piece of code to be added to the server ?
Is it as new file fog.py or as an amendment to another file ?
Thank you
User avatar
DaDMaR
Member
 
Posts: 14
Joined: Wed Jan 04, 2012 4:13 am

Re: Dynamic Fog

Postby SLoW » Tue Jan 31, 2012 8:00 pm

DaDMaR wrote:SLow
I am certainly not a programer, so please explain for myself and others..............
How is the first piece of code to be added to the server ?
Is it as new file fog.py or as an amendment to another file ?
Thank you


Yes, the first block of code should be saved as "dynfog.py" in the scripts folder in pyspades and then added to the config.txt file. The second block of code gets added to the map .txt file (map metadata).
Image
User avatar
SLoW
Global Moderator
 
Posts: 560
Joined: Sat Dec 10, 2011 4:35 pm

Re: Dynamic Fog

Postby LASTofS » Sun Mar 25, 2012 5:17 pm

So how do I set a fog colour to a certain map?
ImageImageImage
Join the [LoS] (last of spades) clan here | my greatest contribution: Image icon on openGL client
User avatar
LASTofS
News Reporter
 
Posts: 852
Joined: Sat Jan 21, 2012 6:34 pm
Location: pls there are kids in here

Re: Dynamic Fog

Postby BlueToonYoshi » Wed Mar 28, 2012 5:07 am

This is a useful script! Good job. I do have a feature that you might be able to put in it though, although I am not sure.

Ok, I notice many people use the daycycle script. I was wondering if there is any possible way to still use the daycycle script, and this script at the same time. Like to see if it checks for something like this: fog = (daycycle). If that is there in the map.txt file or something, it uses the daycycle script instead of the dynfog script.

I don't know if you get what I am trying to say, but yeah.
User avatar
BlueToonYoshi
Member
 
Posts: 240
Joined: Sun Feb 19, 2012 6:03 am
Location: Mississippi

Re: Dynamic Fog

Postby Sasquatch » Wed May 23, 2012 3:27 am

BlueToonYoshi wrote:This is a useful script! Good job. I do have a feature that you might be able to put in it though, although I am not sure.

Ok, I notice many people use the daycycle script. I was wondering if there is any possible way to still use the daycycle script, and this script at the same time. Like to see if it checks for something like this: fog = (daycycle). If that is there in the map.txt file or something, it uses the daycycle script instead of the dynfog script.

I don't know if you get what I am trying to say, but yeah.

I get it. That sounds cool, but would probably need extra code.

also thread necro...
You killed Deuce7
User avatar
Sasquatch
Member
 
Posts: 22
Joined: Sun Mar 04, 2012 1:44 am

Re: Dynamic Fog

Postby shire » Sat Sep 29, 2012 10:56 am

Wao.. I like this.. Amazing & interesting post...
shire
shire
Member
 
Posts: 1
Joined: Sat Sep 29, 2012 10:47 am


Return to Script releases



Who is online

Users browsing this forum: No registered users and 3 guests

cron