init: add workspace files
This commit is contained in:
281
world/task/boss_task.js
Normal file
281
world/task/boss_task.js
Normal file
@@ -0,0 +1,281 @@
|
||||
|
||||
this.inherits(TASK);
|
||||
this.id = "boss";
|
||||
const BOSSTASK = this;
|
||||
this.startup = function () {
|
||||
// this.call_out(this.run, this.random(100000));//this.random(600000)+600000
|
||||
this.check_time();
|
||||
}
|
||||
|
||||
this.stop = function () {
|
||||
if (this.time_handler) clearTimeout(this.time_handler);
|
||||
if (this.boss && this.boss.length) {
|
||||
for (var i = 0; i < this.boss.length; i++) {
|
||||
|
||||
this.boss[i].destroy(this.boss[i].name + "离开了。");
|
||||
}
|
||||
this.boss.length = 0;
|
||||
this.boss = null;
|
||||
}
|
||||
this.time_handler = null;
|
||||
}
|
||||
this.check_time = function () {
|
||||
var dt = new Date();
|
||||
var week = dt.getDay();
|
||||
var hour = dt.getHours();
|
||||
if (hour == 21) {
|
||||
var min = dt.getMinutes();
|
||||
this.next_time = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate(), hour, (parseInt((min + 5) / 5)) * 5, 20);
|
||||
|
||||
} else if (hour == 20) {
|
||||
this.next_time = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate(), 21, 0, 20);
|
||||
} else {
|
||||
this.next_time = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate(), hour + 1, 6 + this.random(50), 20);
|
||||
}
|
||||
|
||||
this.time_handler = this.call_out(this.run, this.next_time - dt);
|
||||
}
|
||||
this.quickly = false;
|
||||
this.boss = null;
|
||||
this.boss_count = 1;
|
||||
this.quick = function () {
|
||||
if (this.quickly) this.quickly = false;
|
||||
else this.quickly = true;
|
||||
this.stop();
|
||||
this.check_time();
|
||||
}
|
||||
const BOSS_LEVELS = ["", "武士", "武师", "宗师", "武圣", "武帝", "武神"];
|
||||
this.run = function () {
|
||||
this.stop();
|
||||
this.check_time();
|
||||
const list = this.check_users();
|
||||
this.boss = [];
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (!list[i]) continue;
|
||||
let level = i + 1;
|
||||
let bs = this.create_boss(level);
|
||||
if (!bs) return console.log("boss 创建失败");
|
||||
this.boss.push(bs);
|
||||
bs.event_id = 'boss' + level;
|
||||
var rm = ROOM.RANDOM(); //ROOM.Get("yz/nanmen");
|
||||
rm.item_changed(bs, true);
|
||||
let desc = '听说' + bs.name + '出现在' + rm.long_name + '一带';
|
||||
let msg = '{"type":"msg","ch":"rumor","content":"' + desc + '。"}';
|
||||
for (var j = 0; j < list[i].length; j++) {
|
||||
list[i][j].send(msg);
|
||||
}
|
||||
EVENTS.add(this.create_event(bs.event_id, level, desc, rm));
|
||||
}
|
||||
}
|
||||
this.create_event = function (evtid, level, desc, rm) {
|
||||
return {
|
||||
id: evtid,
|
||||
name: BOSS_LEVELS[level] + "BOSS挑战",
|
||||
desc: desc + ",你可以前往尝试挑战,根据你造成的伤害可获得丰厚奖励。",
|
||||
time: 0,
|
||||
grade: level,
|
||||
command: "前往挑战",
|
||||
check: (me) => me.level === level,
|
||||
on_command: function (me) {
|
||||
if (me.state) return me.send('你正在' + me.state.title + "。");
|
||||
if (me.query_temp("bcc", 0) >= 5)
|
||||
return me.send('你今日的BOSS挑战次数已满。');
|
||||
if (!me.can_trans()) return;
|
||||
if (rm.is_full(1))
|
||||
return me.send('那里人太多了,你过不去。');
|
||||
me.moveto(rm.path, me.name + "离开了。", me.name + "走了过来。");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.check_users = function () {
|
||||
var list = [];
|
||||
for (var i = 0; i < WORLD.USERS.length; i++) {
|
||||
var user = WORLD.USERS[i];
|
||||
if (!user.level) continue;
|
||||
if (user.level > 5 && this.create_boss2(user)) continue;
|
||||
if (!user.socket) continue;
|
||||
if (user.query_temp("bcc", 0) >= 5) continue;
|
||||
var lv = user.level - 1;
|
||||
if (lv > 4) {
|
||||
lv = 4;
|
||||
}
|
||||
if (!list[lv]) list[lv] = [];
|
||||
list[lv].push(user);
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
this.create_boss = function (player_level) {
|
||||
var max_level = this.boss_levels[WORLD.DATA.query_temp("fb_index", 0)];
|
||||
if (player_level) {
|
||||
var boss_max = this.level_max[player_level][1];
|
||||
var boss_min = this.level_max[player_level][0];
|
||||
if (max_level > boss_max) max_level = boss_max;
|
||||
} else {
|
||||
boss_max = 0;
|
||||
boss_min = 0;
|
||||
}
|
||||
|
||||
var level = this.random(max_level - boss_min) + boss_min;
|
||||
|
||||
if (!this.paths[level]) return console.log(level, max_level, " boss 创建失败");
|
||||
var diff_level = this.levels[level];
|
||||
var boss = NPC.CLONE(this.paths[level]);
|
||||
if (!boss) return;
|
||||
boss.boss_index = level;
|
||||
boss.min_fbindex = this.boss_min_fb[level];
|
||||
var sk_level = (level + 1) * 100;
|
||||
if (diff_level > 300) {
|
||||
sk_level = (level + 1) * 130;
|
||||
}
|
||||
for (var item in boss.skills) {
|
||||
boss.skills[item].level = sk_level;
|
||||
}
|
||||
boss.diff_level = diff_level;
|
||||
boss.hp = boss.max_hp = diff_level * diff_level * 500;
|
||||
|
||||
boss.mp = boss.max_mp = boss.max_hp / 2;
|
||||
boss.prop = {};
|
||||
boss.level = player_level || this.player_levels[level];
|
||||
if (diff_level >= 500) boss.level = 5;
|
||||
boss.init();
|
||||
boss.recount();
|
||||
boss.pfm_rate = 1;
|
||||
boss.recount();
|
||||
boss.record_damage = true;
|
||||
boss.on_died = this.on_died;
|
||||
boss.on_enter = null;
|
||||
boss.on_kill = this.on_kill;
|
||||
boss.no_fight = true;
|
||||
boss.no_refresh = true;
|
||||
boss.on_die = null;
|
||||
|
||||
return boss;
|
||||
}
|
||||
this.on_kill = function (me) {
|
||||
if (me.level > this.level) {
|
||||
if (this.family == FAMILIES.MONSTER) {
|
||||
return me.notify_fail(this.name + "目露凶光狠狠的瞪着你。");
|
||||
}
|
||||
return me.notify_fail(this.name + "对你拱手说道:这位" + me.call() + ",不知" + this.callme() + "有何得罪之处?");
|
||||
}
|
||||
}
|
||||
|
||||
function create_finish_event(boss) {
|
||||
return {
|
||||
id: boss.event_id,
|
||||
name: BOSS_LEVELS[boss.level] + "BOSS挑战",
|
||||
desc: boss.name + "被击败了,解锁快速领取可直接领取基础掉落,并增加一次参与次数",
|
||||
time: BOSSTASK.next_time.getTime(),
|
||||
grade: boss.level,
|
||||
command: "领取",
|
||||
check: (me) => me.level === boss.level,
|
||||
on_command: function (me, par) {
|
||||
BOSSTASK.boss_auto_drops(me, boss, par);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.on_died = function (me, corpse) {
|
||||
if (!this.is_party_boss)
|
||||
EVENTS.add(create_finish_event(this));
|
||||
if (!this.damages) return;
|
||||
corpse.no_alloc = true;
|
||||
corpse.clear_items = clear_items.bind(this);
|
||||
corpse.query_items = query_items.bind(this);
|
||||
corpse.query_damage = query_damage.bind(this);
|
||||
}
|
||||
function query_damage() {
|
||||
var str = [];
|
||||
for (var key in this.damages) {
|
||||
var user = WORLD.getUser(key);
|
||||
if (user) {
|
||||
str.push(user.name);
|
||||
str.push(":");
|
||||
str.push(this.damages[key]);
|
||||
str.push("==");
|
||||
str.push(parseInt(this.damages[key] * 100 / this.max_hp));
|
||||
str.push("%\n");
|
||||
}
|
||||
}
|
||||
return str.join("");
|
||||
}
|
||||
|
||||
const BOSS_DROPS = {
|
||||
lv1_0: [
|
||||
"st/st_red#0", "st/st_gre#0", "st/st_blu#0", "st/st_yel#0"],
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
function query_items(me) {
|
||||
if (!this.damages) return;
|
||||
|
||||
var sh = this.damages[me.id];
|
||||
if (!(sh > 1)) return;
|
||||
if (!this.user_items) this.user_items = {};
|
||||
if (this.user_items[me.id]) return this.user_items[me.id];
|
||||
if (me.query_temp("bcc", 0) >= 5) return;
|
||||
|
||||
|
||||
|
||||
sh = parseInt(sh * 100 / this.max_hp);
|
||||
if (sh < 1) {
|
||||
this.user_items[me.id] = [OBJ.CREATE('money/silver', 1 + me.random(10))];
|
||||
return this.user_items[me.id];
|
||||
}
|
||||
if (sh > 100) sh = 80;
|
||||
var lv = this.diff_level - 20;
|
||||
if (lv < 0) lv = 0;
|
||||
|
||||
var drops = [
|
||||
{
|
||||
obj: "st/xuanjing",
|
||||
min: 1,
|
||||
max: 10
|
||||
}, {
|
||||
obj: BOSS_DROPS.lv1_0,
|
||||
odds: 5000 + lv * 10 + sh * 10
|
||||
}
|
||||
];
|
||||
|
||||
me.add_temp("bcc", 1, UTIL.diff_time());
|
||||
var items = OBJ.create_by_odds(drops);
|
||||
this.user_items[me.id] = items;
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
function clear_items(me) {
|
||||
if (this.user_items) {
|
||||
this.user_items[me.id].length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.levels = [
|
||||
3, 5, 10, 12, 20, 40
|
||||
];
|
||||
this.player_levels = [
|
||||
1, 1, 1, 2, 2, 2,
|
||||
3, 3, 3, 3
|
||||
|
||||
];
|
||||
this.level_max = [
|
||||
[0, 99], [0, 3], [0, 4], [0, 4], [0, 4], [0, 4]
|
||||
];
|
||||
this.boss_levels = [
|
||||
3, 3, 3, 3, 3,
|
||||
3, 3, 3, 4, 4];
|
||||
|
||||
this.boss_min_fb = [
|
||||
1, 4, 6, 7
|
||||
];
|
||||
this.paths = [
|
||||
"yz/lm/zhao", "bj/ao/aobai", "bj/tdh/chen", "bj/shenlong/hong"
|
||||
];
|
||||
95
world/task/goods_task.js
Normal file
95
world/task/goods_task.js
Normal file
@@ -0,0 +1,95 @@
|
||||
|
||||
this.inherits(TASK);
|
||||
this.id = "goods";
|
||||
this.handler = null;
|
||||
this.customer = {};
|
||||
this.startup = function (oldtask) {
|
||||
|
||||
if (oldtask) {
|
||||
this.customer = oldtask.customer;
|
||||
}
|
||||
this.handler = this.call_out(this.refresh_goods, UTIL.diff_time(12));//12点刷新一次
|
||||
}
|
||||
this.refresh_goods = function () {
|
||||
this.handler = null;
|
||||
for (var i = 0; i < WORLD.USERS.length; i++) {
|
||||
WORLD.USERS[i].send('{type:"msg",ch:"chat",content:"近日新到一批宝石,秘籍,丹药,不知哪位江湖朋友需要。",lv:0,name:"唐楠"}');
|
||||
}
|
||||
|
||||
this.customer = {};
|
||||
|
||||
var fam = [FAMILIES.GAIBANG, FAMILIES.WUDANG, FAMILIES.HUASHAN, FAMILIES.XIAOYAO, FAMILIES.EMEI, FAMILIES.SHASHOU, FAMILIES.SHAOLIN, FAMILIES.NONE];
|
||||
for (var i = 0; i < fam.length; i++) {
|
||||
fam[i].customer = {};
|
||||
fam[i].send('{type:"msg",ch:"fam",content:"本门新调拨一批物资,有需要的师弟师妹们请速来兑换。",uid:0,name:"后勤管理员",fam:"' + fam[i].name + '"}');
|
||||
}
|
||||
|
||||
this.startup();
|
||||
}
|
||||
this.query_goods = function (me) {
|
||||
if (this.customer[me.id]) return this.customer[me.id];
|
||||
var ref_count = me.query_temp("ref_count", 0);
|
||||
var list = [];
|
||||
list.push(OBJ.CREATE("st/xuanjing", this.random(100) + 2));
|
||||
|
||||
var st = ["st/st_red", "st/st_gre", "st/st_blu", "st/st_yel"];
|
||||
let max_count = 8;
|
||||
var counts = [3, 3, 2, 1, 1, 1, 1];
|
||||
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var g = this.random(me.level + 1);
|
||||
if (g > 4) g = 4;
|
||||
list.push(OBJ.CREATE(st.random() + "#" + g, this.random(counts[g]) + 1));
|
||||
}
|
||||
max_count -= 2;
|
||||
if (me.random(3) === 1) {
|
||||
st = ["drug/exp", "drug/pot"];
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var g = this.random(1 + me.random(me.level));
|
||||
if (g > 4) g = 4;
|
||||
list.push(OBJ.CREATE(st.random() + "#" + g, this.random(ref_count) + 1));
|
||||
}
|
||||
max_count -= 2;
|
||||
}
|
||||
if (me.random(3) === 1) {
|
||||
st = ["res/cao", "res/yu"];
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var g = this.random((me.level + 1) * 3);
|
||||
list.push(OBJ.CREATE(st.random() + "#" + g, this.random(counts[g] ?? 1) + 1));
|
||||
}
|
||||
max_count -= 2;
|
||||
}
|
||||
if (me.random(3) === 1) {
|
||||
let level = this.random(me.level);
|
||||
let index = this.random(25);
|
||||
list.push(OBJ.CREATE("drug/yf#" + ((index * 5) + level), 1));
|
||||
max_count -= 1;
|
||||
}
|
||||
if (me.random(this.ref_count) > 4) {
|
||||
let level = this.random(me.level);
|
||||
if (level > 3) level = 3;
|
||||
let index = this.random(25);
|
||||
list.push(OBJ.CREATE("drug/yf2#" + ((index * 5) + level), 1));
|
||||
max_count -= 1;
|
||||
}
|
||||
if (max_count > 0) {
|
||||
max_count = Math.min(3, max_count);
|
||||
for (let i = 0; i < max_count; i++) {
|
||||
let level = this.random(me.level) + 1;
|
||||
if (level > 6) level = 6;
|
||||
else if (level < 1) level = 1;
|
||||
let sk = FAMILIES.NONE.query_skill(level);
|
||||
list.push(OBJ.CREATE("book/bc#" + sk.id, 1 + (level < 5 ? me.random(3) : 0)));
|
||||
}
|
||||
}
|
||||
this.customer[me.id] = list;
|
||||
return list;
|
||||
}
|
||||
this.set_goods = function (me, list) {
|
||||
this.customer[me.id] = list;
|
||||
}
|
||||
|
||||
|
||||
this.stop = function () {
|
||||
if (this.handler) clearTimeout(this.handler);
|
||||
}
|
||||
168
world/task/grow_task.js
Normal file
168
world/task/grow_task.js
Normal file
@@ -0,0 +1,168 @@
|
||||
|
||||
this.inherits(USERTASK);
|
||||
this.id = "growup";
|
||||
this.sort = 1;
|
||||
this.query_title = function (player) {
|
||||
var stas = player.query_temp("grow_lv", 0);
|
||||
return "<hic>" + temps[stas].title + "</hic>";
|
||||
}
|
||||
this.query_desc = function (player) {
|
||||
var stas = player.query_temp("grow_lv", 0);
|
||||
return temps[stas].desc;
|
||||
}
|
||||
this.query_state = function (player) {
|
||||
if (!WORLD.is_server(player)) return 0;
|
||||
var stas = player.query_temp("grow_lv", 0);
|
||||
if (stas >= temps.length) return 0;
|
||||
return temps[stas].check(player);
|
||||
}
|
||||
|
||||
this.on_finish = function (player) {
|
||||
if (!WORLD.is_server(player)) return player.notify("你无法完成。");
|
||||
var stas = player.query_temp("grow_lv", 0);
|
||||
if (stas >= temps.length) return;
|
||||
var st = temps[stas].check(player);
|
||||
if (st == 1) return player.notify("你还没完成这个任务。");
|
||||
temps[stas].finish(player);
|
||||
player.set_temp("grow_lv", stas + 1);
|
||||
return true;
|
||||
}
|
||||
const temps = [
|
||||
{
|
||||
title: "学会任意一个技能",
|
||||
desc: "通过秘籍或拜师学会一项技能,奖励:1000经验,1000潜能,<wht>铁剑</wht>\n<mem>可以通过去江湖-门派拜师,当铺购买秘籍,副本掉落武功秘籍等方式学习。</mem>",
|
||||
check: function (player) {
|
||||
if (!player.skills) return 1;
|
||||
for (var item in player.skills) {
|
||||
if (item != "force" || item != "unarmed") {
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
return 1;
|
||||
},
|
||||
finish: function (player) {
|
||||
player.add_exp(1000, 1000);
|
||||
var obj = player.add_obj("eq/lv0/jian");
|
||||
if (obj) {
|
||||
player.notify("你获得了" + obj.unit_name() + "。");
|
||||
}
|
||||
}
|
||||
}
|
||||
, {
|
||||
title: "完成一次副本",
|
||||
desc: "奖励:2000经验,10000潜能,一颗<hiy>养精丹</hiy>\n<mem>点击江湖-副本,尝试完成第一个副本。</mem>",
|
||||
check: function (player) {
|
||||
if (player.query_temp("fb_count") > 0) return 2;
|
||||
return 1;
|
||||
},
|
||||
finish: function (player) {
|
||||
player.add_exp(2000, 10000);
|
||||
var obj = player.add_obj("cash/jing#2", 3);
|
||||
if (obj) {
|
||||
player.notify("你获得了" + obj.unit_name(1) + "。");
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: "参与一种挂机工作",
|
||||
desc: "奖励:3000经验,10000潜能,<hig>背包扩充石</hig>\n<mem>扬州城的西门挖矿,东门采药,北门钓鱼,南门工作,开始任意一种工作后点击完成。</mem>",
|
||||
check: function (player) {
|
||||
if (player.state && player.state.type === 'work') return 2;
|
||||
return 1;
|
||||
},
|
||||
finish: function (player) {
|
||||
player.add_exp(3000, 10000);
|
||||
var obj = player.add_obj("cash/pack_add");
|
||||
if (obj) {
|
||||
player.notify("你获得了" + obj.unit_name(1) + "。");
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "成长为<wht>武士</wht>",
|
||||
desc: "奖励:10000经验,10000潜能,三张<hic>天师符</hic>\n<mem>去扬州城广场寻找金古易提升你的境界。</mem>",
|
||||
check: function (player) {
|
||||
if (player.level > 0) return 2;
|
||||
return 1;
|
||||
},
|
||||
finish: function (player) {
|
||||
player.add_exp(10000, 10000);
|
||||
var obj = player.add_obj("cash/tianshifu", 3);
|
||||
if (obj) {
|
||||
player.notify("你获得了三张" + obj.color_name + "。");
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "找份兼职",
|
||||
desc: "去扬州城的衙门找份追捕工作,每日可以获得大量报酬,\n奖励:10000经验,10000潜能,奖励:80块<hig>玄晶</hig>",
|
||||
check: function (player) {
|
||||
if (player.query_temp('ym_level', 0) > 0) return 2;
|
||||
return 1;
|
||||
},
|
||||
finish: function (player) {
|
||||
player.add_exp(10000, 10000);
|
||||
var obj = player.add_obj('st/xuanjing', 80);
|
||||
if (obj) {
|
||||
player.notify("你获得了" + obj.unit_name(80) + "。");
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "武道塔试炼",
|
||||
desc: "进入武道塔试炼,并战胜第九层守护者\n奖励:20000经验,20000潜能,十张<hic>扫荡符</hic>\n<mem>点击江湖-武道塔进入挑战。</mem>",
|
||||
check: function (player) {
|
||||
if (player.query_temp('wd_level', 0) > 8) return 2;
|
||||
return 1;
|
||||
},
|
||||
finish: function (player) {
|
||||
player.add_exp(20000, 20000);
|
||||
var obj = player.add_obj("cash/saodang", 10);
|
||||
if (obj) {
|
||||
player.notify("你获得了" + obj.unit_name(10) + "。");
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: "成长为<hig>武师</hig>",
|
||||
desc: "奖励:10000经验,10000潜能,五张<hiy>天师符</hiy>",
|
||||
check: function (player) {
|
||||
if (player.level > 1) return 2;
|
||||
return 1;
|
||||
},
|
||||
finish: function (player) {
|
||||
player.add_exp(10000, 10000);
|
||||
var obj = player.add_obj("cash/tianshifu", 5);
|
||||
if (obj) {
|
||||
player.notify("你获得了" + obj.unit_name(5) + "。");
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: "参加襄阳守卫战",
|
||||
desc: "参加一次襄阳守卫战,并最少获得100的军功\n奖励:50000经验,50000潜能>",
|
||||
check: function (player) {
|
||||
if (player.query_temp('jg_week', 0) >= 100) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
},
|
||||
finish: function (player) {
|
||||
player.add_exp(50000, 50000);
|
||||
}
|
||||
}, {
|
||||
title: "成长为<hiy>宗师</hiy>",
|
||||
desc: "成长为<hiy>宗师</hiy>\n奖励:100000经验,100000潜能,一颗<hiy>洗髓丹</hiy>",
|
||||
check: function (player) {
|
||||
if (player.level > 2) return 2;
|
||||
return 1;
|
||||
},
|
||||
finish: function (player) {
|
||||
player.add_exp(100000, 100000);
|
||||
var obj = player.add_obj("cash/xi", 1);
|
||||
if (obj) {
|
||||
player.notify("你获得了" + obj.unit_name(1) + "。");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
];
|
||||
97
world/task/msg.js
Normal file
97
world/task/msg.js
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
this.inherits(TASK);
|
||||
this.id = "msg";
|
||||
this.handler = null;
|
||||
this.startup = function () {
|
||||
this.handler = this.call_out(this.run, 20 * 60000);
|
||||
}
|
||||
this.stop = function () {
|
||||
if (this.handler) clearTimeout(this.handler);
|
||||
}
|
||||
this.msgs = [
|
||||
"欢迎登录,感谢你的支持,如有任何问题或建议",
|
||||
"如有BUG请提交管理员,谢谢配合"
|
||||
|
||||
];
|
||||
this.is_check_file = false;
|
||||
this.run = function () {
|
||||
COMMAND.DO("sys", this.msgs.random());
|
||||
this.startup();
|
||||
var dt = new Date();
|
||||
if (dt.getHours() == 4 && !this.is_check_file) {
|
||||
this.is_check_file = true;
|
||||
this.check_file();
|
||||
}
|
||||
if (dt.getHours() == 5) {
|
||||
this.is_check_file = false;
|
||||
this.clearyz();
|
||||
}
|
||||
}
|
||||
this.clearyz = function () {
|
||||
WORLD.COMMANDS['checkorg'].cmd_clearmail();
|
||||
WORLD.COMMANDS['checkorg'].cmd_clearstore();
|
||||
}
|
||||
|
||||
|
||||
this.check_file = function () {
|
||||
|
||||
const min1 = new Date(Date.now() - 3600000 * 24 * 7);//七天内每个一小时
|
||||
const min2 = new Date(Date.now() - 3600000 * 24 * 30);//30天内每天一个
|
||||
const min3 = new Date(Date.now() - 3600000 * 24 * 160);//一年内一周一个,一年外的删除
|
||||
|
||||
|
||||
const min4 = new Date(Date.now() - 3600000 * 24 * 30);//日志30天内每天一个
|
||||
this.check_temp_files("log", (dir) => {
|
||||
dir = dir.replace("log", "").replace(".txt", "");
|
||||
let pars = dir.split('-');
|
||||
let dt = new Date(pars[0], pars[1] - 1, pars[2]);
|
||||
return dt < min4;
|
||||
});
|
||||
|
||||
this.check_temp_files("req", (dir) => {
|
||||
dir = dir.replace("request", "").replace(".txt", "");
|
||||
let pars = dir.split('-');
|
||||
let dt = new Date(pars[0], pars[1] - 1, pars[2]);
|
||||
return dt < min4;
|
||||
});
|
||||
this.check_temp_files("bak", (dir) => {
|
||||
dir = dir.replace("data", "").replace(".js", "");
|
||||
let pars = dir.split('-');
|
||||
if (pars.length < 3) return false;
|
||||
let dt = new Date(pars[0], pars[1] - 1, pars[2], pars[3]);
|
||||
if (dt > min1) return false;
|
||||
if (dt > min2) {
|
||||
|
||||
if (dt.getHours() === 5) return false;
|
||||
return true;
|
||||
}
|
||||
if (dt > min3) {
|
||||
if (dt.getHours() === 5 && dt.getDay() === 1) return false;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
||||
});
|
||||
|
||||
this.check_temp_files("temp", (dir) => {
|
||||
let pars = dir.split('-');
|
||||
if (pars.length < 5) return false;
|
||||
let dt = new Date(pars[1], pars[2] - 1, pars[3], pars[4]);
|
||||
if (dt > min2) {
|
||||
if (dt.getHours() === 5) return false;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
this.check_temp_files = async function (path, func) {
|
||||
const dir = __PATH.DATA + path + "/";
|
||||
const paths = await fs.readdir(dir);
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
if (func(paths[i])) {
|
||||
fs.unlink(dir + paths[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
153
world/task/sm_task.js
Normal file
153
world/task/sm_task.js
Normal file
@@ -0,0 +1,153 @@
|
||||
|
||||
this.inherits(USERTASK);
|
||||
this.id = "sm";
|
||||
this.on_create = function () {
|
||||
}
|
||||
|
||||
|
||||
const TAGS = ['hig', 'hic', 'hiy', 'hiz', 'hio', 'ord'];
|
||||
|
||||
const TITLES = ['入门弟子', '弟子', '执事', '护法', '长老', '供奉'];
|
||||
this.query_title = function (me) {
|
||||
let tag = TAGS[me.query_temp('sm_level', 0)];
|
||||
return `<${tag}>师门物资</${tag}>`;
|
||||
}
|
||||
|
||||
this.query_desc = function (me) {
|
||||
let tm = me.query_temp("sm_tm", 0);
|
||||
if (!tm) return;
|
||||
|
||||
let sm = 0;
|
||||
let mem = "";
|
||||
let max = 60;
|
||||
if (tm > 0) {
|
||||
sm = Math.floor((Date.now() - tm * 100000) / 3600000);
|
||||
if (sm <= 0) {
|
||||
sm = 0;
|
||||
let time = tm * 100000 + 3600000 - Date.now();
|
||||
if (time > 0) {
|
||||
mem = ",下次领取" + this.format_time_span(time);
|
||||
}
|
||||
} else if (sm < max) {
|
||||
let time = tm * 100000 + 3600000 * (sm + 1) - Date.now();
|
||||
if (time > 0) {
|
||||
mem = ",下次领取" + this.format_time_span(time);
|
||||
}
|
||||
} else {
|
||||
|
||||
mem = ",已到上限";
|
||||
sm = Math.min(sm, 60);
|
||||
}
|
||||
}
|
||||
|
||||
return `你是${me.family.query_task_title(me)},在此期间将持续获得师门的资助,当前累计${sm}/60。<br><mem>每小时获得一份师门资源,可通过后勤管理提升师门职位${mem}</mem>`;
|
||||
}
|
||||
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);
|
||||
}
|
||||
//0 不显示 1,进行中,2.可领取 3.已完成
|
||||
this.query_state = function (me) {
|
||||
let sm = this.query_smcount(me);
|
||||
if (sm < 0) return 0;
|
||||
return sm > 0 ? 2 : 1;
|
||||
}
|
||||
this.format_time_span = function (time) {
|
||||
if (time > 3600000)
|
||||
return Math.floor(time / 3600000) + "小时后";
|
||||
if (time > 60000)
|
||||
return Math.floor(time / 60000) + "分钟后";
|
||||
return Math.floor(time / 1000) + "秒后";
|
||||
|
||||
}
|
||||
const EXPS = [5000, 10000, 12500, 15000, 17500, 20000];
|
||||
|
||||
const GONGJI = [10, 20, 40, 60, 80, 100];
|
||||
const MONEYS = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000];
|
||||
|
||||
this.on_finish = function (me) {
|
||||
let sm = this.query_smcount(me);
|
||||
if (!(sm > 0)) return false;
|
||||
let sm_level = me.query_temp('sm_level', 0);
|
||||
let gongji = GONGJI[sm_level] * sm;
|
||||
let exp = EXPS[sm_level] * sm;
|
||||
let pot = exp;
|
||||
if (me.level > 2) {
|
||||
pot = parseInt(me.exp / 1200);
|
||||
if (pot > 150000) {
|
||||
pot = 150000;
|
||||
}
|
||||
pot = pot * sm;
|
||||
}
|
||||
me.add_temp('gongji', gongji);
|
||||
if (!me.skills) me.skills = {};
|
||||
me.add_exp(exp, pot);
|
||||
|
||||
|
||||
var list = [];
|
||||
for (var i = 0; i < me.family.skills2.length; i++) {
|
||||
if (!me.skills[me.family.skills2[i].id]) {
|
||||
list.push(me.family.skills2[i].id);
|
||||
}
|
||||
}
|
||||
let items = [];
|
||||
let count = sm;
|
||||
while (count > 0) {
|
||||
if (count >= 10) {
|
||||
items.push({
|
||||
obj: list.length > 0 ? "book/up" :
|
||||
"drug/limit_mp#" + Math.min(4, sm_level)
|
||||
});
|
||||
count -= 10;
|
||||
} else {
|
||||
items.push({
|
||||
obj: list.length > 0 ? "book/up" :
|
||||
"drug/limit_mp#" + Math.min(4, sm_level),
|
||||
odds: count * 1000
|
||||
});
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
items = OBJ.create_by_odds(items);
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = me.add_obj(items[i]);
|
||||
if (item) {
|
||||
me.send("你获得了" + items[i].unit_name() + "。");
|
||||
}
|
||||
}
|
||||
|
||||
this.set_curtm(me, sm);
|
||||
|
||||
let limit = me.query_jclimit();
|
||||
let jingli = me.query_temp('ad_jl', 0);
|
||||
if (limit > jingli) {
|
||||
let ad_jl = 10 * sm;
|
||||
let add = limit - jingli;
|
||||
if (add > ad_jl) add = ad_jl;
|
||||
me.add_temp('ad_jl', add);
|
||||
me.notify('<hiy>你增加了' + add + "精力。</hiy>");
|
||||
} else {
|
||||
me.notify("<yel>你的精力已经达到上限。</yel>");
|
||||
}
|
||||
|
||||
me.notify("<hic>你领取了" + sm + "份师门物资,获得" + gongji + "点师门功绩。</hic>");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
this.set_curtm = function (me, count) {
|
||||
|
||||
|
||||
let tm = me.query_temp("sm_tm", 0);
|
||||
|
||||
tm = Math.max((Date.now() - 3600000 * 60) / 100000, tm);
|
||||
|
||||
|
||||
tm += Math.floor((count * 36));
|
||||
|
||||
|
||||
me.set_temp("sm_tm", tm);
|
||||
|
||||
}
|
||||
178
world/task/top_1.js
Normal file
178
world/task/top_1.js
Normal file
@@ -0,0 +1,178 @@
|
||||
|
||||
this.inherits(TASK);
|
||||
this.id = "top";
|
||||
this.prev_time = 0;
|
||||
this.startup = function () {
|
||||
var dt = new Date();
|
||||
var hour = dt.getHours();
|
||||
var day = dt.getDate();
|
||||
if (hour >= 20) day = day + 1;
|
||||
dt = new Date(dt.getFullYear(), dt.getMonth(), day, 20);
|
||||
var diff_time = dt - Date.now();
|
||||
this.time_handler = this.call_out(this.run.bind(this), diff_time);
|
||||
}
|
||||
this.stop = function () {
|
||||
clearTimeout(this.time_handler);
|
||||
}
|
||||
this.run = function () {
|
||||
this.startup();
|
||||
var diff = Date.now() - this.prev_time;
|
||||
if (diff < 600000) return;
|
||||
this.send_score();
|
||||
this.send_tops();
|
||||
this.send_weapons();
|
||||
this.send_family();
|
||||
COMMAND.DO("sys", "排行榜奖励发放完毕,进入社交系统消息中收取。");
|
||||
this.prev_time = Date.now();
|
||||
}
|
||||
this.send_score = function () {
|
||||
let data = WORLD.STATS.SC_STATS;
|
||||
for (let key of FAMS_TATAS) {
|
||||
let stats = data[key];
|
||||
if (!stats) continue;
|
||||
let topname = FAMILIES[key].name + "综合榜";
|
||||
for (var i = 0; i < stats.length; i++) {
|
||||
var user = stats[i];
|
||||
if (i > 19) break;
|
||||
if (!user.id) continue;
|
||||
COMMAND.DO("send", user.id, {
|
||||
from: "score",
|
||||
from_name: "综合榜奖励",
|
||||
content: "你目前在" + topname + "单排名第" +
|
||||
(i + 1) + ",以下是你的每日奖励,请再接再厉继续保持。",
|
||||
attach: [
|
||||
WORLD.COMMANDS.reward.score_reward(i)
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const FAMS_TATAS = ['WUDANG', 'HUASHAN', 'SHAOLIN',
|
||||
'EMEI', 'GAIBANG', 'XIAOYAO', 'SHASHOU', 'NONE'];
|
||||
this.send_tops = function () {
|
||||
for (let key of FAMS_TATAS) {
|
||||
let tops = WORLD.STATS['tops_' + key];
|
||||
if (!tops) continue;
|
||||
let topname = FAMILIES[key].name + "高手榜";
|
||||
for (let i = 0; i < tops.length; i++) {
|
||||
let user = tops[i];
|
||||
if (!user.userid) continue;
|
||||
COMMAND.DO("send", user.userid, {
|
||||
from: "top",
|
||||
from_name: "高手榜奖励",
|
||||
content: "你目前在" + topname + "排名第" + (i + 1) + ",以下是你的每日奖励,请再接再厉继续保持。",
|
||||
attach: [
|
||||
WORLD.COMMANDS.reward.top_reward(i)
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.send_weapons = function () {
|
||||
const map = {};
|
||||
let eqs = WORLD.STATS.EQ_STATS ?? [];
|
||||
for (let stats of eqs) {
|
||||
for (let i = 0; i < stats.length; i++) {
|
||||
let item = stats[i];
|
||||
if (i > 9) break;
|
||||
if (!item.user) continue;
|
||||
let max_count = map[item.user] ?? 0;
|
||||
if (max_count >= 200) continue;
|
||||
let count = (50 + (10 - i) * 5);
|
||||
max_count += count;
|
||||
if (max_count > 200) {
|
||||
count = count - (max_count - 200);
|
||||
max_count = 200;
|
||||
}
|
||||
map[item.user] = max_count;
|
||||
|
||||
COMMAND.DO("send", item.user, {
|
||||
from: "weapon",
|
||||
from_name: "兵器谱奖励",
|
||||
content: "你的" + item.wname + "在兵器谱排名第" + (i + 1) + ",以下是你的每日奖励,请再接再厉继续保持。",
|
||||
attach: [
|
||||
{
|
||||
obj: "st/xuanjing",
|
||||
count: count
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
this.send_family = function () {
|
||||
|
||||
for (var name in FAMILIES) {
|
||||
var fam = FAMILIES[name];
|
||||
this.sort_family(fam);
|
||||
}
|
||||
}
|
||||
//wg_sr
|
||||
this.sort_family = function (fam) {
|
||||
var list = [];
|
||||
var user = null;
|
||||
if (fam.tops) {
|
||||
var max = 0;
|
||||
for (var key in fam.tops) {
|
||||
var item = fam.tops[key];
|
||||
if (item.score > max) {
|
||||
max = item.score;
|
||||
list.length = 0;
|
||||
list.push({ name: item.name, id: key });
|
||||
} else if (item.score == max) {
|
||||
list.push({ name: item.name, id: key });
|
||||
}
|
||||
}
|
||||
|
||||
if (!list.length) return;
|
||||
if (list.length == 1) user = list[0];
|
||||
else {
|
||||
var last_time = Number.MAX_VALUE;
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var item = WORLD.getUser(list[i].id);
|
||||
var time = item ? item.query_temp('last_sm', 1) : Date.now();
|
||||
|
||||
if (time < last_time) {
|
||||
user = list[i];
|
||||
last_time = time;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (fam !== FAMILIES.NONE) return;
|
||||
for (let user of WORLD.USERS) {
|
||||
if (user.family === FAMILIES.NONE && user.query_temp('wg_sr', 0)
|
||||
&& user.query_temp('sr', 0)) {
|
||||
list.push(user);
|
||||
}
|
||||
}
|
||||
if (!list.length) return;
|
||||
user = list.random();
|
||||
}
|
||||
|
||||
|
||||
fam.set_dadizi(user.id, user.name);
|
||||
|
||||
|
||||
COMMAND.DO("send", user.id, {
|
||||
from: "fam",
|
||||
from_name: "门派奖励",
|
||||
content: "恭喜你成为" + fam.name + "的" + fam.top_name + "。",
|
||||
attach: [
|
||||
{
|
||||
obj: "sp/dizi#" + fam.id,
|
||||
count: 1
|
||||
}
|
||||
]
|
||||
});
|
||||
user = WORLD.getUser(user.id);
|
||||
if (user) {
|
||||
user.set_temp('last_sm', Date.now());
|
||||
}
|
||||
}
|
||||
140
world/task/wd_task.js
Normal file
140
world/task/wd_task.js
Normal file
@@ -0,0 +1,140 @@
|
||||
|
||||
this.inherits(USERTASK);
|
||||
this.id = "wudao";
|
||||
|
||||
const TAGS = ['wht', 'hic', 'hiy', 'hiz', 'hio', 'ord'];
|
||||
|
||||
|
||||
this.query_title = function (me) {
|
||||
let wd_lv = me.query_temp("wd_level", 0);
|
||||
|
||||
let lv = Math.floor(wd_lv / 20);
|
||||
|
||||
let tag = TAGS[lv];
|
||||
return `<${tag}>武道塔挑战:${wd_lv}层</${tag}>`;
|
||||
}
|
||||
|
||||
|
||||
this.query_desc = function (me) {
|
||||
let lv = me.query_temp("wd_level", 0);
|
||||
if (!(lv > 0)) return;
|
||||
let tm = me.query_temp("wd_tm", 0);
|
||||
let wd = 0;
|
||||
let mem = "";
|
||||
let max = 7;
|
||||
if (tm > 0) {
|
||||
wd = Math.floor((Date.now() - tm * 100000) / 3600000 / 24);
|
||||
if (wd <= 0) {
|
||||
wd = 0;
|
||||
let time = tm * 100000 + 3600000 * 24 - Date.now();
|
||||
if (time > 0) {
|
||||
mem = ",下次领取" + this.format_time_span(time);
|
||||
}
|
||||
} else if (wd < max) {
|
||||
let time = tm * 100000 + 3600000 * 24 * (wd + 1) - Date.now();
|
||||
if (time > 0) {
|
||||
mem = ",下次领取" + this.format_time_span(time);
|
||||
}
|
||||
} else {
|
||||
mem = ",已到上限";
|
||||
wd = Math.min(wd, 7);
|
||||
}
|
||||
}
|
||||
|
||||
return `你的武道塔挑战记录是${lv}层,守门人将按照你的最高挑战记录发放奖励,当前可领取${wd}/7。<br><mem>每天获得一份奖励,挑战更高层获得更多奖励${mem}</mem>`;
|
||||
}
|
||||
this.format_time_span = function (time) {
|
||||
|
||||
if (time > 3600000)
|
||||
return Math.floor(time / 3600000) + "小时后";
|
||||
if (time > 60000)
|
||||
return Math.floor(time / 60000) + "分钟后";
|
||||
return Math.floor(time / 1000) + "秒后";
|
||||
|
||||
}
|
||||
|
||||
this.query_count = 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);
|
||||
}
|
||||
//0 不显示 1,进行中,2.可领取 3.已完成
|
||||
this.query_state = function (me) {
|
||||
let lv = me.query_temp("wd_level", 0);
|
||||
if (!(lv > 0)) return 0;
|
||||
let sm = this.query_count(me);
|
||||
return sm > 0 ? 2 : 1;
|
||||
}
|
||||
const EXPS = [1000, 2000, 3000, 4000, 5000, 6000, 7000];
|
||||
this.on_finish = function (me) {
|
||||
let wd_count = this.query_count(me);
|
||||
if (!(wd_count > 0)) return false;
|
||||
let wd_lv = me.query_temp("wd_level", 0);
|
||||
if (!(wd_lv > 0)) return false;
|
||||
|
||||
this.set_curtm(me, wd_count);
|
||||
for (let i = 0; i < wd_count; i++) {
|
||||
this.reward(me, wd_lv);
|
||||
}
|
||||
|
||||
me.send('<hic>你领取了' + wd_count + '天的武道塔的奖励。</hic>');
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
this.set_curtm = function (me, count) {
|
||||
let tm = me.query_temp("wd_tm", 0);
|
||||
|
||||
tm = Math.max((Date.now() - 3600000 * 24 * 7) / 100000, tm);
|
||||
|
||||
|
||||
tm += Math.floor((count * 36 * 24));
|
||||
|
||||
|
||||
me.set_temp("wd_tm", tm);
|
||||
|
||||
}
|
||||
|
||||
const REWARDS = [
|
||||
["drug/max_mp#0", "drug/skill2#1"],
|
||||
["drug/max_mp#1", "drug/skill2#2"],
|
||||
["drug/max_mp#2", "drug/skill2#3"],
|
||||
["drug/max_mp#3", "drug/skill2#4"],
|
||||
["drug/max_mp#4", "drug/skill2#5"],
|
||||
];
|
||||
this.reward = function (me, lv) {
|
||||
let items = [];
|
||||
let exp = 10000;
|
||||
if (lv <= 29) {
|
||||
exp += lv * 10000;
|
||||
} else {
|
||||
exp += 29 * 10000;
|
||||
exp += (lv - 29) * 1000;
|
||||
}
|
||||
|
||||
me.add_exp(exp, exp);
|
||||
|
||||
if (lv >= 10) {
|
||||
let wd_count = Math.floor(lv / 10);
|
||||
items.push({
|
||||
obj: "book/wd",
|
||||
count: wd_count
|
||||
});
|
||||
me.add_temp('wds', wd_count);
|
||||
}
|
||||
|
||||
items = OBJ.create_by_odds(items);
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = me.add_obj(items[i]);
|
||||
if (item) {
|
||||
me.send("你获得了" + items[i].unit_name() + "。");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
676
world/task/xy_task.js
Normal file
676
world/task/xy_task.js
Normal file
@@ -0,0 +1,676 @@
|
||||
|
||||
this.inherits(TASK);
|
||||
this.id = "xiangyang";
|
||||
this.is_start = false;
|
||||
this.guards = [];
|
||||
this.boss = null;
|
||||
this.guard = null;
|
||||
this.allow_commands = {
|
||||
bm: true,
|
||||
reward: true,
|
||||
juanxian: true
|
||||
};
|
||||
this.startup = function () {
|
||||
if (this.start_handler) clearTimeout(this.start_handler);
|
||||
var date = new Date();
|
||||
var week = date.getDay();
|
||||
this.xy_area = AREA.Get('xiangyang');
|
||||
var next_date = new Date(date.getFullYear(), date.getMonth(), date.getDate() + (week > 0 ? (7 - week) : 0), 20, 30);
|
||||
if (next_date < date) next_date = new Date(next_date.getFullYear(), next_date.getMonth(), next_date.getDate() + 7, 20, 30);
|
||||
|
||||
this.next_date = next_date;
|
||||
//this.start_handler = this.call_out(this.run, next_date - date + 10);
|
||||
}
|
||||
|
||||
this.can_battle = function () {
|
||||
return Date.now() > 1756674000000;
|
||||
}
|
||||
|
||||
|
||||
this.on_mihan = function () {
|
||||
if (!this.can_battle()) return;
|
||||
COMMAND.DO("rumor", "听说郭大侠收到线报蒙古大军近日将会进攻襄阳!");
|
||||
WORLD.DATA.set_temp("xy_status", 1);
|
||||
this.xy_area.notify_update();
|
||||
this.call_out(this.run, 300000);
|
||||
}
|
||||
this.clear_player = function () {
|
||||
let msg =
|
||||
JSON.stringify({
|
||||
type: "msg", ch: "chat",
|
||||
content: "襄阳战事将起,无关人士请即刻离开。", lv: (3), name: "指挥使"
|
||||
});
|
||||
for (var i = 0; i < WORLD.USERS.length; i++) {
|
||||
if (!WORLD.USERS[i].query_setting("off_chat"))
|
||||
WORLD.USERS[i].send(msg);
|
||||
}
|
||||
let area = this.xy_area;
|
||||
for (let room of area.rooms) {
|
||||
for (let i = 0; i < room.items.length; i++) {
|
||||
let item = room.items[i];
|
||||
if (!item.is_player) continue;
|
||||
if (item.query_temp('xy_bm'))
|
||||
continue;
|
||||
if (item.moveto('yz/beimen') !== 'false') {
|
||||
item.send('<yel>你离开襄阳一路赶到扬州。</yel>');
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.stop = function () {
|
||||
if (this.start_handler) clearTimeout(this.start_handler);
|
||||
|
||||
if (this.check_handler) clearTimeout(this.check_handler);
|
||||
}
|
||||
this.run = function () {
|
||||
this.start_handler = null;
|
||||
if (this.is_start) return;
|
||||
var index = WORLD.DATA.add_temp("xiangyang", 1) + 20;
|
||||
COMMAND.DO("sys", "武神历" + UTIL.to_c(index) + "年蒙古大军挥军南下,襄阳城告急!");
|
||||
|
||||
this.clear_player();
|
||||
this.guards.length = 0;
|
||||
this.step = 0;
|
||||
this.count = 0;
|
||||
this.is_start = true;
|
||||
this.create_guards();
|
||||
this.call_out(this.create_enemy, 10000);
|
||||
}
|
||||
this.create_guards = function () {
|
||||
this.guard = ROOM.Get("xiangyang/guangchang").find_obj_bypath("xiangyang/guo");
|
||||
if (!this.guard) {
|
||||
this.guard = NPC.CLONE("xiangyang/guo");
|
||||
ROOM.Get("xiangyang/guangchang").item_changed(this.guard, true);
|
||||
}
|
||||
|
||||
this.guard.on_die = this.on_guard_die.bind(this, this.guard);
|
||||
this.guard.on_enter = this.check_enemy;
|
||||
|
||||
var rooms = ["xiangyang/eastjie", "xiangyang/westjie", "xiangyang/northjie", "xiangyang/southjie"];
|
||||
for (var i = 1; i < 4; i++) {
|
||||
for (var j = 0; j < rooms.length; j++) {
|
||||
var npc = NPC.CLONE("xiangyang/shouwei" + i);
|
||||
npc.name = UTIL.random_name(1);
|
||||
npc.on_enter = this.check_enemy;
|
||||
npc.is_dasong = true;
|
||||
var rm = ROOM.Get(rooms[j] + i.toString());
|
||||
npc.on_die = this.on_guard_die.bind(this, npc);
|
||||
|
||||
rm.item_changed(npc, true);
|
||||
this.guards.push(npc);
|
||||
}
|
||||
}
|
||||
rooms = ["xiangyang/northgate", "xiangyang/westgate", "xiangyang/southgate", "xiangyang/eastgate"];
|
||||
for (var i = 1; i < 3; i++) {
|
||||
for (var j = 0; j < rooms.length; j++) {
|
||||
for (var k = 0; k < i + 1; k++) {
|
||||
var npc = NPC.CLONE("xiangyang/shouwei" + (3 + i));
|
||||
|
||||
npc.name = UTIL.random_name(1);
|
||||
var rm = ROOM.Get(rooms[j] + i.toString());
|
||||
npc.on_enter = this.check_enemy;
|
||||
npc.is_dasong = true;
|
||||
npc.on_die = this.on_guard_die.bind(this, npc);
|
||||
|
||||
rm.item_changed(npc, true);
|
||||
this.guards.push(npc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.step = 0;
|
||||
this.count = 0;
|
||||
this.create_index = 0;
|
||||
//没隔30秒出现一波5敌人,如果城门被破+10
|
||||
//每隔20波增强一波
|
||||
this.create_enemy = function (par) {
|
||||
if (!this.is_start) return;
|
||||
this.create_handler = null;
|
||||
|
||||
for (var i = 0; i < this.gate_states.length; i++) {
|
||||
var gate = this.gate_states[i];
|
||||
if (!gate.enter_room) {
|
||||
gate.enter_room = ROOM.Get(gate.enter);
|
||||
}
|
||||
if (!gate.enter_room) continue;
|
||||
this.create_index = i;
|
||||
var func = this["create_enemy" + this.step];
|
||||
func && func.call(this, gate);
|
||||
if (gate.step > 1) {
|
||||
|
||||
if (!gate.walls) {
|
||||
gate.walls = [];
|
||||
for (var j = 0; j < gate.wall_index.length; j++) {
|
||||
gate.walls.push(ROOM.Get("xiangyang/walle" + gate.wall_index[j]));
|
||||
}
|
||||
}
|
||||
for (var j = gate.wall_count; j < 10 + gate.step; j++) {
|
||||
this.create_one(5, gate.walls.random(), true);
|
||||
}
|
||||
gate.wall_count = 10 + gate.step;
|
||||
}
|
||||
}
|
||||
this.count++;
|
||||
if (this.step < 6 && this.count == 10) {
|
||||
this.count = 0;
|
||||
this.step++;
|
||||
for (var i = 0; i < this.gate_states.length; i++) {
|
||||
var gate = this.gate_states[i];
|
||||
if (gate.boss) {
|
||||
gate.bing.push(gate.boss);
|
||||
gate.boss = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.step == 6 && !this.boss) {
|
||||
//第六波出蒙哥
|
||||
this.show_boss();
|
||||
} else {
|
||||
this.create_handler = this.call_out(this.create_enemy, 30000);
|
||||
}
|
||||
|
||||
}
|
||||
//第一波 每次5个蒙古兵
|
||||
this.create_enemy0 = function (par) {
|
||||
for (var i = par.bing.length; i < 5; i++) {
|
||||
par.bing.push(this.create_one(5, par.enter_room));
|
||||
}
|
||||
}
|
||||
//第二波 每次4个蒙古兵+1个十夫长
|
||||
this.create_enemy1 = function (par) {
|
||||
if (!par.boss) {
|
||||
par.boss = this.create_one(4, par.enter_room);
|
||||
}
|
||||
for (var i = par.bing.length; i < 4; i++) {
|
||||
par.bing.push(this.create_one(5, par.enter_room));
|
||||
}
|
||||
}
|
||||
//第三波 每次3个蒙古兵+1个十夫长+1个百夫长
|
||||
this.create_enemy2 = function (par) {
|
||||
if (!par.boss) {
|
||||
par.boss = this.create_one(3, par.enter_room);
|
||||
}
|
||||
for (var i = par.bing.length; i < 4; i++) {
|
||||
par.bing.push(this.create_one(i == 3 ? 4 : 5, par.enter_room));
|
||||
}
|
||||
}
|
||||
//第四波 每次3个十夫长+1个百夫长+1个千夫长
|
||||
this.create_enemy3 = function (par) {
|
||||
if (!par.boss) {
|
||||
par.boss = this.create_one(2, par.enter_room);
|
||||
}
|
||||
for (var i = par.bing.length; i < 4; i++) {
|
||||
par.bing.push(this.create_one(i == 3 ? 3 : 4, par.enter_room));
|
||||
}
|
||||
}
|
||||
//第五波 万夫长+2个千夫长
|
||||
this.create_enemy4 = function (par) {
|
||||
if (!par.boss) {
|
||||
par.boss = this.create_one(1, par.enter_room);
|
||||
}
|
||||
for (var i = par.bing.length; i < 4; i++) {
|
||||
par.bing.push(this.create_one(i == 0 ? 2 : 4, par.enter_room));
|
||||
}
|
||||
}
|
||||
//第五波 万夫长+2个千夫长
|
||||
this.create_enemy5 = function (par) {
|
||||
if (!par.boss) {
|
||||
par.boss = this.create_one(1, par.enter_room);
|
||||
}
|
||||
for (var i = par.bing.length; i < 4; i++) {
|
||||
par.bing.push(this.create_one(i < 2 ? 2 : 3, par.enter_room));
|
||||
}
|
||||
}
|
||||
this.create_one = function (index, rm, iswall) {
|
||||
var npc = NPC.CLONE("xiangyang/menggu" + index);
|
||||
npc.name = this.create_mgname();
|
||||
npc.diff_level = 5 - index;
|
||||
// if (index < 4) npc.record_damage = true;
|
||||
// else {
|
||||
|
||||
// }
|
||||
npc.record_damage = true;
|
||||
npc.gate_index = this.create_index;
|
||||
npc.iswall = iswall;
|
||||
if (!iswall) {
|
||||
npc.on_heart_beat = this.check_move.bind(this, npc);
|
||||
}
|
||||
npc.on_die = this.on_bing_die.bind(this, npc);
|
||||
npc.on_died = this.on_bing_died;
|
||||
npc.on_enter = this.check_enemy2;
|
||||
npc.per = npc.random(40) + 1;
|
||||
|
||||
npc.is_menggubing = true;
|
||||
rm.item_changed(npc, true, "一个" + npc.title + "冲了过来。");
|
||||
var item = rm.items.random();
|
||||
if (item && item.is_player) {
|
||||
npc.do_kill(item);
|
||||
}
|
||||
return npc;
|
||||
}
|
||||
this.create_mgname = function () {
|
||||
var str = ["完颜", "纥石烈", "兀颜", "纳兰", "阿迭"].random();
|
||||
str += UTIL.name2[parseInt(Math.random() * UTIL.name2.length)];
|
||||
if (this.random(4) == 1) {
|
||||
str += UTIL.name2[parseInt(Math.random() * UTIL.name2.length)];
|
||||
}
|
||||
return str;
|
||||
}
|
||||
this.gate_states = [
|
||||
{ step: 0, bing: [], dir: "north", enter: "xiangyang/northgate2", name: "北门", wall_count: 0, wall_index: [4, 5, 6, 7, 8, 9, 10, 11] },
|
||||
{ step: 0, bing: [], dir: "west", enter: "xiangyang/westgate2", name: "西门", wall_count: 0, wall_index: [11, 1, 2, 13, 14, 15, 16, 17, 18] },
|
||||
{ step: 0, bing: [], dir: "south", enter: "xiangyang/southgate2", name: "南门", wall_count: 0, wall_index: [18, 19, 20, 21, 22, 23, 24, 25] },
|
||||
{ step: 0, bing: [], dir: "east", enter: "xiangyang/eastgate2", name: "东门", wall_count: 0, wall_index: [25, 26, 27, 28, 1, 2, 3, 4] }
|
||||
];
|
||||
this.check_enemy = function (me) {
|
||||
if (me.is_menggubing) {
|
||||
this.do_kill(me);
|
||||
}
|
||||
}
|
||||
this.check_enemy2 = function (me) {
|
||||
if (!this.fight_type && me.is_player) {
|
||||
this.do_kill(me);
|
||||
}
|
||||
}
|
||||
this.on_guard_die = function (npc, killer, corpse) {
|
||||
if (killer.is_player) {
|
||||
// var count = [1, 2, 3, 4, 5, 5][5 - parseInt(npc.path.replace('xiangyang/shouwei', ''))];
|
||||
// if (count > 0) {
|
||||
// killer.add_temp('jg_week', -count, UTIL.diff_week_time());
|
||||
// killer.add_temp('jg', -count);
|
||||
// killer.notify('<red>你击杀了襄阳守军,军功减少' + count + '。</red>');
|
||||
// }
|
||||
killer.add_temp('jg', -1);
|
||||
killer.notify('<red>你击杀了襄阳守军,军功减少1。</red>');
|
||||
}
|
||||
if (npc == this.guard) {
|
||||
this.finish(0);
|
||||
return;
|
||||
}
|
||||
this.guards.remove(npc);
|
||||
var rm = npc.environment;
|
||||
for (var i = 0; i < rm.items.length; i++) {
|
||||
if (rm.items[i] != npc && rm.items[i].path == npc.path) return;
|
||||
}
|
||||
var isover = true;
|
||||
for (var i = 0; i < this.gate_states.length; i++) {
|
||||
var gate = this.gate_states[i];
|
||||
if (rm.path.indexOf(gate.dir) > -1) {
|
||||
gate.step++;
|
||||
if (gate.step == 2) {
|
||||
this.send_message("襄阳城告急," + gate.name + "被攻破,望各路英雄鼎力相助!");
|
||||
}
|
||||
if (gate.step == 5 && !this.boss) {
|
||||
this.show_boss(gate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.show_boss = function (gate) {
|
||||
if (this.boss) return;
|
||||
if (gate)
|
||||
this.send_message("襄阳城" + gate.name + "被攻破,蒙古各路大军长驱直入,蒙古大汗蒙哥出现在战场中央。");
|
||||
else
|
||||
this.send_message("蒙古各路大军长驱直入,蒙古大汗蒙哥出现在战场中央。");
|
||||
var npc = NPC.CLONE("xiangyang/ge");
|
||||
this.boss = npc;
|
||||
this.boss.add_status({
|
||||
id: "boss",
|
||||
name: "号令",
|
||||
prop: {
|
||||
gj_per: 2,
|
||||
fy_per: 5,
|
||||
ds_per: 5,
|
||||
mz_per: 5,
|
||||
zj_per: 5
|
||||
},
|
||||
no_clear: true,
|
||||
override: 1,
|
||||
count: this.query_enemycount(),
|
||||
max_count: 100,
|
||||
duration: 0,
|
||||
desc: "增加你的属性"
|
||||
});
|
||||
npc.is_menggubing = true;
|
||||
npc.diff_level = 5;
|
||||
this.step = 6;
|
||||
if (this.create_handler) clearTimeout(this.create_handler);
|
||||
npc.on_die = this.on_bing_die.bind(this, npc);
|
||||
npc.on_died = this.on_bing_died;
|
||||
|
||||
ROOM.Get("xiangyang/guangchang").item_changed(npc, true, npc.name + "出现了。");
|
||||
this.check_handler = this.call_out(this.finish.bind(this, 2), 600000);
|
||||
}
|
||||
this.query_enemycount = function () {
|
||||
var sum = 0;
|
||||
for (var i = 0; i < this.gate_states.length; i++) {
|
||||
var gate = this.gate_states[i];
|
||||
sum += gate.bing.length;
|
||||
sum += gate.wall_count;
|
||||
if (gate.boss) sum++;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
this.on_bing_die = function (npc, killer) {
|
||||
if (!this.is_start) return;
|
||||
if (npc == this.boss) {
|
||||
this.finish(1);
|
||||
return;
|
||||
}
|
||||
if (this.boss) {
|
||||
this.boss.remove_status("boss");
|
||||
}
|
||||
var gate = this.gate_states[npc.gate_index];
|
||||
if (npc.iswall) {
|
||||
gate.wall_count--;
|
||||
return;
|
||||
}
|
||||
if (!gate) return;
|
||||
if (npc == gate.boss) {
|
||||
gate.boss = null;
|
||||
} else {
|
||||
gate.bing.remove(npc);
|
||||
}
|
||||
|
||||
}
|
||||
this.check_move = function (npc) {
|
||||
if (npc.environment.is("xiangyang/guangchang")) return;
|
||||
for (var i = 0; i < npc.environment.items.length; i++) {
|
||||
if (npc.environment.items[i].is_dasong) return;
|
||||
}
|
||||
switch (npc.gate_index) {
|
||||
case 0:
|
||||
npc.do_command("go", "south");
|
||||
break;
|
||||
case 1:
|
||||
npc.do_command("go", "east");
|
||||
break;
|
||||
case 2:
|
||||
npc.do_command("go", "north");
|
||||
break;
|
||||
case 3:
|
||||
npc.do_command("go", "west");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.finish = function (issuc) {
|
||||
if (!this.is_start) return;
|
||||
if (this.check_handler) clearTimeout(this.check_handler);
|
||||
for (var i = 0; i < this.gate_states.length; i++) {
|
||||
var gate = this.gate_states[i];
|
||||
if (gate.boss) {
|
||||
gate.boss.destroy();
|
||||
}
|
||||
for (var j = 0; j < gate.bing.length; j++) {
|
||||
gate.bing[j].destroy();
|
||||
}
|
||||
gate.bing = [];
|
||||
gate.boss = null;
|
||||
gate.wall_count = 0;
|
||||
gate.step = 0;
|
||||
}
|
||||
for (var i = 0; i < this.guards.length; i++) {
|
||||
this.guards[i].destroy();
|
||||
}
|
||||
this.guards.length = 0;
|
||||
this.is_start = false;
|
||||
var index = WORLD.DATA.query_temp("xiangyang") + 20;
|
||||
if (issuc == 1) {
|
||||
this.send_message("武神历" + UTIL.to_c(index) + "年蒙古可汗蒙哥被击杀于襄阳城下,襄阳城大获全胜!", true);
|
||||
this.send_message("郭大侠犒赏全军,前往襄阳城领取!", true);
|
||||
WORLD.DATA.set_temp("xy_status", 12, 3600000);
|
||||
WORLD.DATA.set_temp("xy_sc", 2, 3600000);
|
||||
} else if (issuc == 0) {
|
||||
|
||||
this.send_message("武神历" + UTIL.to_c(index) + "年郭大侠战死襄阳,襄阳城失守!", true);
|
||||
if (this.boss)
|
||||
this.boss.destroy();
|
||||
WORLD.DATA.set_temp("xy_status", 10, 3600000);
|
||||
WORLD.DATA.set_temp("xy_sc", 0, 3600000);
|
||||
} else {
|
||||
this.send_message("武神历" + UTIL.to_c(index) + "年蒙古大军久攻不下从襄阳城撤退,襄阳危机解除!", true);
|
||||
this.send_message("郭大侠犒赏全军,前往襄阳城领取!", true);
|
||||
WORLD.DATA.set_temp("xy_status", 11, 3600000);
|
||||
|
||||
WORLD.DATA.set_temp("xy_sc", 1, 3600000);
|
||||
if (this.boss)
|
||||
this.boss.destroy();
|
||||
}
|
||||
this.create_event(issuc);
|
||||
if (this.create_handler) clearTimeout(this.create_handler);
|
||||
this.boss = null;
|
||||
this.guard = null;
|
||||
this.startup();
|
||||
this.xy_area.notify_update();
|
||||
WORLD.DATA.remove_temp('xy_party');
|
||||
|
||||
WORLD.DATA.remove_temp("xy_users");
|
||||
this.call_out(this.reset, 3600000);
|
||||
}
|
||||
this.send_message = function (str, sendall) {
|
||||
COMMAND.DO("sys", str);
|
||||
}
|
||||
|
||||
this.create_event = function (issuc) {
|
||||
let desc = null, command = null;
|
||||
if (issuc === 1) {
|
||||
desc = "襄阳守城活动结束,襄阳城大获全胜,可直接领取犒赏军功!";
|
||||
command = "领取军功";
|
||||
} else if (issuc === 0) {
|
||||
desc = "襄阳守城活动结束,襄阳城失守!";
|
||||
command = "";
|
||||
} else {
|
||||
desc = "襄阳守城活动结束,襄阳危机解除,可直接领取犒赏军功!";
|
||||
command = "领取军功";
|
||||
}
|
||||
EVENTS.add({
|
||||
id: 'xiangyang',
|
||||
name: "襄阳守城",
|
||||
desc: desc,
|
||||
time: WORLD.DATA.temp.xy_status.e,
|
||||
grade: 3,
|
||||
command: command,
|
||||
check: (me) => {
|
||||
if (!this.is_jgmax(me) || me.query_temp('xy_hd', 0) < 2)
|
||||
return true;
|
||||
return false;
|
||||
},
|
||||
on_command: (me) => {
|
||||
this.reward(me);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.reset = function () {
|
||||
this.xy_area.notify_update();
|
||||
}
|
||||
|
||||
this.jg_limit = function (me) {
|
||||
return JUNGONG_LIMITS[me.level];
|
||||
}
|
||||
|
||||
|
||||
this.is_jgmax = function (me) {
|
||||
return me.query_temp('jg_week', 0) >= JUNGONG_LIMITS[me.level];
|
||||
}
|
||||
|
||||
const REWARDS_LIMIT = [0, 10, 20, 30, 40, 50, 60];//奖励等级对应的每份上限
|
||||
const JUNGONG_LIMITS = [10, 50, 100, 200, 300, 400, 500];//每周功绩上限
|
||||
this.reward = function (me, msg = "") {
|
||||
var status = WORLD.DATA.query_temp("xy_status", 0);
|
||||
if (!status) {
|
||||
return me.notify(msg + "最近没什么战事,你可以使用你累积的军功兑换物资!");
|
||||
}
|
||||
if (status == 1) {
|
||||
return me.notify(msg + "襄阳城战事正紧,等击退蒙古大军再说!");
|
||||
}
|
||||
let reward = me.query_temp("xy_hd", 0);
|
||||
if (reward > 1) {
|
||||
return me.notify(msg + "你本周内的奖励军功已经领取过了!");
|
||||
}
|
||||
var count = WORLD.DATA.query_temp("xy_sc", 0);
|
||||
if (!(count > 0 && count < 5))
|
||||
return me.notify(msg + "最近并没有军功奖励可领取。");
|
||||
let limit = REWARDS_LIMIT[me.level];
|
||||
if (!(limit > 0))
|
||||
return me.notify(msg + "你还是先历练历练再来领取犒赏军功吧。");
|
||||
if (reward >= count)
|
||||
return me.notify(msg + "最近并没有更高等级的军功奖励可领取。");
|
||||
|
||||
|
||||
|
||||
me.set_temp('xy_hd', count, UTIL.diff_week_time());
|
||||
let added = (count - reward) * limit;
|
||||
let max = me.add_temp('jg', added);
|
||||
|
||||
return me.notify("<hiy>你领取了" + added + "点军功,目前" + max + "。</hiy>");
|
||||
|
||||
}
|
||||
|
||||
this.bm = function (me, msg = "") {
|
||||
if (me.query_temp("xy_bm")) {
|
||||
return me.notify_fail(msg + "你已经报名守城了。");
|
||||
}
|
||||
const status = WORLD.DATA.query_temp("xy_status", 0);
|
||||
if (status != 1) {
|
||||
return me.notify_fail(msg + "最近没什么战事,不用报名!");
|
||||
}
|
||||
|
||||
if (this.is_jgmax(me))
|
||||
return me.notify_fail(msg + "你本周的军功已经达到到上限。");
|
||||
|
||||
const pt = WORLD.DATA.query_temp('xy_party');
|
||||
if (pt) {
|
||||
if (pt != me.query_temp('pt'))
|
||||
return me.notify_fail(msg + "目前" + pt + "正在协助守城,你就不要去添乱了。");
|
||||
}
|
||||
if (me.query_temp('xy_bm2')) {
|
||||
return me.notify_fail(msg + "你最近刚刚战斗过,休息一天再来报名吧。");
|
||||
}
|
||||
const user_count = WORLD.DATA.query_temp("xy_users", 0);
|
||||
if (user_count >= 40) return me.notify(msg + "参与守城的人已经够了,你就不要去添乱了。");
|
||||
|
||||
me.set_temp('xy_bm', 1, 3600000);
|
||||
me.set_temp('xy_bm2', 1, UTIL.diff_time());
|
||||
WORLD.DATA.add_temp("xy_users", 1);
|
||||
this.xy_area.notify_update();
|
||||
me.notify("<hic>你已经报名参与守城,一周内所获军功未到上限前可重复报名。</hic>");
|
||||
return true;
|
||||
}
|
||||
|
||||
function add_jungong(me, count) {
|
||||
let max = JUNGONG_LIMITS[me.level];
|
||||
if (me.query_temp('jg_week', 0) >= max) return false;
|
||||
let value = me.add_temp('jg_week', count, UTIL.diff_week_time());
|
||||
if (value > max) {
|
||||
me.add_temp('jg_week', max - value, UTIL.diff_week_time());
|
||||
count = count + max - value;
|
||||
me.add_temp('jg', count);
|
||||
value = max;
|
||||
} else {
|
||||
me.add_temp('jg', count);
|
||||
}
|
||||
me.notify("<hiy>你获得了" + count + "点军功,本周已获得"
|
||||
+ value + "/" + max + "。</hiy>");
|
||||
}
|
||||
|
||||
this.on_bing_died = function (killer, corpse) {
|
||||
if (!killer) return;
|
||||
corpse.no_alloc = true;
|
||||
corpse.clear_items = clear_items.bind(this, corpse);
|
||||
corpse.query_items = query_items.bind(this);
|
||||
this.drops_count = 0;
|
||||
if (this.diff_level < 2) {
|
||||
let room = this.die_room;
|
||||
|
||||
let min_damage = this.max_hp * 0.03;
|
||||
for (let key in this.damages) {
|
||||
if (this.damages[key] >= min_damage) {
|
||||
let item = room.find_obj(key);
|
||||
if (!item || item.is_player) {
|
||||
this.drops_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.drops_count === 0)
|
||||
corpse.disappear();
|
||||
}
|
||||
}
|
||||
const JUNGONGS = [1, 5, 10, 15, 20, 25, 30];
|
||||
const EQ_ODDS = [1500, 2500, 3100, 4050, 5001, 5005];
|
||||
//绿 1500-1000
|
||||
//蓝 2500-1000 2500-2000
|
||||
//黄 3100-1000 3100-2000 3100-3000
|
||||
//紫 4050-1000 4050-2000 4050-3000 4050-4000
|
||||
|
||||
function is_bm(user) {
|
||||
var bm = user.query_temp('xy_bm');
|
||||
if (!bm) return false;
|
||||
if (user.query_temp('jg_week', 0)
|
||||
>= JUNGONG_LIMITS[user.level]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function query_items(me) {
|
||||
if (!this.damages) return;
|
||||
var sh = this.damages[me.id];
|
||||
if (!(sh > 0)) return;
|
||||
if (!this.user_items) this.user_items = {};
|
||||
if (this.user_items[me.id]) return this.user_items[me.id];
|
||||
if (!is_bm(me)) return;
|
||||
sh = parseInt(sh * 100 / this.max_hp);
|
||||
if (sh < 3) {
|
||||
this.user_items[me.id] = [OBJ.CREATE('money/silver', 1 + me.random(3))];
|
||||
return this.user_items[me.id];
|
||||
}
|
||||
if (sh > 100) sh = 80;
|
||||
const diff_level = this.diff_level;
|
||||
const drops = [
|
||||
{
|
||||
obj: "money/silver",
|
||||
min: 1,
|
||||
max: 1 + 5 * diff_level
|
||||
}
|
||||
];
|
||||
|
||||
if (diff_level > 3) {
|
||||
drops.push({
|
||||
obj: ["book/bc#zhongpingqiang", "book/bc#longxianggong", "book/bc#mengguqiangfa"],
|
||||
odds: 10 + sh * 50
|
||||
});
|
||||
} else if (diff_level > 1) {
|
||||
drops.push({
|
||||
obj: ["book/bc#zhongpingqiang", "book/bc#mengguqiangfa"],
|
||||
odds: 10 + sh * 50
|
||||
});
|
||||
}
|
||||
var items = OBJ.create_by_odds(drops);
|
||||
|
||||
this.user_items[me.id] = items;
|
||||
|
||||
if (diff_level < 1) {
|
||||
add_jungong(me, 1);
|
||||
} else {
|
||||
add_jungong(me, parseInt(JUNGONGS[diff_level]
|
||||
* Math.max(sh, 50) / 50));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
function clear_items(corpse, me) {
|
||||
if (this.user_items && this.user_items[me.id]) {
|
||||
this.user_items[me.id].length = 0;
|
||||
if (this.drops_count > 0) {
|
||||
this.drops_count--;
|
||||
if (this.drops_count <= 0) {
|
||||
corpse.disappear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
137
world/task/ym_task.js
Normal file
137
world/task/ym_task.js
Normal file
@@ -0,0 +1,137 @@
|
||||
|
||||
this.inherits(USERTASK);
|
||||
this.id = "yamen";
|
||||
|
||||
|
||||
const TAGS = ['wht', 'hig', 'hic', 'hiy', 'hiz', 'hio', 'ord'];
|
||||
this.query_title = function (me) {
|
||||
let tag = TAGS[me.query_temp('ym_level', 0)];
|
||||
return `<${tag}>衙门兼职</${tag}>`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const TITLES = ['', '衙役', '捕快', '捕头', '总捕头', '巡检', '神捕'];
|
||||
|
||||
this.query_desc = function (me) {
|
||||
let lv = me.query_temp("ym_level", 0);
|
||||
if (!(lv > 0)) return;
|
||||
|
||||
let tm = me.query_temp("ym_tm", 0);
|
||||
let ym = 0;
|
||||
let mem = "";
|
||||
let max = 60;
|
||||
if (tm > 0) {
|
||||
ym = Math.floor((Date.now() - tm * 100000) / 3600000);
|
||||
if (ym <= 0) {
|
||||
ym = 0;
|
||||
let time = tm * 100000 + 3600000 - Date.now();
|
||||
if (time > 0) {
|
||||
mem = ",下次领取" + this.format_time_span(time);
|
||||
}
|
||||
} else if (ym < max) {
|
||||
let time = tm * 100000 + 3600000 * (ym + 1) - Date.now();
|
||||
if (time > 0) {
|
||||
mem = ",下次领取" + this.format_time_span(time);
|
||||
}
|
||||
} else {
|
||||
mem = ",已到上限";
|
||||
ym = Math.min(ym, 60);
|
||||
}
|
||||
}
|
||||
return `你帮衙门追捕逃犯,目前是${TITLES[lv]}职位,可以领取衙门发放的报酬,当前累计${ym}/60。<br><mem>每小时获得一份报酬,通过追捕更高级别的逃犯提高收益等级${mem}</mem>`;
|
||||
}
|
||||
this.format_time_span = function (time) {
|
||||
if (time > 3600000)
|
||||
return Math.floor(time / 3600000) + "小时后";
|
||||
if (time > 60000)
|
||||
return Math.floor(time / 60000) + "分钟后";
|
||||
return Math.floor(time / 1000) + "秒后";
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
//0 不显示 1,进行中,2.可领取 3.已完成
|
||||
this.query_state = function (me) {
|
||||
let lv = me.query_temp("ym_level", 0);
|
||||
if (!(lv > 0)) return 0;
|
||||
let sm = this.query_ymcount(me);
|
||||
return sm > 0 ? 2 : 1;
|
||||
}
|
||||
|
||||
//100000 1350000 17066666 84375000 312500000 714583333
|
||||
//1 2 7 20 45 120
|
||||
//100000 700000 2438095 4218750 5208333 600000
|
||||
const EXPS = [0, 5000, 8000, 12000, 16000, 20000, 25000];
|
||||
const STONES = [0, 5, 10, 15, 20, 25, 30, 35, 40, 60, 70, 80, 90];
|
||||
const STONES_PATHS = ["st/st_blu#0", "st/st_gre#0", "st/st_red#0", "st/st_yel#0"];
|
||||
|
||||
this.on_finish = function (me) {
|
||||
let ym_count = this.query_ymcount(me);
|
||||
if (!(ym_count > 0)) return false;
|
||||
let ym_lv = me.query_temp("ym_level", 0);
|
||||
if (!(ym_lv > 0)) return false;
|
||||
let exp = EXPS[ym_lv] * ym_count;
|
||||
let pot = exp;
|
||||
if (me.level > 2) {
|
||||
pot = parseInt(me.exp / 1200);
|
||||
if (pot > 150000) {
|
||||
pot = 150000;
|
||||
}
|
||||
pot = pot * ym_count;
|
||||
}
|
||||
me.add_exp(exp, pot);
|
||||
|
||||
this.set_curtm(me, ym_count);
|
||||
|
||||
let obj_count = STONES[ym_lv] * ym_count;
|
||||
|
||||
let obj = me.add_obj("st/xuanjing", obj_count);
|
||||
if (obj) {
|
||||
me.send("你获得了" + obj.unit_name(obj_count) + "。");
|
||||
}
|
||||
obj_count = ym_count * ym_lv;
|
||||
while (obj_count > 0) {
|
||||
let count = this.random(obj_count);
|
||||
if (count < 1) count = 1;
|
||||
obj = me.add_obj(STONES_PATHS.random(), count);
|
||||
obj_count -= count;
|
||||
me.send("你获得了" + obj.unit_name(count) + "。");
|
||||
}
|
||||
me.send('<hic>你领取了' + ym_count + '份衙门发放的报酬。</hic>');
|
||||
|
||||
let time = Date.now();
|
||||
if (time > WORLD.DATA.act_stime) {
|
||||
let stime = time - ym_count * 3600000;
|
||||
if (stime < WORLD.DATA.act_stime) stime = WORLD.DATA.act_stime;
|
||||
if (time > WORLD.DATA.act_etime) time = WORLD.DATA.act_etime;
|
||||
|
||||
let count = Math.floor((time - stime) / 3600000);
|
||||
count = count * Math.max(me.query_temp('ym_level', 0) - 1, 1);
|
||||
if (count > 0) {
|
||||
let cjjf = me.add_temp('my', count);
|
||||
me.notify('<hiy>你获得' + count + "枚古币,当前总计" + cjjf + "。</hiy>");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
this.set_curtm = function (me, count) {
|
||||
|
||||
|
||||
let tm = me.query_temp("ym_tm", 0);
|
||||
|
||||
tm = Math.max((Date.now() - 3600000 * 60) / 100000, tm);
|
||||
|
||||
|
||||
tm += Math.floor((count * 36));
|
||||
|
||||
|
||||
me.set_temp("ym_tm", tm);
|
||||
|
||||
}
|
||||
197
world/task/ym_task2.js
Normal file
197
world/task/ym_task2.js
Normal file
@@ -0,0 +1,197 @@
|
||||
|
||||
this.inherits(USERTASK);
|
||||
this.id = "yamen2";
|
||||
this.requests = new Map();
|
||||
|
||||
this.on_create = function () {
|
||||
var task = USERTASK.GET('yamen2');
|
||||
if (task) {
|
||||
this.requests = task.requests;
|
||||
}
|
||||
}
|
||||
|
||||
const TAGS = ['wht', 'hic', 'hiy', 'hiz', 'hio', 'ora'];
|
||||
this.query_title = function (me) {
|
||||
let tag = TAGS[me.query_temp('ym_level', 0)];
|
||||
|
||||
return `<${tag}>衙门追捕</${tag}>`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const TITLES = ['', '衙役', '捕快', '捕头', '总捕头', '巡检 ', '神捕'];
|
||||
const UPGRADE_COUNT = [1, 10, 10, 10, 10, 10];
|
||||
|
||||
this.query_desc = function (me) {
|
||||
let request = this.query_request(me);
|
||||
if (!request) return me.remove_temp('ym_task');
|
||||
var str = ["扬州知府委托你追杀逃犯:"];
|
||||
if (request && request.npc) {
|
||||
str.push(request.npc.name);
|
||||
str.push(",据说最近在");
|
||||
str.push(request.wz);
|
||||
str.push("出现过,你还有");
|
||||
var time = request.time - Date.now();
|
||||
if (time <= 0) {
|
||||
this.clear(me);
|
||||
return "你的任务失败了。";
|
||||
}
|
||||
str.push(parseInt(time / 60000));
|
||||
str.push("分");
|
||||
str.push(parseInt((time % 60000) / 1000));
|
||||
str.push("秒去寻找他。\n");
|
||||
let level = me.query_temp('ym_level', 0);
|
||||
let level2 = me.query_temp('ym_lv2', 0);
|
||||
if (level > 0)
|
||||
str.push("<mem>追捕成功后(", level2, '/', UPGRADE_COUNT[level],
|
||||
"),将提升为", TITLES[level + 1], "。</mem>");
|
||||
else
|
||||
str.push("<mem>追捕成功后将加入衙门兼职,每日获得衙门发放的报酬。</mem>");
|
||||
} else {
|
||||
str.push("找不到了。");
|
||||
}
|
||||
|
||||
return str.join("");
|
||||
}
|
||||
|
||||
this.query_state = function (me) {
|
||||
let request = this.query_request(me);
|
||||
if (me.query_temp("ym_task") && request)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const LEVEL_LIMIT = [0, 1000000, 5000000, 17000000, 80000000, 300000000, 1000000000];
|
||||
const LEVEL_LIMIT2 = [0, 0, 0, 0, 23000000, 50000000, 1500000000];
|
||||
|
||||
this.start = function (player) {
|
||||
if (player.query_temp("ym_task")) {
|
||||
var request = this.requests.get(player.id);
|
||||
if (request)
|
||||
return player.notify("程药发对你说道:你不是在追捕吗? 好好干。");
|
||||
}
|
||||
let lv = player.query_temp('ym_level', 0);
|
||||
|
||||
if (lv >= TITLES.length)
|
||||
return player.notify("程药发对你说道:你已经是最高等级的神捕,不用再证明自己。");
|
||||
|
||||
const lv2 = player.query_temp('ym_lv2', 0);
|
||||
|
||||
const npc = NPC.CLONE("pub/yamen");
|
||||
npc.init_from(player, lv, lv2);
|
||||
|
||||
const rm = ROOM.RANDOM();
|
||||
rm.item_changed(npc, true);
|
||||
this.set_request(player, npc, rm.long_name);
|
||||
|
||||
if (lv > 0) {
|
||||
player.notify("程药发对你说道:你来的正好," + npc.name + "作恶多端,还请" + player.call() + "为民除害,听说他最近在" + rm.long_name + "出现过。");
|
||||
|
||||
player.send_commands('goto yamen2', '过去');
|
||||
}
|
||||
else {
|
||||
player.notify("程药发对你说道:这位" + player.call() + ",你还没加入衙门吧,这样,你去除掉" + npc.name + ",我就收了你,听说他最近在" + rm.long_name + "出现过。");
|
||||
}
|
||||
|
||||
player.set_temp("ym_task", npc.id);
|
||||
npc.set_temp("player", player.id);
|
||||
npc.on_died = this.check.bind(this, npc);
|
||||
npc.on_kill = this.check_player;
|
||||
}
|
||||
|
||||
this.to_taofan = function (player) {
|
||||
var request = this.requests.get(player.id);
|
||||
if (request) {
|
||||
let npc = request.npc;
|
||||
if (npc && npc.hp > 0) {
|
||||
player.moveto(npc.environment, player.name + '离开了。', player.name + "走了过来。");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.query_request = function (me) {
|
||||
|
||||
return this.requests.get(me.id);
|
||||
}
|
||||
this.set_request = function (me, npc, wz) {
|
||||
this.requests.set(me.id, {
|
||||
npc: npc,
|
||||
time: Date.now() + 600000,
|
||||
handler: this.call_out(this.clear, 600000, me, npc),
|
||||
wz: wz
|
||||
});
|
||||
}
|
||||
this.check_player = function (me) {
|
||||
if (me.id != this.query_temp("player")) {
|
||||
return me.notify_fail(this.name + "对你喊道:" + me.call(true) + ",别多管闲事!");
|
||||
}
|
||||
}
|
||||
this.remove_request = function (me, isremove) {
|
||||
var request = this.requests.get(me.id);
|
||||
if (!request) return;
|
||||
if (isremove && request.npc) {
|
||||
request.npc.destroy();
|
||||
request.npc.send_room("<cyn>$N向后跃开三尺,高声喊道:青山不改,绿水长流,咱们走着瞧!</cyn>\n");
|
||||
}
|
||||
request.npc = null;
|
||||
clearTimeout(request.handler);
|
||||
this.requests.delete(me.id);
|
||||
}
|
||||
|
||||
this.check = function (npc, killer, corpse) {
|
||||
var user = npc.query_temp("player");
|
||||
if (!killer || killer.id != user || killer.query_temp("ym_task") != npc.id) {
|
||||
var real_player = WORLD.getUser(user);
|
||||
if (real_player) {
|
||||
real_player.notify("<hic>你追捕的逃犯被别人击杀,你的任务失败了。</hic>");
|
||||
real_player.remove_temp("ym_task");
|
||||
this.remove_request(real_player, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const player = killer;
|
||||
this.remove_request(player, false);
|
||||
|
||||
player.remove_temp("ym_task");
|
||||
|
||||
let level = player.query_temp("ym_level", 0);
|
||||
if (level >= TITLES.length) return;
|
||||
|
||||
if (level === 0) {
|
||||
player.notify("<hic>你成功帮助衙门追捕犯人,获得称号【衙役】</hic>");
|
||||
player.add_title(TITLES[1], "ym");
|
||||
player.add_temp("ym_level", 1);
|
||||
player.set_temp("ym_tm", Math.floor(Date.now() / 100000));
|
||||
player.notify("\n<hiy>扬州衙门将对你持续发放报酬,从任务栏领取。</hiy>\n");
|
||||
} else {
|
||||
let level2 = player.add_temp("ym_lv2", 1);
|
||||
if (level2 >= UPGRADE_COUNT[level]) {
|
||||
|
||||
USERTASK.GET('yamen').on_finish(player);
|
||||
level = player.add_temp("ym_level", 1);
|
||||
player.remove_temp("ym_lv2", 0);
|
||||
player.notify("<hic>你帮助衙门连续追捕犯人,获得称号:" + TITLES[level] + "。</hic>");
|
||||
player.add_title(TITLES[level], "ym");
|
||||
player.notify("<hiy>你的衙门报酬等级提高了。</hiy>");
|
||||
} else {
|
||||
|
||||
player.notify("<hic>追捕成功,当前级别" + TITLES[level] + "(" + level2 + "/" + UPGRADE_COUNT[level] + ")。</hic>");
|
||||
|
||||
}
|
||||
let obj = player.add_obj(["st/st_blu#",
|
||||
"st/st_gre#", "st/st_red#", "st/st_yel#"].random() + Math.min(level, 4));
|
||||
player.notify("你获得" + obj.unit_name(1) + "。");
|
||||
let exp = [5000, 8000, 12000, 16000, 20000, 25000][level - 1];
|
||||
player.add_exp(exp, exp);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
this.clear = function (player, npc) {
|
||||
this.giveup(player);
|
||||
player.notify("<red>你的追捕任务失败了。</red>");
|
||||
}
|
||||
this.giveup = function (player) {
|
||||
player.remove_temp("ym_task");
|
||||
this.remove_request(player, true);
|
||||
}
|
||||
Reference in New Issue
Block a user