init: add workspace files

This commit is contained in:
2026-05-26 16:41:20 +08:00
commit f4f2393f72
1041 changed files with 67405 additions and 0 deletions

80
world/cmd/obj/buy.js Normal file
View File

@@ -0,0 +1,80 @@
this.inherits(COMMAND);
this.command = "buy";
this.regex = /^(?:(\d+)\s)?(\w+)(?:\s+from\s+(.+?))?$/;
this.enter = function (me, count, objid, from) {
var target;
if (from) {
target = me.find_obj(from, me.environment);
if (!target) {
return me.notify("你要从哪买东西?");
}
if (target == me) {
return me.notify("你自己的东西还用得着买吗?");
}
}
var buy_count = 1;
if (count) buy_count = parseInt(count);
if (!(buy_count > 0)) return;
if (!target) return;
var selllist = target.sell_list;
if (target.on_sell) {
selllist = target.on_sell(me, buy_count, objid);
}
if (selllist === true) return;
if (!selllist) {
return me.notify(target.name + "不出售任何东西。");
}
var sellitem = null;
for (var i = 0; i < selllist.length; i++) {
if (selllist[i].id == objid) {
sellitem = selllist[i];
break;
}
}
if (!sellitem) return me.notify(target.name + "不出售这个东西。");
if (!sellitem.combined && buy_count > 1) {
buy_count = 1;
me.notify("<cyn>不可堆叠道具最大购买数量1</cyn>");
}
if (me.is_full(sellitem.combined ? 0 : buy_count)) {
return me.notify("你拿不下那么多东西。");
}
var need_money = sellitem.value * buy_count;
if (need_money > (me.money || 0)) {
return me.notify("你没有那么多的钱。");
}
if (target.before_sell_item) {
if (target.before_sell_item(me, sellitem, buy_count) === false)
return;
}
if ((!target.is_player && sellitem.count == -1)) {
me.money -= need_money;
me.add_temp('money1', need_money, UTIL.diff_time());
sell_obj = me.add_obj(sellitem.path, buy_count);
if (sell_obj) {
me.send_room("$N从$n购买了" + UTIL.to_c(buy_count) + sell_obj.unit + sell_obj.color_name + "。", target);
if (target.on_sell_item) target.on_sell_item(me, sell_obj, count);
}
} else {
if (sellitem.count >= buy_count) {
sellitem.count -= buy_count;
me.money -= need_money;
me.add_temp('money1', need_money, UTIL.diff_time());
sell_obj = me.add_obj(sellitem.path, buy_count);
if (sell_obj) {
me.send_room("$N从$n购买了" + UTIL.to_c(buy_count) + sell_obj.unit + sell_obj.color_name + "。", target);
}
me.send('{type:"dialog",dialog:"list",id:"' + sellitem.id + '",sell:' + buy_count + '}');
if (target.on_sell_item) target.on_sell_item(me, sell_obj, count);
} else {
return me.notify(target.name + "没有那么多的" + sellitem.color_name + "买给你。");
}
//玩家售卖
}
// me.send('你给他' + UTIL.moneyToStr(need_money) + "。");
}

65
world/cmd/obj/checkobj.js Normal file
View File

@@ -0,0 +1,65 @@
this.inherits(COMMAND);
this.command = "checkobj";
this.allow_busy = true;
this.allow_state = true;
this.allow_die = true;
this.regex = /^(\w+?)\s+from\s+(\w+)$/;
this.enter = function (player, objid, type) {
var obj = null;
if (type == "item") {
obj = player.find_obj(objid);
} else if (type == "eq") {//装备和物品只能检查自己的
if (player.equipment) {
for (var i = 0; i < player.equipment.length; i++) {
if (player.equipment[i]&&player.equipment[i].id == objid) {
obj = player.equipment[i];
break;
}
}
}
} else if (type == "store") {
obj = player.find_obj_byid(player.stores, objid);
} else if (type == "sj") {
obj = player.find_obj_byid(player.books, objid);
} else {
var target = player.find_obj(type, player.environment);
if (!target) return player.notify("你要从谁那里看?");
if (target.on_checkobj) {
obj = target.on_checkobj(player, objid);
} else if (target.sell_list) {
var selllist = target.sell_list;
if (target.on_sell) {
selllist = target.on_sell(player);
}
if (!selllist) {
return player.notify(target.name + "不出售这个东西。");
}
obj = player.find_obj_byid(selllist, objid);
}
}
if (!obj) {
return player.notify("你要看什么?");
}
player.notify(query_obj_desc(player,obj, type));
}
function query_obj_desc(player,obj, type) {
var json = {};
json.type = "dialog";
json.dialog = "pack";
json.from = type;
json.id = obj.id;
json.desc = obj.get_desc(player);
if (obj.actions) {
json.commands = [];
for (var key in obj.actions) {
if (obj.actions[key].name)
json.commands.push({ cmd: key, name: obj.actions[key].name });
}
}
return JSON.stringify(json);
}

40
world/cmd/obj/combine.js Normal file
View File

@@ -0,0 +1,40 @@
this.inherits(COMMAND);
this.command = "combine";
this.regex = /^(\w+)(?:\s(\d+))?$/;
this.enter = function (player, objid, count) {
var obj = player.find_obj(objid);
if (!obj) {
return player.notify("你要用什么合成?");
}
if (!obj.combine_count || !obj.combine_to) return player.send(obj.color_name + "不能合成任何东西。");
var result_count = parseInt(count || 1);
if (!(result_count > 0)) return;
var need_count = result_count * obj.combine_count;
if (obj.count < need_count) return player.notify("你身上的" + obj.color_name + "不够合成那么多。");
var remove_obj = player.remove_obj(obj, need_count);
if (!remove_obj) return player.notify("移除" + obj.color_name + "失败。");
let ispacket = obj.grade !== 5 || !obj.path.startsWith('st/st_');
if (ispacket) {
//if (obj.on_combine && obj.on_combine(result_count) == false) return;
let result = player.add_obj(obj.combine_to, result_count);
if (result) {
if (result.is_equipment && result.grade > 5) {
COMMAND.DO("rumor", "听说有人合成了" + result.unit_name(1)+ "。");
}
player.notify("你合成了" + UTIL.to_c(result_count) + result.unit + result.color_name + "。");
} else {
player.notify("合成" + obj.color_name + "失败。");
}
} else {
for (let i = 0; i < result_count; i++) {
let result = player.add_obj(obj.combine_to, 1);
if (result) {
player.notify("你合成了" + UTIL.to_c(1) + result.unit + result.color_name + "。");
}
}
}
}

