new script for landslide (rock fall) effect
it's done on player distance right now, apply the script to the rocks you want to fall and when you get near they will fall
some notes;
- rocks will automatically be set to a certain height from the script (you can change it at the top settings) so you can simply place all rocks at ground level in the editor
- rocks start hidden by default (cos it looks better) and finish up the correct way up by default
- rocks wont go through flat terrain (600 height) but it you have changed the height of your terrain you will need to adjust the setting
- each rock will only hit the player once (if he is in range of that rock) so if you want to kill the player set the damage high
- you can adjust the speed of the fall but it will also add a random speed (based on the speed you set) so that rocks fall at different speeds so it looks better
landslide.lua
--set to 0 if u want all rocks to land upright otherwise it will be more random
local random_landing = 0
--set to amount of damage to apply per falling rock
local damage = 100
--set to range player needs to be within to start the landslide
start_fall_range = 300
--set to range player needs to be within to get hit by a rock
local in_damage_range = 100
--set to height of the terrain the rocks will land onto (600 is default flat)
local terrain_height = 600
--set to amount you want the rocks to spin/rotate while falling (if you want them to spin the other direction use a negative)
local spin = 10
--set to the starting height you require
local startingY = 1000
--set to the starting Y rotation you require
local starting_rotation = 180
--set to the speed at which rocks will fall
local speed = 10
local landslide_started = {}
local fall_speed = {}
local fall_delay = {}
local time_set = {}
local time_1 = {}
local time_2 = {}
local time_passed = {}
local x = {}
local damaged = {}
function landslide_init(e)
MoveUp(e, startingY)
RotateX(e,starting_rotation)
landslide_started[e] = 0
fall_speed[e] = -speed
--applies a random amount of speed to make rocks fall in a less organised way, remove if u require a controlled fall
fall_speed[e] = fall_speed[e] - math.random(speed * 2)
fall_delay[e] = 10
time_set[e] = 0
time_1[e] = 0
time_2[e] = 0
time_passed[e] = 0
Hide(e)
x[e] = 0
damaged[e] = 0
end
function landslide_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < start_fall_range and landslide_started[e] == 0 then
landslide_started[e] = 1
end
if landslide_started[e] == 1 then
Show(e)
if time_set[e] == 0 then
time_1[e] = g_Time
time_set[e] = 1
end --initial time set
time_2[e] = g_Time
time_passed[e] = time_2[e] - time_1[e]
if time_passed[e] > fall_delay[e] then
MoveUp(e,fall_speed[e])
RotateX(e,-spin)
x[e] = x[e] + 1
time_set[e] = 0
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < in_damage_range and damaged[e] == 0 then
HurtPlayer(e,damage)
damaged[e] = 1
end --end damage check
end --end time reached delay
if g_Entity[e]['y'] < terrain_height then
MoveUp(e,-(g_Entity[e]['y'] - terrain_height)) --move rock back above ground if it is travelling too fast and goes below (especially noticeable on small rocks)
landslide_started[e] = 2
if math.random(5) == 5 or random_landing == 0 then
while x[e] > 0 do
RotateX(e,spin)
x[e] = x[e] - 1
end
RotateX(e,starting_rotation)
end
end --end landslide ended
end --end landslide happening
end --end function
*also updated the original post with links to the replies containing the scripts so it's easier to find them*
life's one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11