home · contact · privacy
Server, plugin: Refactor ai (plugin hooks).
[plomrogue] / SERVER_COMMANDS
1 Command reading and writing
2 ===========================
3
4 Normal mode
5 -----------
6
7 In normal mode, the server on start up checks for the existence of ./save and,
8 on success, reads all commands from it. If no save file exists, commands from
9 ./confserver/world (or any file defined with the -w argument) are read instead
10 – and written to the file ./record_save. Afterwards, the command "MAKE_WORLD"
11 with the current Unix time as argument is interpreted (and also written to
12 ./record_save).
13
14 In any case, from then on, further commands are read in from ./server_run/in.
15 New commands must be appended to the file – which is what the client does. All
16 commands from ./server_run/in except meta commands are also written to
17 ./record_save.
18
19 Every fifteen seconds, if any turns have passed, ./savefile is written – with a
20 list of all god commands necessary to recreate the current world state. On each
21 world state change, ./server_run/worldstate is updated and a message
22 "WORLD_UPDATED" written to ./server_run/out.
23
24 Replay mode
25 -----------
26
27 In replay mode, commands from ./record_save are read. If a turn number is given
28 as an argument, the file is read until the given turn is reached, or, if the
29 turn number is higher than the last turn of the recorded play, the last turn. If
30 no turn number is given as argument, the record file is replayed until turn 1 is
31 reached. Meta commands in ./record_save are not understood.
32
33 From then on, ./server_run/in is also read. Meta commands sent by the client are
34 interpreted normally, but any player and god command merely furthers reading of
35 ./record_save by one line and is otherwise ignored.
36
37 Command list
38 ============
39
40 Each command is of a single line. It consists at least of one command stringe,
41 in some cases followed by an obligatory argument. Argument fields are described
42 below in square brackets. Number ranges are described by the first legal number,
43 followed by " to ", followed by the last legal number. "[string]" means any text
44 string is expected, which must be enclosed in single quotes if it contains
45 whitespaces. "[char]" means a single ASCII character is expected. If one of a
46 set of pre-defined strings is expected, the legal strings are divided by pipe
47 symbols ("|").
48
49 Commands in lowercase characters ("player commands") are only interpreted if the
50 game world is set active.
51
52 Meta commands
53 -------------
54
55 PING
56 Write "PONG" line to ./server_run/out file.
57
58 QUIT
59 Shut down server.
60
61 THINGS_HERE [0 to 255] [0 to 255]
62 If world exists, write line-by-line list of things visible or in memory at y
63 position of first argument, x position of second argument of map into
64 ./server_run/out file, enclosed by two lines "THINGS_HERE START" and
65 "THINGS_HERE END".
66
67 Player commands
68 ---------------
69
70 ai
71 Do what the AI would do.
72
73 wait
74 Make player character wait one turn.
75
76 move [east|south-east|south-west|west|north-west|north-east]
77 Make player character move into direction described by argument, or attack into
78 that direction if there is an enemy.
79
80 pick_up
81 Make player character pick up topmost thing it is standing on.
82
83 drop [0 to 255]
84 Make player character drop to the ground item of argument's position in the
85 player character's inventory.
86
87 use [0 to 255]
88 Make player character use item of argument's position in player character's
89 inventory.
90
91 God commands
92 ------------
93
94 PLUGIN [string]
95 Run plugin code in ./plugins/[argument], with argument only consisting of
96 alphanumeric characters and underscores.
97
98 TURN [0 to 65535]
99 Set world turn to argument. (Initial value: 0.)
100
101 PLAYER_TYPE [0 to infinity]
102 Set to argument ID of thing type into which a new world's player character will
103 be generated. (Initial value: 0.)
104
105 SEED_RANDOMNESS [0 to 4294967295]
106 Set randomness seed to argument. (Initial value: 0.)
107
108 MAKE_WORLD [0 to 4294967295]
109 Set map seed and randomness seed to argument. Remove all things. (Re-)generate
110 map. Add to map things specified in thing types table in quantity defined there
111 by START_NUMBER command, with first thing (of thing ID of 0) of type defined as
112 player type by PLAYER_TYPE command. Set world turn to 1. Activate world. Answer
113 with 'NEW_WORLD' message in ./server_run/out file.
114
115 MAP_LENGTH [1 to 256]
116 Deactivate world. Remove ./server_run/worldstate file. Remove all things. Remove
117 map. Set map edge length to argument. (Initial value: 64.)
118
119 MAP [0 to 255] [string]
120 Set part of game map to string argument: the line of the argument's number.
121
122 WORLD_ACTIVE [0|1]
123 Set world activity state to argument. If 0, remove ./server_run/worldstate file.
124 Else, if world was so far inactive, a map exists, at least one "wait" thing
125 action is defined, and a thing of ID 0 (= a player character) that is not part
126 of any other thing's inventory, (re-)build all animate things' fields of view,
127 and activate world. (Initial value: 0.)
128
129 TA_ID [0 to infinity]
130 Select thing action to manipulate by argument as ID. If argument is 0, change it
131 to the lowest unused thing action ID greater than 0. If action of ID does not
132 exist yet, create it with default name "wait" and default effort 1.
133
134 TA_EFFORT [0 to 255]
135 Set to argument the number of turns finishing the selected thing action takes.
136
137 TA_NAME [wait|move|use|drop|pick_up]
138 Set selected thing action's name (and thereby function, equal to player
139 command). Legal worlds need at least one action of name "wait", so if this
140 unsets the world's only "wait" action, the world is deactivated, and the
141 ./server_run/worldstate file removed.
142
143 T_ID [-1 to infinity]
144 Select thing to manipulate by argument as ID. If argument is <0, change it to
145 the lowest unused thing ID. If thing of ID does not exist yet, create it with
146 default position of y=0/x=0, the first thing type's ID, and that type's
147 lifepoints value; if world is active and the thing is animate, build its field
148 of view.
149
150 T_TYPE [0 to infinity]
151 Set selected thing's type ID to argument, if the respective ThingType exists.
152
153 T_POSY [0 to 255]
154 Set selected thing's map row position to argument. Delete thing's field of view
155 and, if world is active, rebuild it.
156
157 T_POSX [0 to 255]
158 Set selected thing's map column position to argument. Delete thing's field of
159 view and, if world is active, rebuild it.
160
161 T_COMMAND [0 to infinity]
162 Set to argument the action thing is currently performing, as identified by its
163 thing action ID, if a thing action of that ID is defined. If argument is 0, the
164 thing's command ID is set to that, implying that it is not performing any
165 action.
166
167 T_ARGUMENT [0 to 255]
168 Set selected thing's action argument value to argument.
169
170 T_PROGRESS [0 to 255]
171 Set selected thing's action progress (number of turns already invested in
172 performing the action) value to argument.
173
174 T_LIFEPOINTS [0 to 255]
175 Set selected thing's lifepoints to argument.
176
177 T_SATIATION [-32768 to 32767]
178 Set selected thing's satiation score. Each turn, there is a chance of hitpoint
179 loss that grows with the satiation score's absolute value, and one of hitpoint
180 gain that lowers with it. Each turn, T_SATIATION lessens by the square root of
181 the thing's type's start hitpoints (see TT_LIFEPOINTS).
182
183 T_CARRIES [0 to infinity]
184 Add thing of ID in argument to inventory of selected thing, if said thing is
185 available for carrying and not the selected thing.
186
187 T_MEMMAP [0 to 255] [string]
188 Set part of selected thing's memory of the game map to string argument: the line
189 of the argument's number.
190
191 T_MEMDEPTHMAP [0 to 255] [string]
192 Set part of selected thing's game map memory depth map to string argument: the
193 line of the argument's number.
194
195 T_MEMTHING [0 to infinity] [0 to 255] [0 to 255]
196 Add to selected thing's memory of things on map thing of ID of first argument,
197 y position of second argument and x position of third argument.
198
199 TT_ID [-1 to infinity]
200 Select thing type to manipulate by argument as ID. If argument is < 0, change it
201 to the lowest unused thing type ID. If thing type of ID does not exist yet,
202 create it with default name "(none)", corpse ID equal to the new thing type's
203 ID, symbol "?", and remaining thing type attributes to 0.
204
205 TT_TOOL [|food]
206 (May be left empty.) Defines the way things of the selected type can be used.
207 The only options so far that is interpreted is "food" (may be consumed).
208
209 TT_TOOLPOWER [0 to 65535]
210 Set selected thing type's tool power value to argument. If its tool type is
211 "food", this sets the number of .satiation score points earned by consuming
212 things of that type.
213
214 TT_START_NUMBER [0-255]
215 Set selected thing type's number of things of type to spawn on successful
216 MAKE_WORLD command to argument.
217
218 TT_LIFEPOINTS [0-255]
219 Set selected thing type's initial lifepoints value to argument. Things of 0
220 lifepoints are considered inanimate, otherwise animate. The square root of this
221 is the amount things of the type suffer satiation score loss each turn.
222
223 TT_SYMBOL [char]
224 Set to argument symbol by which things of the selected type are represented on
225 the map.
226
227 TT_NAME [string]
228 Set selected thing type's name to argument. This name identifies things in the
229 game log and the inventory.
230
231 TT_CORPSE_ID [0 to infinity]
232 Set to argument the ID of the thing type that things of the selected type
233 transform into when their state changes from animate to inanimate.
234
235 TT_PROLIFERATE [0 to 65535]
236 If non-zero, there is a chance of 1 divided by the given value each turn for any
237 thing of the selected type to emit an offspring to a random neighbor cell if one
238 is available that is passable and not inhabited by any thing.