考虑两种方法:
1,一台消息机, 消息机上传递着各种不同的消息。
2, 一台消息机, 消息机运行各种不同的状态。

如果采用方法1,区分因消息而区分。同时因为有很多消息是大同小异的, 即类型一致的, 在共用同一消息机的情况, 需在编码期就对这些会类型一致的执行期消息必须进行具体的应用逻辑以区分(例如不同的数值编码)。问题域和设计域不能获得“直接一致”的映射。

如果采用方法2, 区分因消息机而区分。消息大同小异的问题可以因为消息机的不同而自动获得解决。同时针对监听某一个消息的触发, 实现上不用再大家一起并行的监听了, 而是监听层也有层次关系。问题域和设计域的映射更直接, 可以减少很多由于映射不同的实现问题(例如删除时的复杂度)。方法2因为消息机是执行期才产生, 没法提前约定好, 异致需在执行期再进行绑定。

如果没有内部消息机, 那么一些“子消息”就必须走根消息机的渠道, 那么模块内部的“子消息”的定义可能会和其它模块的消息定义起同值冲突。所以子消息最好是在子消息机里面处理, 这样域不同,就不担心和其它模块的冲突了。

主要是节省了为一些用于控制序列的类型一致的消息的反复实现功能。

--[[
file name :     story_server.lua
author  :   Clark/陈泽丹
created :   2012-9-20
purpose :   消息
--]]
--事件转消息
function new_story_msg( _EVENT )
local public = { EVENT = _EVENT, FROM_SVR = nil }
return public
end
--否决消息监听
function new_story_vote_msg_listener()
local public = {}
function public.on_vote( _t_msg )
myPrint("未实现 new_story_vote_msg_listener", 1)
return false
end
return public
end
--执行消息监听
function new_story_action_msg_listener()
local public = {}
function public.on_action( _t_msg )
myPrint("未实现 new_story_action_msg_listener", 1)
end
return public
end
--完毕消息监听
function new_story_response_msg_listener()
local public = {}
function public.on_response( _t_msg )
myPrint("未实现 new_story_response_msg_listener", 1)
end
return public
end
--消息处理机
function new_story_server()
local function new_event_map()
local this_public = {}
this_public.map = {}
function this_public.add_listener(_p_moudle, _event)
if nil == this_public.map[_event] then
this_public.map[_event] = {}
end
local t = this_public.map[_event]
local len = table.getn(t)
for i=1, len do
if t[i] == _p_moudle then
return
end
end
t[ table.getn(t) + 1 ] = _p_moudle
end
function this_public.remove_listener(_p_moudle, _event)
if nil ~= this_public.map[_event] then
local t = this_public.map[_event]
local len = table.getn(t)
for i=1, len do
if t[i] == _p_moudle then
t[i] = t[len]
t[len] = nil
if table.getn(t) <= 0 then
this_public.map[_event] = nil
end
return
end
end
end
end
function this_public.clear()
this_public.map = {}
end
return this_public
end
local public = {}
public.vote_map = new_event_map()
public.action_map = new_event_map()
public.response_map = new_event_map()
function public.clear()
public.vote_map.clear()
public.action_map.clear()
public.response_map.clear()
end
function public.dispatch_msg( _t_msg )
--GameAPI_Print( _t_msg )
_t_msg.FROM_SVR = public
--否决
if nil ~= public.vote_map.map[ _t_msg.EVENT ] then
local t = public.vote_map.map[ _t_msg.EVENT ]
local len = table.getn( t )
for i=1, len do
if t[i].on_vote( _t_msg ) then
return
end
end
end
--触发
if nil ~= public.action_map.map[ _t_msg.EVENT ] then
local t = public.action_map.map[ _t_msg.EVENT ]
local len = table.getn( t )
for i=1, len do
t[i].on_action( _t_msg )
end
end
--完毕
if nil ~= public.response_map.map[ _t_msg.EVENT ] then
local t = public.response_map.map[ _t_msg.EVENT ]
local len = table.getn( t )
for i=1, len do
t[i].on_response( _t_msg )
end
end
end
return public
end
--发送消息
function send_msg_to_server(_server, _t_msg)
_server.dispatch_msg(_t_msg)
end
--[[
file name :     user_story.lua
author  :   Clark/陈泽丹
created :   2012-9-20
purpose :   消息处理者
--]]
--定时函数消息处理自定义者
G_STORY_TIMER_ACTION_FUN = {}
API_AddLUAReqFunc("onStoryTimeCallBack")
function onStoryTimeCallBack(_par1, _par2)
local tgrID = API_GetCurTriggerID()
local lst = G_STORY_TIMER_ACTION_FUN[tgrID]
if nil ~= lst then
local ret = lst.timer_callback(_par1, _par2)
if nil ~= ret then
API_DestroyTriggerG(tgrID)
end
else
API_DestroyTriggerG(tgrID)
end
end
--死亡函数消息处理自定义者
G_STORY_DIE_ACTION_FUN = {}
API_AddLUAReqFunc("onStoryDieCallBack")
function onStoryDieCallBack(_par1, _par2, Type, FastID, KillerType, KillerID, MonsterID, MapID, PosX, PosY)
local tgrID = API_GetCurTriggerID()
local lst = G_STORY_DIE_ACTION_FUN[tgrID]
if nil ~= lst then
local ret = lst.die_callback(_par1, _par2, Type, FastID, KillerType, KillerID, MonsterID, MapID, PosX, PosY)
if nil ~= ret then
API_DestroyTriggerG(tgrID)
end
else
API_DestroyTriggerG(tgrID)
end
end
--应用层消息
function new_inout_msg(_in_msg, _out_msg)
local t_inout_msg = {}
t_inout_msg.in_msg = _in_msg
t_inout_msg.out_msg = _out_msg
return t_inout_msg
end
--生成指定参数消息
function new_par_msg( _t_par )
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data( _t_par ))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end
--记数
function new_story_count()
local private = {}
local public = {}
private.val = 0
function public.set_val( _val )
private.val = _val
end
function public.add_val( _val )
private.val = private.val + _val
end
function public.get_val( )
return private.val
end
function public.is_same( _val )
if private.val == _val then
return true
end
return false
end
return public
end
--消息体系
function new_story()
local pbl_story = {}
local prv_story = {}
prv_story.is_play = true
--发送消息
function prv_story.send_msg_to_server(_server, _t_msg)
if prv_story.is_play then
_server.dispatch_msg(_t_msg)
end
end
--暂停
function pbl_story.pase()
prv_story.is_play = false
end
--进行
function pbl_story.play()
prv_story.is_play = true
end
--获得消息体系进行状态
function pbl_story.is_play()
return prv_story.is_play
end
--否决消息处理类
function prv_story.new_story_user_on_vote()
local public = {}
--消息处理者本身也可以是个消息机
public.msg_svr = new_story_server()
local lst = new_story_vote_msg_listener()
local vote_link = {}
function public.activate( _msg )
prv_story.send_msg_to_server( public.msg_svr,  _msg)
end
--获得当前通讯体系的控制权
function public.get_system( _source )
return pbl_story
end
function public.push_link( _source, _evt )
_evt = _evt or 1
if nil ~= vote_link[ _source ] then
if 1 == vote_link[ _source ][ _evt ] then
return false
end
end
if nil == vote_link[ _source ] then
vote_link[ _source ] = {}
end
vote_link[ _source ][ _evt ] = 1
_source.msg_svr.vote_map.add_listener(lst, _evt)
return true
end
function public.pop_link( _source, _evt )
_evt = _evt or 1
if nil ~= vote_link[ _source ] then
if 1 == vote_link[ _source ][ _evt ] then
_source.msg_svr.vote_map.remove_listener(lst, _evt)
vote_link[ _source ][ _evt ] = nil
end
end
end
function public.clear_pre_link()
for i,v in pairs(vote_link) do
for j,k in pairs(v) do
public.pop_link( i, j )
end
v = nil
end
end
function public.clear_next_link()
public.msg_svr.clear()
end
function public.clear_link()
public.clear_pre_link()
public.clear_next_link()
end
return public, lst
end
--函数参处理器
function pbl_story.new_fun_on_vote( _callback )
--回调函数要求
if nil == _callback then
_callback = function( _t_inout_msg ) return false end
end
local public, lst = prv_story.new_story_user_on_vote()
local t_inout_msg = {new_story_msg(0), new_story_msg(1)}
function lst.on_vote( _t_msg )
t_inout_msg = new_inout_msg(_t_msg, new_story_msg(1) )
local ret = _callback( t_inout_msg )
if ret then
public.activate( t_inout_msg.out_msg )
else
t_inout_msg.out_msg.EVENT = 0
public.activate( t_inout_msg.out_msg )
end
return ret
end
return public
end
--执行消息处理类
function prv_story.new_story_user_on_action()
local public = {}
--消息处理者本身也可以是个消息机
public.msg_svr = new_story_server()
local lst = new_story_action_msg_listener()
local action_link = {}
function public.activate( _msg )
prv_story.send_msg_to_server( public.msg_svr,  _msg)
end
function public.push_link( _source, _evt )
_evt = _evt or 1
if nil ~= action_link[ _source ] then
if 1 == action_link[ _source ][ _evt ] then
return false
end
end
if nil == action_link[ _source ] then
action_link[ _source ] = {}
end
action_link[ _source ][ _evt ] = 1
_source.msg_svr.action_map.add_listener(lst, _evt)
return true
end
function public.pop_link( _source, _evt )
_evt = _evt or 1
if nil ~= action_link[ _source ] then
if 1 == action_link[ _source ][ _evt ] then
_source.msg_svr.action_map.remove_listener(lst, _evt)
action_link[ _source ][ _evt ] = nil
end
end
end
function public.clear_pre_link()
for i,v in pairs(action_link) do
for j,k in pairs(v) do
public.pop_link( i, j )
end
v = nil
end
end
function public.clear_next_link()
public.msg_svr.clear()
end
function public.clear_link()
public.clear_pre_link()
public.clear_next_link()
end
return public, lst
end
--and参处理器
function pbl_story.and_on_action()
local private = {}
local public = {}
private.t_from_svr = {}
function private.init()
for i,v in pairs( private.t_from_svr ) do
private.t_from_svr[i] = false
end
end
function public.new_init_on_action()
return pbl_story.new_fun_on_action( clk_ret_true_for_0_par( private.init ) )
end
function public.new_and_on_action()
local this_public, lst = prv_story.new_story_user_on_action()
local t_inout_msg = {new_story_msg(0), new_story_msg(1)}
local old_push_link = this_public.push_link
function this_public.push_link( _source )
if old_push_link( _source ) then
private.t_from_svr[ _source.msg_svr ] = false
end
end
local old_pop_link = this_public.pop_link
function this_public.pop_link( _source )
old_pop_link( _source )
private.t_from_svr[ _source.msg_svr ] = nil
end
function lst.on_action( _t_msg )
private.t_from_svr[ _t_msg.FROM_SVR ] = true
for i,v in pairs( private.t_from_svr ) do
if false == v then
return
end
end
this_public.activate( _t_msg )
end
return this_public
end
return public
end
--or参处理器
function pbl_story.or_on_action()
local private = {}
local public = {}
private.t_from_svr = {}
function private.init()
for i,v in pairs( private.t_from_svr ) do
private.t_from_svr[i] = false
end
end
function public.new_init_on_action()
return pbl_story.new_fun_on_action( clk_ret_true_for_0_par( private.init ) )
end
function public.new_or_on_action()
local this_public, lst = prv_story.new_story_user_on_action()
local t_inout_msg = {new_story_msg(0), new_story_msg(1)}
local old_push_link = this_public.push_link
function this_public.push_link( _source )
if old_push_link( _source ) then
private.t_from_svr[ _source.msg_svr ] = false
end
end
local old_pop_link = this_public.pop_link
function this_public.pop_link( _source )
old_pop_link( _source )
private.t_from_svr[ _source.msg_svr ] = nil
end
function lst.on_action( _t_msg )
for i,v in pairs( private.t_from_svr ) do
if v then
return
end
end
private.t_from_svr[ _t_msg.FROM_SVR ] = true
this_public.activate( _t_msg )
end
return this_public
end
return public
end
--函数参处理器
function pbl_story.new_fun_on_action( _callback )
--回调函数要求
if nil == _callback then
_callback = function( _t_inout_msg ) return true end
end
local public, lst = prv_story.new_story_user_on_action()
local t_inout_msg = {new_story_msg(0), new_story_msg(1)}
function lst.on_action( _t_msg )
t_inout_msg = new_inout_msg(_t_msg, new_story_msg(1) )
if _callback( t_inout_msg ) then
public.activate( t_inout_msg.out_msg )
else
t_inout_msg.out_msg.EVENT = 0
public.activate( t_inout_msg.out_msg )
end
end
return public
end
function pbl_story.new_timer_on_action( _get_time_step_fun, _callback )
--回调函数要求
if nil == _get_time_step_fun then
_get_time_step_fun = function( _t_inout_msg ) return true end
end
if nil == _callback then
_callback = function( _par1, _par2, _t_inout_msg) return true end
end
--实现
local public, lst = prv_story.new_story_user_on_action()
local t_inout_msg = {new_story_msg(0), new_story_msg(1)}
function lst.timer_callback( _par1, _par2 )
local ret = _callback( _par1, _par2, t_inout_msg )
if ret then
public.activate( t_inout_msg.out_msg )
else
t_inout_msg.out_msg.EVENT = 0
public.activate( t_inout_msg.out_msg )
end
return ret
end
function lst.on_action( _t_msg )
--尝试生成触发器
t_inout_msg = new_inout_msg(_t_msg, new_story_msg(1) )
lst.tgrID = API_CreateTimerTriggerG(0, 0, _get_time_step_fun( t_inout_msg ), -1, "onStoryTimeCallBack")
if nil ~= lst.tgrID then
G_STORY_TIMER_ACTION_FUN[ lst.tgrID ] = lst
else
API_TraceError("new_clk_timer_on_action.on_action is failed!")
end
end
local old_uninit = lst.un_listen
function lst.un_listen()
if nil ~= lst.tgrID then
G_STORY_TIMER_ACTION_FUN[ lst.tgrID ] = nil
end
old_uninit()
end
return public
end
function pbl_story.new_die_on_action(_get_obj_uid_fun, _callback)
--回调函数要求
if nil == _get_obj_uid_fun then
_get_obj_uid_fun = function( _t_inout_msg ) return true end
end
if nil == _callback then
_callback = function( _par1, _par2, Type, FastID, KillerType, KillerID, MonsterID, MapID, PosX, PosY, _t_inout_msg) return true end
end
--实现
local public, lst = prv_story.new_story_user_on_action()
local t_inout_msg = {new_story_msg(0), new_story_msg(1)}
function lst.die_callback( _par1, _par2, Type, FastID, KillerType, KillerID, MonsterID, MapID, PosX, PosY )
local ret = _callback( _par1, _par2, Type, FastID, KillerType, KillerID, MonsterID, MapID, PosX, PosY, t_inout_msg )
if ret then
public.activate( t_inout_msg.out_msg )
else
t_inout_msg.out_msg.EVENT = 0
public.activate( t_inout_msg.out_msg )
end
return ret
end
function lst.on_action( _t_msg )
--尝试生成触发器
t_inout_msg = new_inout_msg(_t_msg, new_story_msg(1) )
local uid = _get_obj_uid_fun( t_inout_msg )
if nil ~= uid then
lst.tgrID = API_CreateDieTriggerG(0, 0, 0, uid, "onStoryDieCallBack")
if nil ~= lst.tgrID then
G_STORY_DIE_ACTION_FUN[ lst.tgrID ] = lst
else
API_TraceError("new_clk_die_on_action.on_action is failed!")
end
end
end
local old_uninit = lst.un_listen
function lst.un_listen()
if nil ~= lst.tgrID then
G_STORY_DIE_ACTION_FUN[ lst.tgrID ] = nil
end
old_uninit()
end
return public
end
return pbl_story
end
-------------------------------------------------------------------------------------------
--提供转换函数
function clk_data_to_fun( _data )
local function do_clk_bind1()
return _data
end
return do_clk_bind1
end
--将函数返回结果作为消息输出
function clk_bind_ret_to_out_msg(_fun)
local function do_clk_story_bind_ret_to_out_msg( _t_inout_msg )
local r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15 = _fun(_t_inout_msg)
_t_inout_msg.out_msg.pre_msg_ret = {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15}
return r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15
end
return do_clk_story_bind_ret_to_out_msg
end
--显示上条消息的结果
function show_pre_msg_ret(_t_inout_msg)
myPrint("show_pre_msg_ret ", 1)
--把用户消息转发出去
if nil ~= _t_inout_msg.in_msg then
if nil ~= _t_inout_msg.in_msg.pre_msg_ret then
GameAPI_Print(_t_inout_msg.in_msg.pre_msg_ret)
local _evt = _t_inout_msg.out_msg.EVENT
_t_inout_msg.out_msg = _t_inout_msg.in_msg
_t_inout_msg.in_msg = nil
_t_inout_msg.out_msg.EVENT = _evt
end
end
end
--转发
function trans_pre_msg_ret(_t_inout_msg)
--把用户消息转发出去
if nil ~= _t_inout_msg.in_msg then
if nil ~= _t_inout_msg.in_msg.pre_msg_ret then
GameAPI_Print(_t_inout_msg.in_msg.pre_msg_ret)
local _evt = _t_inout_msg.out_msg.EVENT
_t_inout_msg.out_msg = _t_inout_msg.in_msg
_t_inout_msg.in_msg = nil
_t_inout_msg.out_msg.EVENT = _evt
end
end
end
--将上条消息的结果转为本消息处理函数的参数
function clk_pre_msg_ret_to_par( _fun )
local function do_clk_pre_msg_ret_to_par( _t_inout_msg )
if nil ~= _t_inout_msg.in_msg.pre_msg_ret then
local fun = clk_bind_fun_data(_fun, _t_inout_msg.in_msg.pre_msg_ret)
return fun()
else
return false
end
end
return do_clk_pre_msg_ret_to_par
end
--提供必返回真的函数
function clk_ret_true_for_1_par(_fun)
local function do_clk_return_true(_par1)
if nil ~= _fun then
_fun(_par1)
end
return true
end
return do_clk_return_true
end
--提供绑定函数和相关参数的
function clk_bind_fun_data( _fun, t_par )
local function do_clk_bind_fun_data()
if nil == _fun then
myPrint("clk_bind_fun_data fun is nil", 1)
return true
end
if nil == t_par then
return _fun()
end
local len = table.getn( t_par )
if 0 == len then
return _fun()
elseif 1 == len then
return _fun(t_par[1])
elseif 2 == len then
return _fun(t_par[1], t_par[2])
elseif 3 == len then
return _fun(t_par[1], t_par[2], t_par[3])
elseif 4 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4])
elseif 5 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5])
elseif 6 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6])
elseif 7 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7])
elseif 8 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8])
elseif 9 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9])
elseif 10 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10])
elseif 11 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], t_par[11])
elseif 12 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], t_par[11], t_par[12])
elseif 13 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], t_par[11], t_par[12], t_par[13])
else
myPrint("clk_bind_fun_data实现",1)  --------------------------------------------------------
return true
end
end
return do_clk_bind_fun_data
end
--提供绑定数据的函数
function clk_bind_data( t_par )
local function do_clk_bind_data()
if nil == t_par then
return nil
end
local len = table.getn( t_par )
if 0 == len then
return nil
elseif 1 == len then
return t_par[1]
elseif 2 == len then
return t_par[1], t_par[2]
elseif 3 == len then
return t_par[1], t_par[2], t_par[3]
elseif 4 == len then
return t_par[1], t_par[2], t_par[3], t_par[4]
elseif 5 == len then
return t_par[1], t_par[2], t_par[3], t_par[4], t_par[5]
elseif 6 == len then
return t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6]
elseif 7 == len then
return t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7]
elseif 8 == len then
return t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8]
elseif 9 == len then
return t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9]
elseif 10 == len then
return t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10]
elseif 11 == len then
return t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], t_par[11]
elseif 12 == len then
return t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], t_par[11], t_par[12]
elseif 13 == len then
return t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], t_par[11], t_par[12], t_par[13]
else
myPrint("clk_bind_data",1)    --------------------------------------------------------
return nil
end
end
return do_clk_bind_data
end
--提供绑定函数,参数, 留待消息
function clk_fun_msg_bind_data( _fun, t_par )
local function do_clk_fun_msg_bind_data( _t_inout_msg )
if nil == _fun then
myPrint("clk_bind_fun_data fun is nil", 1)
return true
end
if nil == t_par then
return _fun(_t_inout_msg)
end
local len = table.getn( t_par )
if 0 == len then
return _fun(_t_inout_msg)
elseif 1 == len then
return _fun(t_par[1], _t_inout_msg)
elseif 2 == len then
return _fun(t_par[1], t_par[2], _t_inout_msg)
elseif 3 == len then
return _fun(t_par[1], t_par[2], t_par[3], _t_inout_msg)
elseif 4 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], _t_inout_msg)
elseif 5 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], _t_inout_msg)
elseif 6 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], _t_inout_msg)
elseif 7 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], _t_inout_msg)
elseif 8 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], _t_inout_msg)
elseif 9 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], _t_inout_msg)
elseif 10 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], _t_inout_msg)
elseif 11 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], t_par[11], _t_inout_msg)
elseif 12 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], t_par[11], t_par[12], _t_inout_msg)
elseif 13 == len then
return _fun(t_par[1], t_par[2], t_par[3], t_par[4], t_par[5], t_par[6], t_par[7], t_par[8], t_par[9], t_par[10], t_par[11], t_par[12], t_par[13], _t_inout_msg)
else
myPrint("do_clk_fun_msg_bind_data未实现",1)  --------------------------------------------------------
return true
end
end
return do_clk_fun_msg_bind_data
end
--将上条消息的某项结果转为本消息处理函数的参数
function clk_pre_msg_ret_to_par_ex( _index, _fun )
local function do_clk_pre_msg_ret_to_par( _t_inout_msg )
if nil ~= _t_inout_msg.in_msg.pre_msg_ret then
if nil ~= _t_inout_msg.in_msg.pre_msg_ret[_index] then
local fun = clk_bind_fun_data(_fun, _t_inout_msg.in_msg.pre_msg_ret[_index])
return fun()
end
myPrint("failed in do_clk_pre_msg_ret_to_par _t_inout_msg.in_msg.pre_msg_ret[_index]", 1)
GameAPI_Print(_t_inout_msg.in_msg.pre_msg_ret)
return false
end
myPrint("failed in do_clk_pre_msg_ret_to_par _t_inout_msg.in_msg.pre_msg_ret", 1)
return false
end
return do_clk_pre_msg_ret_to_par
end
--必返回true
function clk_ret_true_for_0_par(_fun)
local function do_clk_return_true()
if nil ~= _fun then
_fun()
end
return true
end
return do_clk_return_true
end
--结果取反
function clk_turn_bool_ret_for_1_par(_fun)
local function do_clk_turn_bool_ret_for_1_par(_par1)
if nil == _fun then
return true
end
local ret = _fun(_par1)
if ret then
return false
else
return true
end
end
return do_clk_turn_bool_ret_for_1_par
end
--测试函数
function test_fun(_text)
myPrint(_text, 1)
end
--------------------------------------------------
--[[
--必返回true
function clk_return_true_for_par1(_fun)
local function do_clk_return_true(_par1, _par2, _par3, _par4, _par5, _par6, _par7, _par8, _par9, _par10, _par1, _par11, _par12, _par13, _par14, _par15)
--如果是C++,则这里应该按_fun类型进行模板配对的,但执行期语言Lua不用管这些 :)
if nil ~= _par15 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6, _par7, _par8, _par9, _par10, _par1, _par11, _par12, _par13, _par14, _par15)
elseif nil ~= _par14 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6, _par7, _par8, _par9, _par10, _par1, _par11, _par12, _par13, _par14)
elseif nil ~= _par13 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6, _par7, _par8, _par9, _par10, _par1, _par11, _par12, _par13)
elseif nil ~= _par12 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6, _par7, _par8, _par9, _par10, _par1, _par11, _par12)
elseif nil ~= _par11 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6, _par7, _par8, _par9, _par10, _par1, _par11)
elseif nil ~= _par10 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6, _par7, _par8, _par9, _par10)
elseif nil ~= _par9 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6, _par7, _par8, _par9)
elseif nil ~= _par8 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6, _par7, _par8)
elseif nil ~= _par7 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6, _par7)
elseif nil ~= _par6 then
_fun(_par1, _par2, _par3, _par4, _par5, _par6)
elseif nil ~= _par5 then
_fun(_par1, _par2, _par3, _par4, _par5)
elseif nil ~= _par4 then
_fun(_par1, _par2, _par3, _par4)
elseif nil ~= _par3 then
_fun(_par1, _par2, _par3)
elseif nil ~= _par2 then
_fun(_par1, _par2)
elseif nil ~= _par1 then
_fun(_par1)
else
_fun()
end
return true
end
return do_clk_return_true
end
--]]
--[[
file name :     story_base.lua
author  :   Clark/陈泽丹
created :   2011-10-10
purpose :   地图基类
--]]
-- 地图类型
function story_new_map_data( _szName, _UID )
local public = {}
public.TYPE = "story_new_map_data"
public.m_world_name = _szName
public.m_world_obj = _UID
return public
end
function story_to_map_data( _szName, _t_map_uid )
local t = {}
local len = table.getn(_t_map_uid)
for i=1, len do
t[i] = story_new_map_data( _szName, _t_map_uid[i] )
end
return t
end
--是否地图类型(出于效率考虑,类库的API内部将不做此判断(即默认API传进的参数是正确的), 此函数仅提供应用层去为保证参数正确使用)
function story_is_map_data( _map_data )
if "story_new_map_data" == _map_data.TYPE then
return true
end
return false
end
--删除地图
function story_delete_map( _map_data )
API_DestroyEctype(_map_data.m_world_obj)
_map_data.m_world_obj = 0
end
--是否功能类型
function story_is_fun( _par)
if type(story_delete_map) == type(_par) then
return true
end
return false
end
--是否存在
function story_is_here(_map_uid, _role_uid)
if -1 == _map_uid then
return false
end
local temp = LuaPack_API_GetActorMapID(_role_uid)
if -1 == temp then
return false
end
if _map_uid == temp then
return true
else
return false
end
end
--组操作
function story_for_each(_t, _s, _e, _fun)
if nil == _t or nil == _s or nil == _e or nil == _fun then
return {}
end
for i=_s, _e do
_fun( _t[i] )
end
end
--广播信息
function story_broadcast(_t_role_id, _text, _dType)
local function do_story_broadcast( _role_uid )
API_ActorSendMsg(_role_uid, 2, _text)
end
story_for_each(_t_role_id, 1, table.getn(_t_role_id), do_story_broadcast)
end
--接收玩家
function story_recv_roles( _map_data, _x, _y, _t_role_id )
local function do_story_here_recv_roles(_role_uid)
--API_IsBlockTile(map,mapx,mapy,0)
API_ActorGoToMap(_role_uid, _map_data.m_world_obj,  _x, _y)
end
story_for_each(_t_role_id, 1, table.getn(_t_role_id), do_story_here_recv_roles)
end
--广播状态
function story_add_state(_t_role_id, _state, _time)
local function do_story_here_set_state( _role_uid )
API_ActorAddStatus( _role_uid, _state, _time )
end
story_for_each(_t_role_id, 1, table.getn(_t_role_id), do_story_here_set_state)
end
--消除状态
function story_remove_state(_t_role_id, _state)
local function do_story_here_remove_state( _role_uid )
API_ActorRemoveStatus( _role_uid, _state )
end
story_for_each(_t_role_id, 1, table.getn(_t_role_id), do_story_here_remove_state)
end
--查询有无某状态
function story_has_state(_role_uid, _state, _is_main_id)
if nil == _is_main_id then _is_main_id = 0 end
local ret = API_ActorFindStatus(_role_uid, _state, _is_main_id)
return ret
end
--从集合里取出属于指定地图的玩家
function story_get_roles_in_here( _t_map_data, _t_role_id )
local t = {}
local function do_story_get_roles_in_here( _role_uid )
local len = table.getn(_t_map_data)
for i=1, len do
if story_is_here(_t_map_data[i].m_world_obj, _role_uid ) then
t[ table.getn(t) + 1 ] = _role_uid
return
end
end
end
story_for_each(_t_role_id, 1, table.getn(_t_role_id), do_story_get_roles_in_here)
return t
end
--所有英雄到达
function story_all_roles_to( _map_data, _x, _y, _r, _t_role_id )
local len = table.getn(_t_role_id)
for i=1, len do
if false == story_is_here(_map_data.m_world_obj, _t_role_id[i] ) then
return false
end
local x = API_GetActorPosX(_t_role_id[i])
local y = API_GetActorPosY(_t_role_id[i])
if math.abs(x - _x) > _r then
return false
end
if math.abs(y - _y) > _r then
return false
end
end
return true
end
--有若干英雄到达
function story_some_roles_to( _map_data, _x, _y, _r, _t_role_id )
local len = table.getn(_t_role_id)
for i=1, len do
if story_is_here(_map_data.m_world_obj, _t_role_id[i] ) then
local x = API_GetActorPosX(_t_role_id[i])
local y = API_GetActorPosY(_t_role_id[i])
if math.abs(x - _x) <= _r then
if math.abs(y - _y) <= _r then
return true
end
end
end
end
return false
end
--所有指区域都有人到达
function story_all_area_has_role(_t_area, _t_role_id)
local len = table.getn(_t_area)
for i=1, len do
if false == story_some_roles_to(_t_area[i][1], _t_area[i][2],  _t_area[i][3], _t_area[i][4], _t_role_id) then
return false
end
end
return true
end
--地雷广播
function story_area_broadcast(_map_data, _x, _y, _r, _text, _type, _t_role_id)
if story_some_roles_to( _map_data, _x, _y, _r, _t_role_id ) then
story_broadcast(_t_role_id, _text, _type)
return true
end
return false
end
--[[
file name :     story_base.lua
author  :   Clark/陈泽丹
created :   2012-9-10
purpose :   地图基类
--]]
-- NPC类型
function story_npc_new_npc_data(_szNpcID, _szNpcName, _tNpcState, _CurStateID, _MapUID, _BormX, _BormY, _BormDir )
local public = {}
public.TYPE = "story_npc_new_npc_data"
public.m_id = _szNpcID
public.m_name = _szNpcName
public.m_t_state = _tNpcState
public.m_cur_state_index = _CurStateID or 1
public.m_pos = {_MapUID, _BormX, _BormY}
public.dir = _BormDir or 4
public.uid = nil
return public
end
function story_npc_general_t_new_npc_data( _t_npc_list, _map_uid )
local t = {}
local len = table.getn( _t_npc_list )
for i=1, len do
t[i] = story_npc_new_npc_data( _t_npc_list[i][1], _t_npc_list[i][2], _t_npc_list[i][3], 1, _map_uid, _t_npc_list[i][4], _t_npc_list[i][5], _t_npc_list[i][6] )
end
return t
end
--是否NPC类型(出于效率考虑,类库的API内部将不做此判断(即默认API传进的参数是正确的), 此函数仅提供应用层去为保证参数正确使用)
function story_npc_is_npc_data( _npc_data )
if "story_npc_new_npc_data" == _npc_data.TYPE then
return true
end
return false
end
--是否存活
function story_npc_is_live(_npc_data)
if nil == _npc_data.uid then
return false
end
return true
end
--获得UID
function story_npc_get_uid(_npc_data)
return _npc_data.uid
end
--创建NPC
function story_npc_create_npc(_npc_data)
--[[
if API_IsExistByUIDEx(_npc_data.uid) then
story_npc_kill_npc(_npc_data)
end
--]]
_npc_data.uid = API_CreateMonster(_npc_data.m_pos[1], _npc_data.m_t_state[_npc_data.m_cur_state_index],_npc_data.m_pos[2], _npc_data.m_pos[3], _npc_data.dir, 0, -1)
end
--删除NPC
function story_npc_kill_npc(_npc_data)
if nil ~= _npc_data.uid then
API_DestroyMonster(_npc_data.uid)
_npc_data.uid = nil
end
end
--获得位置
function story_npc_get_npc_pos(_npc_data)
if nil == _npc_data.uid then
return _npc_data.m_pos[1], _npc_data.m_pos[2],_npc_data.m_pos[3]
end
local x = API_GetMonsterPosX(_npc_data.uid )
local y = API_GetMonsterPosY(_npc_data.uid )
return _npc_data.m_pos[1], x, y
end
--获得名字
function story_npc_get_npc_name(_npc_data)
if nil == _npc_data.uid  then
return _npc_data.m_name
end
return API_GetMonsterNameByID( _npc_data.m_t_state[_npc_data.m_cur_state_index] )
end
--获取怪物属性值
function story_npc_l_get_npc_effect(_npc_data, _effect_id)
return API_MonsterGetPropNum(_npc_data.uid, _effect_id)
end
--设置怪物属性
function story_npc_set_npc_effect(_npc_data, _effect_id, _time)
return API_MonsterAddStatus(_npc_data.uid, _effect_id, _time)
end
--NPC说话
function story_npc_say(_npc_data, _funText)
if type(Node_NULFun) == type(_funText) then
_funText = _funText()
end
API_SendMonsterMsg(_npc_data.uid, 0, _funText)
end
--区域碰撞检测
function story_npc_is_in_area(_npc_data, _world_uid, _to_x, _to_y, _r)
local w, x, y = story_npc_get_npc_pos(_npc_data)
if w ~= _world_uid then
return false
end
if math.abs(x - _to_x) > _r or math.abs(y - _to_y) > _r then
return false
end
return true
end
--对话机
function story_talk_list( _list)
local w, x, y = story_npc_get_npc_pos(_npc_data)
if w ~= _world_uid then
return false
end
if math.abs(x - _to_x) > _r or math.abs(y - _to_y) > _r then
return false
end
return true
end
--[[
file name :     GM_Test.lua
author  :   Clark/陈泽丹
created :   2011-10-10
purpose :   地图基类
--]]
GM_story = new_story()
GM_ROLE_ID = 133196049
GM_TEST_MAP_UID = 1357
GM_TEST_MAP_X = 307
GM_TEST_MAP_Y = 163
GM_TEST_MAP_R = 4
GM_TEST_MONSTER = 71
--清单
GM_MODULE_NPCS =
{
--ID,           名字,             状态,                          X坐标, Y坐标, 朝向
{"怪物",        "怪物",         {GM_TEST_MONSTER},              GM_TEST_MAP_X,  GM_TEST_MAP_Y+1},
{"怪物",        "怪物",         {GM_TEST_MONSTER},              GM_TEST_MAP_X,  GM_TEST_MAP_Y+3},
{"怪物",        "怪物",         {GM_TEST_MONSTER},              GM_TEST_MAP_X,  GM_TEST_MAP_Y+5},
{"怪物",        "怪物",         {GM_TEST_MONSTER},              GM_TEST_MAP_X,  GM_TEST_MAP_Y+7},
}
GM_MODULE_NPCS1 =
{
--ID,           名字,             状态,                          X坐标, Y坐标, 朝向
{"怪物",        "怪物",         {GM_TEST_MONSTER},              GM_TEST_MAP_X+1,   GM_TEST_MAP_Y},
{"怪物",        "怪物",         {GM_TEST_MONSTER},              GM_TEST_MAP_X+3,   GM_TEST_MAP_Y},
{"怪物",        "怪物",         {GM_TEST_MONSTER},              GM_TEST_MAP_X+5,   GM_TEST_MAP_Y},
{"怪物",        "怪物",         {GM_TEST_MONSTER},              GM_TEST_MAP_X+7,   GM_TEST_MAP_Y},
}
gm_base_t_npc1 = story_npc_general_t_new_npc_data(GM_MODULE_NPCS, GM_TEST_MAP_UID)
gm_base_t_npc2 = story_npc_general_t_new_npc_data(GM_MODULE_NPCS1, GM_TEST_MAP_UID)
function GM_test_module_on_monster_die(_par1, _par2, Type, FastID, KillerType, KillerID, MonsterID, MapID, PosX, PosY, _t_inout_msg)
myPrint("GM_test_module_on_monster_die " .. KillerID .. " kill " .. FastID .. "(" .. MonsterID .. ")", 1)
return true
end
and_action = GM_story.and_on_action()
or_action = GM_story.or_on_action()
all_die = GM_story.and_on_action()
GM_Action_Root = {}
GM_Action =
{
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_pre_msg_ret_to_par(story_broadcast) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_pre_msg_ret_to_par(story_recv_roles) ) ),
{
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_pre_msg_ret_to_par_ex(1, story_add_state) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_pre_msg_ret_to_par_ex(2, story_add_state) ) ),
},
{
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_pre_msg_ret_to_par_ex(1, story_remove_state) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_pre_msg_ret_to_par_ex(2, story_remove_state) ) ),
},
{
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_bind_ret_to_out_msg( clk_pre_msg_ret_to_par( story_get_roles_in_here ) ) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_1_par( show_pre_msg_ret) ),
},
{
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_bind_ret_to_out_msg( clk_pre_msg_ret_to_par( story_has_state ) ) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_1_par( show_pre_msg_ret) ),
},
{
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_bind_ret_to_out_msg( clk_pre_msg_ret_to_par( story_all_roles_to ) ) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_1_par( show_pre_msg_ret) ),
},
{
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_bind_ret_to_out_msg( clk_pre_msg_ret_to_par( story_some_roles_to ) ) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_1_par( show_pre_msg_ret) ),
},
{
GM_story.new_fun_on_action( clk_ret_true_for_1_par( clk_bind_ret_to_out_msg( clk_pre_msg_ret_to_par( story_all_area_has_role ) ) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_1_par( show_pre_msg_ret) ),
},
{
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(test_fun, {"地雷指令 start "}) ) ),
GM_story.new_timer_on_action( clk_data_to_fun(1), clk_ret_true_for_0_par() ),
GM_story.new_fun_on_action( clk_turn_bool_ret_for_1_par( clk_bind_ret_to_out_msg( clk_bind_fun_data(story_area_broadcast, {story_new_map_data("1", GM_TEST_MAP_UID), GM_TEST_MAP_X, GM_TEST_MAP_Y, GM_TEST_MAP_R, "地雷广播引爆", 2, {133196029}}) ) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(test_fun, {"地雷指令 end "}) ) ),
},
{
and_action.new_init_on_action(),
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(test_fun, {"and case 1"}) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(test_fun, {"and case 2"}) ) ),
and_action.new_and_on_action(),
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(test_fun, {"Pass and"}) ) ),
},
{
or_action.new_init_on_action(),
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(test_fun, {"or case 1"}) ) ),
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(test_fun, {"or case 2"}) ) ),
or_action.new_or_on_action(),
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(test_fun, {"Pass or"}) ) ),
},
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(story_for_each, {gm_base_t_npc1, 1, table.getn(gm_base_t_npc1), story_npc_create_npc}) ) ),
{
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(story_for_each, {gm_base_t_npc2, 1, table.getn(gm_base_t_npc2), story_npc_create_npc}) ) ),
all_die.new_init_on_action(),
GM_story.new_die_on_action( clk_bind_fun_data(story_npc_get_uid, {gm_base_t_npc2[1]} ), GM_test_module_on_monster_die ),
GM_story.new_die_on_action( clk_bind_fun_data(story_npc_get_uid, {gm_base_t_npc2[2]} ), GM_test_module_on_monster_die ),
GM_story.new_die_on_action( clk_bind_fun_data(story_npc_get_uid, {gm_base_t_npc2[3]} ), GM_test_module_on_monster_die ),
GM_story.new_die_on_action( clk_bind_fun_data(story_npc_get_uid, {gm_base_t_npc2[4]} ), GM_test_module_on_monster_die ),
all_die.new_and_on_action(),
GM_story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(test_fun, {"all die"}) ) ),
},
}
gm_action_rool_len = table.getn(GM_Action)
for i=1, gm_action_rool_len do
GM_Action_Root[i] = GM_story.new_fun_on_action()
end
GM_Action[1].push_link( GM_Action_Root[1] )
GM_Action[2].push_link( GM_Action_Root[2] )
GM_Action[3][1].push_link( GM_Action_Root[3] )
GM_Action[3][2].push_link( GM_Action_Root[3] )
GM_Action[4][1].push_link( GM_Action_Root[4] )
GM_Action[4][2].push_link( GM_Action_Root[4] )
GM_Action[5][1].push_link( GM_Action_Root[5] )
GM_Action[5][2].push_link( GM_Action[5][1] )
GM_Action[6][1].push_link( GM_Action_Root[6] )
GM_Action[6][2].push_link( GM_Action[6][1] )
GM_Action[7][1].push_link( GM_Action_Root[7] )
GM_Action[7][2].push_link( GM_Action[7][1] )
GM_Action[8][1].push_link( GM_Action_Root[8] )
GM_Action[8][2].push_link( GM_Action[8][1] )
GM_Action[9][1].push_link( GM_Action_Root[9] )
GM_Action[9][2].push_link( GM_Action[9][1] )
GM_Action[10][1].push_link( GM_Action_Root[10] )
GM_Action[10][2].push_link( GM_Action[10][1] )
GM_Action[10][3].push_link( GM_Action[10][2] )
GM_Action[10][4].push_link( GM_Action[10][3] )
GM_Action[10][1].push_link( GM_Action[10][4] )
GM_Action[11][1].push_link( GM_Action_Root[11] )
GM_Action[11][2].push_link( GM_Action[11][1] )
GM_Action[11][3].push_link( GM_Action[11][1] )
GM_Action[11][4].push_link( GM_Action[11][2] )
GM_Action[11][4].push_link( GM_Action[11][3] )
GM_Action[11][5].push_link( GM_Action[11][4] )
GM_Action[12][1].push_link( GM_Action_Root[12] )
GM_Action[12][2].push_link( GM_Action[12][1] )
GM_Action[12][3].push_link( GM_Action[12][1] )
GM_Action[12][4].push_link( GM_Action[12][2] )
GM_Action[12][4].push_link( GM_Action[12][3] )
GM_Action[12][5].push_link( GM_Action[12][4] )
GM_Action[13].push_link( GM_Action_Root[13] )
GM_Action[14][1].push_link( GM_Action_Root[14] )
GM_Action[14][2].push_link( GM_Action[14][1] )
GM_Action[14][3].push_link( GM_Action[14][2] )
GM_Action[14][4].push_link( GM_Action[14][2] )
GM_Action[14][5].push_link( GM_Action[14][2] )
GM_Action[14][6].push_link( GM_Action[14][2] )
GM_Action[14][7].push_link( GM_Action[14][3] )
GM_Action[14][7].push_link( GM_Action[14][4] )
GM_Action[14][7].push_link( GM_Action[14][5] )
GM_Action[14][7].push_link( GM_Action[14][6] )
GM_Action[14][8].push_link( GM_Action[14][7] )
GM_Action[14][1].push_link( GM_Action[14][8] )
function GM_CLK_test_story_base(_role, Type)
local gm_test_msg =
{
[1] = function(_Par1, _Par2, _Par3, _Par4)
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data({ {GM_ROLE_ID}, "测试成功", 2 }))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end,
[2] = function(_Par1, _Par2, _Par3, _Par4)
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data({ story_new_map_data("1", GM_TEST_MAP_UID), GM_TEST_MAP_X, GM_TEST_MAP_Y,  {GM_ROLE_ID} }))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end,
[3] = function(_Par1, _Par2, _Par3, _Par4)
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data({ {{GM_ROLE_ID}, 1501001, 99999999},  {{GM_ROLE_ID}, 776001, 99999999} }))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end,
[4] = function(_Par1, _Par2, _Par3, _Par4)
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data({ {{GM_ROLE_ID}, 1501001},  {{GM_ROLE_ID}, 776001} }))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end,
[5] = function(_Par1, _Par2, _Par3, _Par4)
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data({  {story_new_map_data("1", GM_TEST_MAP_UID)},  {GM_ROLE_ID}   }))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end,
[6] = function(_Par1, _Par2, _Par3, _Par4)
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data({  GM_ROLE_ID,  1501001, 0  }))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end,
[7] = function(_Par1, _Par2, _Par3, _Par4)
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data({   story_new_map_data("1", GM_TEST_MAP_UID),  GM_TEST_MAP_X, GM_TEST_MAP_Y, GM_TEST_MAP_R, {GM_ROLE_ID}  }))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end,
[8] = function(_Par1, _Par2, _Par3, _Par4)
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data({   story_new_map_data("1", GM_TEST_MAP_UID),  GM_TEST_MAP_X, GM_TEST_MAP_Y, GM_TEST_MAP_R, {GM_ROLE_ID}  }))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end,
[9] = function(_Par1, _Par2, _Par3, _Par4)
local inout_msg = new_inout_msg( nil, new_story_msg(1) )
local msg_handle_fun = clk_bind_ret_to_out_msg( clk_bind_data({   {{story_new_map_data("1", GM_TEST_MAP_UID),  GM_TEST_MAP_X, GM_TEST_MAP_Y, GM_TEST_MAP_R}}, {GM_ROLE_ID}  }))
msg_handle_fun( inout_msg )
return inout_msg.out_msg
end,
[10] = function(_Par1, _Par2, _Par3, _Par4)
local msg = new_story_msg(1)
return msg
end,
[11] = function(_Par1, _Par2, _Par3, _Par4)
local msg = new_story_msg(1)
return msg
end,
[12] = function(_Par1, _Par2, _Par3, _Par4)
local msg = new_story_msg(1)
return msg
end,
[13] = function(_Par1, _Par2, _Par3, _Par4)
local msg = new_story_msg(1)
return msg
end,
[14] = function(_Par1, _Par2, _Par3, _Par4)
local msg = new_story_msg(1)
return msg
end,
}
if Type == "CLK_调试指令" then
GM_ROLE_ID = _role
local Par1 = API_RequestGetNumber(2)
local Par2 = API_RequestGetNumber(3)
local Par3 = API_RequestGetNumber(4)
local Par4 = API_RequestGetNumber(5)
local len = table.getn(gm_test_msg)
for i=1, len do
if i == Par1 then
GM_Action_Root[i].activate( gm_test_msg[i](Par1, Par2, Par3, Par4) )
end
end
if 0 == Par1 then
gm_action_rool_len = table.getn(GM_Action)
for i=1, gm_action_rool_len do
GM_Action_Root[i].clear_link()
end
if GM_story.is_play() then
myPrint("pase", 1)
GM_story.pase()
else
myPrint("play", 1)
GM_story.play()
end
end
if -1 == Par1 then
--永久性否决掉根结点1的消息触发
vote_test = GM_story.new_fun_on_vote( clk_ret_true_for_0_par() )
vote_test.push_link( GM_Action_Root[1] )
end
end
end
--[[
file name :     story_module.lua
author  :   Clark/陈泽丹
created :   2011-10-10
purpose :   地图基类
--]]
ACT_HEAD                = "act_head"
ACT_END                 = "act_end"
ACT_CREATE_MONSTERS     = "act_create_monsters"
ACT_DIE_MONSTERS        = "act_die_monsters"
function new_module_actex( _sign_id, _act)
local public = {}
function public.get_sign()
return _sign_id
end
function public.get_act()
return _act
end
return public
end
function story_module_find_act( _t_actex, _sign_id)
local len = table.getn( _t_actex )
for i=1, len do
if _t_actex[i].get_sign() == _sign_id then
return _t_actex[i].get_act()
end
end
return nil
end
--生成一堆怪并监听死亡
function story_module_create_act_and_all_die( _story, _t_npc_par, _map_uid, _die_fun )
local t_npc_obj = nil
local function init_par()
local npc_par = _t_npc_par
if story_is_fun(_t_npc_par) then
npc_par = _t_npc_par()
end
t_npc_obj = story_npc_general_t_new_npc_data( npc_par, _map_uid )
end
local act_s = _story.new_fun_on_action()
local act_e = _story.new_fun_on_action()
local function edit_fun()
act_s.clear_next_link()
act_e.clear_pre_link()
local act_create = _story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(story_for_each, {t_npc_obj, 1, table.getn(t_npc_obj), story_npc_create_npc}) ) )
local all_die = _story.and_on_action()
local act_init = all_die.new_init_on_action()
local act_and = all_die.new_and_on_action()
act_create.push_link(act_s)
act_init.push_link(act_create)
local len = table.getn(t_npc_obj)
if len > 0 then
for i=1, len do
local act = _story.new_die_on_action( clk_bind_fun_data(story_npc_get_uid, { t_npc_obj[i]} ), _die_fun )
act.push_link( act_init )
act_and.push_link( act )
end
else
act_and.push_link(act_init)
end
act_e.push_link(act_and)
return true
end
local act_init_par = _story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(init_par, {}) ) )
local act_edit_fun = _story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(edit_fun, {}) ) )
act_edit_fun.push_link(act_init_par)
act_s.push_link(act_edit_fun)
local act_all_die_show = _story.new_fun_on_action()
act_all_die_show.push_link(act_e)
return { new_module_actex(ACT_HEAD, act_init_par), new_module_actex(ACT_END, act_all_die_show) }
end
--生成波数怪
function story_module_create_monsters( _story, _t_npc, _map_uid, _replay_times, _dt_times, _die_fun)
local times_count = new_story_count()
local init_times = _story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(times_count.set_val, {0}) ) )
local add_times = _story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(times_count.add_val, {1}) ) )
local is_times = _story.new_fun_on_action( clk_bind_fun_data(times_count.is_same, {_replay_times}) )
local not_is_times = _story.new_fun_on_action( clk_turn_bool_ret_for_1_par(  clk_bind_fun_data(times_count.is_same, {_replay_times}) ) )
local monsters_s = _story.new_fun_on_action()
local monsters_e = _story.new_fun_on_action()
monsters_e.push_link( monsters_s )
local t = {}
local len = table.getn(_t_npc)
for i=1, len do
t[i] = {}
local t_act = story_module_create_act_and_all_die(_story, _t_npc[i], _map_uid, _die_fun)
story_module_find_act(t_act, ACT_HEAD).push_link( monsters_e )
monsters_e = story_module_find_act(t_act, ACT_END)
end
local dt_timer = _story.new_timer_on_action( clk_data_to_fun( _dt_times ), clk_ret_true_for_0_par() )
monsters_s.push_link( init_times )
add_times.push_link( monsters_e )
is_times.push_link( add_times )
not_is_times.push_link( add_times )
dt_timer.push_link( not_is_times )
monsters_s.push_link( dt_timer )
local actex =
{
--头结点
new_module_actex(ACT_HEAD, init_times),
--建怪结点
new_module_actex(ACT_CREATE_MONSTERS, monsters_s),
--怪死结点
new_module_actex(ACT_DIE_MONSTERS, monsters_e),
--尾结点
new_module_actex(ACT_END, is_times),
}
return actex
end
--消息机管理者
function G_STL_MsgSvr_Manager()
local private = {}
local public = {}
function public.add_listener( _index, _obj )
if nil == private[_index] then
private[_index] = new_story().new_fun_on_action( clk_ret_true_for_1_par( trans_pre_msg_ret ) )
end
_obj.push_link( private[_index] )
end
function public.remove_listener( _index, _obj  )
if nil ~= private[_index] then
_obj.pop_link( private[_index] )
end
end
function public.send_msg( _index, _msg )
if nil ~= private[_index] then
private[_index].activate( _msg )
return true
end
return false
end
return public
end
--对话NPC信号服
G_stl_on_npc_talk = G_STL_MsgSvr_Manager()
--进入事件信号服
G_stl_enter_fb = G_STL_MsgSvr_Manager()
--副本开启信号服
G_stl_in_fb_server = G_STL_MsgSvr_Manager()
--登陆地图信号服
G_stl_in_server = G_STL_MsgSvr_Manager()
--退出地图信号服
G_stl_out_server = G_STL_MsgSvr_Manager()
--退出副本信号服
G_stl_out_fb_server = G_STL_MsgSvr_Manager()
--初始化副本服
G_stl_init_fb = G_STL_MsgSvr_Manager()
--通关信号服
G_stl_pass_fb = G_STL_MsgSvr_Manager()
--失败信号服
G_stl_fail_fb = G_STL_MsgSvr_Manager()
--初始化副本模块
function clk_translation_machine( _par )
if nil == _par.INDEX then
return
else
if string.len(_par.INDEX) > 10 then
API_TraceError("INDEX: " ..  _par.INDEX .. ", 索引长度超过10个字符!")
return
end
end
--解析开窗参数
if nil ~= _par.OPEN_ENTER_WINDOWS_PART then
local len = table.getn( _par.OPEN_ENTER_WINDOWS_PART )
for i=1, len do
_par.OPEN_ENTER_WINDOWS_PART[i]( _par.INDEX )
end
end
--解析进入参数
if nil ~= _par.ENTER_PART then
local len = table.getn( _par.ENTER_PART )
for i=1, len do
_par.ENTER_PART[i]( _par.INDEX )
end
end
--解析地图参数
if nil ~= _par.MAP_PART then
local len = table.getn( _par.MAP_PART )
for i=1, len do
_par.MAP_PART[i]( _par.INDEX )
end
end
end
--对话NPC
function do_show_dialog_on_npc_talking( _npc, _context)
local function act_fun_is_talking_npg( _msg_role, _msg_npc, _msg_task )
GameAPI_API_ResponseWrite('<text size="13" color="175,216,242" >' .. _context ..'</text><br>')
return true
end
local function do_IS_TALKING_NPC( _par_index )
G_stl_on_npc_talk.add_listener( _npc, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_is_talking_npg )  )  )
end
return do_IS_TALKING_NPC
end
API_AddLUAReqFunc("NPC_TALK_ITEM")
function NPC_TALK_ITEM()
local role_id   = API_RequestGetActorID()
local fb_index  = API_RequestGetString(2)
local npc       = API_RequestGetNumber(3)
local task      = API_RequestGetNumber(4)
G_stl_enter_fb.send_msg(fb_index, new_par_msg({ role_id, fb_index, npc, task }))
end
--对话NPC
function do_show_inter_fb_item_on_npc_talking( _npc, _context, _talk_type )
local function act_fun_talk_item_npg( _par_index )
local function do_act_fun_talk_item_npg( _msg_role, _msg_npc, _msg_task )
GameAPI_API_ResponseWrite(_talk_type ..'<a size="13" color="175,216,242" href="NPC_TALK_ITEM?1='.._msg_role..'&2='.. _par_index .. '&3='.. _msg_npc .. '&4='.. _msg_task ..'">' .. _context .. '</a><br>')
return true
end
return do_act_fun_talk_item_npg
end
local function do_DO_SHOW_TALK_ITEM_ON_NPC_TALKING( _par_index )
G_stl_on_npc_talk.add_listener( _npc, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_talk_item_npg( _par_index ) )  )  )
end
return do_DO_SHOW_TALK_ITEM_ON_NPC_TALKING
end
--是否符合等级
function is_lvl( _min_lvl )
local function act_fun_is_lvl( _role, _par_index, _npc, _task )
local t_roles = ids_getTeamMem(_role)
local len = table.getn(t_roles)
for i=1, len do
--等级判断
if API_GetActorExpLevel( t_roles[i] ) < _min_lvl then
if 1 == len then
GameAPI_ActorSendMsg(_role, 2, "等级低于" .. _min_lvl .."级, 不能进入!")
else
GameAPI_ActorSendMsg( _role, 2, "队伍不能有低于" .. _min_lvl .."级的玩家!" )
end
return true
end
end
return false
end
local function do_IS_LVL( _par_index )
G_stl_enter_fb.add_listener( _par_index, new_story().new_fun_on_vote( clk_pre_msg_ret_to_par( act_fun_is_lvl )  )  )
end
return do_IS_LVL
end
--消耗体力
function is_and_do_cost_power( _val )
local function vote_fun_is_cost_power( _role, _par_index, _npc, _task )
local t_roles = ids_getTeamMem(_role)
local len = table.getn(t_roles)
for i=1, len do
--等级判断
if API_ActorGetPropNum( t_roles[i], 239 ) < _val then
if 1 == len then
GameAPI_ActorSendMsg(_role, 2, "体力值低于" .. _val ..", 不能进入!")
else
GameAPI_ActorSendMsg( _role, 2, "队伍不能有体力值低于" .. _val .."的玩家!" )
end
return true
end
end
return false
end
local function act_fun_do_cost_power( _role, _par_index, _npc, _task )
local t_roles = ids_getTeamMem( _role )
GameAPI_add_power_for_t(t_roles, -1 * _val)
return true
end
local function do_IS_AND_DO_COST_POWER( _par_index )
G_stl_enter_fb.add_listener( _par_index, new_story().new_fun_on_vote( clk_pre_msg_ret_to_par( vote_fun_is_cost_power )  )  )
G_stl_enter_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_do_cost_power )  )  )
end
return do_IS_AND_DO_COST_POWER
end
--生成副本并移动进副本(地点由副本配置表指定)
function do_create_fb_and_enter_fb( _fb_index, _sz_name )
local function act_fun_create_and_enter( _role, _par_index, _npc, _task )
local t_player = t5P_getTeamMem(_role)
local t = {1, table.getn(ids_getTeamMem(_role)), _par_index}
API_CreateEctypeEx(0,t_player[1],t_player[2],t_player[3],t_player[4],t_player[5],_fb_index,0,_sz_name,sz_T2S(t))
return true
end
local function doing_create_fb_and_enter_fb( _par_index )
G_stl_enter_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_create_and_enter )  )  )
end
return doing_create_fb_and_enter_fb
end
--副本参数额外数据
function new_FB_Buf_Manager(  )
function new_FB_Par_DataBase()
local t_par = {}
t_par.par_index = nil
t_par.fb_par = nil
t_par.time_limit = nil
t_par.enter = nil
t_par.roles_size = nil
t_par.t_roles = {}
t_par.t_maps_uid = {}
t_par.is_init = nil
t_par.not_send_ret = true
return t_par
end
local map_index = {}
local private = {}
function private.get_index_by_all( _t_map_uid )
local index = ""
local len = table.getn( _t_map_uid )
for i=1, len do
index = index .. "|" .._t_map_uid[i]
end
return index
end
function private.get_index_by_map( _map_uid )
return map_index[ _map_uid ]
end
local public = {}
function public.create_fb_buf_database( _t_map_uid )
local index = private.get_index_by_all( _t_map_uid )
private[ index ] = new_FB_Par_DataBase()
--建立副索引
local len = table.getn( _t_map_uid )
for i=1, len do
map_index[ _t_map_uid[i] ] = index
end
end
function public.get_fb_par_buf_by_t_map( _t_map_uid )
local index = private.get_index_by_all( _t_map_uid )
return private[ index ]
end
function public.get_fb_par_buf_by_map( _map_uid )
local index = private.get_index_by_map( _map_uid )
return private[ index ]
end
return public
end
G_fb_buf_manager = new_FB_Buf_Manager()
-- 创建完地图后回调
API_AddLUAReqFunc("clk_CreateMapLuaFun_Dest")
function clk_CreateMapLuaFun_Dest(_szUserSign, _szMap)
local t_sign = t_S2T(_szUserSign)
local t_maps_uid = t_S2T(_szMap)
G_fb_buf_manager.create_fb_buf_database(t_maps_uid)
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_t_map(t_maps_uid)
t_fb_buf.par_index = t_sign[3]
t_fb_buf.fb_par = t_sign[1]
t_fb_buf.time_limit = true
t_fb_buf.enter = true
t_fb_buf.roles_size = t_sign[2]
t_fb_buf.roles = {}
t_fb_buf.t_maps_uid = t_maps_uid
t_fb_buf.is_init = false
t_fb_buf.story = nil
t_fb_buf.root_act = nil
t_fb_buf.end_act = nil
G_stl_in_fb_server.send_msg(par_index, new_par_msg({ t_maps_uid }))
end
function clk_init_fb( _fb_buf, _map_uid)
if false == _fb_buf.is_init then
G_stl_init_fb.send_msg(_fb_buf.par_index, new_par_msg( {_map_uid} ) )
_fb_buf.root_act.activate( new_par_msg({_map_uid}) )
_fb_buf.is_init = true
end
end
function clk_send_fb_ret( _fb_buf, _map_uid, _is_pass)
if _fb_buf.not_send_ret then
_fb_buf.not_send_ret = false
if _is_pass then
G_stl_pass_fb.send_msg( _fb_buf.par_index, new_par_msg({ _map_uid }) )
else
G_stl_fail_fb.send_msg( _fb_buf.par_index, new_par_msg({ _map_uid }) )
end
_fb_buf.story.pase()
_fb_buf.root_act.clear_link()
end
end
--登陆副本函数
API_AddLUAReqFunc("clk_OnServerLoginIn")
function clk_OnServerLoginIn(nActorID, nMapID, nDynamicMapID, iPlayerInHereCount)
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map(nDynamicMapID)
G_stl_in_server.send_msg(t_fb_buf.par_index, new_par_msg({ nActorID, nDynamicMapID }))
if 1 == iPlayerInHereCount then
t_fb_buf.roles[ table.getn(t_fb_buf.roles) + 1 ] = nActorID
if t_fb_buf.time_limit then
if t_fb_buf.enter then
--测试成功
if t_fb_buf.roles_size == table.getn(t_fb_buf.roles) then
clk_init_fb(t_fb_buf, nDynamicMapID)
end
else
API_TraceError("已过进入时间底线!")
API_ActorGoToBackMap(nActorID)
end
else
API_TraceError("未过进入时间底线!")
end
end
end
--玩家退出的时候调用的
API_AddLUAReqFunc("clk_OnServerLoginOut")
function clk_OnServerLoginOut(nActorID, nMapID, nDynamicMapID)
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map(nDynamicMapID)
G_stl_out_server.send_msg(t_fb_buf.par_index, new_par_msg({ nActorID, nDynamicMapID }))
end
--计时登陆
function do_time_limit_on_create_fb( _time )
local function act_fun_open_inter_timer( _t_maps_uid )
myPrint(" act_fun_open_inter_timer ", 1)
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_t_map(_t_maps_uid)
t_fb_buf.time_limit = true
end
local function act_fun_inter_timer( _par1, _par2, t_inout_msg )
local function do_act_fun_inter_timer( t_maps_uid )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_t_map(_t_maps_uid)
t_fb_buf.enter = false
clk_init_fb( t_fb_buf, t_maps_uid[1] )
end
local t_map = t_inout_msg.in_msg.pre_msg_ret
do_act_fun_inter_timer( t_map )
return true
end
local function doing_do_on_create_fb_inter_timer( _par_index )
G_stl_in_fb_server.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_open_inter_timer )  )  )
G_stl_in_fb_server.add_listener( _par_index, new_story().new_timer_on_action( clk_data_to_fun(_time), act_fun_inter_timer  )  )
end
return doing_do_on_create_fb_inter_timer
end
--移动(可能异致多次排队问题)
function do_moving_on_fb_init( _index, _x, _y )
local function act_fun_do_moving_on_server_login_in( _map_uid )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
local map_data = story_new_map_data("临时", t_fb_buf.t_maps_uid[_index])
story_recv_roles( map_data, _x, _y, t_fb_buf.roles )
end
local function doing_do_moving_on_server_login_in( _par_index )
G_stl_init_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_do_moving_on_server_login_in )  )  )
end
return doing_do_moving_on_server_login_in
end
--静态地图移动(会和由玩家小退而指定的后备点冲突(可能异致多次排队问题))
function do_static_map_moving_on_server_login_out( _map_id, _x, _y )
local function act_fun_do_static_map_moving_on_server_login_out( _role, _map_uid )
API_ActorGoToMap(_role, _map_id, _x, _y)
end
local function doing_do_static_map_moving_on_server_login_out( _par_index )
G_stl_out_server.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_do_static_map_moving_on_server_login_out )  )  )
end
return doing_do_static_map_moving_on_server_login_out
end
--测试成功
function do_test_fb_pass()
local function act_fun_do_test_fb_pass( _map_uid  )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
clk_send_fb_ret(t_fb_buf, _map_uid, true)
end
local function doing_do_test_fb_pass( _par_index )
G_stl_init_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_do_test_fb_pass )  )  )
end
return doing_do_test_fb_pass
end
--成功加钱
function do_on_pass_award_money( _val )
local function act_fun_do_on_pass_award_money( _map_uid )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
local t_roles = story_get_roles_in_here( story_to_map_data("临时", t_fb_buf.t_maps_uid), t_fb_buf.roles )
local len = table.getn( t_roles )
for i=1, len do
API_ActorAddMoney(t_roles[i],_val,0,"")
end
return true
end
local function doing_do_static_map_moving_on_server_login_out( _par_index )
G_stl_pass_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_do_on_pass_award_money )  )  )
end
return doing_do_static_map_moving_on_server_login_out
end
--成功提示
function do_on_pass_system_say( _text )
local function act_fun_do_on_pass_system_say( _map_uid )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
story_broadcast( t_fb_buf.roles, _text, 2)
return true
end
local function doing_do_on_pass_system_say( _par_index )
G_stl_pass_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_do_on_pass_system_say )  )  )
end
return doing_do_on_pass_system_say
end
--测试失败
function do_test_fb_fail()
local function act_fun_do_test_fb_fail( _map_uid  )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
clk_send_fb_ret(t_fb_buf, _map_uid, false)
end
local function doing_do_test_fb_fail( _par_index )
G_stl_init_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_do_test_fb_fail )  )  )
end
return doing_do_test_fb_fail
end
--失败提示
function do_on_fail_system_say( _text )
local function act_fun_do_on_fail_system_say( _map_uid )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
story_broadcast( t_fb_buf.roles, _text, 2)
return true
end
local function doing_do_on_fail_system_say( _par_index )
G_stl_fail_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_do_on_fail_system_say )  )  )
end
return doing_do_on_fail_system_say
end
--计时失败
function do_edit_fb_time_limit_on_init( _time, _visible )
local function act_fun_do_fb_time_limit_on_init(  _map_uid  )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
local dt_timer = t_fb_buf.story.new_timer_on_action( clk_data_to_fun( _time ), clk_ret_true_for_0_par( clk_bind_fun_data( clk_send_fb_ret, {t_fb_buf, _map_uid, false} ) ) )
dt_timer.push_link( t_fb_buf.root_act )
end
local function act_fun_visible( _map_uid )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
local t_roles = story_get_roles_in_here( story_to_map_data("临时", t_fb_buf.t_maps_uid), t_fb_buf.roles )
local len = table.getn(t_roles)
for i=1, len do
API_WindowOnEventII(t_roles[i], 484, 1, _time, 1)
end
end
local function act_fun_out_server_visible( _map_uid )
--[[
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
local t = story_get_roles_in_here( t_fb_buf.t_maps_uid, t_fb_buf.t_roles )
local len = table.getn(t)
API_OpenWindow(t[i], 484, 0)
end
--]]
end
local function doing_do_fb_time_limit_on_init( _par_index )
G_stl_init_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_do_fb_time_limit_on_init )  )  )
if _visible then
G_stl_init_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_fun_visible )  )  )
end
end
return doing_do_fb_time_limit_on_init
end
--创建指定怪
function do_edit_create_monster_to_fb_story_act( _is_wait_for, _t_npc, _map_index, _replay_times, _dt_times, _die_fun)
local function act_create_monster_to_fb_story_act( _map_uid  )
_replay_times = _replay_times or 1
_dt_times = _dt_times or 1
if nil == _is_wait_for then
_is_wait_for = true
end
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
local t_actex = story_module_create_monsters(t_fb_buf.story, _t_npc, t_fb_buf.t_maps_uid[_map_index], _replay_times, _dt_times, _die_fun)
story_module_find_act(t_actex, ACT_HEAD).push_link( t_fb_buf.end_act )
if _is_wait_for then
t_fb_buf.end_act = story_module_find_act(t_actex, ACT_END)
end
end
local function doing_create_monster_to_fb_story_act( _par_index )
G_stl_init_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_create_monster_to_fb_story_act )  )  )
end
return doing_create_monster_to_fb_story_act
end
--过关
function do_edit_pass_to_fb_story_act()
local function act_do_pass_to_fb_story_act( _map_uid )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
clk_send_fb_ret(t_fb_buf, _map_uid, true)
end
local function act_create_monster_to_fb_story_act( _map_uid  )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
local act = t_fb_buf.story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(act_do_pass_to_fb_story_act, {_map_uid}) ) )
act.push_link( t_fb_buf.end_act )
end
local function doing_create_monster_to_fb_story_act( _par_index )
G_stl_init_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_create_monster_to_fb_story_act )  )  )
end
return doing_create_monster_to_fb_story_act
end
--开始情节
function do_edit_story_start()
local function act_edit_story_start( _map_uid  )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
t_fb_buf.story = new_story()
t_fb_buf.root_act = t_fb_buf.story.new_fun_on_action()
t_fb_buf.end_act = t_fb_buf.root_act
end
local function doing_edit_story_start( _par_index )
G_stl_init_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_edit_story_start )  )  )
end
return doing_edit_story_start
end
--结束情节
function do_edit_story_end()
local function act_do_edit_story_end( _map_uid  )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
clk_send_fb_ret(t_fb_buf, _map_uid, true)
end
local function act_cedit_story_end( _map_uid  )
local t_fb_buf = G_fb_buf_manager.get_fb_par_buf_by_map( _map_uid )
local act = t_fb_buf.story.new_fun_on_action( clk_ret_true_for_0_par( clk_bind_fun_data(act_do_edit_story_end, {_map_uid}) ) )
act.push_link( t_fb_buf.end_act )
t_fb_buf.end_act = act
end
local function doing_edit_story_end( _par_index )
G_stl_init_fb.add_listener( _par_index, new_story().new_fun_on_action( clk_pre_msg_ret_to_par( act_cedit_story_end )  )  )
end
return doing_edit_story_end
end
--独占副本类型
TEST_NPCS_1 =
{
--第一波
{
--ID,           名字,             状态,                          X坐标, Y坐标, 朝向
{"怪物",        "怪物",         {73},                           41,     56},
},
}
TEST_NPCS =
{
--第一波
{
--ID,           名字,             状态,                          X坐标, Y坐标, 朝向
{"怪物",        "怪物",         {71},                           41,     54},
{"怪物",        "怪物",         {71},                           41,     40},
{"怪物",        "怪物",         {71},                           52,     42},
{"怪物",        "怪物",         {71},                           53,     57},
},
{
--ID,           名字,             状态,                          X坐标, Y坐标, 朝向
{"怪物",        "怪物",         {105},                          41,     54},
{"怪物",        "怪物",         {105},                          41,     40},
},
}
WYD_TYPE01 =
{
INDEX = "WYD_TP_01", --无魇洞类型 01
OPEN_ENTER_WINDOWS_PART =
{
do_show_dialog_on_npc_talking(11562, "一段台词1"),
do_show_inter_fb_item_on_npc_talking(11562, "简单难度", IconFbImgStr),
},
ENTER_PART =
{
is_lvl(30),
is_and_do_cost_power(5),
do_create_fb_and_enter_fb(39, "简单"),
},
MAP_PART =
{
do_edit_story_start(),
do_edit_fb_time_limit_on_init(20, true),
do_edit_create_monster_to_fb_story_act( false, TEST_NPCS_1, 1, -1, 2),
do_edit_create_monster_to_fb_story_act( true, TEST_NPCS, 1, 2, 2),
do_edit_pass_to_fb_story_act(),
do_edit_story_end(),
do_time_limit_on_create_fb(5),
do_moving_on_fb_init(1,46,49),
do_static_map_moving_on_server_login_out(1339,93,141),
do_on_pass_award_money( 1000 ),
do_on_pass_system_say( " 恭喜玩家简单难度,闯关成功 " ),
do_on_fail_system_say( " 闯关失败 " ),
--do_on_end_exit()
--do_test_fb_pass(),
--[[
--杀怪成功
--杀波数怪成功
--救人成功
--情节1模块
--情节2模块
--情节3模块
--...
--]]
},
}
--[[
Test_FB1_COMMON =
{
INDEX = "Test_FB1_COMMON",
ENTER_PART =
{
--到时开启模块
},
MAP_PART =
{
--是共享的还是独占的。
--是否计时传人模块(进入时开启一个计时器,到时关闭传送口并反传人员。 人员如果是通过创建副本进入的, 会进入相应的回调接口, 回调接口里会查看是否有进行权限)
},
}
--]]
clk_translation_machine( WYD_TYPE01 )

