init: add workspace files
This commit is contained in:
6
world/cmd/comm/clearwait.js
Normal file
6
world/cmd/comm/clearwait.js
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
this.inherits(COMMAND);
|
||||
this.command = "clearwait";
|
||||
this.enter = function (player, arg, par) {
|
||||
player.wait_input = null;
|
||||
}
|
||||
98
world/cmd/comm/createrole.js
Normal file
98
world/cmd/comm/createrole.js
Normal file
@@ -0,0 +1,98 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "createrole";
|
||||
var name_reg = /^[\u4E00-\u9FA5]{2,5}$/;
|
||||
var id_reg = /^[a-z][a-z0-9]{2,9}$/;
|
||||
this.allow_login = true;
|
||||
this.enter = function (me, pars) {
|
||||
if (me.id) return me.send('{"type":"regist","result":"请刷新页面重新操作"}');
|
||||
pars = pars.split(' ');
|
||||
var name = pars[0], gender = parseInt(pars[1]),
|
||||
str = parseInt(pars[2]), con = parseInt(pars[3]), dex = parseInt(pars[4]), int = parseInt(pars[5]);
|
||||
|
||||
|
||||
if (gender != 1 && gender != 2) {
|
||||
return me.send('{"type":"regist","result":"注册信息错误"}');
|
||||
}
|
||||
if (!name_reg.test(name)) {
|
||||
return me.send('{"type":"regist","result":"姓名需要是2-5个汉字"}');
|
||||
}
|
||||
if (!UTIL.check_word(name)) {
|
||||
return me.send('{"type":"regist","result":"你不能用这个名字"}');
|
||||
}
|
||||
if (WORLD.find_user(name)) {
|
||||
return me.send('{"type":"regist","result":"这个名字已经有人用了"}');
|
||||
}
|
||||
|
||||
|
||||
if (str < 15 || str > 30) {
|
||||
return me.send('{"type":"regist","result":"力量属性需要在15-30之间。"}');
|
||||
}
|
||||
if (con < 15 || con > 30) {
|
||||
return me.send('{"type":"regist","result":"根骨属性需要在15-30之间。"}');
|
||||
}
|
||||
if (dex < 15 || dex > 30) {
|
||||
return me.send('{"type":"regist","result":"身法属性需要在15-30之间。"}');
|
||||
}
|
||||
if (int < 15 || int > 30) {
|
||||
return me.send('{"type":"regist","result":"悟性属性需要在15-30之间。"}');
|
||||
}
|
||||
if (str + con + dex + int != 80) {
|
||||
return me.send('{"type":"regist","result":"属性之和必须等于80"}');
|
||||
}
|
||||
|
||||
me.ip_address = me.socket.remoteAddress;
|
||||
if (!WORLD.USERLOGIN.check_user(me)) return;
|
||||
|
||||
me.name = name;
|
||||
me.id = UTIL.create_id();
|
||||
me.gender = gender;
|
||||
me.level = 0;
|
||||
me.exp = 0;
|
||||
me.pot = 0;
|
||||
//me.age = 14;
|
||||
me.str = str;
|
||||
me.con = con;
|
||||
me.dex = dex;
|
||||
me.int = int;
|
||||
me.per = parseInt(Math.random() * 5) + 20;
|
||||
me.kar = 20;
|
||||
me.limit_mp = 0;
|
||||
me.max_mp = 100;
|
||||
me.recount();
|
||||
me.hp = me.max_hp;
|
||||
me.mp = me.max_mp;
|
||||
me.reg_time = parseInt(Date.now() / 60000);
|
||||
me.set_objects(["eq/lv0/cloth", 1, 1]);
|
||||
me.set_temp("new", 1);
|
||||
me.set_temp("sr", 1);
|
||||
me.set_temp("hy_ct", 50);
|
||||
me.set_setting("ban_pk", 1);
|
||||
me.eq_groups = [];
|
||||
me.sk_groups = [];
|
||||
me.skills = {};
|
||||
this.save2db(me);
|
||||
}
|
||||
|
||||
this.save2db = async function (me) {
|
||||
try {
|
||||
let roleData = me.getData();
|
||||
roleData.server = WORLD.SERVERID;
|
||||
let suc = await WORLD.DB.addRole(roleData);
|
||||
if (suc) {
|
||||
WORLD.USERS.push(me);
|
||||
me.wait_input = null;
|
||||
me.do_login();
|
||||
} else {
|
||||
return me.send('{"type":"regist","result":"创建角色失败"}');
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.errno == 1062) {
|
||||
me.id = null;
|
||||
return me.send('{"type":"regist","result":"角色名称重复,请重新输入"}');
|
||||
} else {
|
||||
console.log("角色创建失败", err, pars);
|
||||
return me.send('{"type":"regist","result":"创建角色失败"}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
50
world/cmd/comm/dc.js
Normal file
50
world/cmd/comm/dc.js
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
this.inherits(COMMAND);
|
||||
this.command = "dc";
|
||||
this.regex = /(\w+)\s+(\w+)\s*(.+)?/;
|
||||
this.enter = function (player, arg, cmd, par) {
|
||||
if (!arg || !cmd) return;
|
||||
var target = player.find_obj(arg, player.environment);
|
||||
if (!target) return player.send("没有这个人。");
|
||||
if (target.master != player.id) return player.send("你没办法这么做。");
|
||||
try {
|
||||
if (!ALLOW_DC[cmd]) return;
|
||||
target.set_listener(player, player);
|
||||
target.do_command(cmd, par);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
target.set_listener(player, null);
|
||||
}
|
||||
const ALLOW_DC = {
|
||||
study: true,
|
||||
store: true,
|
||||
dazuo: true,
|
||||
liaoshang: true,
|
||||
learn: true,
|
||||
xue: true,
|
||||
enable: true,
|
||||
equip: true,
|
||||
unequip: true,
|
||||
lianxi: true,
|
||||
fangqi: true,
|
||||
give: true,
|
||||
caiyao: true,
|
||||
diaoyu: true,
|
||||
cai: true,
|
||||
diao: true,
|
||||
wa: true,
|
||||
wk: true,
|
||||
stopstate: true,
|
||||
state: true,
|
||||
eq: true,
|
||||
uneq: true,
|
||||
checkobj: true,
|
||||
drop: true,
|
||||
lingwu: true,
|
||||
use: true,
|
||||
lianyao: true,
|
||||
sell: true,
|
||||
lingwu3: true,
|
||||
fenjie: true
|
||||
};
|
||||
24
world/cmd/comm/deleterole.js
Normal file
24
world/cmd/comm/deleterole.js
Normal file
@@ -0,0 +1,24 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "deleterole";
|
||||
this.allow_login = true;
|
||||
this.enter = function (me, pars) {
|
||||
if (!pars) return;
|
||||
var olduser = WORLD.getUser(pars);
|
||||
if (olduser) {
|
||||
return me.notify("{type:\"deleterole\",result:0,message:\"登陆中的角色不允许删除\"}");
|
||||
}
|
||||
WORLD.DB.deleteRole(me.userid, pars).then(x => {
|
||||
if (x) {
|
||||
me.notify("{type:\"deleterole\",result:1,id:\"" + pars + "\"}");
|
||||
var user = WORLD.getUser(pars);
|
||||
if (user) {
|
||||
if (user.environment) user.environment.item_changed(user, false);
|
||||
WORLD.USERS.remove(user);
|
||||
}
|
||||
} else {
|
||||
me.notify("{type:\"deleterole\",result:0}");
|
||||
}
|
||||
}).catch(err => {
|
||||
me.notify("{type:\"deleterole\",result:0}");
|
||||
});
|
||||
}
|
||||
68
world/cmd/comm/greet.js
Normal file
68
world/cmd/comm/greet.js
Normal file
@@ -0,0 +1,68 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "greet";
|
||||
this.allow_busy = true;
|
||||
this.allow_state = true;
|
||||
this.allow_die = true;
|
||||
this.enter = function (me, arg) {
|
||||
if (arg == "master") {
|
||||
if (!me.query_temp("shifu")) {
|
||||
return me.notify("你还没有师父。");
|
||||
}
|
||||
if (me.query_temp("greet1")) {
|
||||
return me.notify("你今天已经请安过了。");
|
||||
}
|
||||
var user = WORLD.getUser(me.query_temp("shifu"));
|
||||
if (!user) return me.notify("没有这个玩家,或者不在线。");
|
||||
if (user.query_temp("tudi") != me.id) return me.notify("你不是" + user.name + "徒弟,无法请安。");
|
||||
me.notify("你对" + user.name + "说道:师父好。");
|
||||
user.notify("<hic>" + me.name + "恭恭敬敬的向你打招呼:师父好。</hic>");
|
||||
me.add_exp(10000, 10000);
|
||||
me.set_temp("greet1", 1, UTIL.diff_time());
|
||||
} else {
|
||||
var count = parseInt(arg);
|
||||
if (!(count > 0 && count < 100)) return me.notify("数量错误");
|
||||
|
||||
if (!me.query_temp("wife") && !me.query_temp("husband")) {
|
||||
return me.notify("你还没有结婚。");
|
||||
}
|
||||
if (me.query_temp("greet2")) {
|
||||
return me.notify("你本周已经送过花了。");
|
||||
}
|
||||
var user = WORLD.getUser(me.query_temp("wife") || me.query_temp("husband"));
|
||||
if (!user) return me.notify("没有这个玩家,或者不在线。");
|
||||
if (me.money < 1000 * count) {
|
||||
return me.notify("你身上的钱不够,买不起花。");
|
||||
}
|
||||
if (me.query_temp("wife")) {
|
||||
if (user.query_temp("husband") != me.id) return me.notify("你不是" + user.name + "丈夫,无法送花。");
|
||||
me.money -= 1000 * count;
|
||||
me.notify("你购买了" + UTIL.to_c(count) + "朵玫瑰花送给你妻子" + user.name + "。");
|
||||
me.set_temp("greet2", 1, UTIL.diff_week_time());
|
||||
COMMAND.DO("send", user.id, {
|
||||
content: "你的老公" + me.name + "送给你" + UTIL.to_c(count) + "朵玫瑰花。",
|
||||
attach: [
|
||||
{
|
||||
obj: "money/hua",
|
||||
count: count
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
if (user.query_temp("wife") != me.id) return me.notify("你不是" + user.name + "妻子,无法送花。");
|
||||
me.money -= 10000 * count;
|
||||
me.notify("你购买了" + UTIL.to_c(count) + "朵玫瑰花送给你丈夫" + user.name + "。");
|
||||
me.set_temp("greet2", 1, UTIL.diff_week_time());
|
||||
COMMAND.DO("send", user.id, {
|
||||
content: "你的妻子" + me.name + "送给你" + UTIL.to_c(count) + "朵玫瑰花。",
|
||||
attach: [
|
||||
{
|
||||
obj: "money/hua",
|
||||
count: count
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
69
world/cmd/comm/info.js
Normal file
69
world/cmd/comm/info.js
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
this.inherits(COMMAND);
|
||||
this.command = "info";
|
||||
this.allow_busy = true;
|
||||
this.allow_state = true;
|
||||
this.allow_die = true;
|
||||
this.enter = function (me, tid) {
|
||||
let str = [];
|
||||
let notifier = me;
|
||||
if (tid) {
|
||||
if (me.user_level > 0) {
|
||||
me = WORLD.getUser(tid);
|
||||
if (!me)
|
||||
return notifier.send('没有这个角色。');
|
||||
}
|
||||
}
|
||||
|
||||
str.push(me.color_name, '\n');
|
||||
|
||||
str.push('武道塔进度', me.query_temp('wd_level', 0), '层,已累积', this.query_wdcount(me), '份奖励\n');
|
||||
|
||||
str.push('武道残页总量', me.query_temp('wds', 0), '\n');
|
||||
str.push('门派职位等级', me.family.query_task_title(me),
|
||||
',已累积', this.query_smcount(me), '份师门物资\n');
|
||||
str.push('衙门职位等级', YMTITLES[me.query_temp('ym_level', 0)],
|
||||
',已累积', this.query_ymcount(me), '份奖励\n');
|
||||
|
||||
str.push('今日副本次数', me.query_temp('fb_count_day', 0), '/20', '\n');
|
||||
str.push('BOSS挑战', me.query_temp('bcc', 0), '/5', '\n');
|
||||
if (me.query_temp('qingan')) {
|
||||
str.push('已经门派请安', '\n');
|
||||
} else {
|
||||
str.push('尚未请安', '\n');
|
||||
}
|
||||
if (me.level < 5 && me.level > 2) {
|
||||
|
||||
str.push('获取圣元碎片', me.query_temp('mpz', 0), '/1\n');
|
||||
}
|
||||
if (me.level > 3)
|
||||
str.push('获取帝魄碎片', me.query_temp('mpcd', 0), '/1\n');
|
||||
|
||||
str.push('获取额外', me.query_temp('sssc', 0), '/', 500 + me.query_prop('shashou'), '师门功绩\n');
|
||||
str.push('本周已经获取襄阳军功', me.query_temp('jg_week', 0), '/', JUNGONG_LIMITS[me.level], '\n');
|
||||
|
||||
str.push('已领取', me.query_temp('xy_hd', 0) * REWARDS_LIMIT[me.level], '/', REWARDS_LIMIT[me.level] * 5, '奖励军功\n');
|
||||
notifier.send(str.join(""));
|
||||
}
|
||||
|
||||
const REWARDS_LIMIT = [0, 10, 20, 30, 40, 50, 60];//奖励等级对应的每份上限
|
||||
const JUNGONG_LIMITS = [10, 50, 100, 200, 300, 400, 500];//每周功绩上限
|
||||
const YMTITLES = ['', '衙役', '捕快', '捕头', '总捕头', '巡检 ', '神捕'];
|
||||
this.query_wdcount = function (me) {
|
||||
let tm = me.query_temp("wd_tm", 0);
|
||||
if (!tm) return 0;
|
||||
tm = Math.floor((Date.now() - tm * 100000) / 3600000 / 24);
|
||||
return Math.min(tm, 7);
|
||||
}
|
||||
this.query_smcount = function (me) {
|
||||
let sm = me.query_temp("sm_tm", 0);
|
||||
if (!sm) return -1;
|
||||
sm = Math.floor((Date.now() - sm * 100000) / 3600000);
|
||||
return Math.min(sm, 60);
|
||||
}
|
||||
this.query_ymcount = function (me) {
|
||||
let sm = me.query_temp("ym_tm", 0);
|
||||
if (!sm) return 0;
|
||||
sm = Math.floor((Date.now() - sm * 100000) / 3600000);
|
||||
return Math.min(sm, 60);
|
||||
}
|
||||
102
world/cmd/comm/login.js
Normal file
102
world/cmd/comm/login.js
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
this.inherits(COMMAND);
|
||||
this.command = "login";
|
||||
this.allow_login = true;
|
||||
this.enter = function (user, id) {
|
||||
if (user.id) return;
|
||||
|
||||
if (user.serverid !== WORLD.SERVERID) return;
|
||||
|
||||
user.ip_address = user.socket.remoteAddress;
|
||||
const oldUser = this.check_user(user, id);
|
||||
if (!oldUser) return;
|
||||
if (oldUser.id) {
|
||||
this.relogin(oldUser, user);
|
||||
} else {
|
||||
this.loginIn(user, id);
|
||||
}
|
||||
}
|
||||
this.check_user = function (loginuser, id) {
|
||||
for (var i = 0; i < WORLD.USERS.length; i++) {
|
||||
let user = WORLD.USERS[i];
|
||||
if (user.id === id) {
|
||||
return user;
|
||||
}
|
||||
//其他检测loginuser
|
||||
}
|
||||
return {};
|
||||
}
|
||||
this.relogin = function (oldUser, user) {
|
||||
if (oldUser.userid === user.userid) {
|
||||
if (!this.on_user_relogin(oldUser, user) !== false) return;
|
||||
if (oldUser.password !== user.password && oldUser.loginTime > user.loginTime) {
|
||||
return user.send("{type:'loginerror',msg:'密码失效,请<CMD onclick=\\'HideAndShow(\"#login_panel\")\\'>重新登录</CMD>'}");
|
||||
}
|
||||
oldUser.password = user.password;
|
||||
oldUser.loginTime = user.loginTime;
|
||||
|
||||
oldUser.ip_address = user.socket.remoteAddress;
|
||||
oldUser.disconnect(true);
|
||||
user.socket.setTimeout(0);
|
||||
return oldUser.relogin(user);
|
||||
} else {
|
||||
WORLD.log(null, "登陆失败:" + oldUser.id + ",原始ID:"
|
||||
+ oldUser.userid + ",现在ID:" + user.userid);
|
||||
return user.send("{type:'loginerror',msg:'当前使用的登陆凭证和角色不一致'}");
|
||||
}
|
||||
}
|
||||
this.on_user_relogin = function (user, me) {
|
||||
|
||||
if (user.state && user.state.id == "cross") {
|
||||
if (user.state.is_over || Date.now() - user.state.stime > 1800000) {
|
||||
user.moveto(user.query_temp("enter_room") || "yz/wumiao");
|
||||
return true;
|
||||
} else {
|
||||
me.send("{type:'cross',sid:" + user.state.sid + ",pid:'" + user.id + "',cross_type:'" + user.state.cross_type + "'}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
this.loginIn = async function (user, id) {
|
||||
try {
|
||||
const data = await WORLD.DB.getRoleData(user.userid, id);
|
||||
if (!data) return user.send("{type:'loginerror',msg:'角色读取失败,请重新登陆 '}");
|
||||
|
||||
oldUser = WORLD.getUser(id);
|
||||
if (oldUser) return user.send("{type:'loginerror',msg:'重复登录'}");
|
||||
if (data.pwd !== user.password)
|
||||
return user.send("{type:'loginerror',msg:'密码失效,请<CMD onclick=\\'Process.relogin()\\'>重新登录</CMD>'}");
|
||||
|
||||
WORLD.USERS.push(user);
|
||||
|
||||
user.loadData(data);
|
||||
user.do_login();
|
||||
user.wait_input = null;
|
||||
if (user.socket)
|
||||
user.socket.setTimeout(0);
|
||||
this.on_user_login(user);
|
||||
} catch (e) {
|
||||
console.error('登陆失败', e);
|
||||
WORLD.log(user, "登陆失败", e.message);
|
||||
user.send("{type:'loginerror',msg:'数据加载失败'}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
this.on_user_login = function (user) {
|
||||
user.send("欢迎登陆<HIW>MUD游戏</HIW>");
|
||||
|
||||
|
||||
const area = user.environment.parent;
|
||||
area.on_login && area.on_login(user);
|
||||
|
||||
if (user.force_skill.on_relive) {
|
||||
user.force_skill.on_relive(user);
|
||||
}
|
||||
|
||||
}
|
||||
81
world/cmd/comm/rel.js
Normal file
81
world/cmd/comm/rel.js
Normal file
@@ -0,0 +1,81 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "rel";
|
||||
this.allow_busy = true;
|
||||
this.allow_state = true;
|
||||
this.allow_die = true;
|
||||
this.regex = /^(\w+)?(?:\s+(\w+))?$/;
|
||||
this.enter = function (me, type, cmd) {
|
||||
if (type === 'marry') {
|
||||
return me.send('解除夫妻关系,需要到扬州城的衙门找户部主簿办理。');
|
||||
}
|
||||
else if (type === 'st') {
|
||||
if (me.query_temp('tudi'))
|
||||
return me.send('你的徒弟成长为宗师后自动解除关系,或者去扬州衙门办理强制解除。');
|
||||
if (me.query_temp('shifu'))
|
||||
return me.send('你成长为宗师后自动解除关系,或者去扬州衙门办理强制解除。');
|
||||
return me.send('你没有师父或徒弟,不用解除。');
|
||||
|
||||
} else {
|
||||
let target = FOLLOWER.GET(me, { id: type });
|
||||
if (!target) return me.send('你没有这个随从。');
|
||||
if (cmd === 'stop') {
|
||||
if (!target.state) return me.send(target.name + "没有正在进行的工作。");
|
||||
target.set_state(null);
|
||||
return WORLD.COMMANDS.relation.enter(me);
|
||||
}
|
||||
if (target.state) return me.send(target.name + "正在" + target.state.title + "。");
|
||||
let home = me.query_temp('home');
|
||||
if (!home) return me.send('你还没购买住宅。');
|
||||
if (home !== 2) return me.send('你的住宅没有随从工作的地方。');
|
||||
if (target.environment && target.environment.is_fb()) {
|
||||
return me.send(target.name + "正在副本中。");
|
||||
}
|
||||
|
||||
if (cmd === 'diaoyu' || cmd === 'caiyao' || cmd === 'wk') {
|
||||
|
||||
let room = me.query_home('home/huayuan');
|
||||
if (!room) return me.send('你还没购买带有花园的住宅。');
|
||||
//target.set_listener(me, me);
|
||||
if (target.hp <= 0) target.hp = 1;
|
||||
if (target.environment !== room) {
|
||||
target.moveto(room);
|
||||
}
|
||||
if (cmd === 'diaoyu') {
|
||||
var wea = target.query_weapon();
|
||||
if (!wea ||
|
||||
!wea.path.startsWith("sp/tool/diao")) {
|
||||
return me.notify(target.name + "没有装备钓竿不可以钓鱼(进入住宅选择目标随从-背包-装备钓鱼竿)。");
|
||||
}
|
||||
|
||||
var er = query_er(target);
|
||||
if (!er) return me.notify(target.name + "身上没有鱼饵,可以去扬州城的杂货店购买钓竿和鱼饵。");
|
||||
} else if (cmd === 'wk') {
|
||||
if (target.query_skill('guanshanjue', 0) < 100) {
|
||||
return me.notify(target.name + '的观山诀等级太低,无法在小花园挖矿。');
|
||||
}
|
||||
var wea = target.query_weapon();
|
||||
if (!wea ||
|
||||
!wea.path.startsWith("sp/tool/chu")) {
|
||||
return me.notify(target.name + "没有装备铁镐无法挖矿(进入住宅选择目标随从-背包-装备铁镐)。");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
target.do_command(cmd);
|
||||
// me.do_command('dc', target.id + " " + cmd);
|
||||
// target.set_listener(me, null);
|
||||
return WORLD.COMMANDS.relation.enter(me);
|
||||
} else {
|
||||
return me.send('你要让' + target.name + "做什么?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function query_er(me) {
|
||||
for (var i = 0; i < me.items.length; i++) {
|
||||
if (me.items[i].path.startsWith("sp/tool/er#")) {
|
||||
return me.items[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
315
world/cmd/comm/setting.js
Normal file
315
world/cmd/comm/setting.js
Normal file
@@ -0,0 +1,315 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "setting";
|
||||
this.allow_busy = true;
|
||||
this.allow_state = true;
|
||||
this.allow_die = true;
|
||||
this.regex = /^(?:(\w+)?\s+(.+))?$/;
|
||||
this.enter = function (me, key, value) {
|
||||
if (!me.is_player) return;
|
||||
if (!key) {
|
||||
var str = ['{type:"setting",items:{'];
|
||||
|
||||
if (me.setting) {
|
||||
str.push(JSON.stringify(me.setting));
|
||||
}
|
||||
str.push("}}");
|
||||
me.notify(str.join(""));
|
||||
} else {
|
||||
if (key === 'psxk' || key === 'fullscreen') return;
|
||||
|
||||
let setting_item = setting_keys[key];
|
||||
if (!setting_item) return me.notify("无效设定项。");
|
||||
|
||||
|
||||
|
||||
if (setting_item.type === 'String') {
|
||||
if (value && setting_item.length && value.length > setting_item.length) {
|
||||
return me.notify("设定值太长。");
|
||||
}
|
||||
if (value === 'none') value = "";
|
||||
else if (setting_item.def && setting_item.def === value)
|
||||
value = "";
|
||||
|
||||
} else if (setting_item.type === 'Boolean') {
|
||||
value = value || 0;
|
||||
value = parseInt(value);
|
||||
if (value !== 0 && value !== 1) return me.notify("无效设定值。");
|
||||
|
||||
}
|
||||
if (setting_item.on_setting) {
|
||||
if (setting_item.on_setting(me, value) === false) return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (key == "no_message") {
|
||||
me.no_message = (value == 1) ? true : false;
|
||||
}
|
||||
me.set_setting(key, value);
|
||||
|
||||
if (setting_item.desc) {
|
||||
if (setting_item.type === 'String') {
|
||||
if (value && value !== '0') {
|
||||
me.notify("<hic>已设置" + setting_item.desc + "</hic>");
|
||||
} else {
|
||||
me.notify("<cyn>已取消" + setting_item.desc + "</cyn>");
|
||||
}
|
||||
} else if (setting_item.type === 'Boolean') {
|
||||
if (value) {
|
||||
me.notify("<hic>已开启" + setting_item.desc + "</hic>");
|
||||
} else {
|
||||
me.notify("<cyn>已关闭" + setting_item.desc + "</cyn>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//var parent = me.environment;
|
||||
//if (!parent) return;
|
||||
//switch (key) {
|
||||
// case "exits_map":
|
||||
// parent.send_exits(me);
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
}
|
||||
this.clear = function (me) {
|
||||
let str = [];
|
||||
for (let user of WORLD.USERS) {
|
||||
if (!user.settings) continue;
|
||||
for (let key in user.settings) {
|
||||
if (!setting_keys[key]) {
|
||||
str.push(user.name, key, '\n');
|
||||
delete user.settings[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (me) me.send(str.join(''));
|
||||
}
|
||||
const setting_keys = {
|
||||
'hide_roomdesc': {
|
||||
type: "Boolean",
|
||||
desc: "隐藏房间描述"
|
||||
}, 'exits_dir': {
|
||||
type: "Boolean",
|
||||
desc: "出口描述使用方向描述"
|
||||
},
|
||||
'show_command': {
|
||||
type: "Boolean",
|
||||
desc: "列出NPC或道具的可用命令"
|
||||
|
||||
},
|
||||
'show_roomitem': {
|
||||
type: "Boolean",
|
||||
desc: "在命令栏列出房间内的可用物品"
|
||||
|
||||
}, 'item_firstme': {
|
||||
type: "Boolean",
|
||||
desc: "列出NPC自己始终显示在房间物品第一列"
|
||||
|
||||
},
|
||||
'keep_msg': {
|
||||
type: "Boolean",
|
||||
desc: "切换房间时不清空上房间信息"
|
||||
|
||||
}, 'off_move': {
|
||||
type: "Boolean",
|
||||
desc: "不显示玩家进出房间描述"
|
||||
},
|
||||
'off_plist': {
|
||||
type: "Boolean",
|
||||
desc: "隐藏玩家列表"
|
||||
|
||||
}, 'no_spmsg': {
|
||||
type: "Boolean",
|
||||
desc: "聊天信息不分开显示"
|
||||
|
||||
},
|
||||
'auto_sortitem': {
|
||||
type: "Boolean",
|
||||
desc: "按品质自动排列背包和技能"
|
||||
|
||||
}, 'no_message': {
|
||||
type: "Boolean",
|
||||
desc: " 不显示其他玩家或NPC的房间消息"
|
||||
|
||||
},
|
||||
'auto_showcombat': {
|
||||
type: "Boolean",
|
||||
desc: "战斗时自动打开战斗面板"
|
||||
|
||||
}, 'auto_hideroom': {
|
||||
type: "Boolean",
|
||||
desc: "战斗时自动隐藏房间信息"
|
||||
|
||||
},
|
||||
'no_combatmsg': {
|
||||
type: "Boolean",
|
||||
desc: "不显示其他玩家的战斗信息"
|
||||
|
||||
}, 'no_mcmsg': {
|
||||
type: "Boolean",
|
||||
desc: "不显示自己的普通战斗信息"
|
||||
|
||||
},
|
||||
'combat_wrap': {
|
||||
type: "Boolean",
|
||||
desc: "技能栏允许换行"
|
||||
|
||||
},
|
||||
'action_wrap': {
|
||||
type: "Boolean",
|
||||
desc: "动作栏允许换行"
|
||||
|
||||
},
|
||||
|
||||
'show_hpnum': {
|
||||
type: "Boolean",
|
||||
desc: "显示血量为数字"
|
||||
|
||||
},
|
||||
'off_hp': {
|
||||
type: "Boolean",
|
||||
desc: "关闭血条显示"
|
||||
|
||||
}, 'show_damage': {
|
||||
type: "Boolean",
|
||||
desc: "显示伤害统计"
|
||||
|
||||
}, 'show_sa': {
|
||||
type: "Boolean",
|
||||
desc: "显示快捷动作"
|
||||
|
||||
},
|
||||
'font': {
|
||||
type: "String",
|
||||
length: 10,
|
||||
desc: "字体"
|
||||
},
|
||||
'combat_size': {
|
||||
type: "String",
|
||||
length: 10,
|
||||
desc: "操作栏大小",
|
||||
def: "1em"
|
||||
},
|
||||
'dialog_size': {
|
||||
type: "String",
|
||||
length: 10,
|
||||
desc: "窗口大小",
|
||||
def: "1em"
|
||||
},
|
||||
'menu_size': {
|
||||
type: "String",
|
||||
length: 10,
|
||||
desc: "菜单栏大小",
|
||||
def: "1em"
|
||||
},
|
||||
'fontsize': {
|
||||
type: "String",
|
||||
length: 10,
|
||||
desc: "字体大小",
|
||||
def: "0.875rem"
|
||||
|
||||
}, 'fontcolor': {
|
||||
type: "String",
|
||||
length: 20,
|
||||
desc: "正常字体颜色",
|
||||
def: "#008000"
|
||||
|
||||
}, 'backcolor': {
|
||||
type: "String",
|
||||
length: 20,
|
||||
desc: "背景颜色"
|
||||
|
||||
}, 'hide_equip': {
|
||||
type: "Boolean",
|
||||
desc: "隐藏自己的装备"
|
||||
},
|
||||
'off_fight': {
|
||||
type: "Boolean",
|
||||
desc: "不接受比试"
|
||||
|
||||
}, 'ban_pk': {
|
||||
type: "Boolean",
|
||||
desc: "",
|
||||
on_setting: function (me, value) {
|
||||
if (value == 1) {
|
||||
if (me.query_setting("ban_pk")) return false;
|
||||
// if (me.level >= 3) return me.notify("你已经是宗师,不再需要保护了。");
|
||||
if (me.query_temp("pk")) {
|
||||
return me.notify_fail("<hir>你最近7天内关闭过PK保护或击杀过其他玩家,需要一段时间后才可以再次打开保护。</hir>");
|
||||
}
|
||||
me.notify("你已开启PK保护,不可主动击杀玩家,不可被玩家主动击杀。");
|
||||
me.set_temp("pk", 1, 24 * 3600000 * 7);
|
||||
|
||||
} else {
|
||||
if (!me.query_setting("ban_pk")) return false;
|
||||
me.notify("你已关闭PK保护。");
|
||||
}
|
||||
}
|
||||
|
||||
}, 'no_master': {
|
||||
type: "Boolean",
|
||||
desc: "不接受玩家拜师"
|
||||
|
||||
}, 'no_team': {
|
||||
type: "Boolean",
|
||||
desc: "不接受玩家组队邀请"
|
||||
|
||||
},
|
||||
'off_chat': {
|
||||
type: "Boolean",
|
||||
desc: "屏蔽公共频道"
|
||||
|
||||
}, 'off_fam': {
|
||||
type: "Boolean",
|
||||
desc: "屏蔽门派频道"
|
||||
|
||||
},
|
||||
'off_es': {
|
||||
type: "Boolean",
|
||||
desc: "屏蔽全区频道"
|
||||
|
||||
}, 'off_pty': {
|
||||
type: "Boolean",
|
||||
desc: "屏蔽帮派频道"
|
||||
|
||||
},
|
||||
'auto_get': {
|
||||
type: "Boolean",
|
||||
desc: "击杀NPC后自动拾取战利品"
|
||||
|
||||
}, 'auto_pfm': {
|
||||
type: "String",
|
||||
length: 300,
|
||||
desc: "击杀玩家或NPC时自动出招"
|
||||
|
||||
},
|
||||
'show_cus': {
|
||||
type: "Boolean",
|
||||
desc: "允许其他玩家查看自己的自创武功"
|
||||
|
||||
},
|
||||
'auto_pfm2': {
|
||||
type: "String",
|
||||
length: 300,
|
||||
desc: "被玩家击杀时自动反击"
|
||||
|
||||
}, 'auto_work': {
|
||||
type: "String",
|
||||
length: 400,
|
||||
desc: "",
|
||||
on_setting: function (me, value) {
|
||||
|
||||
if (!value || value === '0')
|
||||
return me.notify('<cyn>已关闭学习,练习,打坐中断后的自动操作</hic>');
|
||||
if (value === '1') {
|
||||
return me.notify('<hic>已设置学习,练习,打坐中断后,自动去挖矿</hic>');
|
||||
}
|
||||
return me.notify('<hic>已设置学习,练习,打坐中断后的自动操作</hic>');
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
30
world/cmd/comm/shortcut.js
Normal file
30
world/cmd/comm/shortcut.js
Normal file
@@ -0,0 +1,30 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "shortcut";
|
||||
this.allow_busy = true;
|
||||
this.allow_state = true;
|
||||
this.allow_die = true;
|
||||
this.allow_faint = true;
|
||||
this.enter = function (player, arg) {
|
||||
if (!arg) return;
|
||||
var obj = player.find_obj(arg);
|
||||
if (!obj) {
|
||||
return player.notify("你身上没有这个东西。");
|
||||
}
|
||||
|
||||
if (obj.is_equipment) {
|
||||
if (obj.eq_type != EQUIP_TYPE.WEAPON) return player.notify("你目前只能设置武器的快捷操作。");
|
||||
} else if (!obj.on_use){
|
||||
return player.notify("这个道具不可以设置快捷操作。");
|
||||
}
|
||||
if (obj.is_shortcut) {
|
||||
obj.is_shortcut = false;
|
||||
player.notify("你取消了" + obj.color_name + "的快速设置。");
|
||||
player.send("{type:'removeAction',id:'" + obj.id + "'}");
|
||||
} else {
|
||||
obj.is_shortcut = true;
|
||||
player.notify("你设置了" + obj.color_name + "的快速使用。");
|
||||
|
||||
player.send("{type:'addAction',id:'" + obj.id + "',name:'" + obj.name + "'}");
|
||||
|
||||
}
|
||||
}
|
||||
221
world/cmd/comm/sx.js
Normal file
221
world/cmd/comm/sx.js
Normal file
@@ -0,0 +1,221 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "sx";
|
||||
this.allow_busy = true;
|
||||
this.allow_state = true;
|
||||
this.allow_die = true;
|
||||
this.regex = /^(\w+)(?:\s+(\w+))?(?:\s+(\w+))?$/;
|
||||
this.enter = function (me, type, par1, par2) {
|
||||
if (type === 'greet') {
|
||||
this.do_greet(me);
|
||||
} else {
|
||||
this.do_manage(me, par1, par2);
|
||||
}
|
||||
}
|
||||
this.do_greet = function (me) {
|
||||
let npc = me.family.first_npc;
|
||||
if (!npc) return me.send('首席目前不在线。');
|
||||
if (me.level > 5) return me.notify("堂堂武神大人就不要凑热闹了好吧。");
|
||||
if (npc.family != me.family) {
|
||||
return me.notify("你又不是" + npc.family.name + "弟子,凑什么热闹。");
|
||||
}
|
||||
if (WORLD.DATA.query_temp(npc.family.id + "_top") == me.id) {
|
||||
return me.notify("你自己就是" + npc.title + ",凑什么热闹。");
|
||||
}
|
||||
if (me.query_temp('qingan')) return me.notify("每天请一次安就可以了,多了会惹人烦的。");
|
||||
|
||||
var user = WORLD.getUser(WORLD.DATA.query_temp(npc.family.id + "_top"));
|
||||
|
||||
var userexp = npc.exp || Number.MAX_VALUE;
|
||||
if (user) userexp = user.exp;
|
||||
|
||||
var ch = npc.gender == 1 ? "师兄" : "师姐";
|
||||
if (me.query_age() > npc.age) {
|
||||
ch = npc.gender == 1 ? "师弟" : "师妹";
|
||||
}
|
||||
var val = 10000 + me.level * 10000;
|
||||
|
||||
me.set_temp('qingan', 1, UTIL.diff_time());
|
||||
//UTIL.add_task(me, 'qa', 1);
|
||||
if (userexp < me.exp) {
|
||||
me.send_room("$N向$n拱手道:" + npc.name + "" + ch + "好。", npc);
|
||||
|
||||
// if (WORLD.is_server(me) && userexp < me.exp * 0.9) {
|
||||
|
||||
// WORLD.DATA.add_temp(fam.id + '_greetings', parseInt(val / 2));
|
||||
// }
|
||||
|
||||
} else {
|
||||
me.send_room("$N向$n恭恭敬敬的一鞠躬:" + npc.name + "" + ch + ",神功盖世,千秋万代。", npc);
|
||||
}
|
||||
me.add_exp(val, val);
|
||||
}
|
||||
this.check_power = function (me, npc) {
|
||||
if (npc.family != me.family) {
|
||||
return me.notify_fail("你又不是" + npc.family.name + "弟子,凑什么热闹。");
|
||||
}
|
||||
if (WORLD.DATA.query_temp(npc.family.id + "_top") !== me.id) {
|
||||
return me.notify_fail("你不是" + npc.title + ",不能更改设置。");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// this.add_action('manage1', null, function (me, paras) {
|
||||
|
||||
// if (!this.check_power(me)) return;
|
||||
// if (WORLD.DATA.query_temp(this.family.id + "_buff", 0))
|
||||
// return me.send('今天已经设置过增益效果了。');
|
||||
// console.log(paras)
|
||||
// });
|
||||
|
||||
|
||||
this.do_manage = function (me, par1, par2) {
|
||||
let npc = me.family.first_npc;
|
||||
if (!npc) return me.send('你的门派还没有首席弟子。');
|
||||
if (!this.check_power(me, npc)) return;
|
||||
if (par1) {
|
||||
if (par1 === 'buff')
|
||||
return this.manage_buff(me, par2);
|
||||
|
||||
if (par1 === 'battle')
|
||||
return this.manage_battle(me, par2);
|
||||
}
|
||||
|
||||
me.send("你是" + npc.title + ",可以更改一些设置。");
|
||||
me.send_commands('sx manage buff', '设置增益', 'sx manage battle', '发起门派战争');
|
||||
}
|
||||
|
||||
this.manage_buff = function (me, par2) {
|
||||
let buff = me.family.query_temp("buff", 0);
|
||||
if (buff >= 1)
|
||||
return me.send('今天已经设置过门派增益了。');
|
||||
|
||||
if (!par2) {
|
||||
me.send('你可以设置以下增益效果,持续一小时:');
|
||||
return me.send_commands('sx manage buff xue', '学习效率+20%',
|
||||
'sx manage buff lianxi', '练习效率+20%',
|
||||
'sx manage buff dazuo', '打坐效率+20%');
|
||||
}
|
||||
let msg = null;
|
||||
switch (par2) {
|
||||
case "xue":
|
||||
me.family.add_temp("study_per", 20, 3600000);
|
||||
msg = "学习效率";
|
||||
break;
|
||||
case "lianxi":
|
||||
me.family.add_temp("lianxi_per", 20, 3600000);
|
||||
msg = "练习效率";
|
||||
break;
|
||||
case "dazuo":
|
||||
me.family.add_temp("dazuo_per", 20, 3600000);
|
||||
msg = "打坐效率";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
me.family.add_temp("buff", 1, UTIL.diff_time());
|
||||
me.send('<cyn>设置完成,全体门派增益效果:' + msg + '+20%</cyn>');
|
||||
|
||||
me.family.send_channel(me, "已设置全体门派增益效果:" + msg + "+20%");
|
||||
|
||||
if (!me.query_temp('qingan')) {
|
||||
var val = 10000 + me.level * 10000;
|
||||
me.add_exp(val, val);
|
||||
me.set_temp('qingan', 1, UTIL.diff_time());
|
||||
}
|
||||
}
|
||||
const FAMS = ['WUDANG', 'SHAOLIN', 'HUASHAN', 'EMEI', 'GAIBANG', 'XIAOYAO'];
|
||||
this.manage_battle = function (me, par2) {
|
||||
if (me.family === FAMILIES.NONE)
|
||||
return me.send('你无门无派,要干什么?');
|
||||
if (me.family === FAMILIES.SHASHOU)
|
||||
return this.manage_battle2(me, par2);
|
||||
if (me.family.battle_family)
|
||||
return me.send('你的门派正在和' + FAMILIES[me.family.battle_family].name + "进行战争。");
|
||||
|
||||
if (me.family.query_temp("sxwar", 0) > 0)
|
||||
return me.send('今天已经开启过门派战争了。');
|
||||
if (me.family.query_temp('battle')) {
|
||||
// let time = me.family.temp["battle"].e - Date.now();
|
||||
// if (time > 20 * 60000) {
|
||||
// return me.send("你的门派刚结刚束战争,需要休养。");
|
||||
// }
|
||||
return me.send("你的门派刚结刚束战争,需要休养。");
|
||||
}
|
||||
if (!par2) {
|
||||
var str = ["{type:\"cmds\",items:["];
|
||||
for (var key of FAMS) {
|
||||
let fam = FAMILIES[key];
|
||||
if (fam === me.family || fam.battle_family || fam.query_temp('battle')) continue;
|
||||
if (str.length > 1) str.push(",");
|
||||
str.push("{cmd:\"sx manage battle ");
|
||||
str.push(key);
|
||||
str.push("\",name:\"", "向", fam.name, '宣战');
|
||||
str.push("\"}");
|
||||
}
|
||||
if (str.length == 1) {
|
||||
return me.notify("当前没有可宣战的门派。");
|
||||
}
|
||||
str.push("]}");
|
||||
|
||||
me.send('选择你要进攻的门派:');
|
||||
return me.send(str.join(""));
|
||||
}
|
||||
let fam = FAMILIES[par2];
|
||||
if (!fam || fam === me.family) return me.send('你要进攻哪个门派?');
|
||||
if (fam.battle_family)
|
||||
return me.send(fam.name + '正在和' + FAMILIES[fam.battle_family].name + "进行战争。");
|
||||
if (fam.query_temp('battle'))
|
||||
return me.send(fam.name + '刚结束战斗,趁人之危非君子所为。');
|
||||
me.family.set_temp("sxwar", 1, UTIL.diff_time());
|
||||
me.family.check_battle(me, null, fam);
|
||||
me.family.send_channel(me, "所有门下弟子听令,开始进攻" + fam.name);
|
||||
}
|
||||
|
||||
this.manage_battle2 = function (me, par2) {
|
||||
if (me.family.query_temp("sxwar", 0) >= 5)
|
||||
return me.send('杀手楼每天最多可介入5次其他门派的战争。');
|
||||
if (me.family.query_temp('battle')) {
|
||||
return me.send("你的门派正在战斗。");
|
||||
}
|
||||
if (!par2) {
|
||||
var str = ["{type:\"cmds\",items:["];
|
||||
for (var key of FAMS) {
|
||||
let fam = FAMILIES[key];
|
||||
if (fam === me.family || !fam.battle_family) continue;
|
||||
if (str.length > 1) str.push(",");
|
||||
str.push("{cmd:\"sx manage battle ");
|
||||
str.push(key);
|
||||
str.push("\",name:\"", "进攻", fam.name);
|
||||
str.push("\"}");
|
||||
}
|
||||
if (str.length == 1) {
|
||||
return me.notify("当前没有正在战斗中的门派。");
|
||||
}
|
||||
str.push("]}");
|
||||
|
||||
me.send('选择你要趁乱进攻的门派:');
|
||||
return me.send(str.join(""));
|
||||
}
|
||||
|
||||
let fam = FAMILIES[par2];
|
||||
if (!fam || fam === me.family) return me.send('你要进攻哪个门派?');
|
||||
if (!fam.battle_family)
|
||||
return me.send(fam.name + '没有发生战争,你无法介入 。');
|
||||
sxwar = me.family.add_temp("sxwar", 1, UTIL.diff_time());
|
||||
me.family.add_temp('battle', 1, 3600000);
|
||||
me.family.set_temp('ss_target', fam.id, 3600000);
|
||||
me.family.send_channel(me, "门下所有杀手听令,开始进攻" + fam.name);
|
||||
me.send('<cyn>已选择' + fam.name + '作为目标门派,本日已开启' + sxwar + '/5次。</cyn>');
|
||||
|
||||
EVENTS.add({
|
||||
id: "SHASHOU_bat",
|
||||
name: "门派战争",
|
||||
desc: "你的门派正在进攻" + fam.name + ",击杀对方弟子会获得丰厚奖励。",
|
||||
time: fam.temp.battle.e,
|
||||
grade: 2,
|
||||
command: "进入战场",
|
||||
check: (me) => me.family === FAMILIES.SHASHOU,
|
||||
on_command: function (me) {
|
||||
me.do_command('goto', 'fam3');
|
||||
}
|
||||
});
|
||||
}
|
||||
22
world/cmd/comm/systask.js
Normal file
22
world/cmd/comm/systask.js
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
this.inherits(COMMAND);
|
||||
this.command = "systask";
|
||||
this.regex = /(\w+)\s+(\w+)?/;
|
||||
this.enter = function (me, arg, par) {
|
||||
if (!arg) return false;
|
||||
var task = TASK.GET(arg);
|
||||
if (!task) return false;
|
||||
if (me.user_level < 5) {
|
||||
let cmds = task.allow_commands;
|
||||
if (!cmds || !cmds[par])
|
||||
return false;
|
||||
}
|
||||
var func = task[par];
|
||||
if (!func) return;
|
||||
func.call(task, me);
|
||||
}
|
||||
|
||||
const ALLOW_COMMANDS = {
|
||||
bm: true,
|
||||
reward: true
|
||||
};
|
||||
234
world/cmd/comm/team.js
Normal file
234
world/cmd/comm/team.js
Normal file
@@ -0,0 +1,234 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "team";
|
||||
this.allow_busy = true;
|
||||
this.allow_state = true;
|
||||
this.allow_die = true;
|
||||
this.allow_faint = true;
|
||||
this.regex = /^(add|with|remove|out|reply|dismiss|set)?(?:\s(\w+))?$/;
|
||||
this.enter = function (me, act, user) {
|
||||
if (act) {
|
||||
var func = this["team_" + act];
|
||||
return func && func.call(this, me, user);
|
||||
} else {
|
||||
|
||||
me.send(teamToString(me));
|
||||
}
|
||||
|
||||
}
|
||||
function teamToString(me) {
|
||||
var str = ['{"type":"dialog","dialog":"team","items":['];
|
||||
if (me.team) {
|
||||
for (var i = 0; i < me.team.length; i++) {
|
||||
var p = me.team[i];
|
||||
|
||||
str.push("{id:\"");
|
||||
str.push(p.id);
|
||||
str.push("\",name:\"");
|
||||
str.push(p.long_name());
|
||||
str.push("\"}");
|
||||
if (i != me.team.length - 1) {
|
||||
str.push(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
str.push("]}");
|
||||
return str.join("");
|
||||
}
|
||||
this.team_set = function (me, arg) {
|
||||
if (!me.team) return me.notify("你没有组队。");
|
||||
if (!arg) {
|
||||
me.notify("目前队伍的分配方式是:" + (me.team.free_get ? "自由拾取" : "需求分配"));
|
||||
if (me.team.free_get) {
|
||||
me.send_commands("team set allot_get", "更改为按需求分配");
|
||||
} else {
|
||||
me.send_commands("team set free_get", "更改为自由拾取");
|
||||
}
|
||||
return;
|
||||
}
|
||||
switch (arg) {
|
||||
case "free_get":
|
||||
me.team.free_get = true;
|
||||
me.send_team("<hig>拾取方式已设置为自由拾取。</hig>");
|
||||
break;
|
||||
case "allot_get":
|
||||
me.team.free_get = false;
|
||||
me.send_team("<hig>拾取方式已设置为需求分配。</hig>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.team_with = function (me, user) {
|
||||
var player = me.find_obj(user, me.environment);
|
||||
if (!player) return me.notify("没有这个玩家,或者不在线");
|
||||
if (player.master != me.id) return me.notify(player.name + "拒绝了你的组队邀请。");
|
||||
if (player.team) return me.notify(player.name + "已加入组队,无法接受你的请求。");
|
||||
if (me.environment.is_fb()) return me.notify("你正在副本,无法邀请别人。");
|
||||
if (me.environment.parent.no_team) return me.notify("你正在副本,无法邀请别人。");
|
||||
if (me.team) {
|
||||
if (me.team.length > 4) {
|
||||
return me.notify("你的队伍人数已满。");
|
||||
}
|
||||
}
|
||||
player.set_temp("team", me.id);
|
||||
|
||||
this.team_reply(player, "ok");
|
||||
}
|
||||
this.team_add = function (me, user) {
|
||||
var player = WORLD.getUser(user);
|
||||
if (!player) {
|
||||
//player = me.find_obj(user, me.environment);
|
||||
//if (player) {
|
||||
// return me.notify(player.name + "已加入组队,无法接受你的请求。");
|
||||
//}
|
||||
|
||||
return me.notify("没有这个玩家,或者不在线");
|
||||
}
|
||||
if (player.serverid !== me.serverid) return me.notify("你不能组他。");
|
||||
if (player === me) return;
|
||||
if (player.query_setting('no_team')) return me.notify(player.name + "目前不接受组队邀请。");
|
||||
|
||||
if (player.team) return me.notify(player.name + "已加入组队,无法接受你的请求。");
|
||||
if (me.environment.is_fb()) return me.notify("你正在副本,无法邀请别人。");
|
||||
if (me.environment.parent.no_team) return me.notify("你正在副本,无法邀请别人。");
|
||||
if (player.query_temp('team') == me.id) return me.notify("你已经邀请过" + player.name + "了,正在等待回应。");
|
||||
|
||||
if (me.team) {
|
||||
if (me.team.length > 4) {
|
||||
return me.notify("你的队伍人数已满。");
|
||||
}
|
||||
for (var i = 0; i < me.team.length; i++) {
|
||||
if (me.team[i].environment && me.team[i].environment.is_fb()) {
|
||||
return me.notify("你的队伍已经开启副本,无法增加队员。");
|
||||
}
|
||||
}
|
||||
}
|
||||
player.send("<hic>" + me.name + "邀请你加入组队,是否同意?</hic>");
|
||||
player.send_commands("team reply ok", "同意", "team reply no", "不同意");
|
||||
player.set_temp("team", me.id, 10000);
|
||||
me.send("<hig>已经发送对" + player.name + "的组队邀请。</hig>");
|
||||
}
|
||||
this.team_reply = function (me, act) {
|
||||
var p = me.query_temp("team");
|
||||
if (!p) return me.send("没有人邀请你组队,或邀请已过期。");
|
||||
var player = WORLD.getUser(p);
|
||||
if (!player) me.send("没有人邀请你组队,或邀请已过期。");
|
||||
if (act == "ok") {
|
||||
if (me.team) return me.send("你已经有队伍了。");
|
||||
if (me.environment && me.environment.parent.is_copy && !me.environment.parent.not_fb) {
|
||||
return me.send("你目前正在副本中,无法加入队伍。");
|
||||
}
|
||||
|
||||
if (me.environment.parent.no_team) return me.notify("你正在副本,无法加入队伍。");
|
||||
if (!player.team) {
|
||||
//如果开始组队的玩家没有队伍就先创建个
|
||||
player.team = [];
|
||||
player.team.alloc = team_dice;
|
||||
player.team.id = UTIL.create_id();
|
||||
player.team.push(player);
|
||||
} else if (player.team.length > 4) {
|
||||
return me.send("<red>" + player.name + "队伍人数已经满了。</red>");
|
||||
}
|
||||
player.team.push(me);
|
||||
me.team = player.team;
|
||||
me.send_team("<hig>" + me.name + "加入队伍。</hig>");
|
||||
me.send_team(teamToString(me));
|
||||
me.on_teamin && me.on_teamin(player);
|
||||
} else {
|
||||
player.send("<red>" + me.name + "拒绝了你的邀请。</red>");
|
||||
me.send("<hic>你拒绝了" + player.name + "的邀请。</hic>");
|
||||
}
|
||||
me.remove_temp("team");
|
||||
}
|
||||
function team_dice(obj) {
|
||||
if (!this.objs || this.objs.indexOf(obj) == -1) return;
|
||||
var me = this[0];
|
||||
if (!me) {
|
||||
for (let i = 0; i < this.objs.length; i++) {
|
||||
this.objs[i].dice = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!obj.dice || !obj.dice.user) {
|
||||
me.send_team(obj.color_name + "所有人都放弃。");
|
||||
return;
|
||||
}
|
||||
var userid = obj.dice.user;
|
||||
|
||||
var player = null;
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
if (this[i].id == userid) {
|
||||
player = this[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!player) {
|
||||
obj.dice = null;
|
||||
this.objs.remove(obj);
|
||||
return me.notify("战利品分配失败,玩家不在队伍。");
|
||||
}
|
||||
obj.dice = null;
|
||||
this.objs.remove(obj);
|
||||
player.add_obj(obj);
|
||||
player.send_team(player.name + "获得" + UTIL.to_c(obj.count) + obj.unit + obj.color_name + "。");
|
||||
}
|
||||
this.team_remove = function (me, user) {
|
||||
var tm = me.team;
|
||||
if (!tm) return me.notify("你还没有加入队伍。");
|
||||
if (me != tm[0]) return me.notify("你不是队长没有权利移除队员。");
|
||||
for (var i = 1; i < tm.length; i++) {
|
||||
var player = tm[i];
|
||||
if (player.id == user) {
|
||||
if (player.environment && player.environment.is_fb()) return me.notify(player.name + "现在正在副本区域,不能移除。");
|
||||
player.send("<red>你被移除出了队伍。</red>");
|
||||
player.on_teamout && player.on_teamout(me);
|
||||
player.team = null;
|
||||
tm.splice(i, 1);
|
||||
|
||||
me.send_team("<hic>" + player.name + "被移出组队。</hic>");
|
||||
me.send_team('{"type":"dialog","dialog":"team",remove:"' + player.id + '"}');
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tm.length == 1) {
|
||||
me.send("<hic>你的队伍解散了。</hic>");
|
||||
me.send('{"type":"dialog","dialog":"team",dismiss:true}');
|
||||
tm.length = 0;
|
||||
me.team = null;
|
||||
checkTeamfb(me);
|
||||
}
|
||||
}
|
||||
this.team_dismiss = function (me) {
|
||||
if (!me.team) return me.notify("你没有加入队伍。");
|
||||
if (me != me.team[0]) return me.notify("你不是队长没有权利解散队伍。");
|
||||
for (var i = 0; i < me.team.length; i++) {
|
||||
var tm = me.team[i];
|
||||
if (tm.environment.is_fb())
|
||||
return me.notify((tm == me ? "你" : tm.name) + "现在正在副本区域,不能解散队伍。");
|
||||
}
|
||||
for (var i = 0; i < me.team.length; i++) {
|
||||
var tm = me.team[i];
|
||||
tm.send("<hic>你的队伍解散了。</hic>");
|
||||
tm.send('{"type":"dialog","dialog":"team",dismiss:true}');
|
||||
if (tm != me) {
|
||||
tm.on_teamout && tm.on_teamout(me);
|
||||
tm.team = null;
|
||||
}
|
||||
}
|
||||
|
||||
me.team.length = 0;
|
||||
me.team = null;
|
||||
checkTeamfb(me);
|
||||
}
|
||||
this.team_out = function (me) {
|
||||
if (!me.team) return me.notify("你没有加入队伍。");
|
||||
if (me.environment.is_fb()) return me.notify("你现在正在副本区域,不能离开队伍。");
|
||||
me.team_out("退出队伍");
|
||||
}
|
||||
|
||||
function checkTeamfb(me) {
|
||||
if (me.environment && me.environment.is_fb()) {
|
||||
WORLD.COMMANDS['cr'].enter(me, 'over')
|
||||
me.notify("<hic>你退出了队伍,自动离开副本。</hic>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
35
world/cmd/comm/title.js
Normal file
35
world/cmd/comm/title.js
Normal file
@@ -0,0 +1,35 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "title";
|
||||
this.allow_busy = true;
|
||||
this.allow_state = true;
|
||||
this.enter = function(me, index) {
|
||||
if (!me.titles) return me.notify("你还没有任何称号。");
|
||||
index = parseInt(index);
|
||||
if (!(index >= 0 && index < me.titles.length)) return me.notify("你没有这个称号。");
|
||||
var title = null;
|
||||
for (var i = 0; i < me.titles.length; i++) {
|
||||
if (i == index) {
|
||||
if (me.titles[i].use) {
|
||||
me.titles[i].use = false;
|
||||
} else {
|
||||
title = me.titles[i];
|
||||
title.use = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
me.titles[i].use = false;
|
||||
}
|
||||
}
|
||||
if (title) {
|
||||
me.title = title.title;
|
||||
me.notify("你决定使用" + title.title + "做为你的称号。");
|
||||
|
||||
} else {
|
||||
me.title = null;
|
||||
me.notify("你决定不使用任何称号。");
|
||||
|
||||
}
|
||||
me.color_name = null;
|
||||
me.environment.item_changed(me, true);
|
||||
|
||||
}
|
||||
50
world/cmd/comm/zigong.js
Normal file
50
world/cmd/comm/zigong.js
Normal file
@@ -0,0 +1,50 @@
|
||||
this.inherits(COMMAND);
|
||||
this.command = "zigong";
|
||||
this.enter = function (me, arg) {
|
||||
if (me.gender == 2) return me.notify("你要割什么?");
|
||||
if (me.gender == 3) return me.notify("你都没有了还要割什么?");
|
||||
var list = [];
|
||||
for (var key in me.skills) {
|
||||
var skill = SKILL.get(key);
|
||||
if (skill.learn_condition) {
|
||||
if (skill.learn_condition.gender &&
|
||||
skill.learn_condition.gender != 3) {
|
||||
list.push(skill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arg=="ok") {
|
||||
var weap = me.query_weapon_type();
|
||||
if (weap == WEAPON_TYPE.NONE) return me.notify("好歹准备个好用的工具吧?");
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (me.remove_skill(list[i].id)) {
|
||||
me.notify('{type:"dialog",dialog:"skills",remove:"' + list[i].id + '"}');
|
||||
}
|
||||
}
|
||||
me.send_room("<hic>$N一咬牙,褪下下衣,伸出" + me.weapon_name() + "插到$P两腿之间,飞速一剜,……\n\n</hic>");
|
||||
me.add_status({
|
||||
id: "faint",
|
||||
is_faint: true,
|
||||
duration: 10000,
|
||||
name: "昏迷", downside: true,
|
||||
finish_msg: "<hiy>慢慢的$N又恢复了知觉...</hiy>\n",
|
||||
start_msg: "<hir>$N顿时惨叫一声昏了过去……</hir>\n"
|
||||
});
|
||||
me.gender = 3;
|
||||
} else {
|
||||
|
||||
var str = ["<hir>你可想好了,割了可就没了!</hir>"];
|
||||
if (list.length) {
|
||||
str.push("\n<hir>以下武功将会被遗忘:");
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
str.push("\n");
|
||||
str.push(list[i].color_name);
|
||||
}
|
||||
str.push("</hir>");
|
||||
}
|
||||
me.send(str.join(""));
|
||||
me.send_commands("zigong ok","确认不要了");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user