home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 93 / CDMM_93_2.ISO / Project Nomads / nomads_demo_eng.exe / DEATHMATCH.TCL < prev    next >
Encoding:
Text File  |  2002-07-29  |  2.5 KB  |  101 lines

  1. #
  2. # deatchmatch.tcl
  3. #
  4. # Server side event handling in multiplayer deathmatch session.
  5. #
  6.  
  7.  
  8. # Lighthouse was destroyed
  9. on lighthouse_destroyed {
  10.  
  11.     puts "*** Lighthouse was destoyed"
  12.  
  13.     # Find destroyed lighthouse
  14.     # Iterate through clans
  15.     for {set i [/world/clans.gethead]} \
  16.         {$i != "null"} \
  17.         {set i [$i.getsucc]} {
  18.  
  19.         # Iterate through objects in clan
  20.         for {set j [$i.gethead]} \
  21.             {$j != "null"} \
  22.             {set j [$j.getsucc]} {
  23.  
  24.             # Look for lighthouse
  25.             if {[$j.isvehicleclass "concret.technical.static.building.towncenter"] == "true"} {
  26.             
  27.                 if {([$j.getstate] == "explode") || 
  28.                     ([$j.getartefactmode] == "true")} {
  29.                 
  30.                     # kill Maennel
  31.                     set userclan [$j.getclan]
  32.                     set maennel [$userclan.getmaennel]
  33.                     if {$maennel != "null"} {
  34.                         $maennel.reduceenergy 100000
  35.                     }
  36.                     
  37.                     # Handle `explode' state
  38.                     set ID [$j.getmachineid]
  39.  
  40.                     /world/session/$ID.setloosed "true"
  41.  
  42.                     puts "*** Player `$ID' was killed. "
  43.                 }
  44.             }
  45.         }
  46.     }
  47. }
  48.  
  49.  
  50. # Character was killed.
  51. on character_destroyed {
  52.  
  53.     puts "*** Character was killed"
  54.  
  55.     # Find killed character;
  56.     # Iterate through clans
  57.     for {set i [/world/clans.gethead]} \
  58.         {$i != "null"} \
  59.         {set i [$i.getsucc]} {
  60.  
  61.         # Iterate through objects in clan
  62.         for {set j [$i.gethead]} \
  63.             {$j != "null"} \
  64.             {set j [$j.getsucc]} {
  65.  
  66.             # Look for character
  67.             if {[$j.isvehicleclass "concret.technical.dynamic.maennel"] == "true"} {
  68.             
  69.                 if {[$j.getstate] == "gameend"} {
  70.                
  71.                     # Mark user as dead.
  72.                     set ID [$j.getmachineid]
  73.  
  74. #                    /world/session/$ID.setloosed "true"
  75.  
  76.                     puts "*** Player `$ID' was killed. "
  77.                 }
  78.             }
  79.         }
  80.     }
  81. }
  82.  
  83.  
  84. # Game over! Find player who won!
  85. on game_over {
  86.     
  87.     puts "*** Game Over"
  88.     
  89.     # Find Client who won game
  90.     for {set i [/world/session.gethead]} \
  91.         {$i != "null"} \
  92.         {set i [$i.getsucc]} {
  93.     
  94.         if {[$i.hasloosed] == "false"} {
  95.             $i.setwon "true"
  96.             
  97.             puts "*** Player `$i' has won. "
  98.         }
  99.     }
  100. }
  101.