彪悍的代码不需要解释_巨魔神大人带领大家走向胜利_:P相关推荐

  1. 彪悍的人生不需要解释

    彪悍的人生不需要解释. 走自己子的路,总有一天我会气死那些看不起我的人. 转载于:https://blog.51cto.com/kinglovelqn/1288071

  2. “彪悍的代码 不羁的创意”—— 网易云信全国高校MINI开发挑战赛战队招募启动...

    4月18日,以"彪悍的代码 不羁的创意"为主题,由网易旗下通讯与视频云服务品牌网易云信主办的"2019全国高校MINI开发挑战赛"正式启动.全国"技术 ...

  3. 知乎热议:28岁郭宇期权过亿,彪悍从字节退休,旅居日本开温泉酒店

    点击上方"视学算法",选择"星标" 干货第一时间送达 整理:公众号@新智元 本文仅做学术分享,如有侵权,请联系删除. 最近28岁程序员郭宇宣布退休上了知乎热搜. ...

  4. 彪悍的老罗,等你解释锤子ROM要如何改变世界

     手上拿着老罗锤子ROM的邀请函,时间越是临近3月27日19:30,心情就越是激动.老罗这个原来从事英语培训行业偏执狂,从去年 4 月份突然宣布进军手机行业以来,其内心的澎湃和躁动就一直没有停止过,不 ...

  5. 【趣图解读】彪悍的程序员不需要解释

    产品经理与程序员好像天生就是一对冤家,双方自带矛盾点.网上关于两者互撕,互殴的新闻也是络绎不绝.我想,归根结底应该还是沟通的问题吧. 以下产品经理与程序员可以说是我辈之楷模,他们教科书般的沟通方式,使 ...

  6. 微软为一人收购一公司?破解索尼程序、写黑客小说,看他彪悍的程序人生!...

    作者 | 伍杏玲 出品 | CSDN(ID:CSDNnews) 格子衬衫.常掉发.双肩包.修电脑.加班多--这些似乎成了大众给程序员的固定标签.近几年流行的"跨界风"开始刷新人们对 ...

  7. 熟悉又陌生 彪悍徐茂栋的双面人生

    "该出手时出手,该冷静时冷静."唯快不破和专注极致,是互联网时代的两个重要铁律,作为一个20年成功的连续创业者,时任窝窝商城董事长兼CEO徐茂栋的创业经历,即是这样的体现. 外界对 ...

  8. 起点低,是彪悍的最好证明!

    阅读本文大概需要4分钟. 一个读者的问题:洋哥,我老家是农村的,只考上了专科,毕业后北漂两年月薪才7000,每天都会很焦虑,想努力但想到自己的过去,又怀疑努力是否有用. 和这个读者聊了很久,说了一大段 ...

  9. UFIDL稀疏自编码代码实现及解释

    UFIDL稀疏自编码代码实现及解释 1.今天我们来讲一下UFIDL的第一个练习. 1.我们来看看最难的一个.m文件 %% ---------- YOUR CODE HERE ------------- ...

