fire_deployed = 1
fire_state = "out"
local height_dif = 0
c_pressed = 0
local heat_range = 400 --how far the player can move away and still get warmed by the fire
local warmth_delay = 999 --how quickly the player restores warmth when fire is lit
local use_range = 120
local light_number = 3
function deployable_fire_init(e)
end
function deployable_fire_main(e)
if fire_deployed == 1 then
if PlayerLooking(e,use_range,25) == 1 then
Panel(65,90,85,99)
TextCenterOnX(75,95,3,"Press C to pick up the fire")
height_dif = g_PlayerPosY - g_Entity[e]['y']
if g_KeyPressC == 1 and c_pressed == 0 then
fire_state = "out"
fire_deployed = 0
c_pressed = 1
StopParticleEmitter(e)
end
if fire_state == "out" then
Panel(40,90,60,99)
TextCenterOnX(50,95,3,"Light the fire? *e*")
if g_KeyPressE == 1 then
StartTimer(e)
fire_state = "lit"
StartParticleEmitter(e)
ShowLight(light_number)
end
end
end
if fire_state == "lit" then
if GetPlayerDistance(e) < heat_range then
if GetTimer(e) > warmth_delay then
StartTimer(e)
--current_cold = current_cold + 1
outside = 0
end
else
outside = 1
end
else
HideLight(light_number)
outside = 1
end
elseif fire_deployed == 0 then
new_y = math.rad(g_PlayerAngY)
fire_x = g_PlayerPosX + (math.sin(new_y) * 70)
fire_z = g_PlayerPosZ + (math.cos(new_y) * 70)
Hide(e)
CollisionOff(e)
CollisionOff(light_number)
HideLight(light_number)
SetPosition(e , fire_x, g_PlayerPosY - height_dif , fire_z)
SetPosition(light_number , fire_x, g_PlayerPosY - height_dif , fire_z)
Panel(65,90,85,99)
TextCenterOnX(75,95,3,"Press C to place a fire")
if g_KeyPressC == 1 and c_pressed == 0 then
Show(e)
CollisionOn(e)
fire_deployed = 1
fire_state = "out"
c_pressed = 1
end
end --fire_deployed
if g_KeyPressC == 0 then
c_pressed = 0
end
--Prompt(fire_deployed.." "..fire_state)
end --main
function PlayerLooking(e,dis,v)
if g_Entity[e] ~= nil then
if dis == nil then
dis = 3000
end
if v == nil then
v = 0.5
end
if GetPlayerDistance(e) <= dis then
local destx = g_Entity[e]['x'] - g_PlayerPosX
local destz = g_Entity[e]['z'] - g_PlayerPosZ
local angle = math.atan2(destx,destz)
angle = angle * (180.0 / math.pi)
if angle <= 0 then
angle = 360 + angle
elseif angle > 360 then
angle = angle - 360
end
while g_PlayerAngY < 0 or g_PlayerAngY > 360 do
if g_PlayerAngY <= 0 then
g_PlayerAngY = 360 + g_PlayerAngY
elseif g_PlayerAngY > 360 then
g_PlayerAngY = g_PlayerAngY - 360
end
end
local L = angle - v
local R = angle + v
if L <= 0 then
L = 360 + L
elseif L > 360 then
L = L - 360
end
if R <= 0 then
R = 360 + R
elseif R > 360 then
R = R - 360
end
if (L < R and math.abs(g_PlayerAngY) > L and math.abs(g_PlayerAngY) < R) then
return 1
elseif (L > R and (math.abs(g_PlayerAngY) > L or math.abs(g_PlayerAngY) < R)) then
return 1
else
return 0
end
else
return 0
end
end
end
local max_cold = 100 --maximum amount cold protection player can store
current_cold = 100 --starting amount of cold protection player has in store
local delay = 2.5 --amount of time between cold protection updates
local damage = 5 --amount of damage to apply when cold protection runs out (will apply some when below 10% to start the heartbeat as a warning)
local damge_delay = 2.5 --how fast damage is applied after cold protection runs out
local healing = 1 --set to 0 if player doesnt automatically restore health from being inside
local health_restore = 1 --how quickly health replenishes once back inside
outside = 1 --set to 1 if player starts outside
local max_health = nil
delay = delay * 1000
damge_delay = damge_delay * 1000
function cold_level_init(e)
Hide(e)
CollisionOff(e)
end
function cold_level_main(e)
Hide(e)
CollisionOff(e)
if max_health == nil then
max_health = g_PlayerHealth
else
Panel(80,81,150,87)
TextCenterOnX(90,84,3,"- Body Temp : "..current_cold.." / "..max_cold)
if g_PlayerHealth < 1 then
current_cold = max_cold
end
if outside == 1 then
if current_cold > 0 then
if GetTimer(e) > delay then
StartTimer(e)
if current_cold < max_cold / 10 then
HurtPlayer(e,damage/10)
end
current_cold = current_cold - 1
end
else
if GetTimer(e) > damge_delay then
current_cold = current_cold - 1
StartTimer(e)
HurtPlayer(e,damage)
end
end
else
if GetTimer(e) > delay then
StartTimer(e)
if current_cold < max_cold then
current_cold = current_cold + 1
end
if healing == 1 and g_PlayerHealth > 0 then
if g_PlayerHealth < max_health then
if g_PlayerHealth + health_restore <= max_health then
SetPlayerHealth(g_PlayerHealth+health_restore)
else
SetPlayerHealth(max_health)
end
end
end
end
end
end
end
function cold_level_exit(e)
end
life\'s one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11