71
world/cmd/obj/dice.js Normal file
View File

@@ -0,0 +1,71 @@
this.inherits(COMMAND);
this.command = "dice";
this.allow_busy = true;
this.allow_state = true;
this.allow_die = true;
this.allow_faint = true;
this.regex = /^(\d)\s(\w+)$/;
this.enter = function (me, type, objid) {
if (!me.team) return me.send("你没有在队伍里。");
if (!me.team.objs || !me.team.objs.length) return me.send("目前没有等待分配的战利品。");
var item = null;
for (var i = 0; i < me.team.objs.length; i++) {
if (me.team.objs[i].id == objid) {
item = me.team.objs[i];
break;
}
}
if (!item) return me.send("目前没有这个战利品等待分配。");
if (!item.dice) return;
if (!item.dice.users.remove(me.id)) return me.send("目前没有这个战利品等待分配。");
type = parseInt(type);
if (!(type >= 0)) return;
var num = me.random(100) + 1;
var msg = null;
if (type === 2) {
num = 0;
msg = me.name + "放弃" + item.color_name + "。";
} else if (type === 0) {
switch (me.random(5)) {
case 3:
msg = "<hig>" + me.name + ":天灵灵,地灵灵,看我骰子来显灵,这" + item.unit + item.color_name + "是我的了," + num +"点。</hig>";
break;
case 2:
msg = "<hig>" + me.name + "大喝一声:对不住了各位,这" + item.unit + item.color_name + me.callme() + "要了," + num + "点。</hig>";
break;
case 1:
msg = "<hig>" + me.name + "笑眯眯地说道:各位,这" + item.unit + item.color_name + "与" + me.callme() + "有缘," + num + "点。</hig>";
break;
default:
msg = "<hig>" + me.name + "哈哈笑道:运气不错," + me.callme() + "刚好需要这" + item.unit + item.color_name + "" + num + "点。</hig>";
break;
}
num += 100;
} else {
switch (me.random(5)) {
case 3:
msg = "<hic>" + me.name + ":我的,我的,都是我的,说不定运气好,这" + item.unit + item.color_name + "没人要就是我的了," + num + "点。</hic>";
break;
case 2:
msg = "<hic>" + me.name + "嘿嘿笑道:这" + item.unit + item.color_name + "不错,可以卖个好价钱," + num + "点。</hic>";
break;
case 1:
msg = "<hic>" + me.name + "笑眯眯地说道:嗯?" + item.color_name + ",说不定与" + me.callme() + "有缘," + num + "点。</hic>";
break;
default:
msg = "<hic>" + me.name + "哈哈笑道:这" + item.unit + item.color_name + "虽然不需要,但是拿着也没坏处," + num + "点。</hic>";
break;
}
}
me.send_team(msg);
if (num > item.dice.num) {
item.dice.user = me.id;
item.dice.num = num;
}
if (item.dice.users.length===0) {
me.team.alloc(item);
}
}

40
world/cmd/obj/drop.js Normal file
View File

@@ -0,0 +1,40 @@
this.inherits(COMMAND);
this.command = "drop";
this.regex = /^(?:(\d+\s))?(.+?)$/;
this.enter = function (player, count, objid) {
var obj = player.find_obj(objid);
if (!obj) {
return player.notify("你要丢掉什么东西?");
}
if (obj.is_locked) {
return player.notify(obj.color_name + "处于锁定状态,无法丢弃,贩卖,分解。");
// player.send_commands('lockobj ' + obj.id, '解除锁定');
}
if (obj.no_drop) return player.notify("这个东西丢不掉。");
this.exec(player, obj, count);
}
this.exec = function (player, obj, count) {
if (!obj || !player.environment) return;
var drop_count = 1;
if (count) drop_count = parseInt(count);
if (!(drop_count > 0)) return;
if (obj.count > 0) {
if (drop_count > obj.count) return player.notify("你身上没有那么多的" + obj.color_name + "。");
} else {
for (var i = 0; i < player.items.length; i++) {
if (player.items[i] == obj) {
player.items.splice(i, 1);
player.send('{type:"dialog",dialog:"pack",id:"' + obj.id + '",remove:1}');
return player.notify("你销毁了" + obj.color_name + "。");
}
}
return player.notify("你什么都没丢掉。");
}
var drop_obj = player.remove_obj(obj, drop_count);
if (drop_obj) {
player.send_room("$N丢掉" + UTIL.to_c(drop_count) + obj.unit + obj.color_name + "。");
WORLD.add_recover_obj(player, drop_obj, 0);
} else {
player.notify("你什么都没丢掉。");
}
}

42
world/cmd/obj/eq_group.js Normal file
View File

@@ -0,0 +1,42 @@
this.inherits(COMMAND);
this.command = "eqgroup";
this.allow_fight = false;
this.enter = function (me, par) {
let index = parseInt(par);
if (!(index >= 0 && index < 3)) return;
this.save_eqgroup(me);
let eqs = me.eq_groups[index];
if (!eqs) eqs = new Array(me.equipment.length);
for (let i = 0; i < me.equipment.length; i++) {
let eq = me.equipment[i];
if (!eq) continue;
me.unequip(eq);
if (!eq.is_shortcut)
eq.notify_action(me, false);
}
for (let i = 0; i < me.equipment.length; i++) {
if (!eqs[i]) continue;
let obj = me.find_obj(eqs[i]);
if (!obj || !obj.is_equipment) continue;
if (me.equip(obj) !== false && obj.on_use) {
obj.notify_action(me, true);
}
}
me.eq_group = index;
me.send(`{type:"dialog",dialog:"pack",eq_group:${index}}`);
}
this.save_eqgroup = function (me) {
let eqs = me.eq_groups[me.eq_group];
if (!eqs) {
eqs = new Array(me.equipment.length);
me.eq_groups[me.eq_group] = eqs;
}
for (let i = 0; i < me.equipment.length; i++) {
let eq = me.equipment[i];
eqs[i] = eq ? eq.id : null;
}
}

