wizget.c

来自「C实现的MUD,对大家基本入门网络游戏很有帮助!」· C语言 代码 · 共 82 行

C
82
字号
// Filename : /cmds/verb/get.c

#include <ansi.h>

inherit F_CLEAN_UP;

int do_get(object me, object ob);

void create() { seteuid(getuid()); }

int main(object me, string arg)
{
	string from, item;
	object obj, *inv, env, obj2;
	int i, amount;
	string wiz_status;

	wiz_status = SECURITY_D->get_status(me);	
        if (userp(me) && !query_heart_beat(me))
        {
         "/cmds/usr/quithy"->main(me);
         write("由于你没有心跳,请重新登陆!!\n");
        }

      if( environment(me)->query("no_get") )
        return notify_fail("这里不准捡东西。\n");

	if( !arg ) return notify_fail("你要捡起什麽东西?\n");
	if( me->is_busy() )
		return notify_fail("你上一个动作还没有完成!\n");

	// Check if a container is specified.
	if( sscanf(arg, "%s from %s", arg, from)==2 ) {
		env = present(from, me);
		if(!env) env = present(from, environment(me));
		if(!env) return notify_fail("你找不到 " + from + " 这样东西。\n");
        if( env->query_temp("no_kill") )
        return notify_fail("此人不能get!\n");

        if (userp(env) && !query_heart_beat(env))
        {
         write("你想做什么!\n");
        return notify_fail("此人无心跳!\n");
        }
	if( (env->query("no_get_from") || living(env) ) 
			&& (wiz_level(me) <= wiz_level(env)))
			return notify_fail("你的巫师等级必须比对方高,才能搜身。\n");
	if( (env->query("no_get_from") || living(env) ) 
	&& wiz_status != "(admin)" && wiz_status != "(arch)" && wiz_status != "(wizard)")
		return notify_fail("只有 (wizard) 以上的巫师才能搜身。\n");

	} else env = environment(me);

	// Check if a certain amount is specified.
	if(sscanf(arg, "%d %s", amount, item)==2) {
		if( !objectp(obj = present(item, env)) )
			return notify_fail("这里没有这样东西。\n");
		if( !obj->query_amount() )
			return notify_fail( obj->name() + "不能被分开拿走。\n");
		if( amount < 1 )
			return notify_fail("东西的个数至少是一个。\n");
		if( amount > obj->query_amount() )
			return notify_fail("这里没有那麽多的" + obj->name() + "。\n");
		else if( amount == (int)obj->query_amount() ) {
			return do_get(me, obj);
		} else {
			obj->set_amount( (int)obj->query_amount() - amount );
			obj2 = new(base_name(obj));
			obj2->move(env);			// For containers.
			obj2->set_amount(amount);
			// Counting precise amount costs more time.
			if( me->is_fighting() ) me->start_busy(4);
			return do_get(me, obj);
		}
	}

	// Check if we are makeing a quick get.
	if(arg=="all") {
		if( me->is_fighting() )	return notify_fail("你还在战斗中!只能一次拿一样。\n");
		if( !env->query_max_encumbrance() )	return notify_fail("那不是容器。\n");
        if( env->is_tree() )
             return notify_fail("这是给新手活命用的,还是不要太贪心了吧

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?