--script by smallg --trigger distance is the entity name & damage applied is the strength of the entity --how far away to determine a hit local hit_distance = 150 --set to 1 to let boulder reset, set to 0 for 1 time only trap local repeating = 1 --destroy the boulder (if not repeating) local destroy = 0 --if you get issues with it not counting as "stopped" then increase the value here local stopped_mod = 1 local trigger_distance = {} local damage = {} local startx = {} local starty = {} local startz = {} local oldx = {} local oldy = {} local oldz = {} local firing = {} local hit = {} function trap_boulder_init_name(e,name) trigger_distance[e] = tonumber(name) CollisionOff(e) firing[e] = 0 hit[e] = 0 end function trap_boulder_main(e) if startx[e] == nil or starty[e] == nil or startz[e] == nil then startx[e] = g_Entity[e]['x'] starty[e] = g_Entity[e]['y'] startz[e] = g_Entity[e]['z'] else if damage[e] == nil then damage[e] = g_Entity[e]['health'] else if firing[e] == 0 then CollisionOff(e) SetPosition(e,startx[e],starty[e],startz[e]) if GetPlayerFlatDistance(e) < trigger_distance[e] then oldx[e] = g_Entity[e]['x'] oldy[e] = g_Entity[e]['y'] oldz[e] = g_Entity[e]['z'] StartTimer(e) hit[e] = 0 firing[e] = 1 end elseif firing[e] == 1 then CollisionOn(e) if GetPlayerDistance(e) < hit_distance then if hit[e] == 0 then HurtPlayer(e,damage[e]) hit[e] = 1 end else hit[e] = 0 end if GetTimer(e) > 1100 then StartTimer(e) if g_Entity[e]['x'] > oldx[e] - stopped_mod and g_Entity[e]['x'] < oldx[e] + stopped_mod and g_Entity[e]['y'] > oldy[e] - stopped_mod and g_Entity[e]['y'] < oldy[e] + stopped_mod and g_Entity[e]['z'] > oldz[e] - stopped_mod and g_Entity[e]['z'] < oldz[e] + stopped_mod then if repeating == 1 then CollisionOff(e) firing[e] = 0 else if destroy == 1 then Hide(e) Destroy(e) else firing[e] = 2 end end else oldx[e] = g_Entity[e]['x'] oldy[e] = g_Entity[e]['y'] oldz[e] = g_Entity[e]['z'] end end end --firing end --damage value set end --start position set end --main function trap_boulder_exit(e) end function GetPlayerFlatDistance(e) tPlayerDX = (g_Entity[e]['x'] - g_PlayerPosX) tPlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ) return math.sqrt(math.abs(tPlayerDX*tPlayerDX)+math.abs(tPlayerDZ*tPlayerDZ)); end