Crossfire Server, Branches 1.12  R18729
c_move.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_c_move_c =
3  * "$Id: c_move.c 11578 2009-02-23 22:02:27Z lalo $";
4  */
5 
6 /*
7  CrossFire, A Multiplayer game for X-windows
8 
9  Copyright (C) 2002 Mark Wedel & Crossfire Development Team
10  Copyright (C) 1992 Frank Tore Johansen
11 
12  This program is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 2 of the License, or
15  (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 
26  The author can be reached via e-mail to crossfire-devel@real-time.com
27 */
28 
34 #include <global.h>
35 #ifndef __CEXTRACT__
36 #include <sproto.h>
37 #endif
38 #include <skills.h>
39 
52 static int move_internal(object *op, char *params, int dir) {
53  if (params) {
54  if (params[0] == 'f') {
55  if (!op->contr->fire_on) {
56  op->contr->fire_on = 1;
57  move_player(op, dir);
58  op->contr->fire_on = 0;
59  return 0;
60  }
61  } else if (params[0] == 'r' && !op->contr->run_on)
62  op->contr->run_on = 1;
63  }
64  move_player(op, dir);
65  return 0;
66 }
67 
77 int command_east(object *op, char *params) {
78  return move_internal(op, params, 3);
79 }
80 
90 int command_north(object *op, char *params) {
91  return move_internal(op, params, 1);
92 }
93 
103 int command_northeast(object *op, char *params) {
104  return move_internal(op, params, 2);
105 }
106 
116 int command_northwest(object *op, char *params) {
117  return move_internal(op, params, 8);
118 }
119 
129 int command_south(object *op, char *params) {
130  return move_internal(op, params, 5);
131 }
132 
142 int command_southeast(object *op, char *params) {
143  return move_internal(op, params, 4);
144 }
145 
155 int command_southwest(object *op, char *params) {
156  return move_internal(op, params, 6);
157 }
158 
168 int command_west(object *op, char *params) {
169  return move_internal(op, params, 7);
170 }
171 
181 int command_stay(object *op, char *params) {
182  if (!op->contr->fire_on && (!params || params[0] != 'f'))
183  return 0;
184  fire(op, 0);
185  return 0;
186 }
int move_player(object *op, int dir)
Definition: player.c:2741
int command_north(object *op, char *params)
Definition: c_move.c:90
int command_stay(object *op, char *params)
Definition: c_move.c:181
uint32 run_on
Definition: player.h:182
int command_southeast(object *op, char *params)
Definition: c_move.c:142
int command_south(object *op, char *params)
Definition: c_move.c:129
int command_east(object *op, char *params)
Definition: c_move.c:77
static int move_internal(object *op, char *params, int dir)
Definition: c_move.c:52
struct pl * contr
Definition: object.h:134
int command_northeast(object *op, char *params)
Definition: c_move.c:103
void fire(object *op, int dir)
Definition: player.c:2204
int command_west(object *op, char *params)
Definition: c_move.c:168
uint32 fire_on
Definition: player.h:181
int command_northwest(object *op, char *params)
Definition: c_move.c:116
int command_southwest(object *op, char *params)
Definition: c_move.c:155