Hi,
1) The problem here is that we have one direction for vertical movement (Y) but two directions for horizontal movement (X and Z) so it is hard to write one script for both cases.
So for X direction the script is:
local startx = {}
local move_speed = {}
local max_move = {}
local activate_range = {}
local close_range = {}
local moved = {}
local state = {}
local door_name = {}
local delay = {}
--name door y2 to move down (otherwise it defaults to up)
function door_horizontal_X_init_name(e,name)
door_name[e] = name
state[e] = "closed"
--how fast the door slides up/down
move_speed[e] = 1
--how far the door will move in total
max_move[e] = 100
--how close the player gets before the door will open
activate_range[e] = 150
--how far away the player needs to be before the door will shut again
close_range[e] = 155
--if "animation" is still too quick adjust delay here
delay[e] = 1
end
function door_horizontal_X_main(e)
if startx[e] == nil then
startx[e] = g_Entity[e]['x']
if door_name[e] == "x2" then
move_speed[e] = -move_speed[e]
--adjusts close range so that door works better when moving down
close_range[e] = close_range[e] * 4
end
else
if state[e] == "closed" then
if GetPlayerDistance(e) < activate_range[e] then
moved[e] = 0
StartTimer(e)
state[e] = "opening"
end
elseif state[e] == "opening" then
if GetTimer(e) > delay[e] then
StartTimer(e)
if moved[e] < max_move[e] then
moved[e] = moved[e] + 1
CollisionOff(e)
SetPosition(e,g_Entity[e]['x']+move_speed[e],g_Entity[e]['y'],g_Entity[e]['z'])
CollisionOn(e)
else
state[e] = "open"
end
end
if GetPlayerDistance(e) > close_range[e] then
state[e] = "closing"
end
elseif state[e] == "open" then
CollisionOff(e)
if GetPlayerDistance(e) > close_range[e] then
StartTimer(e)
state[e] = "closing"
end
elseif state[e] == "closing" then
if GetTimer(e) > delay[e] then
StartTimer(e)
if moved[e] > 0 then
moved[e] = moved[e] - 1
CollisionOff(e)
SetPosition(e,g_Entity[e]['x']-move_speed[e],g_Entity[e]['y'],g_Entity[e]['z'])
if moved[e] < max_move[e] * 0.8 then
CollisionOn(e)
end
else
state[e] = "closed"
end
end
if GetPlayerDistance(e) < activate_range[e] then
state[e] = "opening"
end
end --state
end --setup
end --main
and for Z:
local startz = {}
local move_speed = {}
local max_move = {}
local activate_range = {}
local close_range = {}
local moved = {}
local state = {}
local door_name = {}
local delay = {}
--name door y2 to move down (otherwise it defaults to up)
function door_horizontal_Z_init_name(e,name)
door_name[e] = name
state[e] = "closed"
--how fast the door slides up/down
move_speed[e] = 1
--how far the door will move in total
max_move[e] = 100
--how close the player gets before the door will open
activate_range[e] = 150
--how far away the player needs to be before the door will shut again
close_range[e] = 155
--if "animation" is still too quick adjust delay here
delay[e] = 1
end
function door_horizontal_Z_main(e)
if startz[e] == nil then
startz[e] = g_Entity[e]['z']
if door_name[e] == "z2" then
move_speed[e] = -move_speed[e]
--adjusts close range so that door works better when moving down
close_range[e] = close_range[e] * 4
end
else
if state[e] == "closed" then
if GetPlayerDistance(e) < activate_range[e] then
moved[e] = 0
StartTimer(e)
state[e] = "opening"
end
elseif state[e] == "opening" then
if GetTimer(e) > delay[e] then
StartTimer(e)
if moved[e] < max_move[e] then
moved[e] = moved[e] + 1
CollisionOff(e)
SetPosition(e,g_Entity[e]['x'],g_Entity[e]['y'],g_Entity[e]['z']+move_speed[e])
CollisionOn(e)
else
state[e] = "open"
end
end
if GetPlayerDistance(e) > close_range[e] then
state[e] = "closing"
end
elseif state[e] == "open" then
CollisionOff(e)
if GetPlayerDistance(e) > close_range[e] then
StartTimer(e)
state[e] = "closing"
end
elseif state[e] == "closing" then
if GetTimer(e) > delay[e] then
StartTimer(e)
if moved[e] > 0 then
moved[e] = moved[e] - 1
CollisionOff(e)
SetPosition(e,g_Entity[e]['x'],g_Entity[e]['y'],g_Entity[e]['z']-move_speed[e])
if moved[e] < max_move[e] * 0.8 then
CollisionOn(e)
end
else
state[e] = "closed"
end
end
if GetPlayerDistance(e) < activate_range[e] then
state[e] = "opening"
end
end --state
end --setup
end --main
2) Ok there a several solutions to this problem(keys,vars,activation states), but what do you mean with
Quote: "invoke a spell"
?
Fire a weapon, use an entity, use a item from your inventory,...? That is very unclear.
3) What the hell is collisionmode = 11?
Ebe Editor Free - Build your own EBE structures with easy and without editing any text files
Thread and Download