Mud 版 (精华区)

发信人: jiayb (多情剑客痴情剑), 信区: Mud
标  题: MUD程式篇(六)
发信站: 哈工大紫丁香 (Wed Apr  1 17:58:29 1998), 转信

发信人: mice (风中的云), 信区: MUD
标  题: MUD程式篇(六)
发信站: 冰城驿站之BBS (Thu Feb 26 14:24:04 1998), 转信

   下面我以造一个保镖为例,介绍一些稍复杂的程序。
inherit NPC;
void create()
{
        set_name("金甲护卫",({"bodyguard","guard"}));
        set("long","金甲护卫身上发出金光,危然不可侵犯!\n");
        set("age",24);
        set("gender","雄性");
        set("combat_exp",100000);
        set("cor",30);
        set("cps",10);

        set("force",1000);
        set("max_force",1000);
        set("force_factor",20);
        set("score",100000);

        set_skill("force",100);
        set_skill("sword",100);
        set_skill("six-chaos-sword",100);
        set_skill("celestial",100);
set_skill("pyrobat-steps",100);

        map_skill("force","celestial"); //Equals enable force celecial
        map_skill("sword","six-chaos-sword");
        map_skill("parry","six-chaos-sword");
        map_skill("dodge","pyrobat-steps");
        set_skill("dodge",90);
        set_skill("parry",60);

        set_temp("apply/attack",160);
        set_temp("apply/dodge",100);
        set_temp("apply/armor",200);
        setup();
}
void init()
{

        ::init();
        //command("go south");
        set("chat_chance",10);
        add_action("kill_it","killit");
        message_vision(__PORT__ ,this_player());
        if(is_fighting()) message_vision("Hello!\n",this_player());
        set("chat_msg",({"我是Self的卫士!\n"}));

}

int kill_it(string arg)
{
        object envi;
        object dest;
        envi=environment(this_player());
        dest=present(arg,envi);
       kill_ob(dest);
}

        关于bg.c的一些说明:
1、 在建一个简单的room时,为节约内存,在setup();之后,我们都加了如下函数:replace_program(ROOM);  ,但如程序有init(); 等函数,则应将此句去掉。
2、 init() 函数在人物进入到此房间时触发,并直到离开时结束,此函数也可用于NPC。
当你见到这个NPC时,此函数被触发。
3、 add_action(string arg1,string arg2) ,其中,arg1为你定义的函数名,arg2为你在此处给player增加的指令。可以用localcmds查出。


--
※ 修改:.yangx 于 Apr  1 17:41:33 修改本文.[FROM: 202.97.228.245]
※ 来源:.冰城驿站之BBS bbs.hr.hl.cn.[FROM: 202.118.226.90]

--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: yangx.bbs@bbs.hr.hl.]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:8.853毫秒