| 1 | -- Create the trigger | 
|---|
| 2 | trigger = ScriptTrigger() | 
|---|
| 3 | trigger:setName("falldowntrigger") | 
|---|
| 4 | trigger:setScript("falldown.lua") | 
|---|
| 5 | trigger:setFunction("tick") | 
|---|
| 6 | trigger:setAbsCoor(670.307190, 0, -410.386810) | 
|---|
| 7 | trigger:setTarget("Player") | 
|---|
| 8 | trigger:setRadius(100) | 
|---|
| 9 |  | 
|---|
| 10 |  | 
|---|
| 11 | -- Get objects from orxonox | 
|---|
| 12 | thisscript:addObject("GenericNPC", "fallingguy") | 
|---|
| 13 | thisscript:addObject("FPSPlayer", "Player") | 
|---|
| 14 | thisscript:addObject("GenericNPC","fleemechanic") | 
|---|
| 15 |  | 
|---|
| 16 | dy = 0 | 
|---|
| 17 | randTime = 0 | 
|---|
| 18 | eventFinished = false | 
|---|
| 19 | randinit = false | 
|---|
| 20 | mtheight = -10 | 
|---|
| 21 |  | 
|---|
| 22 | function RandTime() | 
|---|
| 23 |  | 
|---|
| 24 | if not randinit then | 
|---|
| 25 | math.randomseed(os.clock()) | 
|---|
| 26 | randinit = true | 
|---|
| 27 | randTime = 8 * math.random() | 
|---|
| 28 | end | 
|---|
| 29 | end | 
|---|
| 30 |  | 
|---|
| 31 |  | 
|---|
| 32 | function fallDown(timestep) | 
|---|
| 33 | dy = dy + timestep | 
|---|
| 34 | thisX = fallingguy:getAbsCoorX() | 
|---|
| 35 | thisY = fallingguy:getAbsCoorY() | 
|---|
| 36 | thisZ = fallingguy:getAbsCoorZ() | 
|---|
| 37 |  | 
|---|
| 38 | fallingguy:setAbsCoor(thisX, thisY - dy, thisZ) | 
|---|
| 39 |  | 
|---|
| 40 | if thisY < -100 then | 
|---|
| 41 | eventFinished = true | 
|---|
| 42 | end | 
|---|
| 43 |  | 
|---|
| 44 | end | 
|---|
| 45 |  | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | fleeprogrammed = false | 
|---|
| 49 | function flee(timestep) | 
|---|
| 50 | if not fleeprogrammed then | 
|---|
| 51 | fleemechanic:runTo( 735.658142, mtheight, -1525.291870) | 
|---|
| 52 | fleemechanic:runTo( 746.021912, mtheight, -1416.895508) | 
|---|
| 53 | fleemechanic:runTo( 746.021912, mtheight, -1415.689819) | 
|---|
| 54 | fleemechanic:runTo( 745.840454, mtheight, -1314.824585) | 
|---|
| 55 | fleemechanic:runTo( 745.840454, mtheight, -1313.533691) | 
|---|
| 56 | fleemechanic:runTo( 745.840454, mtheight, -1312.239258) | 
|---|
| 57 | fleemechanic:runTo( 745.840454, mtheight, -1310.942749) | 
|---|
| 58 | fleemechanic:runTo( 686.141907, mtheight, -1174.515015) | 
|---|
| 59 | fleemechanic:runTo( 685.479614, mtheight, -1173.372925) | 
|---|
| 60 | fleemechanic:runTo( 684.815857, mtheight, -1172.228271) | 
|---|
| 61 | fleemechanic:runTo( 630.430725, mtheight, -1072.972168) | 
|---|
| 62 | fleemechanic:runTo( 629.804199, mtheight, -1071.821777) | 
|---|
| 63 | fleemechanic:runTo( 629.174438, mtheight, -1070.665527) | 
|---|
| 64 | fleemechanic:runTo( 628.542786, mtheight, -1069.505859) | 
|---|
| 65 | fleemechanic:runTo( 627.905334, mtheight, -1068.335449) | 
|---|
| 66 | fleemechanic:runTo( 582.125610, mtheight, -969.282288) | 
|---|
| 67 | fleemechanic:runTo( 581.719971, mtheight, -968.030273) | 
|---|
| 68 | fleemechanic:runTo( 581.312866, mtheight, -966.773621) | 
|---|
| 69 | fleemechanic:runTo( 580.904602, mtheight, -965.513550) | 
|---|
| 70 | fleemechanic:runTo( 580.492493, mtheight, -964.241638) | 
|---|
| 71 | fleemechanic:runTo( 555.827942, mtheight, -873.071045) | 
|---|
| 72 | fleemechanic:runTo( 555.657410, mtheight, -871.761780) | 
|---|
| 73 | fleemechanic:runTo( 555.485962, mtheight, -870.445679) | 
|---|
| 74 | fleemechanic:runTo( 555.314087, mtheight, -869.126160) | 
|---|
| 75 | fleemechanic:runTo( 555.141418, mtheight, -867.800598) | 
|---|
| 76 | fleemechanic:runTo( 554.968262, mtheight, -866.471069) | 
|---|
| 77 | fleemechanic:runTo( 554.794922, mtheight, -865.140076) | 
|---|
| 78 | fleemechanic:runTo( 547.754639, mtheight, -767.221680) | 
|---|
| 79 | fleemechanic:runTo( 547.722961, mtheight, -765.892944) | 
|---|
| 80 | fleemechanic:runTo( 547.691223, mtheight, -764.562683) | 
|---|
| 81 | fleemechanic:runTo( 547.659180, mtheight, -763.219604) | 
|---|
| 82 | fleemechanic:runTo( 548.969849, mtheight, -649.171387) | 
|---|
| 83 | fleemechanic:runTo( 549.043274, mtheight, -647.850952) | 
|---|
| 84 | fleemechanic:runTo( 549.117126, mtheight, -646.523193) | 
|---|
| 85 | fleemechanic:runTo( 549.191101, mtheight, -645.193542) | 
|---|
| 86 | fleemechanic:runTo( 549.265137, mtheight, -643.862305) | 
|---|
| 87 | fleemechanic:runTo( 568.188416, mtheight, -510.499756) | 
|---|
| 88 | fleemechanic:runTo( 568.575439, mtheight, -509.219055) | 
|---|
| 89 | fleemechanic:runTo( 568.964539, mtheight, -507.931458) | 
|---|
| 90 | fleemechanic:runTo( 569.355469, mtheight, -506.637726) | 
|---|
| 91 | fleemechanic:runTo( 626.359924, mtheight, -384.633179) | 
|---|
| 92 | fleemechanic:runTo( 627.059998, mtheight, -383.511444) | 
|---|
| 93 | fleemechanic:runTo( 627.764282, mtheight, -382.382935) | 
|---|
| 94 | fleemechanic:runTo( 628.469055, mtheight, -381.253601) | 
|---|
| 95 | fleemechanic:runTo( 629.178345, mtheight, -380.117065) | 
|---|
| 96 | fleemechanic:runTo( 629.888367, mtheight, -378.979340) | 
|---|
| 97 | fleemechanic:runTo( 630.599548, mtheight, -377.839752) | 
|---|
| 98 | fleemechanic:runTo( 631.316711, mtheight, -376.690643) | 
|---|
| 99 | fleemechanic:runTo( 704.250305, mtheight, -250.679443) | 
|---|
| 100 | fleemechanic:runTo( 704.842896, mtheight, -249.538712) | 
|---|
| 101 | fleemechanic:runTo( 705.438721, mtheight, -248.391754) | 
|---|
| 102 | fleemechanic:runTo( 706.033630, mtheight, -247.246506) | 
|---|
| 103 | fleemechanic:runTo( 706.628479, mtheight, -246.101395) | 
|---|
| 104 | fleemechanic:runTo( 707.229248, mtheight, -244.944870) | 
|---|
| 105 | fleemechanic:runTo( 707.831665, mtheight, -243.785248) | 
|---|
| 106 | fleeprogrammed = true | 
|---|
| 107 |  | 
|---|
| 108 | end | 
|---|
| 109 | end | 
|---|
| 110 |  | 
|---|
| 111 |  | 
|---|
| 112 | function tick(timestep) | 
|---|
| 113 |  flee(timestep) | 
|---|
| 114 | RandTime() | 
|---|
| 115 | if randTime > 0 then | 
|---|
| 116 | randTime = randTime - timestep | 
|---|
| 117 | else | 
|---|
| 118 | fallDown(timestep) | 
|---|
| 119 | end | 
|---|
| 120 |  | 
|---|
| 121 | return eventFinished | 
|---|
| 122 |  | 
|---|
| 123 | end | 
|---|