#include <config.h>

inherit F_CLEAN_UP;

int do_drop(object me, object obj, int raw);

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

int main(object me, string arg) { object obj, *inv, obj2; int i, amount; mixed info; string item;

if (!arg) return notify_fail("你要丢下什么东西?\n");

if (sscanf(arg, "%d %s", amount, item) != 2) // 判断 sscanf 函数返回值是否正确
{
	item = arg;
	amount = 1;
}

if (!objectp(obj = present(item, me)))
	return notify_fail("你身上没有这样东西。\n");

if (amount <= 0) // 修改提示信息
	return notify_fail("数量不能为零。\n");

if (wiz_level(me) < 3 && (info = obj->query("no_drop")))
{
	tell_object(me, stringp(info) ? info : obj->name() + "不能被丢弃。\n");
	return 1;
}

if (!obj->query_amount())
	return notify_fail(obj->name() + "不能被分开丢弃。\n");

if (amount > obj->query_amount())
	return notify_fail("你没有那么多的" + obj->name() + "。\n");

if (amount == obj->query_amount())
{
	if (!do_drop(me, obj, 0)) // 修改提示信息
	{
		obj->move(environment(me));
		return 0;
	}

	if (!raw) {
		tell_object(me, "你丢下了" + obj->short() + "。\n");
		message("vision", me->name() + "丢下了一" + obj->query("unit") + obj->name() + "。\n", environment(me), ({ me }));
	}
	return 1;
}
else
{
	obj->set_amount(obj->query_amount() - amount);
	obj2 = new(base_name(obj));
	obj2->set_amount(amount);
	if (!do_drop(me, obj2, 0))
	{
		obj2->move(environment(me));
		return 0;
	}

	if (!raw) {
		tell_object(me, "你丢下了" + obj2->short() + "。\n");
		message("vision", me->name() + "丢下了一" + obj2->query("unit") + obj2->name() + "。\n", environment(me), ({ me }));
	}
	return 1;
}

return 0;

}

int do_drop(object me, object obj, int raw) { mixed no_drop; object riding;

if (obj == (riding = me->query_temp("is_riding")))
{
	message_vision("$N从$n背上飞身跳下。\n", me, riding);
	me->delete_temp("is_riding");
	obj->delete_temp("is_rided_by");
	obj->move(environment(me));
	return 1;
}

if (!clonep(obj)) // 修改提示信息
{
	write(obj->query("name") + "化作一道流光消失了!!\n");
	destruct(obj);
	return 1;
}

if (wiz_level(me) < 3 && obj->query("no_drop"))
	return notify_fail(obj->name() + "不能被丢弃。\n");

if (no_drop = environment(me)->query("no_drop"))
	return notify_fail(stringp(no_drop) ? no_drop : "这里东西丢弃下去也看不见。\n");

if (!wizardp(me)) {
	switch ((string)obj->query("equipped"))
	{
		case "worn":
			tell_object(me, obj->name() + "必须脱下来才能丢掉。\n");
			return 0;

		case "wielded":
			tell_object(me, obj->name() + "必须解除装备才能丢掉。\n");
			return 0;
	}

	if (!obj->is_character() && !obj->can_combine_to(environment(me)) && sizeof(filter_array(all_inventory(environment(me)), (: ! $1->is_character() :))) >= MAX_ITEM_IN_ROOM) // 修改提示信息
	{
		tell_object(me, "这里东西太多了,你乱丢恐怕" + obj->name() + "就找不到了。\n");
		return 0;
	}
}

if (wiz_level(me) < 3 && obj->query("no_drop"))
{
	tell_object(me, "这样东西不能随便丢弃。\n");
	return 0;
}

if (obj->move(environment(me)))
{
	if (obj->is_character() && obj->query_weight() > 20000)
		message_vision("$N将$n从背上放了下来,躺在地上。\n", me, obj);
	else {
		if (!raw)
			message_vision(sprintf(NOR"$N丢下%s%s$n。"NOR"\n", 
							 obj->query_amount() ? CHINESE_D->chinese_number(obj->query_amount()) : "一",
							 obj->query_amount() ? obj->query("base_unit") : obj->query("unit")), me, obj);
		else
			write(NOR"你丢下了"+(obj->query_amount()?CHINESE_D->chinese_number(obj->query_amount()):"一" )+
				NOR+ (obj->query_amount()?obj->query("base_unit"):obj->query("unit"))+NOR +  obj->name() + "\n");

		if (!obj->is_character() && !obj->query("value") && !obj->value())
		{
			write(obj->query("name") + "掉地上消失了。\n"); // 修改提示信息
			destruct(obj);
		}
	}
	return 1;
}

return 0;

}

int help(object me) { write(@HELP 指令格式: drop <物品名称> | all

这个指令可以让你丢下你所携带的物品。

丢弃所有物品的格式为:drop all。

HELP); return 1;

MUD游戏物品丢弃功能优化:检测Bug与完善逻辑

原文地址: https://www.cveoy.top/t/topic/m5V8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录