Crossfire Server, Trunk  1.75.0
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 */
87  object_remove(op);
89  return;
90  }
91  }
92  }
93  } /* if tmp->type == PLAYER */
94  } /* For all objects on this space */
95 }
96 
102 static method_ret marker_type_process(object *op) {
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)
Gets the bottom object on a map.
Definition: map.h:170
PLAYER
@ PLAYER
Definition: object.h:112
global.h
move_marker
static void move_marker(object *op)
Move function for marker objects.
Definition: marker.cpp:61
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
object::x
int16_t x
Definition: object.h:335
object::map
struct mapstruct * map
Pointer to the map in which this object is present.
Definition: object.h:305
init_type_marker
void init_type_marker(void)
Initializer for the marker object type.
Definition: marker.cpp:40
NDI_NAVY
#define NDI_NAVY
Definition: newclient.h:247
register_process
void register_process(int ob_type, process_func method)
Registers the process method for the given type.
Definition: ob_types.cpp:71
MSG_TYPE_MISC
#define MSG_TYPE_MISC
Messages that don't go elsewhere.
Definition: newclient.h:416
object::above
object * above
Pointer to the object stacked above this one.
Definition: object.h:296
draw_ext_info
vs only yadda is in because all tags get reset on the next draw_ext_info In the second since it is all in one draw_ext_info
Definition: media-tags.txt:61
TRIGGER_MARKER
@ TRIGGER_MARKER
inserts an invisible, weightless force into a player with a specified string WHEN TRIGGERED.
Definition: object.h:158
object::y
int16_t y
Position in the map for this object.
Definition: object.h:335
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects,...
Definition: object.cpp:1560
marker_type_process
static method_ret marker_type_process(object *op)
Processes a marker.
Definition: marker.cpp:102
MARKER
@ MARKER
inserts an invisible, weightless force into a player with a specified string.
Definition: object.h:163
add_string
sstring add_string(const char *str)
This will add 'str' to the hash table.
Definition: shstr.cpp:124
object::type
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
living::food
int32_t food
How much food in stomach.
Definition: living.h:48
sproto.h
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:423
register_trigger
void register_trigger(int ob_type, trigger_func method)
Registers the trigger method for the given type.
Definition: ob_types.cpp:98
method_ret
char method_ret
Define some standard return values for callbacks which don't need to return any other results.
Definition: ob_methods.h:14
ob_types.h
sounds.h
object::lore
sstring lore
Obscure information about this object, to get put into books and the like.
Definition: object.h:332
NDI_UNIQUE
#define NDI_UNIQUE
Print immediately, don't buffer.
Definition: newclient.h:265
object::slaying
sstring slaying
Which race to do double damage to.
Definition: object.h:327
object::msg
sstring msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:330
add_force
object * add_force(object *op, const char *name, int duration)
Add or return an existing force inside 'op' with the given 'name' and 'duration' in units of 100 tick...
Definition: object.cpp:5430
find_force
object * find_force(object *op, const char *name)
Find a force with the given 'name' in the slaying field.
Definition: object.cpp:5425
marker_type_trigger
static method_ret marker_type_trigger(object *op, object *cause, int state)
A marker is triggered.
Definition: marker.cpp:114
object_remove
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to.
Definition: object.cpp:1833
ob_methods.h
object::stats
living stats
Str, Con, Dex, etc.
Definition: object.h:378
living::hp
int16_t hp
Hit Points.
Definition: living.h:40