-- Originally made by smallg -- https://forum.game-guru.com/thread/207801?page=10#msg2531534 local move_speed = {} local trigger_range = {} local damage_range = {} local move_range = {} local moved = {} local damage = {} local repeating = {} local startx = {} local starty = {} local startz = {} --set entity to immobile --sound at slot 0 will loop for a sliding wall etc effect function trap_wall5_init(e) --if trap will reset after player moves away or dies etc repeating[e] = 1 --when to start moving the wall trigger_range[e] = 2000 -- was 260 --max range at which damage can be applied (also requires walls to be closed) damage_range[e] = 80 --wall will stop getting closer after it's moved this far (damage will stop too) move_range[e] = 500 -- originally 230 --how fast the wall will "slide" move_speed[e] = 350 --damage per 0.25s damage[e] = 10 end local function GetPlayerFlatDistance( e ) local Ent = g_Entity[ e ] local DX = Ent.x - g_PlayerPosX local DZ = Ent.z - g_PlayerPosZ return math.sqrt( DX*DX + DZ*DZ ) end function trap_wall5_main(e) local Ent = g_Entity[ e ] if repeating[ e ] == 1 and ( startx[ e ] == nil or starty[ e ] == nil or startz[ e ] == nil ) then CollisionOff( e ) startx[ e ] = Ent.x starty[ e ] = Ent.y startz[ e ] = Ent.z else if GetPlayerFlatDistance( e ) < trigger_range[ e ] then if moved[ e ] == nil then moved[ e ] = 0 end LoopSound( e, 0 ) if moved[ e ] < move_range[ e ] then CollisionOff( e ) MoveForward( e,move_speed[ e ] ) moved[ e ] = moved[ e ] + 1 --CollisionOn( e ) if moved[ e ] > move_range[ e ] * 0.9 then if GetPlayerFlatDistance( e ) < damage_range[ e ] then if GetTimer( e ) > 250 then StartTimer( e ) HurtPlayer( e, damage[ e ] ) end end end else StopSound( e, 0 ) end else --CollisionOn( e ) StopSound( e, 0 ) if repeating[ e ] == 1 then moved[ e ] = 0 CollisionOff( e ) SetPosition( e, startx[ e ], starty[ e ], startz[ e ] ) --CollisionOn( e ) end end end end