/*Ok. This is a snippet written by Davion. It allows for interesting stuff! *It basicly allows the ability to add a new command, and have it trigged *Through progs. Its pretty simple right now. However if you people add to *Your progs enough, you will have a most amazing feature to softcode commands. *First off, this snippet is made with the idea that one has Oprogs and Rprogs *already added to the mud. So if ya don't got them, you could prolly convert *this snippet easily. And make sure to add the prototypes! */ /* * Now, add to the tables in tables.c, oprog_flags, and rprogs_flags. */ { "alias", TRIG_ALIAS, TRUE }, /* Add a new trigger in merc.h (Or other main header)*/ #define TRIG_ALIAS () /* Add this code to interp.c, in void interpret right before it parse's through the cmd_table to find the command you provided. */ /* * Look for command in command table. */ if(HAS_TRIGGER_ROOM(ch->in_room,TRIG_ALIAS ) ) { if( p_alias_trigger(ch, command, NULL, PRG_RPROG, argument) ) return; } for( pObj = ch->in_room->contents ; pObj ; pObj = pObj->next_content ) { if(HAS_TRIGGER_OBJ(pObj, TRIG_ALIAS ) ) if( p_alias_trigger(ch, command, pObj, PRG_OPROG, argument ) ) return; } for ( pObj = ch->carrying; pObj; pObj = pObj->next_content ) { if(HAS_TRIGGER_OBJ(pObj, TRIG_ALIAS ) ) if( p_alias_trigger(ch, command, pObj, PRG_OPROG, argument ) ) return; } /* Now add this to the bottom of your mob_prog.c file */ bool p_alias_trigger( CHAR_DATA *ch, char *cmd, OBJ_DATA *pObj, int type, char *argument) { PROG_LIST *prg; ROOM_INDEX_DATA *pRoom; char arg[MSL], trig[MSL], *phrase, arg2[MSL]; CHAR_DATA *vch; OBJ_DATA *obj; arg[0] = '\0'; arg2[0] = arg[0]; trig[0] = arg[0]; pRoom = ch->in_room; if( cmd[0] == '\0' ) return FALSE; if(type == PRG_OPROG && !pObj ) { logf2("BUG: p_alias_trigger- type == oprog|pObj == NULL" ); return FALSE; } if(type == PRG_RPROG ) { for ( prg = pRoom->rprogs ; prg ; prg = prg->next ) { phrase = prg->trig_phrase; phrase = one_argument(phrase, trig); phrase = one_argument(phrase, arg ); if( !str_cmp( cmd, trig ) ) { if( !str_cmp( arg, "char" ) ) { if( ( vch = get_char_room(ch, NULL, argument ) ) == NULL ) { send_to_char("They aren't here.\n\r",ch); return TRUE; } else { program_flow( prg->vnum, prg->code, NULL, NULL, pRoom, ch, NULL, vch ); return TRUE; } } else if( !str_cmp(arg, "obj" ) ) { if( ( obj = get_obj_list( ch, argument, pRoom->contents ) ) == NULL ) { send_to_char("You can't find that anywhere!\n\r",ch); return TRUE; } else { program_flow( prg->vnum, prg->code, NULL, NULL, pRoom, ch, obj, NULL ); return TRUE; } } else { program_flow( prg->vnum, prg->code, NULL, NULL, pRoom, ch, NULL, NULL ); return TRUE; } } } } else if( type == PRG_OPROG) { for( prg = pObj->pIndexData->oprogs ; prg; prg = prg->next ) { phrase = prg->trig_phrase; phrase = one_argument(phrase, trig); phrase = one_argument(phrase, arg ); if( !str_cmp( cmd, trig ) ) { if( !str_cmp( arg, "char" ) ) { if( ( vch = get_char_room(ch, NULL, argument ) ) == NULL ) { send_to_char("They aren't here.\n\r",ch); return TRUE; } else { program_flow( prg->vnum, prg->code, NULL, pObj, NULL, ch, NULL, vch ); return TRUE; } } else if( !str_cmp(arg, "obj" ) ) { if( ( obj = get_obj_list( ch, argument, pRoom->contents ) ) == NULL ) { send_to_char("You can't find that anywhere!\n\r",ch); return TRUE; } else { program_flow( prg->vnum, prg->code, NULL, pObj,NULL, ch, obj, NULL ); return TRUE; } } else { program_flow( prg->vnum, prg->code, NULL, pObj, NULL, ch, NULL, NULL ); return TRUE; } } } } return FALSE; } /*That should be all you need! Have fun with it. *Any comments/questions send an e-mail to davionkalhen@gmail.com *I'll try to respond as soon as possible! *Davion*/