From: refugee@seeker.hermesnet.net Here's a little something I'm using on my mud. Seems to work :) Thanks to all the boys and girls who release code, 'tis much appreciated. Should be pretty self explanatory. If you have trouble, I might help you out if I'm in a good mood. I ask 2 things if you decide to use this code: 1) some kind of credit in a helpfile somewhere 2) if you make any improvements, etc, send 'em along to me :) Here's a little additional info before you go to all the trouble of saving the attachment... get_mem_data() is designed to pull a specific memory from ch, namely, the memory referring to target. It is used by most of the other functions included. mob_remember() is used to set the memory of ch regarding target. Use in fight.c like: mob_remember(ch, victim, MEM_HOSTILE); ... to make 'ch' hostile to 'victim'. mem_fade() is basically a memory update function. I've arbitrarily chosen 4 mud-days as the amount of time it takes for a mob to forget a victim. (It turns out that players don't particularly care for mobs that remember them for a week of Real Time, tho' us imp types might find it hilarious ;) You'll probably get some errors if you haven't implemented that track code... I don't recall off-hand who did it, but whoever it was, thanx :) mob_forget() strips 'memory' from 'ch'. Prolly should use get_mem_data() to pick out which memory to strip... This code, or something similar, should be added to aggr_update() /* Trilby sez: ACK! He found me! */ if ( IS_NPC(ch) && can_see(ch, wch) ) { MEM_DATA *remember; if ( (remember = get_mem_data(ch, wch)) != NULL) { if ( IS_SET(remember->reaction, MEM_AFRAID) && IS_SET(ch->act, ACT_WIMPY) && ch->wait < PULSE_VIOLENCE / 2 && number_bits(2) == 1) do_flee(ch, "self"); if ( IS_SET(remember->reaction, MEM_HOSTILE) && ch->fighting == NULL ) multi_hit(ch, wch, TYPE_UNDEFINED); } } ----Trilby the Bad Cat---- RefugeeMUD refugee.hermesnet.net 9000 5123013011 -------------------------------------------------------------------- /* * ACT_MOB.C: Trilby@Refugee MUD * Copyright 1997, Lord Thomas Burbridge * * Mobile memory procedures. * * This work is a derivative of ROM2.4 * Copyright 1995, Russ Taylor. */ #include #include #include #include #include #include "merc.h" #include "tables.h" #include "recycle.h" MEM_DATA *get_mem_data(CHAR_DATA *ch, CHAR_DATA *target) { MEM_DATA *remember; if ( !IS_NPC(ch)) { bug( "get_mem_data: ch not NPC", 0); return NULL; } if ( ch == NULL ) { bug( "get_mem_data: NULL ch", 0 ); return NULL; } if ( target == NULL ) { bug( "get_mem_data: NULL target", 0 ); return NULL; } for ( remember = ch->memory ; remember != NULL ; remember = remember->next ) { if ( remember->id == target->id ) return remember; } return NULL; } void mob_remember(CHAR_DATA *ch, CHAR_DATA *target, int reaction) { MEM_DATA *remember; if ( !IS_NPC(ch) ) { bug( "mob_remember: ch not NPC", 0); return; } if ( ch == NULL ) { bug( "mob_remember: NULL ch", 0 ); return; } if ( target == NULL ) { bug( "mob_remember: NULL target", 0 ); return; } if ( (remember = get_mem_data(ch, target)) == NULL ) { remember = new_mem_data(); remember->next = ch->memory; ch->memory = remember; } remember->id = target->id; remember->when = current_time; SET_BIT( remember->reaction, reaction); return; } void mem_fade(CHAR_DATA *ch) /* called from char_update */ { MEM_DATA *remember, *remember_next; if ( ch == NULL ) { bug( "mem_fade: NULL ch", 0 ); return; } if ( !IS_NPC(ch)) { bug("mem_fade: ch not NPC", 0); return; } if ( ch->memory == NULL ) return; for ( remember = ch->memory ; remember != NULL ; remember = remember_next ) { remember_next = remember->next; if (IS_NPC(ch) && IS_SET(ch->off_flags, OFF_HUNT) && ch->hunting == NULL && IS_SET(remember->reaction, MEM_HOSTILE)) ch->hunting = get_char_id( remember->id ); if ( current_time - remember->when < (96 * 60) ) mob_forget( ch, remember ); } return; } void mob_forget( CHAR_DATA *ch, MEM_DATA *memory ) { if ( !IS_NPC(ch) ) { bug( "mob_forget: ch not NPC", 0); return; } if ( ch == NULL ) { bug( "mob_forget: NULL ch", 0); return; } if ( memory == NULL ) return; if ( memory == ch->memory ) { ch->memory = memory->next; } else { MEM_DATA *prev; for ( prev = ch->memory ; prev != NULL ; prev = prev->next ) { if ( prev->next == memory ) { prev->next = memory->next; break; } if ( prev == NULL ) { bug( "mob_forget: memory not found", 0); return; } } } free_mem_data(memory); return; }