Guest User

map_entity_check

a guest
May 19th, 2012
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stray_entity_fix()
  2.  
  3. //Preliminary check to see if the user placed the correct entities or the correct combination of entities.
  4. var capsExist, cap1Exists, cap2Exists, cap3Exists, cap4Exists, cap5Exists, blueIntelExists, redIntelExists, sufficientCapMats, arenaCPExists, genBlueExists, genRedExists, kothCPExists, dkothCPRedExists, dkothCPBlueExists;
  5. blueIntelExists = false
  6. redIntelExists = false
  7. sufficientCapMats = false
  8. cap1Exists = false
  9. cap2Exists = false
  10. cap3Exists = false
  11. cap4Exists = false
  12. cap5Exists = false
  13. capsExists = false
  14. arenaCPExists = false
  15. genRedExists = false
  16. genBlueExists = false
  17. kothCPExists = false
  18. dkothCPRedExists = false
  19. dkothCPBlueExists = false
  20. with (LevelEntity){
  21.     //CTF
  22.     if (type == "intelRed"){
  23.         redIntelExists = true
  24.     }else if (type == "intelBlue"){
  25.         blueIntelExists = true
  26.     //Arena
  27.     }else if (type == "arenaCP"){
  28.         if instance_number(arenaCP)>1{
  29.             show_message("Only one Arena Control Point is possible.")
  30.             exit;
  31.         }
  32.         arenaCPExists = true
  33.     //KoTH
  34.     }else if (type == "kothCP"){
  35.         if instance_number(kothCP)>1{
  36.             show_message("Only one KoTH Control Point is possible.")
  37.             exit;
  38.         }
  39.         KothCPExists = true
  40.     //DKoTH
  41.     }else if (type == "dkothCPRed"){
  42.         if instance_number(dkothCPRed)>1{
  43.             show_message("Only one DKoTH Control Point for each team is possible.")
  44.             exit;
  45.         }
  46.         DKothCPRedExists = true
  47.     }else if (type == "dkothCPBlue"){
  48.         if instance_number(dkothCPBlue)>1{
  49.             show_message("Only one DKoTH Control Point for each team is possible.")
  50.             exit;
  51.         }
  52.         DKothCPBlueExists = true
  53.     //Generator
  54.     }else if (type == "generatorRed"){
  55.         GenRedExists = true
  56.         if instance_number(generatorRed)>1{
  57.             show_message("Only one Generator per team.")
  58.             exit;
  59.         }
  60.     }else if (type == "generatorBlue"){
  61.         GenBlueExists = true
  62.         if instance_number(generatorBlue)>1{
  63.             show_message("Only one Generator per team.")
  64.             exit;
  65.         }
  66.     //CP
  67.     }else if (type == "captureZone"){
  68.         sufficientCapMats = true
  69.     }else if (global.gamemode == 2) {
  70.         if (type == "controlPoint1"){
  71.             if (cap1Exists == true){
  72.                 show_message("Please do not place more than one instance of a unique control point.")
  73.                 exit;
  74.             }else{
  75.                 cap1Exists = true
  76.             }
  77.         }else if (type == "controlPoint2"){
  78.             if (cap2Exists == true){
  79.                 show_message("Please do not place more than one instance of a unique control point.")
  80.                 exit;
  81.             }else{
  82.                 cap2Exists = true
  83.             }
  84.         }else if (type == "controlPoint3"){
  85.             if (cap3Exists == true){
  86.                 show_message("Please do not place more than one instance of a unique control point.")
  87.                 exit;
  88.             }else{
  89.                 cap3Exists = true
  90.             }
  91.         }else if (type == "controlPoint4"){
  92.             if (cap4Exists == true){
  93.                 show_message("Please do not place more than one instance of a unique control point.")
  94.                 exit;
  95.             }else{
  96.                 cap4Exists = true
  97.             }
  98.         }else if (type == "controlPoint5"){
  99.             if (cap5Exists == true){
  100.                 show_message("Please do not place more than one instance of a unique control point.")
  101.                 exit
  102.             }else{
  103.                 cap5Exists = true
  104.             }
  105.         }
  106.     }
  107. }
  108.  
  109. if (cap1Exists == true or cap2Exists == true or cap3Exists == true or cap4Exists == true or cap5Exists == true){
  110.     capsExist = true
  111. }
  112. //Checking the entities based on the game-mode.
  113. if global.gamemode == 1{
  114.     if (((redIntelExists == true) and (blueIntelExists == false)) or ((redIntelExists == false) and (blueIntelExists == true)) or ((redIntelExists == false) and (blueIntelExists == false))){
  115.         show_message("If you are making a traditional CTF map, you must place both the Red intelligence and the Blue intelligence somewhere on the map.")
  116.         exit;
  117.     }
  118. }else if global.gamemode == 2{
  119.     if (capsExist == true and sufficientCapMats == false or capsExist == false and sufficientCapMats == true){
  120.         show_message("Please make sure you've placed all the Capture Points AND Capture Zones.")
  121.        exit;
  122.    }
  123. }else if global.gamemode == 3{
  124.    if (arenaCPExists == false or sufficientCapMats == false){
  125.        show_message("Please make sure you've placed the Arena Capture Point and the necessary capture zones.")
  126.         exit;
  127.     }
  128. }else if global.gamemode == 4{
  129.     if (genRedExists = false and genBlueExists = true) or (genRedExists = true and genBlueExists= false){
  130.         show_message("For generator maps you need both generators.")
  131.         exit;
  132.     }
  133. }else if global.gamemode == 5{
  134.     if (kothCPExists == false or sufficientCapMats == false){
  135.         show_message("Please make sure you've placed the KoTH Capture Point and the necessary Capture Zones.")
  136.        exit;
  137.    }
  138. }else if global.gamemode == 6{
  139.    if (dkothCPRedExists == false and dkothCPBlueExists == true) or (dkothCPRedExists == true and dkothCPBlueExists == false){
  140.        show_message("Please make sure you've placed the DKoTH Capture Point and the necessary Capture Zones.")
  141.         exit;
  142.     }
  143. }
RAW Paste Data