12 1. Create a transport object in the map editor. Ensure that its type is actually TRANSPORT.
14 2. Add Python events that trigger this script. Transports require at least two events:
16 - event_time, which periodically calls this script to move the transport along
18 - event_apply and/or event_say, to start and stop the transport
20 In practice, each event has fields:
23 slaying /python/items/roll-o-matic.py
29 Which makes roll-o-matic work for ships.
34 key_direction =
'rom_dir'
35 key_follow =
'rom_follow'
37 dir_x = [ 0, 0, 1, 1, 1, 0, -1, -1, -1 ]
38 dir_y = [ 0, -1, -1, 0, 1, 1, 1, 0, -1 ]
44 return ob.ArchName
in {
'sea_route',
'sea_route_2',
'sea_route_3',
'sea_route_4'}
49 """Find all objects satisfying is_floor() at the given location."""
50 obj = me.Map.ObjectAt(x, y)
57 obj = me.Map.ObjectAt(me.X, me.Y)
59 if obj.Type == Crossfire.Type.PLAYER:
65 """Check whether one floor at the given location matches the given 'name'."""
79 me.WriteKey(key_direction,
'', 1)
80 me.WriteKey(key_follow,
'', 1)
81 me.Map.Print(
'The %s stops moving.'%me.Name)
84 floor = me.ReadKey(key_follow)
88 for check
in check_directions:
90 if has_floor(x + dir_x[d], y + dir_y[d], floor):
93 me.WriteKey(key_direction,
str(d))
109 want_dir = me.ReadKey(key_direction)
110 floor = me.ReadKey(key_follow)
111 if want_dir ==
'' or floor ==
'':
115 want_dir =
int(want_dir)
118 check_directions = [0, 1, -1, 2, -2, 3, -3]
120 curr_tile = me.Map.ObjectAt(me.X, me.Y)
121 while curr_tile !=
None:
122 if curr_tile.Name ==
'shipwreck':
125 curr_tile = curr_tile.Above
128 check_directions = [0, 1, -1]
129 try_move(check_directions, want_dir)
135 floor = floors[0].Name
137 if me.ReadKey(key_direction) ==
'':
138 me.Map.Print(
'The %s starts moving!' % me.Name)
140 me.WriteKey(key_direction,
str(want_dir), 1)
141 me.WriteKey(key_follow, floor, 1)
144 msg = Crossfire.WhatIsMessage()
146 if me.ReadKey(key_direction) !=
'':
152 for d
in Crossfire.DirectionName.keys():
153 if msg == Crossfire.DirectionName[d].lower():
163 if pl.Transport !=
None:
169 try_move([0, 1, 2, 3, 4, 5, 6, 7], 0)
170 Crossfire.SetReturnValue(0)
176 if "ship_mode" in params:
180 Crossfire.SetReturnValue(1)
182 if evt.Subtype == Crossfire.EventType.SAY:
184 elif evt.Subtype == Crossfire.EventType.APPLY:
186 elif evt.Subtype == Crossfire.EventType.TIME:
190 evt = Crossfire.WhatIsEvent()
191 me = Crossfire.WhoAmI()
192 pl = Crossfire.WhoIsActivator()
193 params = Crossfire.ScriptParameters()