add game&rawdata
This commit is contained in:
parent
0133cd976c
commit
49b34b5546
45731 changed files with 709831 additions and 0 deletions
77
gamedata/scripts/combat_restrictor.script
Normal file
77
gamedata/scripts/combat_restrictor.script
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
|
||||
|
||||
combat_sectors = {}
|
||||
|
||||
function register_combat_restrictor(restrictor)
|
||||
if combat_sectors[restrictor:name()] == nil then
|
||||
combat_sectors[restrictor:name()] = restrictor
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function apply_combat_restrictor(npc)
|
||||
-- èòåðèðóåìñÿ ïî ðåñòðèêòîðàì, èùåì â êîòîðîì ìû íàõîäèìñÿ è àïïëàèì åãî
|
||||
local npc_position = npc:position()
|
||||
for k,v in pairs(combat_sectors) do
|
||||
if v:inside(npc_position) then
|
||||
npc:add_restrictions(k, "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function clear_combat_restrictor(npc)
|
||||
local out_restr = utils.parse_names(npc:out_restrictions())
|
||||
|
||||
for k,v in pairs(out_restr) do
|
||||
if combat_sectors[v] ~= nil then
|
||||
npc:remove_restrictions(v, "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function accessible_job(se_obj, way_name)
|
||||
local obj = db.storage[se_obj.id]
|
||||
if obj == nil then
|
||||
return false
|
||||
end
|
||||
-- Áåðåì êëèåíòñêèé îáúåêò ÍÏÑ
|
||||
obj = obj.object
|
||||
if obj == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
local npc_position = obj:position()
|
||||
local job_position = patrol(way_name):point(0)
|
||||
|
||||
-- Áåðåì ðåñòðèêòîð ïî ïîçèöèè ïóòè
|
||||
-- Áåðåì ðåñòðèêòîð ïî ïîçèöèè ÍÏÑ
|
||||
local is_npc_inside = false
|
||||
for k,v in pairs(combat_sectors) do
|
||||
if v:inside(npc_position) then
|
||||
is_npc_inside = true
|
||||
if v:inside(job_position) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Åñëè îíè ñîâïàäàþò - òî èñòèíà, èíà÷å ëîæü.
|
||||
return is_npc_inside ~= true
|
||||
end
|
||||
|
||||
|
||||
function get_job_restrictor(way_name)
|
||||
-- Áåðåì ñìàðò ïî ïîçèöèè ïóòè
|
||||
local job_position = patrol(way_name):point(0)
|
||||
for k,v in pairs(combat_sectors) do
|
||||
if v:inside(job_position) then
|
||||
return k
|
||||
end
|
||||
end
|
||||
-- Âîçâðàùàåì åãî èìÿ
|
||||
return ""
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue