用far语言写的mud框架

自动移动


inherit "obj/biota.c"


//执行
void heartbeat(){

    scan();

}


 void scan(){
    chat();
 }


//随机走动
int randomMove(){

    map exits;
	string *dirs;

    if (! mapp(exits = environment(this).query("exits")) ) return 0;
    dirs = keys(exits);

	if ( sizeof(dirs)<=0 ) return 0;

    command(this,"go " + dirs[random(0,sizeof(dirs))]);

}

 int chat(){

    var chatMsgs = query("chatMsg");
    if( random( 0,120 ) < query("chatChance")) {
         foreach( cmsg in chatMsgs ){
               if( mapp(cmsg) ){
                   cmsg["fn"]();
               }
         }
    }

 }
posted @ 2025-01-03 08:56  方东信  阅读(37)  评论(0)    收藏  举报