00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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) {
00073
00074
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
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
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
00106 remove_ob(op);
00107 free_object(op);
00108 return;
00109 }
00110 }
00111 }
00112 }
00113 }
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 }