最新文章

  1. html css文本框按钮,css样式之区分input是按钮还是文本框的方法
  2. Spring MVC 中的 forward 和 redirect
  3. Condition.signal
  4. 奥巴马经济顾问:哪怕丢了“饭碗”,也必须加大投资AI!
  5. [POJ2888] Magic Bracelet
  6. Web3.js 学习
  7. 响应式禁用(Bootstrap PK AmazeUI)
  8. Leetcode每日一题:155.min-stack(最小栈)
  9. 剖析 AI 和大数据的分布式实践 —— 2018 UCan下午茶·北京站
  10. ubuntu16.04源码编译安装nginx1.16.2
  11. processing一个作品_当你触摸到一束光| 交互灯光装置课程学员作品回顾
  12. 计算机网络管理员试题2016,2016年 -1月自考计算机网络管理试题真题.doc
  13. 解读全新闪存FlashSystem 9100
  14. flv转mp4,电脑视频flv怎么批量转mp4格式
  15. SQL学习笔记(06)_SELECT INTO
  16. The simplest Singleton
  17. 其他 | 狼人杀入门
  18. 基于JavaWeb的果蔬生鲜交易系统
  19. 更换iphone4s电池图文教程
  20. 2020年396分上岸湖南大学计算机专硕考研经验分享

热门文章

  1. iOS及历史版本特性介绍
  2. c语言创建文件夹cpp,c语言实现文件夹的创建和删除
  3. html中表格实现在页面居中显示,table居中显示 css table 单元格 居中
  4. 计算机专业贵州排名2015,2015贵州省大学最佳专业排行榜,贵州大学雄居榜首
  5. 劳动合同的形式与内容
  6. 上海师范大学Windows端VPN使用教程及课表查询方法
  7. java第二章测试题_MOOC选修课答案第二章单元测试答案_Java程序设计查询答案
  8. IPFS 二维码添加的问题
  9. Linux下在shell中使用curl模拟get,post请求访问接口并设置代理
  10. python趣味编程-坦克大战游戏