Crossfire Server, Trunk
doors_galore.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # Script for the ogre chief in /scorn/houses/doors_galore
3 #
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #
19 # author: Nicolas for Khaleh
20 
21 # This script waits for the ogre chief to be at a certain position
22 # then will move it to another while picking loot, then move it back
23 # to another position.
24 # Should be connected to the 'event_time' of the chief
25 
26 import Crossfire
27 
28 # Coordinates to be at to start the grab-move
29 start_x = 20
30 start_y = 4
31 # Where to go to while picking loot
32 grab_to_x = 20
33 grab_to_y = 8
34 
35 # Where to go back
36 to_final_x = 20
37 to_final_y = 7
38 
39 # if you want to see what the chief is doing, set that to 1
40 chief_talks = 0
41 
42 def move_grab(me):
43 
44  if chief_talks:
45  me.Say('grab')
46 
47  below = me.Below
48  while below.Floor == 0:
49  take = below
50  below = below.Below
51  if chief_talks:
52  me.Say('taking %s'%take.Name)
53  me.Take(take)
54 
55  if me.X == grab_to_x and me.Y == grab_to_y:
56  me.WriteKey('grab_state', 'final', 1)
57  return
58 
59  me.Move(Crossfire.Direction.SOUTH)
60 
61 def move_final(me):
62  if chief_talks:
63  me.Say('final')
64 
65  me.Move(Crossfire.Direction.NORTH)
66 
67  if me.X == to_final_x and me.Y == to_final_y:
68  me.WriteKey('grab_state', 'finished', 1)
69  if chief_talks:
70  me.Say('finished')
71 
72 def process():
73  me = Crossfire.WhoAmI()
74  state = me.ReadKey('grab_state')
75  if state == 'finished':
76  return
77 
78  if state == '':
79  if me.X != start_x or me.Y != start_y:
80  if chief_talks:
81  me.Say('not at place')
82  return
83 
84  me.WriteKey('grab_state', 'grabbing', 1)
85  state = 'grabbing'
86  # fall through
87 
88  Crossfire.SetReturnValue(1)
89 
90  if state == 'grabbing':
91  move_grab(me)
92  return
93 
94  if state == 'final':
95  move_final(me)
96 
97 process()
doors_galore.move_grab
def move_grab(me)
Definition: doors_galore.py:42
doors_galore.process
def process()
Definition: doors_galore.py:72
doors_galore.move_final
def move_final(me)
Definition: doors_galore.py:61