add game&rawdata
This commit is contained in:
parent
0133cd976c
commit
49b34b5546
45731 changed files with 709831 additions and 0 deletions
126
gamedata/scripts/sim_objects.script
Normal file
126
gamedata/scripts/sim_objects.script
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
--'******************************************************
|
||||
--'* Ðååñòð ïåðñîíàæåé.
|
||||
--'******************************************************
|
||||
|
||||
--' Òàáëèöà ñîäåðæàùàÿ îáúåêòû è äàííûå î íèõ â ôîðìàòå:
|
||||
--' npc = { smart_id, squad_id, flags}
|
||||
local objects = {}
|
||||
|
||||
--' Òàáëèöà ñîäåðæàùàÿ îáúåêòû ñãðóïèðîâàííûå ïî squad_id:
|
||||
local squad_objects = {}
|
||||
|
||||
--' Çíà÷åíèÿ ôëàãîâ:
|
||||
--' alive - æèâîé ïåðñîíàæ èëè ìåðòâûé
|
||||
--' marked - ïîìå÷åí ëè îí ìàïñïîòîì.
|
||||
|
||||
--' Ðåãèñòðàöèÿ íîâîãî ïåðñîíàæà.
|
||||
function register_object(obj)
|
||||
if objects[obj.id] ~= nil then
|
||||
abort("Object already exist in list [%s]", obj:name())
|
||||
end
|
||||
|
||||
objects[obj.id] = {smart_id = -1, squad_id = nil, flags = {}}
|
||||
|
||||
objects[obj.id].flags.alive = obj:alive()
|
||||
set_obj_squad(obj, -1)
|
||||
|
||||
show_object_spot(obj)
|
||||
|
||||
--' ÂÐÅÌÅÍÍÎ. Çäåñü áóäåì âûáèðàòü ñìàðòòåððåéí.
|
||||
local obj_ini = obj:spawn_ini()
|
||||
local smart = utils.cfg_get_string(obj_ini, "logic", "smart_terrain", obj, false, "", "")
|
||||
printf("SMART = %s", smart)
|
||||
local smart_obj = sim_board.get_sim_board():get_smart_by_name(smart)
|
||||
|
||||
if smart_obj == nil then
|
||||
return
|
||||
end
|
||||
|
||||
printf("SMART_ID = %s ", smart_obj.id)
|
||||
alife():object(smart_obj.id):register_npc(obj)
|
||||
--obj.m_smart_terrain_id = tonumber(smart_id)
|
||||
end
|
||||
|
||||
--' ÀíÐåãèñòðàöèÿ ïåðñîíàæà.
|
||||
function unregister_object(obj)
|
||||
if objects[obj.id] == nil then
|
||||
abort("Trying to unregister nil object [%s]", obj:name())
|
||||
end
|
||||
|
||||
hide_object_spot(obj)
|
||||
|
||||
objects[obj.id] = nil
|
||||
end
|
||||
|
||||
--' Îòìåòèòü îáúåêò êàê ïîìåðøèé.
|
||||
function object_die(obj)
|
||||
objects[obj.id].flags.alive = false
|
||||
|
||||
hide_object_spot(obj)
|
||||
|
||||
--' Óáðàòü îáúåêò èç îòðÿäà.
|
||||
local squad_id = objects[obj.id].squad_id
|
||||
squad_objects[squad_id][obj.id] = nil
|
||||
objects[obj.id].squad_id = nil
|
||||
|
||||
printf("Object %s died:", obj:name())
|
||||
print_table(objects[obj.id])
|
||||
end
|
||||
|
||||
--' Ïîêàçàòü îáúåêò íà êàðòå
|
||||
function show_object_spot(obj)
|
||||
if objects[obj.id].flags.marked then
|
||||
return
|
||||
end
|
||||
if not objects[obj.id].flags.alive then
|
||||
return
|
||||
end
|
||||
|
||||
objects[obj.id].flags.marked = true
|
||||
|
||||
local community = getObjComunity(obj)
|
||||
if(_G.dev_debug) then
|
||||
level.map_add_object_spot(obj.id, "alife_presentation_"..community, obj:name())
|
||||
end
|
||||
end
|
||||
|
||||
--' Óáðàòü îáúåêò ñ êàðòû
|
||||
function hide_object_spot(obj)
|
||||
if not objects[obj.id].flags.marked then
|
||||
return
|
||||
end
|
||||
|
||||
objects[obj.id].flags.marked = false
|
||||
|
||||
local community = getObjComunity(obj)
|
||||
if(_G.dev_debug) then
|
||||
level.map_remove_object_spot(obj.id, "alife_presentation_"..community)
|
||||
end
|
||||
end
|
||||
|
||||
--' Ïîëó÷èòü ãðóïïèðîâêó îáúåêòà
|
||||
function getObjComunity(obj)
|
||||
if obj:clsid() == clsid.script_stalker then
|
||||
return obj:community()
|
||||
else
|
||||
return "monster"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--' Îáíóëåíèå ñïèñêà íà ñîçäàíèè èãðû.
|
||||
function clear()
|
||||
objects = {}
|
||||
squad_objects = {}
|
||||
end
|
||||
|
||||
|
||||
|
||||
--' Òåñòîâûå ôóíêöèè
|
||||
function print()
|
||||
printf("Object list:")
|
||||
print_table(objects)
|
||||
printf("Squad list:")
|
||||
print_table(squad_objects)
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue