Crossfire Server, Trunk  R21024
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(ob_methods *context, object *op);
35 static method_ret marker_type_trigger(ob_methods *context, 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, *tmp2;
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  /* cycle through his inventory to look for the MARK we want to
74  * place
75  */
77  /* if we didn't find our own MARK */
78  if (tmp2 == NULL) {
79  object *force = create_archetype(FORCE_NAME);
80 
81  force->speed = 0;
82  if (op->stats.food) {
83  force->speed = 0.01;
84  force->speed_left = -op->stats.food;
85  }
86  object_update_speed(force);
87  /* put in the lock code */
88  force->slaying = add_string(op->slaying);
89 
90  if (op->lore)
91  force->lore = add_string(op->lore);
92 
93  object_insert_in_ob(force, tmp);
94  if (op->msg)
96  op->msg);
97 
98  if (op->stats.hp > 0) {
99  op->stats.hp--;
100  if (op->stats.hp == 0) {
101  /* marker expires--granted mark number limit */
102  object_remove(op);
104  return;
105  }
106  }
107  } /* if tmp2 == NULL */
108  } /* if tmp->type == PLAYER */
109  } /* For all objects on this space */
110 }
111 
118 static method_ret marker_type_process(ob_methods *context, object *op) {
119  move_marker(op);
120  return METHOD_OK;
121 }
122 
131 static method_ret marker_type_trigger(ob_methods *context, object *op, object *cause, int state) {
132  move_marker(op);
133  return METHOD_OK;
134 }
#define MSG_TYPE_MISC
Definition: newclient.h:389
const char * slaying
Definition: object.h:319
struct obj * above
Definition: object.h:288
object * object_find_by_type_and_slaying(const object *who, int type, const char *slaying)
Definition: object.c:4067
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Definition: main.c:310
int16_t hp
Definition: living.h:40
#define NDI_NAVY
Definition: newclient.h:223
static void move_marker(object *op)
Definition: marker.c:61
char method_ret
Definition: ob_methods.h:14
const char * lore
Definition: object.h:323
void object_free_drop_inventory(object *ob)
Definition: object.c:1389
int16_t y
Definition: object.h:326
object * create_archetype(const char *name)
Definition: arch.c:617
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2705
float speed_left
Definition: object.h:329
Definition: object.h:158
#define METHOD_OK
Definition: ob_methods.h:15
struct mapdef * map
Definition: object.h:297
float speed
Definition: object.h:328
void register_trigger(int ob_type, trigger_func method)
Definition: ob_types.c:98
int16_t x
Definition: object.h:326
Definition: object.h:107
void init_type_marker(void)
Definition: marker.c:40
living stats
Definition: object.h:368
uint8_t type
Definition: object.h:338
const char * msg
Definition: object.h:322
void register_process(int ob_type, process_func method)
Definition: ob_types.c:71
#define FORCE_NAME
Definition: spells.h:169
static method_ret marker_type_trigger(ob_methods *context, object *op, object *cause, int state)
Definition: marker.c:131
sstring add_string(const char *str)
Definition: shstr.c:124
#define GET_MAP_OB(M, X, Y)
Definition: map.h:172
#define NDI_UNIQUE
Definition: newclient.h:245
#define MSG_SUBTYPE_NONE
Definition: newclient.h:398
static method_ret marker_type_process(ob_methods *context, object *op)
Definition: marker.c:118
void object_update_speed(object *op)
Definition: object.c:1150
void object_remove(object *op)
Definition: object.c:1669
int32_t food
Definition: living.h:48
Definition: object.h:224