Overpowered tools source in python

#1
Hi guys, long time no see :) I recently wiped my computer clean and lost all the source code for the map making tools I had made,
going back to the domain it seems like it broke... I asked my supplier to recover the data and they said its too late and my VPS no longer exists...
so I recreated the functionality in python (no ui / formatting for .ent) feel free to use it as you please, I might recreate the tools in the future but as I currently don’t have a lot of time on my hands for this kind of project this might take a while...

anyhow the code isn’t too complicated and I decided python would be nice since its so versatile these days
so here it is:
Source Code - in github
 
Last edited:

Janno

3D# General
Staff member
#10
Hi guys, long time no see :) I recently wiped my computer clean and lost all the source code for the map making tools I had made,
going back to the domain it seems like it broke... I asked my supplier to recover the data and they said its too late and my VPS no longer exists...
so I recreated the functionality in python (no ui / formatting for .ent) feel free to use it as you please, I might recreate the tools in the future but as I currently don’t have a lot of time on my hands for this kind of project this might take a while...

anyhow the code isn’t too complicated and I decided python would be nice since its so versatile these days
so here it is:
Python:
## Initializing a Point on the 3 axis x,y,z ##
class Point:
    def __init__(self, x=0, y=0, z=0):
        self.x = x
        self.y = y
        self.z = z
      
    ## Matching .ent files format ##
    def toString(self):
        return (f"\"{self.x} {self.y} {self.z}\"") ## "x y x"
      

## Setting a default point (0,0,0) ##
DEF_POINT = Point()


## Getting 2 points (corners of a rectangle) and offsets for each axis and filling the missing points in the rectangle according to the offset ##
def fillRectangle(c1 = DEF_POINT, c2 = DEF_POINT, offset = DEF_POINT):
  
    ## Rotating the corners to fixed positions opposite each :
    #--top corners:
    #p6            p8#
    #p5            p7#
    #--bottom corners:
    #p2            p4#
    #p1            p3#
    p1 = Point(min(c1.x, c2.x), min(c1.y, c2.y), min(c1.z, c2.z))
    p8 = Point(max(c1.x, c2.x), max(c1.y, c2.y), max(c1.z, c2.z))
  
    points = []
  
    ## Nesting each axis list into a 3D array ##
    for i in range(p1.z, p8.z + 1, offset.z):
        for j in range(p1.y, p8.y + 1, offset.y):
            for k in range(p1.x, p8.x + 1, offset.x):
                points.append(Point(k, j, i))
  
    return points


## Removes all the inner points leaving only the ouline in the list (Taking into account that the list is sorted from the min to max) ##
def outline(arr):
  
    pMin = Point(arr[0].x, arr[0].y, arr[0].z) ## Smallest point (lowest values)
    pMax = Point(arr[len(arr) - 1].x, arr[len(arr) - 1].y, arr[len(arr) - 1].z) ## Largest point
    buffer = []
  
    for i in range(len(arr)):
        if (arr[i].x == pMin.x or arr[i].x == pMax.x or arr[i].y == pMin.y or arr[i].y == pMax.y or arr[i].z == pMin.z or arr[i].z == pMax.z):
            buffer.append(arr[i])
  
    return buffer
      
      
## A function to duplicate an array and moving it by a set offset on each axis ##
def duplicate(arr, offset, times):
  
    tArr = [] ## Temporary array ##
    buffer = arr ## Buffer to keep the currently active array ##
  
    ## Nested loop that pushes all the points into a buffer then combine it with the original list ##
    for i in range(times):
        for j in range(len(buffer)):
            tArr.append(Point(buffer[j].x + offset.x, buffer[j].y + offset.y, buffer[j].z + offset.z))
        arr.extend(tArr)
        buffer = tArr
        tArr.clear()
    return arr
      
      
## Function to post all the points in a list to the console ##
def spit(arr):
  
    print(f"List length: {len(arr)}")
    for i in range(len(arr)):
        print(arr[i].toString())


### TESTERS ###
p1 = Point(0, 0, 0)
p2 = Point(10, 10, 10)
offset = Point(5, 5, 5)
dOffset = Point(100,100,100)
cube = outline(fillRectangle(p1, p2, offset))
duplicate(cube, dOffset, 2)

spit(cube)
edit: this would be the output for those who are interested:
this is 2 cubes (100 units apart) with their middles deleted

Code:
List length: 52
"0 0 0"
"5 0 0"
"10 0 0"
"0 5 0"
"5 5 0"
"10 5 0"
"0 10 0"
"5 10 0"
"10 10 0"
"0 0 5"
"5 0 5"
"10 0 5"
"0 5 5"
"10 5 5"
"0 10 5"
"5 10 5"
"10 10 5"
"0 0 10"
"5 0 10"
"10 0 10"
"0 5 10"
"5 5 10"
"10 5 10"
"0 10 10"
"5 10 10"
"10 10 10"
"100 100 100"
"105 100 100"
"110 100 100"
"100 105 100"
"105 105 100"
"110 105 100"
"100 110 100"
"105 110 100"
"110 110 100"
"100 100 105"
"105 100 105"
"110 100 105"
"100 105 105"
"110 105 105"
"100 110 105"
"105 110 105"
"110 110 105"
"100 100 110"
"105 100 110"
"110 100 110"
"100 105 110"
"105 105 110"
"110 105 110"
"100 110 110"
"105 110 110"
"110 110 110"
A shame you lost the website, the online version was quite good. But someone might find the py script useful as well.
 
#12
Great to see you back once again.
Fortunately, I saved/downloaded both website and the online app before the shutdown.
If anybody wants any of them, feel free to contact me. :)
Great work, kawa.
 
Last edited:
#14
Great to see you back once again.
Fortunately, I saved/downloaded both website and the online app before the shutdown.
If anybody wants any of them, feel free to contact me. :)
Great work, kawa.
nice! you are so prepared :}

send it to me, I can upload to forums.
Sounds good!
If you are having trouble feel free to ask me anything.
Although it should be pretty straight forward, if I recall correctly I didn't use any frameworks or even libraries outside the integrated ones on the website version
simple HTML/JS/CSS files with bootstrap and JQuery integrated with the online versions.
 
#15
I made it into an API if anyone is interested sof2-ent-map-tools
you can create pretty much any entity with this like a floor full of boosters which you couldn’t do with the old tools
Also because there are no fixed properties now you can pretty much add any key you want (like target, targetname, spawnflags etc...)
to use it just clone the repository and import ent.py from there you can make any entity preset you want via the API

I got the old UI from splash now and I might integrate the new api into it with a few changes
I could also make a tkinter UI and compile it into a windows executable this just takes time :/
and technically I can add different shapes to it, idk if it will be practical though who uses triangles and hexagons in his maps anyway?