Crossfire Server, Trunk
c_move.c
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:531
object_free
void object_free(object *ob, int flags)
Definition: object.c:1578
add_string
sstring add_string(const char *str)
Definition: shstr.c:124
command_south
void command_south(object *op, const char *params)
Definition: c_move.c:101
command_west
void command_west(object *op, const char *params)
Definition: c_move.c:134
diamondslots.x
x
Definition: diamondslots.py:15
obj::map
struct mapdef * map
Definition: object.h:300
object_new
object * object_new(void)
Definition: object.c:1255
command_northwest
void command_northwest(object *op, const char *params)
Definition: c_move.c:90
EXIT_PATH
#define EXIT_PATH(xyz)
Definition: define.h:439
do_goto
void do_goto(object *op, const char *name, int x, int y)
Definition: c_move.c:151
command_stay
void command_stay(object *op, const char *params)
Definition: c_move.c:145
move_player
int move_player(object *op, int dir)
Definition: player.c:2923
command_southwest
void command_southwest(object *op, const char *params)
Definition: c_move.c:123
skills.h
obj::name
sstring name
Definition: object.h:314
fire
void fire(object *op, int dir)
Definition: player.c:2373
move_internal
static void move_internal(object *op, const char *params, int dir)
Definition: c_move.c:35
sproto.h
command_north
void command_north(object *op, const char *params)
Definition: c_move.c:68
EXIT_X
#define EXIT_X(xyz)
Definition: define.h:441
enter_exit
void enter_exit(object *op, object *exit_ob)
Definition: server.c:732
give.op
op
Definition: give.py:33
command_northeast
void command_northeast(object *op, const char *params)
Definition: c_move.c:79
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
command_southeast
void command_southeast(object *op, const char *params)
Definition: c_move.c:112
command_east
void command_east(object *op, const char *params)
Definition: c_move.c:57
give.name
name
Definition: give.py:27