Beispiel #1
0
string query_idle_string(object ob)
{
    int days,hours,minutes,seconds;
    int idle;
    string str;

   if(ob->query_noidle()) return "-BLOCK-";
    str = "";

    if(!(idle = query_idle(ob)))
        return "0s";

    days = idle / 86400;
    idle = idle % 86400;

    hours = idle / 3600;
    idle = idle % 3600;

    minutes = idle / 60;
    seconds = idle % 60;

    if(days) str += days+"d ";
    if(hours) str += hours+"h ";
    if(minutes) str += minutes+"m ";
    if(seconds) str += seconds+"s";

    return str;
}
Beispiel #2
0
Datei: who.c Projekt: rmanis/lil
int main(string arg) {
    object user;

    printf("%-25s  idle\n", "name (*edit, +input)");
    printf("---------------------     -----\n");
    foreach (user in users()) {
        printf("%-25s %4dm\n", (string)user->query_name() +
                (in_edit(user) ? "*" : "") +
                (in_input(user) ? "+" : ""),
                query_idle(user) / 60
        );
    }
Beispiel #3
0
int cmd_mudstate() {
   int i;
   object *u;
   string out;
   i=sizeof(u=users());
   write("Lvl "+alig_str("Player", 15)+alig_str("Vitals", 15));
   while(i--) {
     out = ""+alig_str(u[i]->query_level()+"", 3)+""+alig_str(u[i]->query_name(), 13);
     out += alig_str("hp:"+u[i]->query_hp()+"/"+u[i]->query_max_hp(), 16)+
       alig_str("sp:"+u[i]->query_sp()+"/"+u[i]->query_max_sp(), 20);
     out += (u[i]->query_current_attacker()?"%^BOLD%^%^RED%^in battle%^RESET%^ ":"")+
       (query_idle(u[i]) > 1800?"idle":"");
     write(out);
   }
   return 1;
}
Beispiel #4
0
int main(string arg)
{
    object *list;
    int j;

    printf("%-25s idle\n", "name (*edit, +input)");
    printf("--------------------      ----\n");
    for (list = users(), j = 0; j < sizeof(list); j++) {
        printf("%-25s %4d\n", (string)list[j]->query_name() +
                (in_edit(this_player()) ? "*" : "") +
                (in_input(this_player()) ? "+" : ""),
                query_idle(this_player()) / 60
              );
    }
    return 1;
}
Beispiel #5
0
int main(object me, string arg)
{
	string target, mud;
	object obj;
        string no_tell, can_tell;
        string reply_out;

	if (! arg || arg == "")
		return notify_fail("你要回答什么?\n");

	if (! stringp(target = me->query_temp("reply")) )
		return notify_fail("刚才没有人和你说过话。\n");

	if (sscanf(target, "%s@%s", target, mud) == 2)
	{
		GTELL->send_gtell(lower_case(mud), lower_case(target), me, arg);
		write("网路讯息已送出,可能要稍候才能得到回应。\n");
		return 1;
	}

	obj = find_player(target);
	if (! obj || ! me->visible(obj))
	{
		if (MESSAGE_D->send_msg_to(me, target, arg))
			return 1;
		return notify_fail("刚才和你说话的人现在已经离开游戏了。\n");
	}

        no_tell = obj->query("env/no_tell");
	if (! wizardp(me) && (no_tell == "all" || no_tell == "ALL" ||
	    is_sub(me->query("id"), no_tell)))
        {
                can_tell = obj->query("env/can_tell");
                if (! is_sub(me->query("id"), can_tell))
		        return notify_fail("这个人不想听你罗嗦啦。\n");
        }

	if (playerp(obj) && obj->is_net_dead())
		return notify_fail("这个人现在不在线上,听不到你的话。\n");

	if (! living(obj))
		return notify_fail("这人现在恐怕听不到你说的话了...\n");

	reply_out = sprintf(HIG "%s回答你:%s\n" NOR,
                            me->name(1) + HIG "(" + me->query("id") + ")", arg);
        if (! TELL_CMD->notice_user(me->name(1), me->query("id"), obj, reply_out))
                return 1;

        // 成功的回答了
	write(HIG "你回答" + obj->name(1) + HIG + "(" + obj->query("id") +
              "):" + arg + "\n" NOR);

        if (query_idle(obj) >= 120)
                write(YEL "可是" + obj->name(1) +
                      YEL "已经在猪圈中发呆有" + chinese_number(query_idle(obj) / 60) +
                      "分钟了,恐怕没法听到你的话。\n");

        // 如果选择的不是全阻塞(2),则自动忽略这条信息,显示
        // 下一条信息。
        if (me->query("env/jam_talk") != 2)
                SKIP_CMD->main(me, "");

	return 1;
}
Beispiel #6
0
void heart_beat()
{
	int wimpy_ratio, cnd_flag;
	mapping my;
	object ob;

	my = query_entire_dbase();

	// If we are dying because of mortal wounds?
	if( my["eff_kee"] < 0 || my["eff_sen"] < 0 || my["eff_gin"] < 0) {
		remove_all_enemy();
		die();
		return;
	}

	// If we're dying or falling unconcious?
	if( my["kee"] < 0 || my["sen"] < 0 || my["gin"] < 0) {
		remove_all_enemy();
		if( !living(this_object()) ) die();
		else unconcious();
		return;
	}

	// Do attack if we are fighting.
	if( is_busy() ) {
		continue_action();
		// We don't want heart beat be halt eventually, so return here.
		return;
	} else {
		// Is it time to flee?
		if( is_fighting()
		&&	intp(wimpy_ratio = (int)query("env/wimpy"))
		&&	wimpy_ratio > 0
		&&	(	my["kee"] * 100 / my["max_kee"] <= wimpy_ratio
			||	my["sen"] * 100 / my["max_sen"] <= wimpy_ratio
			||	my["gin"] * 100 / my["max_gin"] <= wimpy_ratio) )
			GO_CMD->do_flee(this_object());
		// Do attack or clean up enemy if we have fleed.
		attack();
	}

	if( !userp(this_object()) ) {
		this_object()->chat();
		// chat() may do anything -- include destruct(this_object())
		if( !this_object() ) return;	
	}

	if( tick--  ) return;
	else tick = 5 + random(10);

	cnd_flag = update_condition();

	// If we are compeletely in peace, turn off heart beat.
	// heal_up() must be called prior to other two to make sure it is called
	// because the && operator is lazy :P
	if( ((cnd_flag & CND_NO_HEAL_UP) || !heal_up())
	&&	!is_fighting() 
	&&	!interactive(this_object())) {
		if( environment() ) {
			ob = first_inventory(environment());
			while(ob && !interactive(ob))
				ob = next_inventory(ob);
		}
		if( !ob ) set_heart_beat(0);
	}

	if( !interactive(this_object()) ) return;

	// Make us a bit older. Only player's update_age is defined.
	// Note: update_age() is no need to be called every heart_beat, it
	//       remember how much time has passed since last call.
	this_object()->update_age();

	if(query_idle(this_object()) > IDLE_TIMEOUT)
		this_object()->user_dump(DUMP_IDLE);
}
Beispiel #7
0
int main(object me, string arg)
{
	string target, msg, mud;
        string my_id;
	object obj;
        string no_tell, can_tell;
        string tell_out;

	if (! arg || sscanf(arg, "%s %s", target, msg) != 2)
                return help(me);

	if (sscanf(target, "%s@%s", target, mud) == 2)
	{
		if (GTELL->send_gtell(mud, target, me, msg))
		{
			write("网路讯息已送出,可能要稍候才能得到回应。\n");
			return 1;
		}
	}

	obj = find_player(target);
	if (! obj || ! me->visible(obj))
	{
		if (MESSAGE_D->send_msg_to(me, target, msg))
			return 1;
		return notify_fail("这个用户没有登录,你无法和他交谈。\n");
	}

        my_id = me->query("id");
        no_tell = obj->query("env/no_tell");
	if (! wizardp(me) && (no_tell == "all" || no_tell == "ALL" ||
	    is_sub(my_id, no_tell)))
        {
                can_tell = obj->query("env/can_tell");
                if (! is_sub(my_id, can_tell))
		        return notify_fail("这个人不想听你罗嗦啦。\n");
        }

	if (! interactive(obj) || obj->is_net_dead())
		return notify_fail("此人现在不在线上,听不到你的话。\n");

	if (! living(obj))
		return notify_fail("这人现在恐怕听不到你说的话了...\n");

        if (me->ban_say(1))
                return 0;

        if (obj == me)
        {
                message_vision("$N喃喃自语。\n", me);
                return 1;
        }

        tell_out = sprintf(HIG "%s告诉你:%s\n" NOR,
		           me->name(1) + HIG + "(" +
                           capitalize(my_id) + ")", msg);

        if (! notice_user(me->name(1), my_id, obj, tell_out))
                return 1;

	write(sprintf(HIG "你告诉%s(%s):%s\n" NOR,
                      obj->name(1) + HIG,
                      capitalize(obj->query("id")), msg));

        if (query_idle(obj) >= 120)
                write(YEL "可是" + obj->name(1) +
                      YEL "已经在猪圈中发呆有" + chinese_number(query_idle(obj) / 60) +
                      "分钟了,恐怕没法立刻回答你。\n");

	return 1;
}
Beispiel #8
0
void second( object *user , string str )
{
	int     i, count, state;
	string  list, CO, state_str, list2;
	user = sort_array(user, "sort_rank", this_object());
        i = sizeof(user);
        list = sprintf( HIG"《"HIY"%|10s"HIG"》"HIC" 线上帮众 "NOR"-\n", str );
	list+= "───────────────────────────────────────\n";
	count = 0;

        while( i-- )
        {
                switch(user[i]->query("clan/rank")) {
	case 1  :       CO = HIW + "Ψ";        break;
	case 2  :       CO = HIC + "ζ";        break;
        case 3  :       CO = HIY + "Φ";        break;
        case 4  :       CO = HIG + "卍";        break;
        case 5  :       CO = HIM + "Ξ";        break;
        case 6  :       CO = HIB + "∏";        break;
        case 7  :       CO = HIR + "Χ";        break;
		default :       CO = NOR + "?";        break;
		}

        if(this_player())
        if( wizardp(user[i]) && !wizardp(this_player()))
			continue;
		if( wiz_level(this_player())<6 && user[i]->query("env/隐身") && wiz_level(user[i]) && wiz_level(user[i]) > wiz_level(this_player()) )
		{
		 continue;
		}
		state = 0;
		state_str = "";
		count++;

                list = sprintf( "%s"HIC"【"NOR"%|10s"HIC"】"NOR"%s%|10s%s"NOR"",
			list,
                        area(user[i]),
                        CO,
                        (user[i]->query("clan/title") ? user[i]->query("clan/title") : "--无职衔--"), CO );
/*
		list2 = (user[i]->query("title") ? user[i]->query("title") : "" ) +
                        (user[i]->query("nickname") ? "「"+user[i]->query("nickname")+"”" : " " ) +
                        user[i]->query("name")+"("+user[i]->query("id")+")";
                if( strlen((list2))>80 )*/
                	list2 = (user[i]->query("nickname") ? "「"+user[i]->query("nickname")+"”" : " " ) +
                        	user[i]->query("name")+"("+user[i]->query("id")+")";
                list += list2;

		if( user[i]->query_temp("netdead") ) {
			state_str += HIR"(断线)"NOR;
			state = 1;
		}
		if( !environment(user[i]) ) {
			state_str += HIG"(异次元)"NOR;
			state = 1;
		}
		if( in_edit(user[i]) ) {
			state_str += HIY"(编辑)"NOR;
			state = 1;
		}
		if( in_input(user[i]) ) {
			state_str += HIC"(阅\读)"NOR;
			state = 1;
		}
		if( interactive(user[i]) && query_idle(user[i])>120 ) {
                	state_str += sprintf( "%s", HIM"(发呆 "+query_idle(user[i])/60+" 分钟)"NOR );
                	state = 1;
                }
                if( state ) list = list + /*"\t\t\t   " +*/ state_str;
                list += "\n";
        }

	list +=	"───────────────────────────────────────\n";
	list += sprintf( " 目前线上共有 %d 位帮众, 系统负担: %s\n\n", count, query_load_average() );

        this_player()->start_more(list);
}
Beispiel #9
0
void do_tests() {
    if (this_player())
	ASSERT(intp(query_idle(this_player())));
}
Beispiel #10
0
void heart_beat()
{
        int t;
        int period;
        int wimpy_ratio, cnd_flag;
        mapping my;
        object ob;
	object me;
	string prompt;
	int is_player;

	me = this_object();
        my = query_entire_dbase();

        if (userp(me) && living(me) && mapp(my["env"]))
        {
                // update prompt
		prompt = my["env"]["prompt"];
                if ((prompt == "time" || prompt == "mud" || prompt == "hp") &&
		    is_waiting_command() && ! me->is_attach_system())
                    
                {
                        write_prompt();
                }
                
        }

        // If we're dying or falling unconcious?
        if (my["qi"] < 0 || my["jing"] < 0)
        {
                if (! living(me)) die();
                else unconcious();

                // Why does the living test? Because
                // The wizard may set immortal but his
                // qi was -1, so I don't want return,
                // or the continue_action will never be
                // called in such case.
                if (! me || ! living(me))
                        return;
        }

        if (is_p_busy())
        {
                continue_p_busy();
        }
        
        // Do attack if we are fighting.
        if (is_busy())
        {
                continue_action();
                // We don't want heart beat be halt eventually, so return here.
        } else
	if (living(me))
        {
                string apply;
                object apply_ob;

                // Is it time to flee?
                if (is_fighting() &&
                   intp(wimpy_ratio = (int)query("env/wimpy")) &&
                   wimpy_ratio > 0 &&
                   (my["qi"] * 100 / my["max_qi"] <= wimpy_ratio ||
                    my["jing"] * 100 / my["max_jing"] <= wimpy_ratio))
                {
                        if (stringp(apply = query("env/wimpy_apply")) &&
                            objectp(apply_ob = present(apply, me)) &&
                            apply_ob->query("can_apply_for_wimpy"))
                        {
                                apply_ob->apply_for_wimpy(this_object());
                        } else
                                GO_CMD->do_flee(this_object());
                }
                
                if (query("auto_perform") || me->query_auto_perform())
                {                       
                        if (my["eff_jing"] > 0 && my["jing"] * 100 / my["eff_jing"] <= 70)
                                SKILL_D("force/regenerate")->exert(me, me);
                        if (my["eff_qi"] > 0 && my["qi"] * 100 / my["eff_qi"] <= 70)
                                SKILL_D("force/recover")->exert(me, me);

                        // 如果不在打架而且处于受伤状态,则自行疗伤
                        if (! is_fighting())
                        {
                                if (my["eff_jing"] < my["max_jing"])
                                        SKILL_D("force/inspire")->exert(me, me);
                                if (my["eff_qi"] < my["max_qi"])
                                        SKILL_D("force/heal")->exert(me, me);
                        }
                }
                // Do attack or clean up enemy if we have fleed.
                if (is_busy())
                        continue_action();
                else
                        attack();
        }

        if (my["doing"] == "scheme")
                // executing schedule now
                SCHEME_CMD->execute_schedule(me);

        if (! me) return;

        if (! (is_player = playerp(me)))
        {
                me->scan();
                // scan() may do anything -- include destruct(this_object())
                if (! me) return;
        }

        if ((t = time()) < next_beat) return;
        else next_beat = t + 5 + random(10);

	if (! my["not_living"])
        	cnd_flag = update_condition();
	if (! me) return;

	if (! (cnd_flag & CND_NO_HEAL_UP))
		cnd_flag = heal_up();

        // If we are compeletely in peace, turn off heart beat.
        // heal_up() must be called prior to other two to make sure it is called
        // because the && operator is lazy :P
        if (! cnd_flag &&
	    ! is_player &&
            ! keep_beat_flag &&
            ! is_fighting() &&
	    ! is_busy() &&
            ! interactive(this_object()))
        {
                if (environment() && query("chat_msg"))
                {
                        ob = first_inventory(environment());
                        while (ob && ! interactive(ob))
                                ob = next_inventory(ob);
                } else
                        ob = 0;
                if (! ob) set_heart_beat(0);
        }

        update_all_limb_damage();
        
        if (! me || ! is_player) return;

        // Make us a bit older. Only player's update_age is defined.
        // Note: update_age() is no need to be called every heart_beat, it
        //       remember how much time has passed since last call.
        me->update_age();

#ifdef AUTO_SAVE
        if (living(me))
        {
            	period = t - ((int) my["last_save"]);
                if (period < 0 || period > 15 * 60)
            	{
                	string msg;
                        msg = HBCYN HIW "【档案存储】您的档案已经自动存盘,"
                              "欢迎访问论坛 http://bbs.mudbuilder.com/ 。\n" NOR;
                	if (! me->save())
                    	msg = HIR "【数据保护】由于数据异常,您的档"
                              "案本次存盘失败。\n" NOR;
                	set("last_save", t);
                	tell_object(me, msg);
            }
        }
#endif
	if (! interactive(me))
		return;

        if (my["food"] <= 0 || my["water"] <= 0)
        {
		if (environment() &&
		    ! environment()->is_chat_room() &&
                    ! wizardp(me) &&
                    ! query_condition("hunger"))
		{
			// born & enter the world
                        apply_condition("hunger", 1);
		}
        }

        if (query_idle(me) > IDLE_TIMEOUT && ! wizardp(me) &&
            (! mapp(my["env"]) || ! my["env"]["keep_idle"]))
                me->user_dump(DUMP_IDLE);
}