the freeze script for any1 interested, 2 versions - 1 which uses a custom AI for soldiers as if you use stock AI and they are firing at you when you freeze time they will continue to fire at you when frozen (it's a very basic script but if there's enough demand i can add waypoint code, it just didn't get added during my tests)
- the second (soldier_script.lua) will allow you to assign a stock ai script (mainly for zombies as they dont have guns so the bug above isn't an issue)
assign freeze.lua to any dynamic object that you set to always active (note it will become invisible)
local input_key = 16 --button to press to trigger the freeze/unfreeze
local max_psychic = 12 --limit on the amount of "psychic" player can have (adjusts maximum amount of time enemies can be frozen for)
local current_psychic = max_psychic / 2 --starting psychic of player
local psychic_recharge_time = 1.25 --how fast psychic recharges
local first_image = 1 --slot number of first image to use
local max_image = 7 --slot number of last image to use
local image_delay = 1 --how fast they update (in milliseconds)
----------------
psychic_recharge_time = psychic_recharge_time * 1000
pressed = 0
frozen = 0
local image = 0
local new_image_delay = 1
local init_psychic_recharge_time = psychic_recharge_time
local time_to_freeze = 5000
local starting_psychic = 0
local drain_timer = 0
----------------
--works with soldier.lua and soldier_script.lua
function freeze_init(e)
Hide(e)
CollisionOff(e)
LoadImages("the experiment",0) --folder that stores the images of the psychic "effect"
end
function freeze_main(e)
Hide(e)
CollisionOff(e)
if timer == nil then
psychic_recharge_time = g_Time + init_psychic_recharge_time
StartTimer(e)
timer = 1
starting_psychic = current_psychic
else
Panel(0,70,20,75)
TextCenterOnX(10,72.5,3,"Psychic : "..current_psychic.." / "..max_psychic)
if current_psychic < max_psychic then
if g_Time > psychic_recharge_time and frozen == 0 then
current_psychic = current_psychic + 1
psychic_recharge_time = g_Time + init_psychic_recharge_time
end
else
psychic_recharge_time = g_Time + init_psychic_recharge_time
end
if frozen == 0 then
StartTimer(e)
if GetScancode() == input_key and pressed == 0 then
if current_psychic > 0 then
drain_timer = g_Time
image = first_image
new_image_delay = image_delay
time_to_freeze = (current_psychic * 1000)+100
PromptDuration("Freezing time",1100)
pressed = 1
FreezeAI()
for a = 1, 9999 do
if g_Entity[a] ~= nil and a ~= e then
if ai_soldier_state[a] ~= nil then
StopAnimation(a)
end
end
end
frozen = 1
else
PromptDuration("You're too exhausted right now",1100)
end
end
else
if g_Time > drain_timer + 1000 then
current_psychic = current_psychic - 1
drain_timer = g_Time
end
if GetTimer(e) > new_image_delay then
new_image_delay = new_image_delay + image_delay
if image > max_image then
image = first_image
else
image = image + 1
end
ShowImage(image)
SetImagePosition(50,50)
end
if GetTimer(e) > time_to_freeze then
psychic_recharge_time = g_Time + init_psychic_recharge_time
current_psychic = 0
PromptDuration("Real time",1100)
frozen = 0
UnFreezeAI()
HideImage(image)
for a = 1, 9999 do
if g_Entity[a] ~= nil and a ~= e then
if ai_soldier_state[a] ~= nil then
PlayAnimation(a)
end
end
end
end
if GetScancode() == input_key and pressed == 0 then
psychic_recharge_time = g_Time + init_psychic_recharge_time
pressed = 1
PromptDuration("Real time",1100)
frozen = 0
UnFreezeAI()
HideImage(image)
for a = 1, 9999 do
if g_Entity[a] ~= nil and a ~= e then
if ai_soldier_state[a] ~= nil then
PlayAnimation(a)
end
end
end
current_psychic = math.floor((time_to_freeze - GetTimer(e)) / 1000)
end
end
if GetScancode() == 0 then
pressed = 0
end
if g_PlayerHealth < 1 then
current_psychic = starting_psychic
end
end --timer set
end
give all enemies the required script (soldier.lua for soldiers & soldier_script.lua for zombies or if you don't mind the gun bug)
local hp_set = {}
--time until enemy swaps from attack to alert (while player can't be seen)
local back_to_alert = 6000
--time until enemy swaps from alert to patrol/idle (while player can't be seen)
local back_to_patrol = 3000
package.path = "scriptbank/?.lua;"
require('ai_zombiewalk3') --name of AI script to use (no .lua needed)
function soldier_script_init(e)
ai_zombiewalk3_init(e) --init(e) call from the AI script used
end
function soldier_script_main(e)
if hp_set[e] == nil then
hp_set[e] = 1
SetEntityHealth(e,g_Entity[e]['health']+5000)
else
if frozen == 0 then
ai_zombiewalk3_main(e) --main(e) call from the AI script used
if g_Entity[e]['health'] < 5000 then
SetEntityHealth(e,0)
end
else
if g_Entity[e]['health'] < 5000 then
if GetPlayerDistance(e) > 80 then
CollisionOff(e)
else
CollisionOn(e)
end
SetEntityHealth(e,4999)
end
end --frozen
end --hp set
--Prompt(ai_soldier_state[e].." "..AIGetEntityHeardSound(g_Entity[e]['obj']).." "..g_Entity[e]['plrvisible'].." "..GetAnimationFrame(e))
end
function soldier_script_exit(e)
ai_zombiewalk3_exit(e) --exit(e) call from the AI script used
end
local hit = {}
local targetx = {}
local targetz = {}
local startx = {}
local startz = {}
local hp_set = {}
--time until enemy swaps from attack to alert (while player can't be seen)
local back_to_alert = 6000
--time until enemy swaps from alert to patrol/idle (while player can't be seen)
local back_to_patrol = 3000
function soldier_init(e)
ai_soldier_state[e] = "patrol"
hit[e] = 0
end
function soldier_main(e)
if hp_set[e] == nil then
hp_set[e] = 1
SetEntityHealth(e,g_Entity[e]['health']+5000)
else
if targetx[e] == nil or targetz[e] == nil then
targetx[e] = g_Entity[e]['x']
targetz[e] = g_Entity[e]['z']
startx[e] = g_Entity[e]['x']
startz[e] = g_Entity[e]['z']
end
if frozen == 0 then
if g_Entity[e]['health'] < 5000 then
SetEntityHealth(e,0)
end
if ai_soldier_state[e] == "patrol" then
CharacterControlUnarmed(e)
StartTimer(e)
if g_Entity[e]['plrvisible'] == 1 or AIGetEntityHeardSound(g_Entity[e]['obj']) == 1 then
targetx[e] = g_PlayerPosX
targetz[e] = g_PlayerPosZ
ai_soldier_state[e] = "alert"
else
targetx[e] = startx[e]
targetz[e] = startz[e]
end
AIEntityGoToPosition(g_Entity[e]['obj'],targetx[e],targetz[e])
elseif ai_soldier_state[e] == "alert" then
CharacterControlArmed(e)
AIEntityGoToPosition(g_Entity[e]['obj'],targetx[e],targetz[e])
if g_Entity[e]['plrvisible'] == 1 or AIGetEntityHeardSound(g_Entity[e]['obj']) == 1 then
StartTimer(e)
targetx[e] = g_PlayerPosX
targetz[e] = g_PlayerPosZ
if GetPlayerDistance(e) < 800 then
ai_soldier_state[e] = "attack"
end
else
if GetTimer(e) > back_to_patrol then
ai_soldier_state[e] = "patrol"
end
end
elseif ai_soldier_state[e] == "attack" then
RotateToPlayer(e)
if g_Entity[e]['plrvisible'] == 1 then
targetx[e] = g_PlayerPosX
targetz[e] = g_PlayerPosZ
StartTimer(e)
if GetPlayerDistance(e) < 800 then
CharacterControlArmed(e)
FireWeapon(e)
else
ai_soldier_state[e] = "alert"
end
else
CharacterControlArmed(e)
AIEntityGoToPosition(g_Entity[e]['obj'],targetx[e],targetz[e])
if GetTimer(e) > back_to_alert then
StartTimer(e)
ai_soldier_state[e] = "alert"
end
end
end --state
else
targetx[e] = g_Entity[e]['x']
targetz[e] = g_Entity[e]['z']
if g_Entity[e]['health'] < 5000 then
if GetPlayerDistance(e) > 80 then
CollisionOff(e)
else
CollisionOn(e)
end
SetEntityHealth(e,4999)
end
end --frozen
end --hp set
--Prompt(ai_soldier_state[e].." "..AIGetEntityHeardSound(g_Entity[e]['obj']).." "..g_Entity[e]['plrvisible'].." "..GetAnimationFrame(e))
end
function soldier_exit(e)
end
press Q to freeze the enemies
(note you can change the settings in freeze.lua)
video (have made some improvements too, for example psychic counter now updates while you are using the freeze so you can easily see how much you have left)
p.s. although the script can allow for images they arent required, it still works without them
life\'s one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11