Crossfire Server, Trunk  R20513
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 }
void command_northwest(object *op, const char *params)
&#39;northwest&#39; command.
Definition: c_move.c:90
void command_west(object *op, const char *params)
&#39;west&#39; command.
Definition: c_move.c:134
void command_southeast(object *op, const char *params)
&#39;southeast&#39; command.
Definition: c_move.c:112
int move_player(object *op, int dir)
Player gave us a direction, check whether to move or fire.
Definition: player.c:3007
void command_southwest(object *op, const char *params)
&#39;southwest&#39; command.
Definition: c_move.c:123
uint32_t run_on
Player should keep moving in dir until run is off.
Definition: player.h:128
void command_stay(object *op, const char *params)
&#39;stay&#39; command.
Definition: c_move.c:145
Global type definitions and header inclusions.
static void move_internal(object *op, const char *params, int dir)
A player is moving in a direction, but this may indicate firing.
Definition: c_move.c:35
void command_north(object *op, const char *params)
&#39;north&#39; command.
Definition: c_move.c:68
struct pl * contr
Pointer to the player which control this object.
Definition: object.h:276
Skill-related defines, including subtypes.
void fire(object *op, int dir)
Received a fire command for the player - go and do it.
Definition: player.c:2466
uint32_t fire_on
Player should fire object, not move.
Definition: player.h:127
void command_northeast(object *op, const char *params)
&#39;northeast&#39; command.
Definition: c_move.c:79
void command_south(object *op, const char *params)
&#39;south&#39; command.
Definition: c_move.c:101
void command_east(object *op, const char *params)
&#39;east&#39; command.
Definition: c_move.c:57