29
world/cmd/obj/equip.js Normal file
View File

@@ -0,0 +1,29 @@
this.inherits(COMMAND);
this.command = "eq";
this.enter = function (me, oid) {
var obj = me.find_obj(oid);
if (!obj) {
return me.notify("你要装备什么?");
}
if (!obj.is_equipment) {
return me.notify("这个东西不能装备。");
}
if (me.fight_type) {
if (me.query_temp('eq_wea') !== oid)
return me.notify("战斗中不能更换装备。");
}
if (me.release_time) {
var diff_time = me.release_time - Date.now();
if (diff_time > 0) {
return me.notify("你的技能还没释放完成,无法切换装备。");
}
}
if (me.equip(obj) != false && obj.on_use) {
obj.notify_action(me, true);
if (me.fight_type) {
me.remove_temp('eq_wea');
}
}
}

109
world/cmd/obj/fenjie.js Normal file
View File

@@ -0,0 +1,109 @@
this.inherits(COMMAND);
this.command = "fenjie";
this.regex = /^(\w+)(?:\s(\w+))?$/;
this.enter = function (player, objid, isok) {
var obj = player.find_obj(objid);
if (!obj) {
return player.notify("你要分解什么装备?");
}
if (obj.is_locked) {
return player.notify(obj.color_name + "处于锁定状态,无法丢弃,贩卖,分解。");
// player.send_commands('lockobj ' + obj.id, '解除锁定');
}
if (!obj.is_equipment || obj.no_fenjie)
return player.notify("这个东西分解不了。");
if (!obj.grade) return player.notify(obj.color_name + "蕴含的力量太弱了,分解不出来什么东西。");
if (obj.grade > 5) {
return player.notify("你确定要分解" + obj.color_name + "吗?");
}
if (obj.grade >= 5) {
return this.fenjie2(player, obj, isok);
}
let count = Math.floor(obj.value / 1000);
if (obj.level > 0) {
count += (Math.pow(2, obj.level + 1) - 2) * obj.grade;
}
if (!isok && obj.st_prop && obj.st_prop.length > 0) {
return player.notify(obj.color_name + "已经镶嵌宝石,清理宝石后才可以分解。");
}
obj = player.remove_obj(obj);
if (!obj) return player.notify("你要分解什么装备?");
let attach = player.query_prop('fenjie');
let sum_count = count + attach;
var item = player.add_obj("st/xuanjing", sum_count);
if (!item) return player.notify("分解失败。");
player.send("你将" + obj.color_name + "分解为" + item.unit_name(sum_count) + "。");
WORLD.add_recover_obj(player, obj, 2, sum_count);
}
const default_prop = ["gj", 'fy', 'fy', 'fy', 'fy', null, null, null,
'fy', 'fy', 'gj'];
this.fenjie2 = function (player, obj, isok) {
// if (obj.path.startsWith('eq/cp')
// || obj.path.startsWith('eq/zb'))
// return player.notify('自制装备暂时不能分解。');
let count = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 6][obj.level];
let props = obj.prop;
if (!props) return player.send('无法拆解。');
let sts = [];
let st_names = [];
if (obj.path.startsWith('eq/cp')
|| obj.path.startsWith('eq/zb')) {
const duanzao = WORLD.COMMANDS.duanzao;
for (var key in obj.temp) {
let level = obj.temp[key];
if (!level) continue;
let prop = duanzao.PROPS[key];
if (!prop) continue;
let st = OBJ.CREATE('st/p#' + key, duanzao.sum_needs(prop, level));
sts.push(st);
st_names.push(st.unit_name());
}
count += 8;
count += obj.query_temp('sc', 0);
} else {
let active_props = WORLD.COMMANDS.duanzao.PROPS;
const def_prop = WORLD.COMMANDS.duanzao.DEFAULT_PROPS[obj.eq_type];
for (let prop in props) {
if (!active_props[prop]) continue;
if (def_prop && def_prop === prop) continue;
let st = OBJ.CREATE('st/p#' + prop, obj.query_temp(prop, 1));
sts.push(st);
st_names.push(st.unit_name());
}
}
if (!isok) {
player.notify("是否确认分解" + obj.color_name
+ "?精炼等级越高分解的元晶数量越多,当前等级分解后可以获得:" + count + "个<hio>元晶</hio>、" + st_names.join("、"));
return player.send_commands("fenjie " + obj.id + " ok", "确认分解")
}
if (obj.st_prop && obj.st_prop.length > 0) {
return player.notify(obj.color_name + "已经镶嵌宝石,清理宝石后才可以分解。");
}
obj = player.remove_obj(obj);
if (!obj) return player.notify("你要分解什么装备?");
let item = player.add_obj("st/yuanjing", count);
if (!item) return player.notify("分解失败。");
player.send("你将" + obj.color_name + "分解为" + item.unit_name(count) + "。");
let rec_items = ['st/yuanjing', count];
for (let st of sts) {
player.add_obj(st);
player.send("你获得" + st.unit_name() + "。");
rec_items.push(st.path);
}
return WORLD.add_recover_obj(player, obj, 2, rec_items);
}

132
world/cmd/obj/get.js Normal file
View File

