| version 1.1 | | version 1.2 |
|---|
| | |
| import CFPython | | import Crossfire |
| | | |
| world_prefix = '/world/world_' | | world_prefix = '/world/world_' |
| world_len = len( world_prefix ) + len( 'xxx_xxx' ) | | world_len = len( world_prefix ) + len( 'xxx_xxx' ) |
| world_sep = '_' | | world_sep = '_' |
| world_map_size = 50 | | world_map_size = 50 |
| | | |
| CFPython.SetReturnValue( 1 ) | | Crossfire.SetReturnValue( 1 ) |
| | | |
| player = CFPython.WhoIsActivator() | | player = Crossfire.WhoIsActivator() |
| gps = CFPython.WhoAmI() | | gps = Crossfire.WhoAmI() |
| map = CFPython.GetMap( player ) | | map = player.Map |
| | | |
| if ( map == 0 ): | | if ( map == 0 ): |
| CFPython.CFWrite( 'You\'re lost in a vacuum!', player ) | | player.Write( 'You\'re lost in a vacuum!') |
| else: | | else: |
| path = CFPython.GetMapPath( map ) | | path = map.Path |
| if ( path.find( world_prefix ) != 0 ) or ( len( path ) != world_len ): | | if ( path.find( world_prefix ) != 0 ) or ( len( path ) != world_len ): |
| CFPython.Write( 'You can\'t position yourself here.', player ) | | player.Write( 'You can\'t position yourself here.' ) |
| else: | | else: |
| marked = CFPython.GetMarkedItem( player ) | | marked = player.MarkedItem |
| | | |
| if ( marked != gps ) and ( CFPython.GetFood( gps ) == 0 ): | | if ( marked != gps ) and ( gps.Food == 0 ): |
| CFPython.Write( 'You must fix the origin of the positioning system first!', player ) | | player.Write( 'You must fix the origin of the positioning system first!' ) |
| else: | | else: |
| coord = path.split( world_sep ) | | coord = path.split( world_sep ) |
| if ( len( coord ) != 3 ): | | if ( len( coord ) != 3 ): |
| CFPython.Write( 'Strange place, you can\'t position yourself...', player ) | | player.Write( 'Strange place, you can\'t position yourself...' ) |
| else: | | else: |
| map_x = int( coord[ 1 ] ) - 99 | | map_x = int( coord[ 1 ] ) - 99 |
| map_y = int( coord[ 2 ] ) - 99 | | map_y = int( coord[ 2 ] ) - 99 |
| x = map_x * world_map_size + CFPython.GetXPosition( player ) | | x = map_x * world_map_size + player.X |
| y = map_y * world_map_size + CFPython.GetYPosition( player ) | | y = map_y * world_map_size + player.Y |
| | | |
| if ( marked == gps ): | | if ( marked == gps ): |
| CFPython.SetHP( gps, x ) | | gps.HP=x |
| CFPython.SetSP( gps, y ) | | gps.SP=y |
| CFPython.SetFood( gps, 1 ) | | gps.Food=1 |
| CFPython.Write( 'You reset the origin of the system.', player ) | | player.Write( 'You reset the origin of the system.' ) |
| else: | | else: |
| x = x - CFPython.GetHP( gps ) | | x = x - gps.HP |
| y = y - CFPython.GetSP( gps ) | | y = y - gps.SP |
| CFPython.Write( 'You are at %s:%s.'%( x, y ), player ) | | player.Write( 'You are at %s:%s.'%( x, y )) |