Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- donation_interactive.lua
- -- Читает файл донатов и вызывает игровые эффекты.
- local VFS = getFS()
- local DONATE_PATH = "donations.txt" -- файл от RutonyChat
- local LOG_PATH = "donations_effects.log" -- лог эффектов
- local last_line, timer, interval = nil, 0, 5 -- интервал 5 сек
- -- Список действий: по сумме >= sum — вызвать fn
- local actions = {
- { sum=20, fn="spawn_dogs" },
- { sum=70, fn="spawn_snorks" },
- { sum=75, fn="spawn_boars" },
- { sum=95, fn="spawn_pseudodogs" },
- { sum=130, fn="spawn_psydogs" },
- { sum=150, fn="spawn_burers" },
- { sum=200, fn="spawn_bloodsuckers" },
- { sum=300, fn="spawn_controllers" },
- { sum=400, fn="spawn_pseudogigants" },
- { sum=750, fn="spawn_fear_hour" },
- { sum=65, fn="spawn_zombies" },
- { sum=120, fn="spawn_bandit_squad" },
- { sum=250, fn="spawn_monolith_squad" },
- { sum=110, fn="spawn_loner_squad" },
- { sum=235, fn="spawn_anomaly_burner" },
- { sum=140, fn="spawn_anomaly_electra" },
- { sum=225, fn="spawn_anomaly_mines" },
- { sum=21, fn="eat_can" },
- { sum=45, fn="heal_full" },
- { sum=57, fn="mega_heal" },
- { sum=55, fn="drunk_vodka" },
- { sum=80, fn="give_money" },
- { sum=90, fn="repair_gear" },
- { sum=64, fn="give_medkit_pack" },
- { sum=40, fn="give_ammo_slots" },
- { sum=85, fn="temp_infinite_ammo" },
- { sum=47, fn="give_random_artifact" },
- { sum=190, fn="kill_nearby" },
- { sum=205, fn="swap_primary_weapon" },
- { sum=210, fn="swap_armor" },
- { sum=255, fn="temp_teleports" },
- { sum=124, fn="moon_gravity" },
- { sum=145, fn="drunk_cam_effect" },
- { sum=101, fn="bag_on_head" },
- { sum=60, fn="teleport_random" },
- { sum=166, fn="butt_kickers" },
- { sum=77, fn="drop_grenade_under" },
- { sum=115, fn="shovel_head_hit" },
- { sum=125, fn="disable_wasd" },
- { sum=230, fn="uranium_pants" },
- { sum=330, fn="break_random_inventory" },
- { sum=420, fn="steal_all_money" },
- { sum=570, fn="steal_all_weapons" },
- { sum=550, fn="steal_armor" },
- { sum=247, fn="spawn_predator_anomaly" },
- { sum=135, fn="pistol_only" },
- { sum=335, fn="ban_firearms" },
- { sum=1500, fn="steal_everything" },
- }
- -- Запись в лог (VFS)
- local function write_log(msg)
- local f = VFS:w_open(LOG_PATH)
- if not f then return end
- f:open_chunk(0)
- f:w_stringZ(os.date("%H:%M:%S").." "..msg.."\n")
- f:close_chunk()
- VFS:w_close(f)
- end
- -- Чтение последней строки из donations.txt
- local function read_last_line()
- local f = VFS:r_open(DONATE_PATH)
- if not f then write_log("ERROR: donations.txt not found"); return nil end
- f:open_chunk(0)
- local text = f:r_stringZ()
- f:close_chunk()
- VFS:r_close(f)
- if not text or text == "" then return nil end
- local last
- for line in string.gmatch(text, "[^\r\n]+") do last = line end
- return last
- end
- -- Получаем точку на 10м от игрока в случайном направлении
- local function get_spawn_pos()
- local pos = actor:position()
- local angle = math.random() * 2 * math.pi
- pos.x = pos.x + math.cos(angle) * 10
- pos.z = pos.z + math.sin(angle) * 10
- return pos
- end
- -- Удобная обёртка для alife():create
- local function spawn(section, count)
- local pos = get_spawn_pos()
- local lv, gv = actor:level_vertex_id(), actor:game_vertex_id()
- for i=1,(count or 1) do
- alife():create(section, pos, lv, gv)
- end
- end
- --[[
- Определяем все функции-эффекты:
- spawn_dogs, spawn_snorks, ..., steal_everything
- Ниже — примеры нескольких, остальные аналогично.
- ]]
- function spawn_dogs() spawn("monster_dog", 2); write_log("spawn_dogs") end
- function spawn_snorks() spawn("monster_snork", 2); write_log("spawn_snorks") end
- function spawn_boars() spawn("monster_boar", 3); write_log("spawn_boars") end
- function spawn_pseudodogs() spawn("monster_pseudodog", 3); write_log("spawn_pseudodogs") end
- function spawn_psydogs() spawn("monster_pseudodog", 2); write_log("spawn_psydogs") end
- function spawn_burers() spawn("monster_burer", 2); write_log("spawn_burers") end
- function spawn_bloodsuckers() spawn("monster_bloodsucker",2); write_log("spawn_bloodsuckers") end
- function spawn_controllers() spawn("monster_controller", 1); write_log("spawn_controllers") end
- function spawn_pseudogigants() spawn("monster_giant", 2); write_log("spawn_pseudogigants") end
- function spawn_fear_hour()
- for i=1,10 do local m={"monster_snork","monster_bloodsucker","monster_controller","monster_burer"}
- spawn(m[math.random(#m)],1)
- end
- write_log("spawn_fear_hour")
- end
- function spawn_zombies() spawn("stalker_zombied", 4); write_log("spawn_zombies") end
- function spawn_bandit_squad() spawn("stalker_bandit", 4); write_log("spawn_bandit_squad") end
- function spawn_monolith_squad() spawn("stalker_monolith", 4); write_log("spawn_monolith_squad") end
- function spawn_loner_squad() spawn("stalker_loner", 4); write_log("spawn_loner_squad") end
- function spawn_anomaly_burner() spawn("anomaly_thermic", 1); write_log("spawn_anomaly_burner") end
- function spawn_anomaly_electra() spawn("anomaly_electra", 1); write_log("spawn_anomaly_electra") end
- function spawn_anomaly_mines() spawn("anomaly_mine", 1); write_log("spawn_anomaly_mines") end
- function eat_can() db.actor:object():conditions():set_satiety(1); write_log("eat_can") end
- function heal_full() db.actor:object():set_health(1.0); write_log("heal_full") end
- function mega_heal() db.actor:object():set_wound_heal(true); write_log("mega_heal") end
- function drunk_vodka() db.actor:object():conditions():set_radiation(1); write_log("drunk_vodka") end
- function give_money() db.actor:object():set_money(math.random(1,50000)); write_log("give_money") end
- function repair_gear()
- for _,itm in ipairs(db.actor:inventory():get_all()) do itm:set_condition(1.0) end
- write_log("repair_gear")
- end
- function give_medkit_pack() spawn("first_aid_kit",5); write_log("give_medkit_pack") end
- function give_ammo_slots()
- local w = actor:get_wpn_slot(0) if w then w:add_ammo(30) end
- write_log("give_ammo_slots")
- end
- function temp_infinite_ammo()
- db.actor:object():conditions():set_infinite_ammo(true,60); write_log("temp_infinite_ammo")
- end
- function give_random_artifact() spawn("artifact_random",1); write_log("give_random_artifact") end
- function kill_nearby()
- for _,o in ipairs(level:get_objects_in_radius(150,{"npc","ai"})) do
- o:object():hit(actor, o:position(), 9999, "explosion_hit")
- end
- write_log("kill_nearby")
- end
- function swap_primary_weapon()
- actor:inventory():drop_active_weapon()
- spawn("wpn_ak74",1); write_log("swap_primary_weapon")
- end
- function swap_armor()
- actor:drop_armor()
- spawn("outfit_cschelic",1); write_log("swap_armor")
- end
- function temp_teleports()
- for i=1,3 do actor:teleport(get_spawn_pos()) end
- write_log("temp_teleports")
- end
- function moon_gravity()
- level:set_gravity(0.15); _G._moon_timer=60; write_log("moon_gravity") end
- function drunk_cam_effect()
- _G._drunk_time=180; write_log("drunk_cam_effect") end
- function bag_on_head()
- spawn("misc\\bag",1); write_log("bag_on_head") end
- function teleport_random()
- actor:teleport(level:get_random_point()); write_log("teleport_random") end
- function butt_kickers()
- actor:apply_force(actor:position(), vector(0,1,0)*500); write_log("butt_kickers") end
- function drop_grenade_under()
- spawn("wpn_rgd5",1); write_log("drop_grenade_under") end
- function shovel_head_hit()
- db.actor:object():set_health(0.01); write_log("shovel_head_hit") end
- function disable_wasd()
- level:disable_input({"move_forward","move_back","move_left","move_right"},60)
- write_log("disable_wasd")
- end
- function uranium_pants()
- _G._uranium_time=120; write_log("uranium_pants") end
- function break_random_inventory()
- for _,itm in ipairs(db.actor:inventory():get_all()) do
- itm:set_condition(math.random())
- end
- write_log("break_random_inventory")
- end
- function steal_all_money() db.actor:object():set_money(1); write_log("steal_all_money") end
- function steal_all_weapons() actor:drop_all_weapons(); write_log("steal_all_weapons") end
- function steal_armor() actor:drop_armor(); write_log("steal_armor") end
- function spawn_predator_anomaly() spawn("anomaly_gravi",1); write_log("spawn_predator_anomaly") end
- function pistol_only()
- actor:drop_all_weapons_except("wpn_pistol"); write_log("pistol_only") end
- function ban_firearms()
- level:disable_input({"fire"},60); write_log("ban_firearms") end
- function steal_everything()
- actor:inventory():clear_except_story(); write_log("steal_everything") end
- -- Update dt: проверка файла и таймеры
- function Update(dt)
- -- таймеры временных эффектов
- if _G._moon_timer then _G._moon_timer=_G._moon_timer-dt
- if _G._moon_timer<=0 then level:set_gravity(1.0); _G._moon_timer=nil end
- end
- if _G._drunk_time then _G._drunk_time=_G._drunk_time-dt
- if _G._drunk_time<=0 then _G._drunk_time=nil end
- end
- if _G._uranium_time then _G._uranium_time=_G._uranium_time-dt
- if _G._uranium_time<=0 then _G._uranium_time=nil end
- end
- -- проверка лог-файла каждые interval
- timer = timer + dt
- if timer < interval then return end
- timer = 0
- local line = read_last_line()
- if not line or line == last_line then return end
- last_line = line
- local amt = tonumber(string.match(line, "(%d+%.?%d*)"))
- if not amt then write_log("Invalid line: "..line); return end
- for _,act in ipairs(actions) do
- if amt >= act.sum then
- local fn = _G[act.fn]
- if fn then
- local ok,err = pcall(fn)
- if not ok then write_log("Error "..act.fn..": "..err) end
- else
- write_log("Missing func: "..act.fn)
- end
- break
- end
- end
- end
Add Comment
Please, Sign In to add comment