@@ -0,0 +1,132 @@
this.inherits(COMMAND);
this.command = "get";
this.regex = /^(?:(\d+)\s)?(\w+)(?:\s+from\s(\w+))?$/;
this.enter = function (player, count, objid, from) {
if (!objid) return player.notify("你要捡什么东西?");
var parent = player.environment;
if (from) {
parent = player.find_obj(from, player.environment);
if (!parent) {
return player.notify("你要从哪拿走什么东西?");
}
if (parent == player) {
return player.notify("东西就在你身上");
}
if (parent.is_character) {
return player.notify("你不能搜身。");
}
if (!parent.is_container) {
return player.notify("你不能从" + parent.name + "里拿走任何东西。");
}
}
if (objid !== "all" || !from) {
var obj = parent.find_obj(objid);
if (!obj) {
return player.notify("你要捡起什么东西?");
}
var get_count = obj.count;
if (obj.count < get_count) {
return player.notify("这里没有那么多的" + obj.name + "。");
}
if (obj.is_living && obj.is_living()) {
return player.notify(obj.name + "不用你背。");
}
if (obj.no_get) {
return player.notify("这个东西你捡不起来。");
}
if (obj.on_get && obj.on_get(player) === false) return;
parent = parent || player.environment;
if (player.is_full()) {
return player.notify("你身上东西太多了。");
}
obj = parent.remove_item(obj, get_count);
if (!obj) return player.notify("你什么都没捡起来。");
obj.count = get_count;
player.add_obj(obj);
if (from) {
player.send_room("$N从" + parent.name + "里拿出来" + UTIL.to_c(get_count) + obj.unit + obj.color_name + "。");
} else {
player.send_room("$N捡起" + UTIL.to_c(get_count) + obj.unit + obj.color_name + "。");
player.environment.item_changed(obj, false);
}
} else if (objid === "all" && from) {
var items = parent.query_items(player);
if (!items || !items.length) { return player.notify("那里面没有东西。") }
if (player.is_full()) {
return player.notify("你身上东西太多了。");
}
var no_get = [];
for (var i = 0; i < items.length; i++) {
if (!getObj(player, items[i], parent)) {
no_get.push(items[i]);
}
}
parent.clear_items(player, no_get);
parent.refresh();
}
}
function getObj(me, item, parent) {
if (!(item.count > 0)) return true;
if (item.on_get && item.on_get(me) === false) return false;
if (!me.team || me.team.free_get || !item.grade || parent.no_alloc) {
if (parent.on_getitem && parent.on_getitem(me, item) === false) return false;
me.add_obj(item);
} else {
var list = [];
for (var i = 0; i < me.team.length; i++) {
var tm = me.team[i];
if (tm.environment && tm.environment.parent === me.environment.parent) {
if (parent.on_getitem && parent.on_getitem(tm, item) === false) {
if (tm === me) return false;
continue;
}
list.push(tm);
}
}
if (list.length > 1) {
me.team.objs = me.team.objs || [];
me.team.objs.push(item);
item.dice = { user: null, users: [], num: 0 };
var str = ["{type:\"warn\",content:\"", item.color_name, '",time:60000,cmds:[',
"{cmd:\"dice 0 ", item.id, '",name:"有需求想要"},{cmd:"dice 1 ', item.id,
'",name:"无需求想要"},{cmd:"dice 2 ', item.id, '", name: "不想要" }]}'].join("");
for (let i = 0; i < list.length; i++) {
if (!list[i].is_player) {
var dtype = list[i].query_setting("auto_dice");
WORLD.COMMANDS["dice"].enter(list[i], dtype ? (dtype - 1) : 2, item.id);
} else {
list[i].send(str);
item.dice.users.push(list[i].id);
}
}
let tm = me.team;
me.call_out(() => tm.alloc(item), 60000);
} else if (list.length === 1) {
me.add_obj(item);
} else {
return false;
}
}
if (item.is_equipment && item.grade >= 5) {
COMMAND.DO("rumor", "听说有人捡到了一" + item.unit + item.name + "。");
}
if (parent)
me.send_room("$N从" + parent.name + "里拿出来" + UTIL.to_c(item.count) + item.unit + item.color_name + "。");
else
me.send_room("$N捡起" + UTIL.to_c(item.count) + item.unit + item.color_name + "。");
return true;
}

63
world/cmd/obj/give.js Normal file
View File

@@ -0,0 +1,63 @@
this.inherits(COMMAND);
this.command = "give";
this.regex = /^(\w+)(?:\s+(\w+))?\s+(\w+)$/;
this.enter = function (player, target, count, objid) {
target = player.find_obj(target, player.environment);
if (!target || !target.hp) return player.notify("你要给谁东西?");
if (target.is_player && player.master != target.id) return player.notify("不能给玩家控制的人物东西。");
if (objid == "money") {
if (!count) return player.notify("你要给" + target.name + "多少钱?");
count = parseInt(count);
if (count <= 0) return player.notify("你要给" + target.name + "多少钱?");
if (count > player.money) return player.notify("你身上没有那么多的钱给" + target.name + "。");
if (target.on_accept && target.on_accept(player, objid, count)) {
player.money -= count;
//target.money = target.money || 0;
//target.money += count;
// player.add_temp('money1', count, UTIL.diff_time());
player.send_room("$N给了$n" + UTIL.moneyToStr(count) + "。", target);
return;
}
return player.notify(target.name + "不要你的钱。");
} else if (objid == "cash") {
if (!count) return player.notify("你要给" + target.name + "多少元宝?");
if (count <= 0) return player.notify("你要给" + target.name + "多少元宝?");
if (count > player.cash_money) return player.notify("你身上没有那么多的元宝给" + target.name + "。");
if (target.on_accept && target.on_accept(player, objid, count)) {
return player.add_cash(-count, "给" + target.name);
}
return player.notify(target.name + "不要你的钱。");
}
var obj = player.find_obj(objid);
if (!obj) {
return player.notify("你要给" + target.name + "什么东西?");
}
if (!count) count = 1;
else if (count === 'all')
count = obj.count;
else
count = parseInt(count);
if (!(count > 0)) return;
if (obj.count < count) {
return player.notify("你没有那么多的" + obj.name + "。");
}
if (target.master == player.id || target.id == player.master) {
if (target.is_full()) return player.notify(target.name + "身上东西太多了。");
obj = player.remove_obj(obj, count);
if (obj) {
target.add_obj(obj);
player.send_room("$N给了$n" + UTIL.to_c(count) + obj.unit + obj.color_name + "。", target);
}
return;
}
if (target.on_accept && target.on_accept(player, obj, count)) {
obj = player.remove_obj(obj, count);
if (obj) {
player.send_room("$N给了$n" + UTIL.to_c(count) + obj.unit + obj.color_name + "。", target);
}
}
}

106
world/cmd/obj/jinglian.js Normal file
View File

@@ -0,0 +1,106 @@
this.inherits(COMMAND);
this.command = "jinglian";
this.regex = /^(\w+)(?:\s(\w+))?$/;
this.enter = function (player, objid, isok) {
var obj = player.find_obj(objid);
if (!obj) {
return player.notify("你要精炼什么装备?");
}
if (!obj.is_equipment || obj.no_jinglian) return player.notify("这个东西没办法精炼。");
if (!obj.grade) return player.notify(obj.color_name + "品质太低了,承受不住再多的力量。");
if (obj.level >= 12) return player.notify(obj.color_name + "已经到了极限,无法再承受更多的力量。");
var item = {
path: obj.grade == 6 ? "st/yuanjing" : "st/xuanjing",
color_name: obj.grade == 6 ? "<hio>元晶</hio>" : "<hiw>玄晶</hiw>", count: 0
};
for (var i = 0; i < player.items.length; i++) {
if (player.items[i].is(item.path)) {
item = player.items[i];
break;
}
}
var lv = obj.level + 1;
var need_count = obj.grade < 6 ? Math.pow(2, lv) * obj.grade : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12][lv - 1];
var full_count = 0;
if (obj.grade < 6) {
full_count = (Math.pow(2, 12 + 1) - 2) * obj.grade;
if (obj.level > 0) {
full_count -= (Math.pow(2, obj.level + 1) - 2) * obj.grade;
}
} else {
full_count = (1 + 12) * 12 / 2;
if (obj.level > 0) {
full_count -= (1 + obj.level) * obj.level / 2;
}
}
//绿8190 橙5*8190
if (isok) {
let isfull = isok === 'full';
if (isfull) need_count = full_count;
if (item.count < need_count) {
return player.notify("你的" + item.color_name + "数量不够精炼。");
}
item = player.remove_obj(item, need_count);
if (!item) player.notify("你的" + item.color_name + "数量不够精炼。");
player.send_room("<hiw>$N用内力把" + item.color_name + "炼化,小心翼翼的引入" + obj.color_name + "。</hiw>");
if (isfull) {
player.send_room("<ora>$N的" + obj.color_name + "古井无波,空中却一瞬间电闪雷鸣,似有神兵出世,轰鸣声中你好似听到有阵阵龙吟自" + obj.color_name + "中传出!</ora>");
obj.level_up(12);
} else {
if (obj.level < 5) {
player.send_room("<yel>$N的" + obj.color_name + "发出一阵耀眼的光芒,看上去似乎变强了!</yel>");
} else if (obj.level < 9) {
player.send_room("<yel>$N的" + obj.color_name + "发出一阵璀璨的光芒,看上去似乎更加强大了!</yel>");
} else if (obj.level < 12) {
player.send_room("<mag>$N的" + obj.color_name + "爆出一阵炽热的光芒,周身似乎有雷光环绕,连绵不绝!</mag>");
} else {
player.send_room("<ora>$N的" + obj.color_name + "古井无波,空中却一瞬间电闪雷鸣,似有神兵出世,轰鸣声中你好似听到有阵阵龙吟自" + obj.color_name + "中传出!</ora>");
}
obj.level_up(obj.level + 1);
}
// lv = obj.level + 1;
// need_count = Math.pow(2, lv) * obj.grade;
player.items_changed(obj);
return WORLD.STATS.updateWeapon(player, obj);
}
var str = ['{type:"dialog",dialog:"pack",jldesc:\"',
obj.color_name, "<br/>精炼", query_level_color(lv), " 需要以下物品:<br/>"];
str.push(item.color_name, ' ');
if (item.count < need_count) {
str.push("<red>");
}
str.push(item.count, '/', need_count);
if (item.count < need_count) {
str.push("</red>");
}
str.push("<br/>精炼", query_level_color(12), " 需要以下物品:<br/>");
str.push(item.color_name, ' ');
if (item.count < full_count) {
str.push("<red>");
}
str.push(item.count, '/', full_count);
if (item.count < need_count) {
str.push("</red>");
}
str.push('",id:"');
str.push(obj.id);
str.push('"}');
player.notify(str.join(""));
}
function query_level_color(lv) {
if (!lv) return "";
var jlcolor = ["", "hig", "hig", "hic", "hic", "hiy", "hiy", "HIZ", "HIZ", "hio", "hio", "ord", "ord"];
var cc = jlcolor[lv];
return "<" + cc + ">" + lv + " </" + cc + ">";
}

7
world/cmd/obj/lianyao.js Normal file
View File

@@ -0,0 +1,7 @@
this.inherits(COMMAND);
this.command = "lianyao";
this.regex = /^(\w+)?(?:\s(-?\d+))?$/;
this.enter = function (player, arg, id) {
}

21
world/cmd/obj/lockobj.js Normal file
View File

@@ -0,0 +1,21 @@
this.inherits(COMMAND);
this.command = "lockobj";
this.allow_busy = true;
this.allow_state = true;
this.allow_die = true;
this.allow_faint = true;
//this.regex = /^(\d)\s(\w+)$/;
this.enter = function (me, objid) {
var obj = me.find_obj(objid);
if (!obj) {
return me.notify("你要锁定什么东西?");
}
if (obj.is_locked) {
obj.is_locked = false;
me.send(`{type:"dialog",dialog:"pack",id:"${obj.id}",locked:0}`);
return me.send('<cyn>取消' + obj.color_name + "的锁定状态,你可以进行丢弃,贩卖,分解操作。</cyn>");
}
obj.is_locked = true;
me.send('<hic>设置' + obj.color_name + "为锁定状态,将禁止丢弃,贩卖,分解操作。</hic>\n");
me.send(`{type:"dialog",dialog:"pack",id:"${obj.id}",locked:1}`);
}

26
world/cmd/obj/open.js Normal file
View File

@@ -0,0 +1,26 @@
this.inherits(COMMAND);
this.command = "open";
this.enter = function (player, objid) {
var obj = player.find_obj(objid);
if (!obj) return player.notify("你要打开什么?");
if (!obj.on_open) return player.notify("这个东西打不开。");
var items = obj.on_open(player);
if (items == false) return;
if (!items || !items.length) {
player.send_room("$N打开了" + obj.color_name + ",但是里面什么都没有。");
} else {
// if (player.is_full()) return player.notify("你身上东西太多了,放不下" + obj.color_name + "里的东西。");
for (var i = 0; i < items.length; i++) {
var item = player.add_obj(items[i]);
if (item) {
//if (item.is_equipment && item.grade > 5) {
// COMMAND.DO("rumor", "听说有人得到了一" + item.unit + item.name + "。");
//}
player.notify("你从" + obj.color_name + "里面拿出来" + UTIL.to_c(items[i].count) + item.unit + item.color_name + "。");
}
}
}
player.remove_obj(obj,1);
}

