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

int amount; string item; object obj, obj2;

if (sscanf(arg, "%d %s", amount, item) == 2) { obj = present(item, me); if (!obj) { return notify_fail('你身上没有这样东西。\n'); } if (wiz_level(me) < 3 && obj->query('no_drop')) { return notify_fail(obj->name() + '不能被丢弃。\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 == obj->query_amount()) { return do_drop(me, obj); } else { obj->set_amount(obj->query_amount() - amount); obj2 = new(base_name(obj)); obj2->set_amount(amount); if (!do_drop(me, obj2)) { obj2->move(me); return 0; } return 1; } } else { obj = present(arg, me); if (!obj) { return notify_fail('你身上没有这样东西。\n'); } if (wiz_level(me) < 3 && obj->query('no_drop')) { return notify_fail(obj->name() + '不能被丢弃。\n'); } return do_drop(me, obj); }

MUD游戏代码优化:处理物品丢弃逻辑

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

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