ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_move.C
Revision: 1.25
Committed: Sat Nov 17 23:40:03 2018 UTC (5 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.24: +1 -0 lines
Log Message:
copyright update 2018

File Contents

# User Rev Content
1 elmex 1.1 /*
2 root 1.12 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 root 1.23 *
4 root 1.25 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
5 root 1.24 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
6 root 1.17 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
7     * Copyright (©) 1992 Frank Tore Johansen
8 root 1.23 *
9 root 1.15 * 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 root 1.23 *
14 root 1.11 * 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 root 1.23 *
19 root 1.15 * 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 root 1.23 *
23 root 1.12 * The authors can be reached via e-mail to <support@deliantra.net>
24 pippijn 1.7 */
25 elmex 1.1
26     #include <global.h>
27 root 1.5 #include <sproto.h>
28 elmex 1.1 #include <skills.h>
29    
30 root 1.3 static int
31     move_internal (object *op, char *params, int dir)
32 elmex 1.1 {
33 root 1.3 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 root 1.9
49 root 1.3 move_player (op, dir);
50 elmex 1.1 return 0;
51     }
52    
53 root 1.3 int
54     command_east (object *op, char *params)
55 elmex 1.1 {
56 root 1.3 return move_internal (op, params, 3);
57 elmex 1.1 }
58    
59 root 1.3 int
60     command_north (object *op, char *params)
61 elmex 1.1 {
62 root 1.3 return move_internal (op, params, 1);
63 elmex 1.1 }
64    
65 root 1.3 int
66     command_northeast (object *op, char *params)
67 elmex 1.1 {
68 root 1.3 return move_internal (op, params, 2);
69 elmex 1.1 }
70    
71 root 1.3 int
72     command_northwest (object *op, char *params)
73 elmex 1.1 {
74 root 1.3 return move_internal (op, params, 8);
75 elmex 1.1 }
76    
77 root 1.3 int
78     command_south (object *op, char *params)
79 elmex 1.1 {
80 root 1.3 return move_internal (op, params, 5);
81 elmex 1.1 }
82    
83 root 1.3 int
84     command_southeast (object *op, char *params)
85 elmex 1.1 {
86 root 1.3 return move_internal (op, params, 4);
87 elmex 1.1 }
88    
89 root 1.3 int
90     command_southwest (object *op, char *params)
91 elmex 1.1 {
92 root 1.3 return move_internal (op, params, 6);
93 elmex 1.1 }
94    
95 root 1.3 int
96     command_west (object *op, char *params)
97 elmex 1.1 {
98 root 1.3 return move_internal (op, params, 7);
99 elmex 1.1 }
100    
101 root 1.3 int
102     command_stay (object *op, char *params)
103 elmex 1.1 {
104     if (!op->contr->fire_on && (!params || params[0] != 'f'))
105     return 0;
106 root 1.14
107 root 1.3 fire (op, 0);
108 elmex 1.1 return 0;
109     }
110 root 1.19
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 root 1.20 op->direction = dir;
123 root 1.19 op->contr->run_on = 1;
124 root 1.20
125     return 1;
126 root 1.19 }
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 root 1.20 op->direction = dir;
147 root 1.19 op->contr->fire_on = 1;
148 root 1.20
149     return 1;
150 root 1.19 }
151    
152     int
153     command_fire_stop (object *op, char *params)
154     {
155     op->contr->fire_on = 0;
156     return 1;
157     }
158