Crossfire Server, Trunk  R20513
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
Messages that don&#39;t go elsewhere.
Definition: newclient.h:389
Sound-related defines.
Typedefs for ob_methods.
Definition: ob_methods.h:45
const char * slaying
Which race to do double damage to.
Definition: object.h:319
struct obj * above
Pointer to the object stacked above this one.
Definition: object.h:288
object * object_find_by_type_and_slaying(const object *who, int type, const char *slaying)
Find object in inventory by type and slaying.
Definition: object.c:4049
Global type definitions and header inclusions.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
Definition: main.c:310
int16_t hp
Hit Points.
Definition: living.h:39
#define NDI_NAVY
Definition: newclient.h:223
static void move_marker(object *op)
Move function for marker objects.
Definition: marker.c:61
char method_ret
Define some standard return values for callbacks which don&#39;t need to return any other results...
Definition: ob_methods.h:14
const char * lore
Obscure information about this object, to get put into books and the like.
Definition: object.h:323
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
Definition: object.c:1368
int16_t y
Position in the map for this object.
Definition: object.h:326
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
Definition: arch.c:620
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
Definition: object.c:2690
float speed_left
How much speed is left to spend this round.
Definition: object.h:329
inserts an invisible, weightless force into a player with a specified string.
Definition: object.h:158
#define METHOD_OK
Definition: ob_methods.h:15
inserts an invisible, weightless force into a player with a specified string WHEN TRIGGERED...
Definition: object.h:153
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
float speed
The overall speed of this object.
Definition: object.h:328
void register_trigger(int ob_type, trigger_func method)
Registers the trigger method for the given type.
Definition: ob_types.c:98
int16_t x
Definition: object.h:326
Object type variables.
See Player.
Definition: object.h:107
void init_type_marker(void)
Initializer for the marker object type.
Definition: marker.c:40
living stats
Str, Con, Dex, etc.
Definition: object.h:368
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:338
const char * msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:322
void register_process(int ob_type, process_func method)
Registers the process method for the given type.
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)
A marker is triggered.
Definition: marker.c:131
sstring add_string(const char *str)
This will add &#39;str&#39; to the hash table.
Definition: shstr.c:124
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
Definition: map.h:172
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:245
#define MSG_SUBTYPE_NONE
Definition: newclient.h:398
static method_ret marker_type_process(ob_methods *context, object *op)
Processes a marker.
Definition: marker.c:118
Object type functions and variables.
void object_update_speed(object *op)
Updates the speed of an object.
Definition: object.c:1129
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.c:1654
int32_t food
How much food in stomach.
Definition: living.h:47
Definition: object.h:224