File: CFWorld.py

package info (click to toggle)
crossfire-maps 1.71.0-1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 211,128 kB
  • sloc: python: 7,656; ansic: 2,143; perl: 744; sh: 73; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 731 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#CFWorld.py
#A small module for checking where is bigworld an object is if it's in bigworld.
import Crossfire

world_prefix = "/world/world_"
world_prefix_len = len(world_prefix)
world_len = len(world_prefix) + len('xxx_xxx')
world_sep = '_'
bigmapxsize = 50
bigmapysize = 50

#Return an x,y tuple of where in bigworld an object is. Return false if not in bigworld. In current bigworld, values range from 5000 to 6499.
def loc_from_ob(ob):
    cfmap = ob.Map
    if ((cfmap.Path.find(world_prefix) != 0) or (len(cfmap.Path) != world_len)):
        return False
    strloc = cfmap.Path[world_prefix_len:].split(world_sep)
    x = (int(strloc[0]) * bigmapxsize) + ob.X
    y = (int(strloc[1]) * bigmapysize) + ob.Y
    return (x, y)