Crossfire Server, Trunk
marker.cpp
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:170
PLAYER
@ PLAYER
Definition: object.h:112
global.h
move_marker
static void move_marker(object *op)
Definition: marker.cpp:61
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
init_type_marker
void init_type_marker(void)
Definition: marker.cpp:40
Ice.tmp
int tmp
Definition: Ice.py:207
NDI_NAVY
#define NDI_NAVY
Definition: newclient.h:247
register_process
void register_process(int ob_type, process_func method)
Definition: ob_types.cpp:71
MSG_TYPE_MISC
#define MSG_TYPE_MISC
Definition: newclient.h:416
TRIGGER_MARKER
@ TRIGGER_MARKER
Definition: object.h:158
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.cpp:1560
marker_type_process
static method_ret marker_type_process(object *op)
Definition: marker.cpp:102
MARKER
@ MARKER
Definition: object.h:163
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
sproto.h
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:423
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
register_trigger
void register_trigger(int ob_type, trigger_func method)
Definition: ob_types.cpp:98
method_ret
char method_ret
Definition: ob_methods.h:14
ob_types.h
sounds.h
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:265
give.op
op
Definition: give.py:33
add_force
object * add_force(object *op, const char *name, int duration)
Definition: object.cpp:5430
find_force
object * find_force(object *op, const char *name)
Definition: object.cpp:5425
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.cpp:308
marker_type_trigger
static method_ret marker_type_trigger(object *op, object *cause, int state)
Definition: marker.cpp:114
object_remove
void object_remove(object *op)
Definition: object.cpp:1833
ob_methods.h
dragon.state
state
Definition: dragon.py:84
dragon_attune.force
force
Definition: dragon_attune.py:45