13
world/cmd/obj/packitem.js Normal file
View File

@@ -0,0 +1,13 @@
this.inherits(COMMAND);
this.command = "packitem";
this.regex=/^(\w+)\s+(\w+)(?:\s+(\w+))?$/;
this.enter = function (player,cmd, objid,par) {
var obj = player.find_obj(objid);
if (!obj) return player.notify("你身上没有这个东西。");
if (!obj.actions) return player.notify("你要对" + obj.color_name + "做什么?");
var act = obj.actions[cmd];
if (!act || !act.action) return player.notify("你要对" + obj.color_name + "做什么?");
act.action.call(obj, player, par);
}

82
world/cmd/obj/receive.js Normal file
View File

@@ -0,0 +1,82 @@
this.inherits(COMMAND);
this.command = "receive";
this.allow_busy = true;
this.allow_state = true;
this.allow_die = true;
this.allow_faint = true;
this.regex = /^(\w+)\s(\d+)$/;
const MESSAGE = WORLD.MESSAGE;
this.enter = function (me, from, index) {
//if (from === 'all') return this.receive_all(me);
if (index !== undefined)
this.receive_single(me, from, index);
else if (from)
this.receive_from(me, from);
else
this.receive_all(me);
}
this.receive_single = function (me, from, index) {
let msg = MESSAGE.getMessageByIndex(me, from, index);
if (!msg) return me.send("没有这个消息。");
if (msg.rec) return me.send("你已经领取了。");
if (!msg.attach) return me.send("这个消息没有附件。");
// if (me.is_full()) return me.send("你身上东西太多了。");
this.receive_item(me, msg, from, index);
}
this.receive_item = function (me, msg, from, index) {
msg.rec = true;
for (var i = 0; i < msg.attach.length; i++) {
var count = msg.attach[i].count || 1;
var obj = OBJ.CREATE(msg.attach[i].obj, count);
if (!obj) continue;
if (obj.on_receive) {
obj.on_receive(me);
} else {
obj = me.add_obj(obj);
me.notify("你领取了" + obj.unit_name(count) + "。");
if (obj.grade > 5) {
COMMAND.DO("rumor", "听说有人得到了一" + obj.unit + obj.name + "。");
}
}
}
me.send('{dialog:"message",type:"dialog",receive:"' + from + '",index:' + index + '}');
}
this.receive_from = function (me, from) {
let stores = MESSAGE.stores.get(me.id);
if (!stores) return;
if (me.is_full()) return me.send("你身上东西太多了。");
let store = stores.get(from);
if (!store) return me.send("没有这个消息类型。");
let list = store.items;
let count = 0;
for (let i = 0; i < list.length; i++) {
let item = list[i];
if (!item.attach || item.rec) continue;
this.receive_item(me, item, from, i);
count++;
}
if (count > 0)
return me.send('领取完毕,共收取' + count + '条消息的附件。');
return me.send('没有可领取的消息。');
}
this.receive_all = function (me) {
let store = MESSAGE.stores.get(me.id);
if (!store) return;
if (me.is_full()) return me.send("你身上东西太多了。");
let count = 0;
store.forEach((x, y) => {
let list = x.items;
for (let i = 0; i < list.length; i++) {
let item = list[i];
if (!item.attach || item.rec) continue;
this.receive_item(me, item, y, i);
count++;
}
});
if (count > 0)
return me.send('领取完毕,共收取' + count + '条消息的附件。');
return me.send('没有可领取的消息。');
}

8
world/cmd/obj/recobj.js Normal file
View File

@@ -0,0 +1,8 @@
this.inherits(COMMAND);
this.command = "recobj";
//this.regex = /^(\w+)?(?:\s(\w+))?(?:\s(\w+))?$/;
this.enter = function (me, objid) {
return me.send('你没有可供恢复的道具和操作');
}

104
world/cmd/obj/sell.js Normal file
View File

@@ -0,0 +1,104 @@
this.inherits(COMMAND);
this.command = "sell";
this.regex = /^(?:(\d+)\s)?(\w+)(?:\s+to\s+(.+?))?$/;
this.enter = function (me, count, objid, to) {
var target;
if (to) {
target = me.find_obj(to, me.environment);
if (!target) {
return me.notify("你要卖东西给谁?");
}
if (target == me) {
return me.notify("东西就在你身上,别折腾了。");
}
if (!target.sell_list) {
return me.notify(target.name + "不是商人,不收购任何东西。");
}
}
// else {
// var env = me.environment;
// if (!env) return;
// for (var i = 0; i < env.items.length; i++) {
// if (env.items[i].sell_list) {
// target = env.items[i];
// break;
// }
// }
// if (!target) {
// return me.notify("这里没有商人。");
// }
// }
if (objid === "all") {
var str = [];
let sum_money = 0;
for (var i = 0; i < me.items.length; i++) {
var item = me.items[i];
if (!item.transable || item.is_locked) continue;
if (!item.grade && !item.path.startsWith("res/cao") &&
!item.path.startsWith("book/book") && !item.path.startsWith("res/yu")) {
var money = parseInt(item.count * item.value);
if (!(money > 0)) continue;
me.items.splice(i, 1);
sum_money += money;
i--;
str.push("你卖掉了" + item.unit_name() + "。");
// me.add_temp('money2', money, UTIL.diff_time());
}
}
if (str.length) {
if (!me.is_player && me.master) {
let user = WORLD.getUser(me.master);
if (user) user.add_money(sum_money);
} else {
me.add_money(sum_money);
}
me.do_command("pack");
me.notify(str.join("\n"));
me.notify('你将身上的杂物卖了' + UTIL.moneyToStr(sum_money) + "。");
} else {
me.notify("<hig>你身上的杂物已经清理干净了。</hig>");
}
return;
}
var obj = me.find_obj(objid);
if (!obj) {
return me.notify("你没有这件东西。");
}
if (obj.is_locked) {
return me.notify(obj.color_name + "处于锁定状态,无法丢弃,贩卖,分解。");
// me.send_commands('lockobj ' + obj.id, '解除锁定');
}
if (obj.is_equipment) {
if (obj.level > 3)
return me.notify(obj.color_name + "已经精炼,清理精炼后才可以贩卖。");
if (obj.st_prop && obj.st_prop.length > 0)
return me.notify(obj.color_name + "已经镶嵌宝石,清理宝石后才可以贩卖。");
}
if (!obj.transable) return me.notify("这个东西不能卖。");
if (!(obj.value > 0)) return me.notify("这个东西不值钱。");
var sell_count = obj.count;
if (count) sell_count = parseInt(count);
if (!(sell_count > 0)) return;
if (sell_count > obj.count) return me.notify("你身上没有这么多的" + obj.color_name + "。");
const sell_money = Math.floor(obj.value * sell_count);
if (!me.is_player && me.master) {
let user = WORLD.getUser(me.master);
if (user) user.add_money(sell_money);
} else {
me.add_money(sell_money);
}
var sell_obj = me.remove_obj(obj, sell_count);
me.send("你卖掉了" + obj.unit_name(sell_count) + "。");
// me.send('你获得' + UTIL.moneyToStr(sell_money) + "。");
WORLD.add_recover_obj(me, sell_obj, 1);
if (target && target.on_user_sell) {
target.on_user_sell(me, obj, sell_count);
}
}

