141 lines
4.5 KiB
Lua
141 lines
4.5 KiB
Lua
-- QF入口文件 当m2启动时候就会加载
|
|
math.randomseed(tostring(os.time()):reverse():sub(1, 7))
|
|
|
|
local _,errinfo = pcall(function ()
|
|
--配置
|
|
require("Envir/QuestDiary/config/VarCfg.lua") --全局变量
|
|
require("Envir/QuestDiary/config/GlobalVarDefine.lua") --G变量定义
|
|
require("Envir/QuestDiary/config/EquipSiteDefine.lua") --装备位置
|
|
require("Envir/Market_Def/shuxingzhixing.lua") ----各类属性执行
|
|
require("Envir/Market_Def/zhuanshuattr.lua") ----专属装备属性操作
|
|
|
|
require("Envir/Market_Def/wza.lua") --个人封装函数
|
|
require("Envir/Market_Def/UseItem.lua") --使用道具31类双击触发
|
|
|
|
require("Envir/Market_Def/denglujiemian.lua") --登录界面
|
|
require("Envir/Market_Def/GmBox.lua") ----gm命令箱
|
|
require("Envir/Market_Def/npcdianji.lua") ----npc点击
|
|
end)
|
|
|
|
if errinfo then release_print("初始化QFunction-0.lua", errinfo) end
|
|
|
|
--引擎启动
|
|
function startup()
|
|
if getsysint("开区时间") == 0 then -----设置开区时间
|
|
setsysint("开区时间",os.time())
|
|
end
|
|
|
|
setontimerex(1, 1*60) --1分钟执行一次的全局定时器
|
|
end
|
|
|
|
--1分钟执行一次的全局定时器
|
|
function ontimerex1()
|
|
local nowTime = os.time()
|
|
local kftick = getsysint("开区时间")
|
|
local config = GLOBAL_VAR.CDconfig
|
|
local serverTime = nowTime - kftick
|
|
|
|
--获取基础值
|
|
local function _getBasicValue(i)
|
|
for j = #config[i].Basic, 1, -1 do
|
|
if serverTime >= config[i].Basic[j][1] * 3600 then
|
|
return config[i].Basic[j][2]
|
|
end
|
|
end
|
|
end
|
|
|
|
for i = 1, #config do
|
|
--从G100开始
|
|
local id = 100 + i - 1
|
|
local basic = _getBasicValue(i)
|
|
SetGVar(id, basic)
|
|
end
|
|
end
|
|
|
|
--登录触发
|
|
function login(actor)
|
|
local play_name = getname(actor)
|
|
local server_name = getconst(actor,"<$SERVERNAME>") --服务器名字
|
|
local user_account = getconst(actor,"<$USERACCOUNT>")
|
|
|
|
if tonumber(globalinfo(3)) ~= getsysint("合区次数") then
|
|
setsysint("合区次数",tonumber(globalinfo(3)))
|
|
end
|
|
|
|
-- 刷怪初始化
|
|
for i = 1, #GLOBAL_VAR.config do
|
|
if GetGVar(GLOBAL_VAR.config[i][1]) ~= GLOBAL_VAR.config[i][2] then
|
|
SetGVar(GLOBAL_VAR.config[i][1], GLOBAL_VAR.config[i][2])
|
|
end
|
|
end
|
|
|
|
--显示击杀玩家次数以及阵亡次数
|
|
local kill_count = getint(actor, "杀死玩家次数")
|
|
local death_count = getint(actor, "被玩家杀死次数")
|
|
setranklevelname(actor,"%s\\[击杀"..kill_count.."人]\\[阵亡"..death_count.."次]")
|
|
|
|
--魔血球
|
|
if getispc(actor) then
|
|
callscriptex(actor, "PLAYMAGICBALLEFFECT", 0, 12, 200, -1, 0, 1, 15, -3, 100)
|
|
callscriptex(actor, "PLAYMAGICBALLEFFECT", 0, 12, 200, -1, 1, 1, -6, -3, 100)
|
|
callscriptex(actor, "PLAYMAGICBALLEFFECT", 0, 12, 200, -1, 2, 1, 16, -3, 100)
|
|
else
|
|
callscriptex(actor, "PLAYMAGICBALLEFFECT", 0, 12, 200, -1, 0, 1, 0, 7, 100)
|
|
callscriptex(actor, "PLAYMAGICBALLEFFECT", 0, 12, 200, -1, 1, 1, -6, 7, 100)
|
|
callscriptex(actor, "PLAYMAGICBALLEFFECT", 0, 12, 200, -1, 2, 1, 0, 7, 100)
|
|
end
|
|
|
|
--------新人登录段
|
|
local isnewhuman = getbaseinfo(actor, 47)
|
|
if isnewhuman then
|
|
--角色创建时间
|
|
setint(actor,"角色创建时间",os.time())
|
|
|
|
giveitem(actor,"随机传送石",1,370)
|
|
giveitem(actor,"盟重回城石",1,370)
|
|
--初次登陆添加技能
|
|
local skilltab = {
|
|
"基本剑术","攻杀剑术","刺杀剑术","野蛮冲撞","半月弯刀","烈火剑法","施毒术",
|
|
}
|
|
for _, skill_name in ipairs(skilltab) do
|
|
if getskillinfo(actor,getskillindex(skill_name),1) == nil then
|
|
addskill(actor, getskillindex(skill_name), 3)
|
|
end
|
|
end
|
|
|
|
changestorage(actor, 48*5) --仓库格子
|
|
setbagcount(actor, 40*3+6) --背包格子
|
|
setsndaitembox(actor,1) --开启首饰盒
|
|
mapmove(actor,"dl1",330,330,6) --飞到出生点
|
|
callscriptex(actor, "CLIENTSWITCH", 0, 1)
|
|
callscriptex(actor, "CLIENTSWITCH", 2, 1)
|
|
else
|
|
mapmove(actor,"dl1",330,330,6)
|
|
end
|
|
-------新人登陆段结束
|
|
|
|
denglu_addbuttons(actor) --添加按钮 在文件denglujiemian里
|
|
|
|
end
|
|
|
|
--人物攻击前触发
|
|
function attackdamage(actor,shoujizhe,gongjizhe,skillid,damage,model)
|
|
damage = gongjiqianzhixing(actor,shoujizhe,gongjizhe,skillid,damage,model)
|
|
return damage
|
|
end
|
|
|
|
--玩家受击前触发
|
|
function struckdamage(actor,gongjizhe,shoujizhe,skillid,damage)
|
|
damage = shoujiqianzhixing(actor,gongjizhe,shoujizhe,skillid,damage)
|
|
return damage
|
|
end
|
|
|
|
--穿戴装备后触发
|
|
function takeonex(actor,makeIndex,where,itemName,idx)
|
|
add_zhuanshu_attr(actor, itemName)
|
|
end
|
|
|
|
--脱下装备后触发
|
|
function takeoffex(actor,makeIndex,where,itemName,idx)
|
|
del_zhuanshu_attr(actor, itemName)
|
|
end |