1 |
/* |
2 |
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 |
* |
4 |
* Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
5 |
* Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
6 |
* Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
7 |
* Copyright (©) 1992 Frank Tore Johansen |
8 |
* |
9 |
* Deliantra is free software: you can redistribute it and/or modify it under |
10 |
* the terms of the Affero GNU General Public License as published by the |
11 |
* Free Software Foundation, either version 3 of the License, or (at your |
12 |
* option) any later version. |
13 |
* |
14 |
* This program is distributed in the hope that it will be useful, |
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
* GNU General Public License for more details. |
18 |
* |
19 |
* You should have received a copy of the Affero GNU General Public License |
20 |
* and the GNU General Public License along with this program. If not, see |
21 |
* <http://www.gnu.org/licenses/>. |
22 |
* |
23 |
* The authors can be reached via e-mail to <support@deliantra.net> |
24 |
*/ |
25 |
|
26 |
#include <global.h> |
27 |
#include <sproto.h> |
28 |
#include <skills.h> |
29 |
|
30 |
static int |
31 |
move_internal (object *op, char *params, int dir) |
32 |
{ |
33 |
if (params) |
34 |
{ |
35 |
if (params[0] == 'f') |
36 |
{ |
37 |
if (!op->contr->fire_on) |
38 |
{ |
39 |
op->contr->fire_on = 1; |
40 |
move_player (op, dir); |
41 |
op->contr->fire_on = 0; |
42 |
return 0; |
43 |
} |
44 |
} |
45 |
else if (params[0] == 'r' && !op->contr->run_on) |
46 |
op->contr->run_on = 1; |
47 |
} |
48 |
|
49 |
move_player (op, dir); |
50 |
return 0; |
51 |
} |
52 |
|
53 |
int |
54 |
command_east (object *op, char *params) |
55 |
{ |
56 |
return move_internal (op, params, 3); |
57 |
} |
58 |
|
59 |
int |
60 |
command_north (object *op, char *params) |
61 |
{ |
62 |
return move_internal (op, params, 1); |
63 |
} |
64 |
|
65 |
int |
66 |
command_northeast (object *op, char *params) |
67 |
{ |
68 |
return move_internal (op, params, 2); |
69 |
} |
70 |
|
71 |
int |
72 |
command_northwest (object *op, char *params) |
73 |
{ |
74 |
return move_internal (op, params, 8); |
75 |
} |
76 |
|
77 |
int |
78 |
command_south (object *op, char *params) |
79 |
{ |
80 |
return move_internal (op, params, 5); |
81 |
} |
82 |
|
83 |
int |
84 |
command_southeast (object *op, char *params) |
85 |
{ |
86 |
return move_internal (op, params, 4); |
87 |
} |
88 |
|
89 |
int |
90 |
command_southwest (object *op, char *params) |
91 |
{ |
92 |
return move_internal (op, params, 6); |
93 |
} |
94 |
|
95 |
int |
96 |
command_west (object *op, char *params) |
97 |
{ |
98 |
return move_internal (op, params, 7); |
99 |
} |
100 |
|
101 |
int |
102 |
command_stay (object *op, char *params) |
103 |
{ |
104 |
if (!op->contr->fire_on && (!params || params[0] != 'f')) |
105 |
return 0; |
106 |
|
107 |
fire (op, 0); |
108 |
return 0; |
109 |
} |
110 |
|
111 |
int |
112 |
command_run (object *op, char *params) |
113 |
{ |
114 |
int dir = params ? atoi (params) : 0; |
115 |
|
116 |
if (dir < 0 || dir >= 9) |
117 |
{ |
118 |
new_draw_info (NDI_UNIQUE, 0, op, "Can't run into a non adjacent square."); |
119 |
return 0; |
120 |
} |
121 |
|
122 |
op->direction = dir; |
123 |
op->contr->run_on = 1; |
124 |
|
125 |
return 1; |
126 |
} |
127 |
|
128 |
int |
129 |
command_run_stop (object *op, char *params) |
130 |
{ |
131 |
op->contr->run_on = 0; |
132 |
return 1; |
133 |
} |
134 |
|
135 |
int |
136 |
command_fire (object *op, char *params) |
137 |
{ |
138 |
int dir = params ? atoi (params) : 0; |
139 |
|
140 |
if (dir < 0 || dir >= 9) |
141 |
{ |
142 |
new_draw_info (NDI_UNIQUE, 0, op, "Can't fire to a non adjacent square."); |
143 |
return 0; |
144 |
}; |
145 |
|
146 |
op->direction = dir; |
147 |
op->contr->fire_on = 1; |
148 |
|
149 |
return 1; |
150 |
} |
151 |
|
152 |
int |
153 |
command_fire_stop (object *op, char *params) |
154 |
{ |
155 |
op->contr->fire_on = 0; |
156 |
return 1; |
157 |
} |
158 |
|