Crossfire Server, Branch 1.12
R12190
|
00001 /* 00002 CrossFire, A Multiplayer game for X-windows 00003 00004 Copyright (C) 2008 Crossfire Development Team 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 00020 The authors can be reached via e-mail at crossfire-devel@real-time.com 00021 */ 00022 00028 #include <global.h> 00029 #include <ob_methods.h> 00030 #include <ob_types.h> 00031 #include <sounds.h> 00032 #include <sproto.h> 00033 00034 static method_ret marker_type_process(ob_methods *context, object *op); 00035 static method_ret marker_type_trigger(ob_methods *context, object *op, object *cause, int state); 00036 00040 void init_type_marker(void) { 00041 register_process(MARKER, marker_type_process); 00042 register_trigger(TRIGGER_MARKER, marker_type_trigger); 00043 } 00044 00061 void move_marker(object *op) { 00062 object *tmp, *tmp2; 00063 00064 /* 00065 * markers not on a map for any reason should not crash server 00066 */ 00067 if (!op->map) { 00068 return; 00069 } 00070 00071 for (tmp = GET_MAP_OB(op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) { 00072 if (tmp->type == PLAYER) { /* we've got someone to MARK */ 00073 /* cycle through his inventory to look for the MARK we want to 00074 * place 00075 */ 00076 for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) { 00077 if (tmp2->type == FORCE && tmp2->slaying && !strcmp(tmp2->slaying, op->slaying)) 00078 break; 00079 } 00080 00081 /* if we didn't find our own MARK */ 00082 if (tmp2 == NULL) { 00083 object *force = create_archetype(FORCE_NAME); 00084 00085 force->speed = 0; 00086 if (op->stats.food) { 00087 force->speed = 0.01; 00088 force->speed_left = -op->stats.food; 00089 } 00090 update_ob_speed(force); 00091 /* put in the lock code */ 00092 force->slaying = add_string(op->slaying); 00093 00094 if (op->lore) 00095 force->lore = add_string(op->lore); 00096 00097 insert_ob_in_ob(force, tmp); 00098 if (op->msg) 00099 draw_ext_info(NDI_UNIQUE|NDI_NAVY, 0, tmp, MSG_TYPE_MISC, MSG_SUBTYPE_NONE, 00100 op->msg, op->msg); 00101 00102 if (op->stats.hp > 0) { 00103 op->stats.hp--; 00104 if (op->stats.hp == 0) { 00105 /* marker expires--granted mark number limit */ 00106 remove_ob(op); 00107 free_object(op); 00108 return; 00109 } 00110 } 00111 } /* if tmp2 == NULL */ 00112 } /* if tmp->type == PLAYER */ 00113 } /* For all objects on this space */ 00114 } 00115 00122 static method_ret marker_type_process(ob_methods *context, object *op) { 00123 move_marker(op); 00124 return METHOD_OK; 00125 } 00126 00135 static method_ret marker_type_trigger(ob_methods *context, object *op, object *cause, int state) { 00136 move_marker(op); 00137 return METHOD_OK; 00138 }