Crossfire Server, Trunk
marker.c
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
3 
4  Copyright (C) 2008 Crossfire Development Team
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 
20  The authors can be reached via e-mail at crossfire-devel@real-time.com
21 */
22 
28 #include <global.h>
29 #include <ob_methods.h>
30 #include <ob_types.h>
31 #include <sounds.h>
32 #include <sproto.h>
33 
34 static method_ret marker_type_process(object *op);
35 static method_ret marker_type_trigger(object *op, object *cause, int state);
36 
40 void init_type_marker(void) {
43 }
44 
61 static void move_marker(object *op) {
62  object *tmp;
63 
64  /*
65  * markers not on a map for any reason should not crash server
66  */
67  if (!op->map) {
68  return;
69  }
70 
71  for (tmp = GET_MAP_OB(op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) {
72  if (tmp->type == PLAYER) { /* we've got someone to MARK */
73  if (!find_force(tmp, op->slaying)) {
74  object *force = add_force(tmp, op->slaying, op->stats.food);
75 
76  if (op->lore)
77  force->lore = add_string(op->lore);
78 
79  if (op->msg)
81  op->msg);
82 
83  if (op->stats.hp > 0) {
84  op->stats.hp--;
85  if (op->stats.hp == 0) {
86  /* marker expires--granted mark number limit */
89  return;
90  }
91  }
92  }
93  } /* if tmp->type == PLAYER */
94  } /* For all objects on this space */
95 }
96 
103  move_marker(op);
104  return METHOD_OK;
105 }
106 
114 static method_ret marker_type_trigger(object *op, object *cause, int state) {
115  (void)cause;
116  (void)state;
117  move_marker(op);
118  return METHOD_OK;
119 }
GET_MAP_OB
#define GET_MAP_OB(M, X, Y)
Definition: map.h:173
PLAYER
@ PLAYER
Definition: object.h:107
global.h
add_string
sstring add_string(const char *str)
Definition: shstr.c:124
object_remove
void object_remove(object *op)
Definition: object.c:1819
marker_type_trigger
static method_ret marker_type_trigger(object *op, object *cause, int state)
Definition: marker.c:114
register_process
void register_process(int ob_type, process_func method)
Definition: ob_types.c:71
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
Ice.tmp
int tmp
Definition: Ice.py:207
NDI_NAVY
#define NDI_NAVY
Definition: newclient.h:244
MSG_TYPE_MISC
#define MSG_TYPE_MISC
Definition: newclient.h:413
TRIGGER_MARKER
@ TRIGGER_MARKER
Definition: object.h:153
find_force
object * find_force(object *op, const char *name)
Definition: object.c:5391
MARKER
@ MARKER
Definition: object.h:158
init_type_marker
void init_type_marker(void)
Definition: marker.c:40
sproto.h
register_trigger
void register_trigger(int ob_type, trigger_func method)
Definition: ob_types.c:98
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:420
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
method_ret
char method_ret
Definition: ob_methods.h:14
ob_types.h
sounds.h
marker_type_process
static method_ret marker_type_process(object *op)
Definition: marker.c:102
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:262
give.op
op
Definition: give.py:33
move_marker
static void move_marker(object *op)
Definition: marker.c:61
draw_ext_info
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Definition: main.c:309
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.c:1546
quest.state
state
Definition: quest.py:13
add_force
object * add_force(object *op, const char *name, int duration)
Definition: object.c:5396
ob_methods.h
dragon_attune.force
force
Definition: dragon_attune.py:45