add game&rawdata
This commit is contained in:
parent
0133cd976c
commit
49b34b5546
45731 changed files with 709831 additions and 0 deletions
98
gamedata/scripts/sr_teleport.script
Normal file
98
gamedata/scripts/sr_teleport.script
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
----------------------------------------------------------------------------------------------------
|
||||
-- Do nothing
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
local i,k,v = 0,0,0
|
||||
|
||||
local teleport_idle = 0
|
||||
local teleport_activated = 1
|
||||
|
||||
class "action_teleport"
|
||||
function action_teleport:__init(obj, storage)
|
||||
self.object = obj
|
||||
self.st = storage
|
||||
|
||||
self.state = teleport_idle
|
||||
self.timer = nil
|
||||
end
|
||||
function action_teleport:update(delta)
|
||||
if not db.actor then
|
||||
return
|
||||
end
|
||||
|
||||
if self.state == teleport_idle then
|
||||
if self.object:inside(db.actor:position()) then
|
||||
-- Îáðàáîòêà òåëåïîðòà
|
||||
self.state = teleport_activated
|
||||
self.timer = time_global()
|
||||
level.add_pp_effector ("teleport.ppe", 2006, false)
|
||||
--set_postprocess("scripts\\teleport.ltx")
|
||||
end
|
||||
end
|
||||
if self.state == teleport_activated then
|
||||
if time_global() - self.timer >= self.st.timeout then
|
||||
-- Ïðîèçâîäèì òåëåïîðòàöèþ
|
||||
local temp = {}
|
||||
local max_rnd = 0
|
||||
for k,v in pairs(self.st.points) do
|
||||
-- Îïðåäåëÿþòñÿ äîïóñòèìûå ñîñòîÿíèÿ äëÿ ëàãåðÿ.
|
||||
temp[k] = v
|
||||
max_rnd = max_rnd + v.prob
|
||||
end
|
||||
-- Îñóùåñòâëÿåòñÿ ðàíäîìíûé âçâåøåííûé ïåðåõîä.
|
||||
local p = math.random(0,max_rnd)
|
||||
for k,v in pairs(temp) do
|
||||
p = p - v.prob
|
||||
if p <= 0 then
|
||||
-- òåëåïîðò â âûáðàííóþ òî÷êó
|
||||
printf("teleporting to [%s] look [%s]", v.point, v.look)
|
||||
db.actor:set_actor_position(patrol(v.point):point(0))
|
||||
local dir = patrol(v.look):point(0):sub(patrol(v.point):point(0))
|
||||
db.actor:set_actor_direction(-dir:getH())
|
||||
local snd_obj = sound_object("affects\\tinnitus3a")
|
||||
snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
|
||||
break
|
||||
end
|
||||
end
|
||||
self.state = teleport_idle
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
if xr_logic.try_switch_to_another_section(self.object, self.st, db.actor) then
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------------
|
||||
function add_to_binder(npc, ini, scheme, section, storage)
|
||||
local action = action_teleport(npc, storage)
|
||||
|
||||
-- Çàðåãèñòðèðîâàòü âñå actions, â êîòîðûõ äîëæåí áûòü âûçâàí ìåòîä reset_scheme ïðè èçìåíåíèè íàñòðîåê ñõåìû:
|
||||
xr_logic.subscribe_action_for_events(npc, storage, action)
|
||||
end
|
||||
|
||||
function set_scheme(obj, ini, scheme, section, gulag_name)
|
||||
local st = xr_logic.assign_storage_and_bind(obj, ini, scheme, section)
|
||||
st.logic = xr_logic.cfg_get_switch_conditions(ini, section, obj)
|
||||
|
||||
st.timeout = utils.cfg_get_number(ini, section, "timeout", obj, false, 900)
|
||||
|
||||
st.points = {}
|
||||
for i=1,10 do
|
||||
local t = {
|
||||
point = utils.cfg_get_string(ini, section, "point"..tostring(i), obj, false, "", "none"),
|
||||
look = utils.cfg_get_string(ini, section, "look"..tostring(i), obj, false, "", "none"),
|
||||
prob = utils.cfg_get_number(ini, section, "prob"..tostring(i), obj, false, 100)
|
||||
}
|
||||
if t.point == "none" or t.look == "none" then
|
||||
break
|
||||
end
|
||||
table.insert(st.points, t)
|
||||
end
|
||||
if #st.points == 0 then
|
||||
abort("Wrong point nums in sr_teleport [%s]", tostring(section))
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue