1 |
/* |
2 |
* CrossFire, A Multiplayer game for X-windows |
3 |
* |
4 |
* Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 |
* Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 |
* Copyright (C) 1992 Frank Tore Johansen |
7 |
* |
8 |
* This program is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License as published by |
10 |
* the Free Software Foundation; either version 2 of the License, or |
11 |
* (at your option) any later version. |
12 |
* |
13 |
* This program is distributed in the hope that it will be useful, |
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
* GNU General Public License for more details. |
17 |
* |
18 |
* You should have received a copy of the GNU General Public License |
19 |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 |
* |
22 |
* The author can be reached via e-mail to <crossfire@schmorp.de> |
23 |
*/ |
24 |
|
25 |
#include <global.h> |
26 |
#include <sproto.h> |
27 |
#include <skills.h> |
28 |
|
29 |
static int |
30 |
move_internal (object *op, char *params, int dir) |
31 |
{ |
32 |
if (params) |
33 |
{ |
34 |
if (params[0] == 'f') |
35 |
{ |
36 |
if (!op->contr->fire_on) |
37 |
{ |
38 |
op->contr->fire_on = 1; |
39 |
move_player (op, dir); |
40 |
op->contr->fire_on = 0; |
41 |
return 0; |
42 |
} |
43 |
} |
44 |
else if (params[0] == 'r' && !op->contr->run_on) |
45 |
op->contr->run_on = 1; |
46 |
} |
47 |
move_player (op, dir); |
48 |
return 0; |
49 |
} |
50 |
|
51 |
int |
52 |
command_east (object *op, char *params) |
53 |
{ |
54 |
return move_internal (op, params, 3); |
55 |
} |
56 |
|
57 |
int |
58 |
command_north (object *op, char *params) |
59 |
{ |
60 |
return move_internal (op, params, 1); |
61 |
} |
62 |
|
63 |
int |
64 |
command_northeast (object *op, char *params) |
65 |
{ |
66 |
return move_internal (op, params, 2); |
67 |
} |
68 |
|
69 |
int |
70 |
command_northwest (object *op, char *params) |
71 |
{ |
72 |
return move_internal (op, params, 8); |
73 |
} |
74 |
|
75 |
int |
76 |
command_south (object *op, char *params) |
77 |
{ |
78 |
return move_internal (op, params, 5); |
79 |
} |
80 |
|
81 |
int |
82 |
command_southeast (object *op, char *params) |
83 |
{ |
84 |
return move_internal (op, params, 4); |
85 |
} |
86 |
|
87 |
int |
88 |
command_southwest (object *op, char *params) |
89 |
{ |
90 |
return move_internal (op, params, 6); |
91 |
} |
92 |
|
93 |
int |
94 |
command_west (object *op, char *params) |
95 |
{ |
96 |
return move_internal (op, params, 7); |
97 |
} |
98 |
|
99 |
int |
100 |
command_stay (object *op, char *params) |
101 |
{ |
102 |
if (!op->contr->fire_on && (!params || params[0] != 'f')) |
103 |
return 0; |
104 |
fire (op, 0); |
105 |
return 0; |
106 |
} |