*point = '\0';one line before
buf[0] = UPPER(buf[0]);Without this, stuff left in the player's buffer can fire mobprogs. This is particularly bad when a player enters the game and gets greet_proc over and over again.
Under Envy 1.0, I put this code into aggr_update(), after the descriptor loop was done. This goes through all of the characters looking for MOBprograms. I believe the 'optimization' not to do the actions when no players were in the zone was the cause of people's 'memory leaks', the line '(wch->in_room->area->nplayer > 0)' in the if(). See, if "the kobold leaves north" every minute that is 25 bytes * 60min/hour or 1.5k per hour times say 10 mobiles times 100 mobprogrammed mobiles in zones without players is 1.5megs/hour of leaks. All of these mobprograms are going to fire, too, the first time a player enters the zone, which is probably not what was intended.
// Now respond to MOBprograms--Slash for ( ch = char_list; ch != NULL; ch = wch_next ) { wch_next = ch->next; /* MOBProgram ACT_PROG trigger */ if ( IS_NPC( ch ) && ch->mpactnum > 0) // Merc 2.2 only freed this memory when a player was in the zone, I see // no reason to wait for that to happen--Slash // && wch->in_room->area->nplayer > 0 ) { // Examine everything the mobile heard since the last aggr_update(), and // respond to it MPROG_ACT_LIST * tmp_act, *tmp2_act; for ( tmp_act = ch->mpact; tmp_act != NULL; tmp_act = tmp_act->next ) { mprog_wordlist_check( tmp_act->buf, ch, tmp_act->ch, tmp_act->obj, tmp_act->vo, ACT_PROG ); free_string( tmp_act->buf ); } // Free the memory allocated to the 'act() memory' for ( tmp_act = ch->mpact; tmp_act != NULL; tmp_act = tmp2_act ) { tmp2_act = tmp_act->next; free_mem( tmp_act, sizeof( MPROG_ACT_LIST ) ); } // Zap the pointer to the memory ch->mpactnum = 0; ch->mpact = NULL; } }
if ( ( to->deleted ) || ( !to->desc && IS_NPC( to ) ) || !IS_AWAKE( to ) ) continue;the purpose of this is to not send act() messages to not send act() messages to deleted characters, sleepers, or mobiles with no one switched into them. But mobiles with ACT_PROG triggers still need to see the actions, so make the second line:
|| ( !to->desc && IS_NPC( to ) && !(to->pIndexData->progtypes & ACT_PROG ) )
void mprog_speech_trigger( char *txt, CHAR_DATA *mob ) { static depth = 0; if (depth++ < 3) old_speech_trigger(txt, mob); depth--; }(You can change the max depth (3) to anything you want. I believe 3 is what I used (this is one of the pieces of code I lost.) The idea is to allow a mobile to speak, another mobile to respond, and then the first to say the final thing, allow mini conversations.)
if ( ch->position == POS_FIGHTING ) { bug( "MpKill - Already fighting from vnum %d", ch->pIndexData->vnum ); return; }This is a bad thing if you use the 'mpkill' command in your scripts. For example, if the executioner is fighting someone and and an evil character says 'looking at?' using the stock Merc 2.2 MOBprogs then bug() will be called.
void check_arrival(CHAR_DATA *ch, bool f) { if ( (f || !IS_AFFECTED(ch, AFF_SNEAK)) && ( IS_NPC(ch) || !IS_SET(ch->act, PLR_WIZINVIS) ) ) { mprog_entry_trigger(ch); mprog_greet_trigger(ch); } }The boolean is used for controlling the SNEAK skill. If a player has sneak he avoids the mprog_entry and greet triggers walking, but not necessarily when being summoned or teleporting. It is up to the imp to call this with or without the ability to sneak past mobiles after calls to char_to_room().