-- Create the trigger trigger = ScriptTrigger() trigger:setName("falldowntrigger") trigger:setScript("falldown.lua") trigger:setFunction("tick") trigger:setAbsCoor(670.307190, 0, -410.386810) trigger:setTarget("Player") trigger:setRadius(100) -- Get objects from orxonox thisscript:addObject("TestEntity", "fallingguy") thisscript:addObject("FPSPlayer", "Player") thisscript:addObject("GenericNPC","fleemechanic") dy = 0 randTime = 0 eventFinished = false randinit = false mtheight = -10 function RandTime() if not randinit then math.randomseed(os.clock()) randinit = true randTime = 8 * math.random() end end function fallDown(timestep) dy = dy + timestep thisX = fallingguy:getAbsCoorX() thisY = fallingguy:getAbsCoorY() thisZ = fallingguy:getAbsCoorZ() fallingguy:setAbsCoor(thisX, thisY - dy, thisZ) if thisY < -100 then eventFinished = true end end fleeprogrammed = false function flee(timestep) if not fleeprogrammed then fleemechanic:runTo( 735.658142, mtheight, -1525.291870) fleemechanic:runTo( 746.021912, mtheight, -1416.895508) fleemechanic:runTo( 746.021912, mtheight, -1415.689819) fleemechanic:runTo( 745.840454, mtheight, -1314.824585) fleemechanic:runTo( 745.840454, mtheight, -1313.533691) fleemechanic:runTo( 745.840454, mtheight, -1312.239258) fleemechanic:runTo( 745.840454, mtheight, -1310.942749) fleemechanic:runTo( 686.141907, mtheight, -1174.515015) fleemechanic:runTo( 685.479614, mtheight, -1173.372925) fleemechanic:runTo( 684.815857, mtheight, -1172.228271) fleemechanic:runTo( 630.430725, mtheight, -1072.972168) fleemechanic:runTo( 629.804199, mtheight, -1071.821777) fleemechanic:runTo( 629.174438, mtheight, -1070.665527) fleemechanic:runTo( 628.542786, mtheight, -1069.505859) fleemechanic:runTo( 627.905334, mtheight, -1068.335449) fleemechanic:runTo( 582.125610, mtheight, -969.282288) fleemechanic:runTo( 581.719971, mtheight, -968.030273) fleemechanic:runTo( 581.312866, mtheight, -966.773621) fleemechanic:runTo( 580.904602, mtheight, -965.513550) fleemechanic:runTo( 580.492493, mtheight, -964.241638) fleemechanic:runTo( 555.827942, mtheight, -873.071045) fleemechanic:runTo( 555.657410, mtheight, -871.761780) fleemechanic:runTo( 555.485962, mtheight, -870.445679) fleemechanic:runTo( 555.314087, mtheight, -869.126160) fleemechanic:runTo( 555.141418, mtheight, -867.800598) fleemechanic:runTo( 554.968262, mtheight, -866.471069) fleemechanic:runTo( 554.794922, mtheight, -865.140076) fleemechanic:runTo( 547.754639, mtheight, -767.221680) fleemechanic:runTo( 547.722961, mtheight, -765.892944) fleemechanic:runTo( 547.691223, mtheight, -764.562683) fleemechanic:runTo( 547.659180, mtheight, -763.219604) fleemechanic:runTo( 548.969849, mtheight, -649.171387) fleemechanic:runTo( 549.043274, mtheight, -647.850952) fleemechanic:runTo( 549.117126, mtheight, -646.523193) fleemechanic:runTo( 549.191101, mtheight, -645.193542) fleemechanic:runTo( 549.265137, mtheight, -643.862305) fleemechanic:runTo( 568.188416, mtheight, -510.499756) fleemechanic:runTo( 568.575439, mtheight, -509.219055) fleemechanic:runTo( 568.964539, mtheight, -507.931458) fleemechanic:runTo( 569.355469, mtheight, -506.637726) fleemechanic:runTo( 626.359924, mtheight, -384.633179) fleemechanic:runTo( 627.059998, mtheight, -383.511444) fleemechanic:runTo( 627.764282, mtheight, -382.382935) fleemechanic:runTo( 628.469055, mtheight, -381.253601) fleemechanic:runTo( 629.178345, mtheight, -380.117065) fleemechanic:runTo( 629.888367, mtheight, -378.979340) fleemechanic:runTo( 630.599548, mtheight, -377.839752) fleemechanic:runTo( 631.316711, mtheight, -376.690643) fleemechanic:runTo( 704.250305, mtheight, -250.679443) fleemechanic:runTo( 704.842896, mtheight, -249.538712) fleemechanic:runTo( 705.438721, mtheight, -248.391754) fleemechanic:runTo( 706.033630, mtheight, -247.246506) fleemechanic:runTo( 706.628479, mtheight, -246.101395) fleemechanic:runTo( 707.229248, mtheight, -244.944870) fleemechanic:runTo( 707.831665, mtheight, -243.785248) fleeprogrammed = true end end function tick(timestep) flee(timestep) RandTime() if randTime > 0 then randTime = randTime - timestep else fallDown(timestep) end return eventFinished end