Cage drop script;
GetPlayerDistance(e) has changed since previous versions so ... watch out for that.
I would have kept it working as it was-- then allow for separate 'Y' check.
Lines 42, 43;
This was tested on the aqueduct water "con_pipe" in "Cityscape" . The rotation is set for that--
change to all zero's (just don't call me, I'm not an attorney) for your model.
The "trap" will behave with physics and roll off player if set to IsImmobile = no but it will drop with gravity that way.
Nevertheless, I suggest the manual drop with IsImmobile = yes to erase those concerns.
local origpntx = {}
local origpnty = {}
local origpntz = {}
local sttimer = {}
local activating = {}
local hitground = {}
local movedown = {}
local distx = {}
local distz = {}
local bashing = {}
local settime = {}
function cage_drop_init(e)
origpntx[e] = g_Entity[e]['x']
origpnty[e] = g_Entity[e]['y']
origpntz[e] = g_Entity[e]['z']
sttimer[e] = 0
activating[e] = 0
settime[e] = 3000 -- Set time by 1 x 1000 per each second delay...
--------------------- Important!
hitground[e] = 111 -- set to zero for gravity drop or number for slow drop (must be height of cage drop)
--------------------- Object must be set to IsImobbile = no for gravity drop
movedown[e] = 0
bashing[e] = 0
end -- init
function cage_drop_main(e)
distx[e] = math.abs(g_PlayerPosX - g_Entity[e]['x'])
distz[e] = math.abs(g_PlayerPosZ - g_Entity[e]['z'])
if activating[e] == 0 then
-- if GetPlayerDistance(e) < 500 then
if distx[e] < 80 and distz[e] < 80 then
sttimer[e] = g_Time
activating[e] = 1
else
activating[e] = 0
CollisionOff(e)
SetPosition(e, origpntx[e], origpnty[e], origpntz[e] )
ResetPosition(e, origpntx[e], origpnty[e], origpntz[e] )
SetRotation(e, 0, 0, 90 )
ResetRotation(e, 0, 0, 90 )
CollisionOn(e)
end -- setup trap // check distance, set time
end -- look for player
if activating[e] == 1 then
Text(11,44,1,"Cage dropping in... "..math.floor((settime[e] - (g_Time - sttimer[e] )) / 1000)+1 )
if g_Time > sttimer[e] + settime[e] then -- allow 2 seconds (set any amount, even zero)
activating[e] = 2
end -- check timer
end -- trap sees you!
if activating[e] == 2 then -- dropping cage down
if movedown[e] < hitground[e] then
movedown[e] = movedown[e] + 1 -- set your speed at this number
CollisionOff(e)
SetPosition(e, origpntx[e], origpnty[e] - movedown[e], origpntz[e] )
ResetPosition(e, origpntx[e], origpnty[e] - movedown[e], origpntz[e] )
SetRotation(e, 0, 0, 90 )
ResetRotation(e, 0, 0, 90 )
CollisionOn(e)
else
activating[e] = 3 -- finished trap!
end -- check for ground
end -- move down
if activating[e] == 3 then
if distx[e] < 50 and distz[e] < 50 then
Text(5,5,1, "Press 'E' to bash out of cage." )
Text(8,8,1, "Bashing... "..math.floor(bashing[e]) )
if g_Scancode == 18 then bashing[e] = bashing[e] + 0.22 end
if bashing[e] > 100 then activating[e] = 4 end
end
end -- bashing out of cage
if activating[e] == 4 then -- raising cage back up
if movedown[e] > 0 then
movedown[e] = movedown[e] - 1 -- set your speed at this number
CollisionOff(e)
SetPosition(e, origpntx[e], origpnty[e] - movedown[e], origpntz[e] )
ResetPosition(e, origpntx[e], origpnty[e] - movedown[e], origpntz[e] )
SetRotation(e, 0, 0, 90 )
ResetRotation(e, 0, 0, 90 )
CollisionOn(e)
else
activating[e] = 0 -- finished trap!
bashing[e] = 0
end -- check for ground
end -- move down
Text(11,91,1, "activating; "..activating[e] ) -- debugging // watch activation
Text(11,94,1, "plrdis; "..GetPlayerDistance(e) ) -- debugging // find player distance setting....
end -- main