[script] watercolor

Intended for use on live public servers.
8 posts Page 1 of 1 First unread post
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


as the topic might suggests, this script changes the color of watertiles, simple as that
if something similiar that has been already written, sorry for posting this

commands:
/togglewatercolors (/twc): toggles this script on and off
/watercolor <R> <G> <B> (/wc): sets the watercolors, similiar to the usage of /fog (eg. /wc 255 0 255 for a manly pink tone)
/watercoloroffset <value> (/wco): adds a little offset to the colors since a plain monochrome tone would be boring right? (needless to say that any value above 255 aint smart here)

this might be totaly useless but some of you may like to change the atmosphere of a map like turning it into a bloody hell or a paradisiacal beach
Image

or you are just crazy and set up eye cancers like this one
Image

anyways changes apply only after changing a map
aand i dont know whether this is just an issue on my side, but players might disconnect during mapchange when the server / computer is too slow, it worked without any issues on a public server but when i tried it out on my localhost i had to make sure that my pc isnt running at 100% in order to prevent it



--------------------------------the enhancement------------------------------------------


so since izzy had some suggestions regarding this script, i tried implementing his ideas
the second attachmed script features following additions/commands:

- you can set it now with the command /watercolor <R><G><B> [offset]
- /watercolorcommands (/wcmd) show you all available commands for this script
- the watercolor is being randomly chosen from a colorlist in the script
Code: Select all
watercolors = [(255,0,0), (0,255,0), (0,0,255), (255,255,0), (0,255,255), (255,0,255)]
[you can enhance this list however you want, im too lazy to find good matches, would appreciate it if someone else posts a beter list with colors that wont make you want tearing your eyes off]
this can be toggled off via the command /watercolorrandom (/wcr)
- with the command /watercolorprevent (/wcp) you can deactivate the changes after each map advance
- watercolors can be set within the map.txt file, it must look like that for example:
Code: Select all
extensions = {
'water_damage' : 10,
'water_color' : [(255, 0, 255), (125, 0, 0)],
'water_color_offset' : 80 }
- to deactivate this feature use /watercolormap
- to set the watercolor to the winning teams color (whoever has more caps) type /watercolorteams (/wct)
however i couldnt find a suitable hook so it works only as long as a map is being advanced by an admin, in other words if a map is being changed once a game has been won, it automaticaly takes 0-0 as the ending score and thus detecting a tie which makes the server pick the spectator teams color (black) as the winning teams color
if anyone has an alternative idea for that, feel free to state it
Attachments
watercolorenhanced.py
/twc > /wct > /wcm > /wcr
(5.95 KiB) Downloaded 274 times
watercolor.py
lol almost forgot to upload it
(2.12 KiB) Downloaded 293 times
Last edited by Dr.Morphman on Wed Apr 09, 2014 2:17 pm, edited 3 times in total.
izzy
Head Admin / Co-founder
Head Admin / Co-founder
Posts: 474
Joined: Tue Oct 09, 2012 8:16 pm


What an awesome idea.

Suggestions/requests:

1) Merge /watercolor and /watercoloroffset into /watercolor <R> <G> <B> [offset]
2) Optionally set winning team's color as the next map's water color.
3) Optionally always randomize color for all maps.
4) Ability to permanently set color per map, maybe via map extensions?
5) Automatically toggle off after map is loaded with custom colors to prevent next map from being affected.
a girl
Scripter
Scripter
Posts: 85
Joined: Thu Nov 15, 2012 6:32 am


I wrote one of these once upon a time... never used it much though... were you able to get around the client crash problem whenever a block at layer 63 is removed?

Edit: after looking at my code, I remembered that I did a generic texture as well... a lot of the testdrive maps were really monochromatic so i wrote this texture script to randomize it a bit, or a lot depending on your preferences... i also included an ocean command that would change the water color with an option for a color offset much like you did... but i remember a huge downfall being that it kicked everyone on the server... i didn't care because i planned to use it in a build server anyway and just save the maps.

Anyway, if you want mine for comparison, here it is... i've never released it because it was pretty derpy. Hope your's turned out better.
Attachments
texture.py
(3.39 KiB) Downloaded 253 times
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


oookay izzy i updated it according to the requests as much as i could
izzy
Head Admin / Co-founder
Head Admin / Co-founder
Posts: 474
Joined: Tue Oct 09, 2012 8:16 pm


Wow, that was fast. Thanks!
Dr.Morphman wrote:
- lastly i tried to make the watercolor change depending on the winning team of the previous game with the command /watercolorteams (/wct), however i couldnt find a suitable hook so it works only as long as a map is being advanced by an admin, in other words if a map is being changed once a game has been won, it automaticaly takes 0-0 as the ending score and thus detecting a tie which makes the server pick the spectator teams color (black) as the winning teams color
if anyone has an alternative idea for that, feel free to state it
How about a separate capture counter for each team; on_flag_take increases carrier's team counter, on_flag_drop decreases carrier's team counter, on_flag_capture checks if either counter = cap_limit?
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


izzy wrote:
How about a separate capture counter for each team; on_flag_take increases carrier's team counter, on_flag_drop decreases carrier's team counter, on_flag_capture checks if either counter = cap_limit?
oh... hehe... yeaaaah sometimes i tend to fail seeing the easiest things, thanks for the hint

the script has been updated/fixed
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


a girl wrote:
Edit: after looking at my code, I remembered that I did a generic texture as well... a lot of the testdrive maps were really monochromatic so i wrote this texture script to randomize it a bit, or a lot depending on your preferences... i also included an ocean command that would change the water color with an option for a color offset much like you did... but i remember a huge downfall being that it kicked everyone on the server... i didn't care because i planned to use it in a build server anyway and just save the maps.
I have way too much freetime, anyways i realized that in order to prevent players from getting kicked you'd have to avoid checking so many areas (512x512x63 is too much for the server to handle apparently, especialy when you do not apply it on_mapchange)

i reused the main part of your code to create this what appears to be working without kicking players (it changes only the color of non-water tiles though)
Code: Select all
import random

def randomize_block(self, a, b, c, value):
	R1, G1, B1 = self.map.get_color(a, b, c)
	R2, G2, B2 = R1 + random.randint(-value, value), G1 + random.randint(-value, value), B1 + random.randint(-value, value)
	if R2 < 0:
		R2 = 0
	if G2 < 0:
		G2 = 0
	if B2 < 0:
		B2 = 0
	if R2 > 255:
		R2 = 255
	if G2 > 255:
		G2 = 255
	if B2 > 255:
		B2 = 255
	RGB = (R2, G2, B2)
	self.map.set_point(a, b, c, RGB)

def apply_script(protocol, connection, config):
	
	class TextureProtocol(protocol):

			def on_map_change(self, map):
				for a in range(512):
					for b in range(512):
						if self.map.get_solid(a,b, self.map.get_z(a,b)) and self.map.get_z(a,b) < 63: 
						    randomize_block(self, a, b, self.map.get_z(a,b), 15)
				return protocol.on_map_change(self, map)
			
	return TextureProtocol, connection
i kinda couldnt understand why but it didnt kick me out everytime when i used this part of the texture script together with my watercolor script, so it might work if you use both scripts at once with a powerfull pc/server
a girl
Scripter
Scripter
Posts: 85
Joined: Thu Nov 15, 2012 6:32 am


I always assumed it was a glitch with the .75 client. Other scripts that attempt to modify the ocean level blocks have always crashed those clients, even if it's only a single block. I guess it will need more testing.
8 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 13 guests