[SCRIPT] Map merger

Intended for use on live public servers.
15 posts Page 1 of 1 First unread post
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


This script merges maps.
Code: Select all
"""
thepolm3
Does crazy stuff
"""
def mean(*args):
    sum = 0
    for number in args:
        sum+=number
    sum/=len(args)
    return sum

def colour_average(one,two):
    ra,ga,ba=one
    rb,gb,bb=two
    return (mean(ra,rb),mean(ga,gb),mean(ba,bb))

def apply_script(protocol,connection,config):
    class MergerProtocol(protocol):
        old_map=None
        def on_map_change(self,map):
            oldmap = self.old_map
            if oldmap:
                print("Map merging in process...")
                for x in range(512):
                    for y in range(512):
                        oz,nz = oldmap.get_z(x,y),map.get_z(x,y)
                        oc,nc = oldmap.get_color(x,y,oz),map.get_color(x,y,nz)
                        colour = colour_average(oc,nc)
                        newz = mean(oz,nz)
                        for z in range(63):
                            if z<newz:
                                map.remove_point(x,y,z)
                            else:
                                map.set_point(x,y,z,colour)
                print("Map merging complete.")
            self.old_map=map.copy()
            return protocol.on_map_change(self,map)
    return MergerProtocol,connection
Instead of a boring ol text thing, here is the result;
BRIDGEWAY or hallwars
I planned to do more examples, but this just blew me away;
Spoiler:
Image
Image
Link to the map download;
Attachments
mapmerger.py
(1.24 KiB) Downloaded 308 times
Lostmotel
League Participant
League Participant
Posts: 298
Joined: Sun Nov 18, 2012 1:09 pm


hehe, I like it.
Now we can create even crazier maps on the HOMO servers Blue_BigSmile
The only thing I don't like is the way the objects and tunnels get merged but I guess it's not possible to keep them like they where before.
Anyways good work Blue_Happy1
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


I've been trying to think of a way to merge tunnels n things :/
prob;em is, if you don't merge based on height you end up with a rubbish filler map instead of an new one whhich feels like both its ancestors. If I think Of something I'll let you know
TB_
Post Demon
Post Demon
Posts: 998
Joined: Tue Nov 20, 2012 6:59 pm


So it takes the heightmap from one map and the colourmap from the other?
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


naaah that would suck. You'd get a map that looks like one thing but plays like another
what it does is merge both the height AND the colour - see bridgeway for an example
shaz


This thread needs more attention. Great script dude!
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Thanks shaz!
cow
Deuced Up
Posts: 56
Joined: Mon Nov 05, 2012 7:40 pm


Huh, so it gets an average of both the color values and the height values?
The result looks amazing, definitely going on Sw, great work as usual!
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


tanks!
shaz


Just to ask is there any command by default to set this script on or off or will this need to be added ourselves?
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


the way it works is you put two maps in your rotation and then it will merge them when you advance. Press F1 to save as lastsav.vxl and then you have a map to play on your server
shaz


thepolm3, I was going to ask actually once a merged map is being played, if:

a). You use !map [mapname], only a single map will be played next right?
b). You add more than two maps in the rotation, thus it'll only choose one? (Or will it choose two randomly from the rotation)


I just need this clarified, thanks!
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


So basically it merges on advance, so if you have hallway, then advance to bridge wars, it will merge those maps. If you then advance to anticbridge, it will merge that with bridge wars, as that was the previous map.
shaz


Hmm.

So is there no way to be able to just use one map and also be able to use merging maps without having to unload the script?
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


What yiu do is merge 2 maps, do f1, and then use that as your map
15 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 22 guests