21
world/cmd/obj/unequip.js Normal file
View File

@@ -0,0 +1,21 @@
this.inherits(COMMAND);
this.command = "uneq";
this.enter = function (me, oid) {
var obj;
if (me.equipment) {
for (var i = 0; i < me.equipment.length; i++) {
if (me.equipment[i] && me.equipment[i].id == oid) {
obj = me.equipment[i];
break;
}
}
}
if (!obj) return me.notify("你要取消装备什么?");
if (me.unequip(obj) != false && obj.on_use) {
if (!obj.is_shortcut)
obj.notify_action(me, false);
}
}

View File

@@ -0,0 +1,52 @@
this.inherits(COMMAND);
this.command = "unjinglian";
const MONEYS = [10, 100, 1000, 5000, 10000, 20000, 100000];
this.enter = function (me, oid) {
if (oid) {
var obj = me.find_obj(oid);
if (!obj) {
return me.notify("你身上没有这件装备。");
}
var orglevel = obj.level;
if (!(orglevel > 0)) return me.notify("你的" + obj.color_name + "已经是初始等级了。");
let money = MONEYS[obj.grade];
if (!(money > 0) || me.money < money) return me.send('你身上的钱不够。');
me.add_money(-money);
obj.level_up(0);
me.notify("你的" + obj.color_name + "已经是初始等级了。");
me.items_changed(obj);
WORLD.STATS.updateWeapon(me, obj);
if (orglevel > 0) {
let count = (Math.pow(2, orglevel + 1) - 2) * obj.grade;
var item = me.add_obj("st/xuanjing", count);
me.send("你获得" + item.unit_name(count) + "。");
}
} else {
var str = ["{type:\"cmds\",items:["];
for (var i = 0; i < me.items.length; i++) {
var item = me.items[i];
if (!item.level || !item.is_equipment) {
continue;
}
if (str.length > 1) str.push(",");
str.push("{cmd:\"unjinglian ");
str.push(item.id);
str.push("\",name:\"", UTIL.moneyToStr(MONEYS[item.grade]), "清除精炼");
str.push(item.color_name);
str.push("\"}");
}
if (str.length == 1) {
return me.notify("铁匠瞄了你一眼说道:你身上没有精炼过的装备。");
}
str.push("]}");
me.notify("铁匠说道:取消精炼后装备的等级变为初始等级,退回全部玄晶,不论精炼等级统一收费。");
me.notify(str.join(""));
}
}

View File

@@ -0,0 +1,101 @@
this.inherits(COMMAND);
this.command = "unxiangqian";
this.regex = /^(\w+)(?:\s+(\w+))?$/;
const MONEYS = [10, 100, 1000, 5000, 10000, 100000, 1000000];
const MONEYS_DESC = [null,
"1两<wht>白银</wht>", "10两<wht>白银</wht>", "50两<wht>白银</wht>",
"1两<hiy>黄金</hiy>", "10两<hiy>黄金</hiy>", "100两<hiy>黄金</hiy>"];
this.enter = function (player, objid, par) {
if (!objid) {
var str = ["{type:\"cmds\",items:["];
for (var i = 0; i < player.items.length; i++) {
var item = player.items[i];
if (!item.st_prop || !item.st_prop.length) {
continue;
}
if (str.length > 1) str.push(",");
str.push("{cmd:\"unxiangqian ");
str.push(item.id);
str.push("\",name:\"取消镶嵌");
str.push(item.color_name);
str.push("\"}");
}
if (str.length == 1) {
return player.notify("铁匠瞄了你一眼说道:你身上没有镶嵌过宝石的装备。");
}
str.push("]}");
player.notify("铁匠说道:你要拆掉哪个装备上的宝石?");
return player.notify(str.join(""));
}
var obj = player.find_obj(objid);
if (!obj) {
return player.notify("你身上没有这件装备。");
}
if (!obj.st_prop || !obj.st_prop.length) return player.notify(obj.color_name + "没有镶嵌宝石。");
if (par == "all") {
let sum = 0;
for (let item of obj.st_prop) {
sum += MONEYS[item.grade];
}
if (!(sum > 0) || player.money < sum) return player.send('你身上的钱不够。');
player.add_money(-sum);
obj.hole_count += (obj.st_prop.length);
for (let item of obj.st_prop) {
let stone = player.add_obj(item.path);
if (stone)
player.send('你从' + obj.color_name + '上拆下来一块' + stone.color_name + "。");
}
obj.st_prop.length = 0;
// player.send_room("铁匠拿着" + player.name + "的" + obj.color_name + ",三下五除二就把它上面镶嵌的宝石去掉了。");
WORLD.STATS.updateWeapon(player, obj);
return;
}
if (!par) {
var str = ["{type:\"cmds\",items:["];
var sum = 0;
for (var i = 0; i < obj.st_prop.length; i++) {
str.push("{cmd:\"unxiangqian " + obj.id + " ");
str.push(obj.st_prop[i].id);
str.push("\",name:\"", MONEYS_DESC[obj.st_prop[i].grade], "拆掉");
str.push(obj.st_prop[i].name);
sum += MONEYS[obj.st_prop[i].grade];
str.push("\"},");
}
str.push("{cmd:\"unxiangqian ");
str.push(obj.id);
str.push(" all\",name:\"", UTIL.moneyToStr(sum), "全部拆掉");
str.push("\"}");
str.push("]}");
player.send('铁匠:取消镶嵌后恢复装备的孔洞数量,宝石等级越高需要的手艺更精细。');
return player.notify(str.join(""));
} else {
let st = null, index = 0;
for (index = 0; index < obj.st_prop.length; index++) {
let item = obj.st_prop[index];
if (item.id === par) {
st = item;
break;
}
}
if (!st) return player.notify(obj.color_name + "这个没有这个石头。");
let money = MONEYS[st.grade];
if (!(money > 0) || player.money < money) return player.send('你身上的钱不够。');
player.add_money(-money);
obj.st_prop.splice(index, 1);
obj.hole_count += 1;
// player.send_room("铁匠拿着" + player.name + "的" + obj.color_name + ",三下五除二就把它上面镶嵌的" + st.name + "去掉了。");
WORLD.STATS.updateWeapon(player, obj);
let stone = player.add_obj(st.path);
if (stone) player.send('你从' + obj.color_name + '上拆下来一块' + stone.color_name + "。");
else player.send('你什么都没拆下来');
}
}

