File: positioning_system.py

package info (click to toggle)
crossfire-maps 1.75.0%2Bdfsg1-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 275,656 kB
  • sloc: python: 7,711; sql: 92; sh: 73; makefile: 7
file content (43 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Crossfire

world_prefix = '/world/world_'
world_len = len( world_prefix ) + len( 'xxx_xxx' )
world_sep = '_'
world_map_size = 50

Crossfire.SetReturnValue( 1 )

player = Crossfire.WhoIsActivator()
gps = Crossfire.WhoAmI()
map = player.Map

if ( map == 0 ):
	player.Write( 'You\'re lost in a vacuum!')
else:
	path = map.Path
	if ( path.find( world_prefix ) != 0 ) or ( len( path ) != world_len ):
		player.Write( 'You can\'t position yourself here.' )
	else:
		marked = player.MarkedItem

		if ( marked != gps ) and ( gps.Food == 0 ):
			player.Write( 'You must fix the origin of the positioning system first!' )
		else:
			coord = path.split( world_sep )
			if ( len( coord ) != 3 ):
				player.Write( 'Strange place, you can\'t position yourself...' )
			else:
				map_x = int( coord[ 1 ] ) - 99
				map_y = int( coord[ 2 ] ) - 99
				x = map_x * world_map_size + player.X
				y = map_y * world_map_size + player.Y

				if ( marked == gps ):
					gps.HP=x
					gps.SP=y
					gps.Food=1
					player.Write( 'You reset the origin of the system.' )
				else:
					x = x - gps.HP
					y = y - gps.SP
					player.Write( 'You are at %s:%s.'%( x, y ))