feat(quests): add AVA2 travel menu and staged sash compatibility deployment
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate an NPC menu; instanced dungeons always go to their original admission NPC."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
ROOT=Path(__file__).resolve().parent
|
||||
|
||||
def generate():
|
||||
rows=json.loads((ROOT/'destinations.json').read_text())['destinations']
|
||||
lines=['-- Generated by generate.py; UTF-8, compiled as GBK by install.py.',
|
||||
'quest ava2_travel begin',' state start begin',
|
||||
' function destinations()',' return {']
|
||||
for row in rows:
|
||||
lines.append(' {%s, %d, %d, %d, %s},'%(
|
||||
json.dumps(row['name'],ensure_ascii=False),row['x'],row['y'],row['level'],
|
||||
'true' if row['mode']=='entrance' else 'false'))
|
||||
lines+=[' }',' end', ''' function menu()
|
||||
local destinations = ava2_travel.destinations()
|
||||
local page = 1
|
||||
while true do
|
||||
local first = (page-1)*5+1
|
||||
local last = math.min(first+4,table.getn(destinations))
|
||||
local options = {}
|
||||
for i=first,last do table.insert(options,destinations[i][1]) end
|
||||
local count = table.getn(options)
|
||||
local previous = 0
|
||||
local following = 0
|
||||
if page>1 then table.insert(options,"上一页") previous=table.getn(options) end
|
||||
if last<table.getn(destinations) then table.insert(options,"下一页") following=table.getn(options) end
|
||||
table.insert(options,"关闭")
|
||||
say_title("新地图与副本入口")
|
||||
local choice=select_table(options)
|
||||
if choice==table.getn(options) then return
|
||||
elseif previous>0 and choice==previous then page=page-1
|
||||
elseif following>0 and choice==following then page=page+1
|
||||
elseif choice>=1 and choice<=count then
|
||||
local target=destinations[first+choice-1]
|
||||
say_title(target[1])
|
||||
if pc.get_level()<target[4] then
|
||||
say("需要等级:"..target[4])
|
||||
return
|
||||
end
|
||||
if target[5] then
|
||||
say("传送到入口 NPC 附近。")
|
||||
say("门票、组队及冷却仍由原副本检查。")
|
||||
end
|
||||
if select("传送","取消")==1 then
|
||||
if not pc.can_warp() then
|
||||
say("当前不能传送,请稍后再试。")
|
||||
return
|
||||
end
|
||||
pc.warp(target[2],target[3])
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
when 9012.chat."新地图与副本入口" or 20090.chat."新地图与副本入口" begin
|
||||
ava2_travel.menu()
|
||||
end
|
||||
end
|
||||
end''']
|
||||
result='\n'.join(lines)+'\n'
|
||||
if b'\\' in result.encode('gbk'):raise ValueError('GBK backslash byte is unsafe for qc')
|
||||
return result
|
||||
|
||||
if __name__=='__main__':(ROOT/'ava2_travel.quest').write_text(generate())
|
||||
Reference in New Issue
Block a user