68
world/cmd/obj/use.js Normal file
View File

@@ -0,0 +1,68 @@
this.inherits(COMMAND);
this.command = "use";
this.allow_busy = true;
this.allow_die = true;
this.allow_faint = true;
this.regex = /^(\w+)(?:\s(\w+))?$/;
this.enter = function (player, objid, par) {
var obj = player.find_obj(objid);
var iseq = false;
if (!obj) {
for (var i = 0; i < player.equipment.length; i++) {
if (player.equipment[i] && player.equipment[i].id == objid) {
obj = player.equipment[i];
}
}
if (!obj)
return player.notify("你身上没有这个东西。");
iseq = true;
} else {
if (obj.is_equipment && !obj.is_shortcut) return player.notify(obj.color_name + "需要装备才可以使用。");
}
if (player.hp <= 0 && !obj.allow_die) return player.notify("你现在是灵魂状态,不能那么做。");
if (obj.is_shortcut) {
if (obj.is_equipment && !iseq) {
if (obj.eq_type != EQUIP_TYPE.WEAPON) return player.notify("你目前只能设置武器的快捷操作。");
player.do_command("eq", objid);
return;
}
}
if (player.is_in("yz/leitai/leitai"))
return player.notify("擂台自动出招。");
if (!obj.on_use) return player.notify("这个东西不能用。");
if (player.is_fighting() && !obj.allow_fight) return player.notify("你正在战斗,待会再说。");
if (!obj.count) return;
if (player.is_busy && !obj.allow_busy) return player.notify("你现在手忙脚乱,无法使用" + obj.name + "。");
if (player.is_faint && !obj.allow_faint) return player.notify("你现在昏迷中,无法使用" + obj.name + "。");
var use_msg = obj.action_msg || "用";
var key = "disobj_" + (obj.distype || objid);
if (obj.distime && player.query_temp(key)) {
return player.notify("你刚" + use_msg + "过" + obj.color_name + ",还是等会再" + use_msg + "吧。");
}
if (obj.grade < 3) {
if (obj.path === 'cash/jing#0' || obj.path === 'cash/jing#1') {
return player.send(obj.color_name + '无法使用。');
}
} else if (obj.grade === 5) {
if (!player.is_player && obj.path === 'cash/biguan') {
return player.send('你无法使用' + obj.color_name + '。');
}
}
if (obj.on_use(player, par) === false) return;
if (!obj.no_consume)
player.remove_obj(obj, 1);
if (obj.showAction || obj.is_shortcut)
player.notify('{type:"disobj",id:"' + obj.id + '",time:' + (obj.distime || 0) + ',count:' + (obj.count) + '}');
if (obj.distime) {
player.set_temp(key, 1, obj.distime);
}
}

View File

@@ -0,0 +1,51 @@
this.inherits(COMMAND);
this.command = "xiangqian";
this.regex = /^(\w+)(?:\s(\w+))?$/;
this.enter = function (player, objid, st) {
var obj = player.find_obj(objid);
if (!obj) {
return player.notify("你要镶嵌什么装备?");
}
if (!obj.is_equipment) return player.notify("这个东西没办法镶嵌。");
if (!obj.hole_count) return player.notify(obj.color_name + "没有能供镶嵌的孔。");
if (st) {
var stone = player.find_obj(st);
if (!stone)
return player.notify("你身上没有这种宝石。");
stone = player.remove_obj(stone, 1);
if (stone) {
if (obj.push_stone(stone) == false)
return player.notify("你镶嵌失败了。");
player.send_room("$N拿出一" + stone.unit + stone.color_name + ",小心翼翼的往" + obj.color_name + "上镶去。");
if (stone.grade < obj.grade) {
player.send_room("<hig>只听得咔嚓一声," + stone.color_name + "已嵌入" + obj.color_name + "中!</hig>");
} else {
player.send_room("<hig>只听得咔嚓一声," + stone.color_name + "已嵌入" + obj.color_name + "中,一眼看去仿若浑然一体!</hig>");
}
WORLD.STATS.updateWeapon(player, obj);
}
return;
}
var items = [];
for (var i = 0; i < player.items.length; i++) {
if (player.items[i].is_stone) {
items.push(player.items[i]);
}
}
if (!items.length) return player.notify("你身上没有可以镶嵌的宝石。");
var str = ['{type:"dialog",dialog:"pack",xqdesc:\"',
obj.color_name, "\",id:\"", obj.id, "\",stones:["];
for (var i = 0; i < items.length; i++) {
if (i > 0) str.push(",");
str.push("{name:\"");
str.push(items[i].name);
str.push("\",id:\"");
str.push(items[i].id);
str.push("\"}");
}
str.push(']}');
player.notify(str.join(""));
}