Crossfire Server, Trunk
c_move.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
19 #include <global.h>
20 #ifndef __CEXTRACT__
21 #include <sproto.h>
22 #endif
23 #include <skills.h>
24 
35 static void move_internal(object *op, const char *params, int dir) {
36  if (*params != '\0') {
37  if (params[0] == 'f') {
38  if (!op->contr->fire_on) {
39  op->contr->fire_on = 1;
40  move_player(op, dir);
41  op->contr->fire_on = 0;
42  return;
43  }
44  } else if (params[0] == 'r' && !op->contr->run_on)
45  op->contr->run_on = 1;
46  }
47  move_player(op, dir);
48 }
49 
57 void command_east(object *op, const char *params) {
58  move_internal(op, params, 3);
59 }
60 
68 void command_north(object *op, const char *params) {
69  move_internal(op, params, 1);
70 }
71 
79 void command_northeast(object *op, const char *params) {
80  move_internal(op, params, 2);
81 }
82 
90 void command_northwest(object *op, const char *params) {
91  move_internal(op, params, 8);
92 }
93 
101 void command_south(object *op, const char *params) {
102  move_internal(op, params, 5);
103 }
104 
112 void command_southeast(object *op, const char *params) {
113  move_internal(op, params, 4);
114 }
115 
123 void command_southwest(object *op, const char *params) {
124  move_internal(op, params, 6);
125 }
126 
134 void command_west(object *op, const char *params) {
135  move_internal(op, params, 7);
136 }
137 
145 void command_stay(object *op, const char *params) {
146  if (!op->contr->fire_on && params[0] != 'f')
147  return;
148  fire(op, 0);
149 }
150 
151 void do_goto(object *op, const char *name, int x, int y) {
152  object *dummy;
153  dummy = object_new();
154  dummy->map = op->map;
155  EXIT_PATH(dummy) = add_string(name);
156  EXIT_X(dummy) = x;
157  EXIT_Y(dummy) = y;
158  dummy->name = add_string(name);
159 
160  enter_exit(op, dummy);
162 }
global.h
FREE_OBJ_NO_DESTROY_CALLBACK
#define FREE_OBJ_NO_DESTROY_CALLBACK
Definition: object.h:545
diamondslots.x
x
Definition: diamondslots.py:15
command_southeast
void command_southeast(object *op, const char *params)
Definition: c_move.cpp:112
EXIT_PATH
#define EXIT_PATH(xyz)
Definition: define.h:439
object::map
struct mapstruct * map
Definition: object.h:305
command_west
void command_west(object *op, const char *params)
Definition: c_move.cpp:134
command_stay
void command_stay(object *op, const char *params)
Definition: c_move.cpp:145
move_player
int move_player(object *op, int dir)
Definition: player.cpp:2948
skills.h
move_internal
static void move_internal(object *op, const char *params, int dir)
Definition: c_move.cpp:35
command_northwest
void command_northwest(object *op, const char *params)
Definition: c_move.cpp:90
fire
void fire(object *op, int dir)
Definition: player.cpp:2396
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
object_free
void object_free(object *ob, int flags)
Definition: object.cpp:1592
sproto.h
command_southwest
void command_southwest(object *op, const char *params)
Definition: c_move.cpp:123
EXIT_X
#define EXIT_X(xyz)
Definition: define.h:441
object_new
object * object_new(void)
Definition: object.cpp:1273
command_east
void command_east(object *op, const char *params)
Definition: c_move.cpp:57
object::name
sstring name
Definition: object.h:319
command_north
void command_north(object *op, const char *params)
Definition: c_move.cpp:68
enter_exit
void enter_exit(object *op, object *exit_ob)
Definition: server.cpp:727
command_south
void command_south(object *op, const char *params)
Definition: c_move.cpp:101
give.op
op
Definition: give.py:33
roll-o-matic.params
params
Definition: roll-o-matic.py:193
EXIT_Y
#define EXIT_Y(xyz)
Definition: define.h:442
diamondslots.y
y
Definition: diamondslots.py:16
do_goto
void do_goto(object *op, const char *name, int x, int y)
Definition: c_move.cpp:151
give.name
name
Definition: give.py:27
command_northeast
void command_northeast(object *op, const char *params)
Definition: c_move.cpp:79