Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 29, 2006, 7:25:25 PM (18 years ago)
Author:
snellen
Message:

continued implementation…

Location:
data/branches/single_player_map/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • data/branches/single_player_map/scripts/prisoner.lua

    r3946 r3954  
    66spaceShipReached = false
    77spaceShipEntered = false
     8playerInLock = false
    89
    910randTime = 0
    1011
    11 function setCellDoor(timestep)
     12function observeGuard()
     13guardX = guard:getAbsCoorX()
     14guardY = guard:getAbsCoorY()
     15guardZ = guard:getAbsCoorZ()
     16
     17if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 60 then
    1218cellDoorOpened = true
    13 return true
    14 end
    15 
    16 
     19end
     20
     21end
     22
     23function observePlayer()
     24playerX = Player:getAbsCoorX()
     25playerY = Player:getAbsCoorY()
     26playerZ = Player:getAbsCoorZ()
     27
     28if dist( playerX,playerY,playerZ,161.76,49,358.87 ) < 60 then
     29playerInLock = true
     30end
     31
     32walkProgrammed = false
     33exitProgrammed = false
    1734function walkInCell(timestep)
    1835
     36if not walkProgrammed then
     37--io.write("Guard called \n")
     38prisoner:walkTo(-132, 29, 238.381805)
     39prisoner:walkTo(-138.41, 29, 275.25)
     40prisoner:walkTo(-143.70, 29, 275.35)
     41prisoner:walkTo(-149.10, 29, 226.66)
     42prisoner:walkTo(-149.10, 29, 196.83)
     43prisoner:walkTo(-145.82, 29, 189.74)
     44prisoner:walkTo(-138.48, 29, 184.28)
     45prisoner:walkTo(35.48, 29, 191.28)
     46prisoner:runTo(102, 29, 203.28)
     47prisoner:runTo(164, 29, 245.28)
     48
     49walkProgrammed = true
     50end
     51
    1952if cellDoorOpened then
    2053
    21 if randTime == 0 then
    22 randTime = 30 * math.random()
    23 else
    24 randTime = randTime - timestep
    25 end
    26 
    27 if randTime < 0 then
    28 -- goto cellexit
    29 -- if exit reached: return true
    30 end
    31 
    32 end
    33 
    34 
    35 return false
    36 
    37 end
    38 
    39 
    40 
     54 if randTime == 0 then
     55 randTime = 30 * math.random()
     56 else
     57 randTime = randTime - timestep
     58 end
     59
     60 if randTime < 0 then
     61 -- goto cellexit
     62  if not exitProgrammed then
     63   prisoner:walkTo(-132, 29, 238.381805)
     64   prisoner:walkTo(-138.41, 29, 275.25)
     65   prisoner:walkTo(-143.70, 29, 275.35)
     66   prisoner:walkTo(-149.10, 29, 226.66)
     67   prisoner:walkTo(-149.10, 29, 196.83)
     68   prisoner:walkTo(-145.82, 29, 189.74)
     69   prisoner:walkTo(-138.48, 29, 184.28)
     70   prisoner:walkTo(35.48, 29, 191.28)
     71   prisoner:runTo(102, 29, 203.28)
     72   prisoner:runTo(164, 29, 245.28)
     73
     74   exitProgrammed = true
     75  end
     76
     77  if guard:finalGoalReached() then
     78   return true
     79  end
     80
     81 end
     82
     83return false
     84end
     85
     86
     87return false
     88
     89end
     90
     91
     92gotoExitProgrammed = false
    4193function goToExit(timestep)
    4294-- do not forget to make him wait until the player triggeres the trip to the hangar
    43 
    44 return false
    45 end
    46 
    47 
     95if not gotoExitProgrammed and playerInLock then
     96prisoner:walkTo(-132, 29, 238.381805)
     97prisoner:walkTo(-138.41, 29, 275.25)
     98prisoner:walkTo(-143.70, 29, 275.35)
     99prisoner:walkTo(-149.10, 29, 226.66)
     100prisoner:walkTo(-149.10, 29, 196.83)
     101prisoner:walkTo(-145.82, 29, 189.74)
     102prisoner:walkTo(-138.48, 29, 184.28)
     103prisoner:walkTo(35.48, 29, 191.28)
     104prisoner:runTo(102, 29, 203.28)
     105prisoner:runTo(164, 29, 245.28)
     106
     107gotoExitProgrammed = true
     108end
     109
     110if prisoner:finalGoalReached() then
     111   return true
     112end
     113
     114return false
     115end
     116
     117hangarRouteProgrammed = false
    48118function goToHangar(timestep)
    49119
    50 
    51 return false
    52 
    53 end
    54 
    55 
     120if not hangarRouteProgrammed then
     121prisoner:walkTo(-132, 29, 238.381805)
     122prisoner:walkTo(-138.41, 29, 275.25)
     123prisoner:walkTo(-143.70, 29, 275.35)
     124prisoner:walkTo(-149.10, 29, 226.66)
     125prisoner:walkTo(-149.10, 29, 196.83)
     126prisoner:walkTo(-145.82, 29, 189.74)
     127prisoner:walkTo(-138.48, 29, 184.28)
     128prisoner:walkTo(35.48, 29, 191.28)
     129prisoner:runTo(102, 29, 203.28)
     130prisoner:runTo(164, 29, 245.28)
     131
     132hangarRouteProgrammed = true
     133end
     134
     135if prisoner:finalGoalReached() then
     136   return true
     137end
     138
     139return false
     140
     141end
     142
     143spaceshipRouteProgrammed = false
    56144function goToSpaceship(timestep)
    57145
     146if not spaceshipRouteProgrammed then
     147prisoner:walkTo(-132, 29, 238.381805)
     148prisoner:walkTo(-138.41, 29, 275.25)
     149prisoner:walkTo(-143.70, 29, 275.35)
     150prisoner:walkTo(-149.10, 29, 226.66)
     151prisoner:walkTo(-149.10, 29, 196.83)
     152prisoner:walkTo(-145.82, 29, 189.74)
     153prisoner:walkTo(-138.48, 29, 184.28)
     154prisoner:walkTo(35.48, 29, 191.28)
     155prisoner:runTo(102, 29, 203.28)
     156prisoner:runTo(164, 29, 245.28)
     157
     158spaceshipRouteProgrammed = true
     159end
     160
     161if prisoner:finalGoalReached() then
     162   return true
     163end
     164
    58165return false
    59166
     
    71178
    72179--io.write("Prisoner called \n")
     180
     181 observeGuard()
     182 observePlayer()
     183
    73184
    74185if not cellDoorOpend then
  • data/branches/single_player_map/scripts/secondguard.lua

    r3951 r3954  
    99-- Returns the distance between (x1,x2,x3) and (y1,y2,y3)
    1010function dist( x1,x2,x3, y1,y2,y3 )
    11 
    1211return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 )
    13 
    1412end
    1513
     
    2018guardZ = guard:getAbsCoorZ()
    2119
    22 if dist( guardX,guardY,guardZ,161.76,49,358.87 ) < 60 then
     20if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 60 then
    2321allOk = false
    2422end
     
    3836end
    3937
     38cellProgrammed = false
     39function goToCell(timestep)
    4040
    41 function goToCell(timestep)
     41if not cellProgrammed then
     42--io.write("Guard called \n")
     43secondguard:walkTo(-132, 29, 238.381805)
     44secondguard:walkTo(-138.41, 29, 275.25)
     45secondguard:walkTo(-143.70, 29, 275.35)
     46secondguard:walkTo(-149.10, 29, 226.66)
     47secondguard:walkTo(-149.10, 29, 196.83)
     48secondguard:walkTo(-145.82, 29, 189.74)
     49secondguard:walkTo(-138.48, 29, 184.28)
     50secondguard:walkTo(35.48, 29, 191.28)
     51secondguard:runTo(102, 29, 203.28)
     52secondguard:runTo(164, 29, 245.28)
     53
     54cellProgrammed = true
     55end
     56
     57if secondguard:finalGoalReached() then
     58return true
     59end
    4260
    4361return false
    4462end
    4563
     64guideProgrammed = false
    4665function goToGuidePosition(timestep)
     66
     67if not guideProgrammed then
     68--io.write("Guard called \n")
     69secondguard:walkTo(-132, 29, 238.381805)
     70secondguard:walkTo(-138.41, 29, 275.25)
     71secondguard:walkTo(-143.70, 29, 275.35)
     72secondguard:walkTo(-149.10, 29, 226.66)
     73secondguard:walkTo(-149.10, 29, 196.83)
     74secondguard:walkTo(-145.82, 29, 189.74)
     75secondguard:walkTo(-138.48, 29, 184.28)
     76secondguard:walkTo(35.48, 29, 191.28)
     77secondguard:runTo(102, 29, 203.28)
     78secondguard:runTo(164, 29, 245.28)
     79
     80guideProgrammed = true
     81end
     82
     83if secondguard:finalGoalReached() then
     84return true
     85end
    4786
    4887return false
    4988end
    5089
     90hangarProgrammed = false
    5191function goToHangar(timestep)
    5292
     93if not hangarProgrammed then
     94--io.write("Guard called \n")
     95secondguard:walkTo(-132, 29, 238.381805)
     96secondguard:walkTo(-138.41, 29, 275.25)
     97secondguard:walkTo(-143.70, 29, 275.35)
     98secondguard:walkTo(-149.10, 29, 226.66)
     99secondguard:walkTo(-149.10, 29, 196.83)
     100secondguard:walkTo(-145.82, 29, 189.74)
     101secondguard:walkTo(-138.48, 29, 184.28)
     102secondguard:walkTo(35.48, 29, 191.28)
     103secondguard:runTo(102, 29, 203.28)
     104secondguard:runTo(164, 29, 245.28)
     105
     106hangarProgrammed = true
     107end
     108
     109if secondguard:finalGoalReached() then
     110return true
     111end
     112
    53113return false
     114
    54115end
    55116
Note: See TracChangeset for help on using the changeset viewer.