HunterGreen

CrystalShip command module code

Dec 29th, 2021
1,407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. On Command:
  2.  CS R[ESET]            - Reset all queues and variables for the command chair
  3.  CS SH[OCKWAVE]        - Call for a shockwave
  4.  CS V[ORTEX]           - Call for a vortex
  5.  CS PATH <d> <d> <d>   - Specify a path for autopilot hunting
  6.  CS AUTO ON/OFF        - Turn autopilot hunting on (from vortex) or off
  7.  CS T[ARGET] <tar>     - Manually call a target
  8.  CS C[LARITY]          - Manually call non-emergency clarity
  9.  CS D[UST]             - Scoop up glaetherial dust
  10.  CS AN[CHOR]           - Call for the ship to drop anchor
  11.  CS F[ORCEFIELD]       - Turn on the ship's forcefield
  12. CS Q[UIET]            - Start the ship silent running
  13. CS N[OISY]            - Stop the ship silent running
  14. CS X[VERSE]           - Transverse through a planar gate
  15. CS SP[IRAL]           - Put the ship into a spiral
  16. CS HELP KEYS          - Show help for piloting numpad
  17.  
  18. Numpad Controls:
  19. +----------+----------+----------+----------+
  20. | Num      | /        | *        | -        |
  21. | Lock     | Launch   | Dock     | Siphon   |
  22. +----------+----------+----------+----------+
  23. | 7        | 8        | 9        | +        |
  24. | NW       | N ▲      | NE       | Emerg.   |
  25. +----------+----------+----------+ Clarity  | 5 stops glide
  26. | 4        | 5        | 6        |          |   and also looks
  27. | W ◄      | Stop/Look| E ►      |          |
  28. +----------+----------+----------+----------+
  29. | 1        | 2        | 3        | Enter    |
  30. | SW       | S ▼      | SE       |          |
  31. +----------+----------+----------+          |
  32. | 0                   | .        |          | . toggles between
  33. |                     | Glide    |          |   moves and glides
  34. +---------------------+----------+----------+
  35.  
  36. ALIAS: cs r
  37.     set_variable("lCSAutoPath","");
  38.     set_variable("pCSAutoHunt","off");
  39.     set_variable("iCSAutoPosition","1");
  40.     set_variable("pCSGlide","off");
  41.     set_variable("pCSResiphon","0");
  42.     set_variable("iCSShockwavesEndingSoon","0");
  43.     set_variable("pCSShocked","0");
  44.     display_notice("[CrystalShip] All command chair functions reset.","yellow");
  45.  
  46. GROUP: Numpad
  47.     KEYBIND: 111:"pilot launch"
  48.     KEYBIND: 106:"pilot dock"
  49.     KEYBIND: 109:"shipt Siphon"
  50.     KEYBIND: 107:"shipt Emergency clarity"
  51.     KEYBIND: 103: run_function("cs_pilot_direction","nw","CrystalShip");
  52.     KEYBIND: 104: run_function("cs_pilot_direction","n","CrystalShip");
  53.     KEYBIND: 105: run_function("cs_pilot_direction","ne","CrystalShip");
  54.     KEYBIND: 100: run_function("cs_pilot_direction","w","CrystalShip");
  55.     KEYBIND: 101:
  56.         if (get_variable("pCSGlide") == "on") send_command("pilot glide stop");
  57.         send_command("ship look");
  58.     KEYBIND: 102: run_function("cs_pilot_direction","e","CrystalShip");
  59.     KEYBIND: 97: run_function("cs_pilot_direction","sw","CrystalShip");
  60.     KEYBIND: 98: run_function("cs_pilot_direction","s","CrystalShip");
  61.     KEYBIND: 99: run_function("cs_pilot_direction","se","CrystalShip");
  62.     KEYBIND: 110:
  63.         var pCSGlide = get_variable("pCSGlide");
  64.         if (pCSGlide == "off") pCSGlide = "on"; else pCSGlide = "off";
  65.         set_variable("pCSGlide",pCSGlide);
  66.         display_notice("[CrystalShip] Gliding is now " + pCSGlide + ".","yellow");
  67.     TRIGGER: You are unable to leave as you are still locked into the command chair.
  68.         gag line
  69.     TRIGGER: There is no exit in that direction.
  70.         gag line
  71.  
  72.  
  73. FUNCTION: cs_pilot_direction
  74.     var pCSGlide = get_variable("pCSGlide");
  75.     if (pCSGlide == "on") pCSGlide = "glide"; else pCSGlide = "steer";
  76.     send_command("pilot " + pCSGlide + " " + args);
  77.  
  78.     var pCSHuntAutopilot = get_variable("pCSHuntAutopilot");
  79.     if (pCSHuntAutopilot == "on") {
  80.         set_variable("pCSHuntAutopilot","off");
  81.         display_notice("[CrystalShip] Autopilot hunting disabled. Return to vortex and CS AUTO ON to resume","yellow");
  82.  
  83. ALIAS: cs v
  84.     shipt Vortex
  85.  
  86. ALIAS: cs sh
  87.     shipt Shockwave
  88.  
  89. TRIGGER: A nearby turret blankets aetherspace with bolts of crackling energy, which ripple around this space in waves of coruscating power.
  90.     if (get_variable("pCSAutoHunt") != "on") return;
  91.     var seconds = new Date().getTime() / 1000;
  92.     seconds += (57*60);
  93.     set_variable("iCSShockwavesEndingSoon",seconds);
  94.  
  95. ALIAS: cs path <d1> <d2> <d3>
  96.     p0 = <d1>
  97.     p1 = <d2>
  98.     p2 = <d3>
  99.     var lCSAutoDirections = get_variable("p0") + "|" + get_variable("p1") + "|" + get_variable("p2");
  100.     set_variable("lCSAutoDirections",lCSAutoDirections);
  101.     display_notice("[CrystalShip] Directions set for autopilot hunting. Go to the vortex and CS AUTO ON to begin.","yellow");
  102.  
  103. ALIAS: cs auto on
  104.     // verify a path is set
  105.     var lCSAutoDirections = get_variable("lCSAutoDirections");
  106.     if (lCSAutoDirections == "" || lCSAutoDirections.split("|").length < 3) {
  107.         display_notice("[CrystalShip] You must set a path with CS PATH <d> <d> <d> first.","red");
  108.         return;
  109.     }
  110.  
  111.     set_variable("pCSAutoHunt","on");
  112.     set_variable("iCSAutoPosition","1");
  113.     set_variable("lCSAutoCreatures","");
  114.     set_variable("pCSGlide","off");
  115.     display_notice("[CrystalShip] Autopilot hunting on. Use numpad to move and interrupt it.","yellow");
  116.  
  117.     // kick the process off
  118.     send_command("shipt Siphon");
  119.  
  120. ALIAS: cs auto off
  121.     if (get_variable("pCSAutoHunt") != "on") {
  122.         display_notice("[CrystalShip] Autopilot hunting is already off.","red");
  123.         return;
  124.     }
  125.  
  126.     set_variable("pCSHuntAutopilot","off");
  127.     display_notice("[CrystalShip] Autopilot hunting off. Return to vortex and CS AUTO ON to resume.","yellow");
  128.     set_variable("iCSAutoPosition","1");
  129.     set_variable("pCSResiphon","0");
  130.  
  131. TRIGGER: (Ship): You say, "Siphon."
  132.     if (get_variable("pCSAutoHunt") != "on") return;
  133.     set_variable("pCSResiphon","1");
  134.     setTimeout(function() {
  135.         if (get_variable("pCSResiphon") == "1")
  136.             send_command("shipt Siphon");
  137.     }, 2000);
  138.  
  139. FUNCTION: cs_creature_long_to_short
  140.     var sCreature = "";
  141.     if (args = "a tendril of kethuru") sCreature = "tendril";
  142.     else {
  143.         var words = args.split(" ");
  144.         sCreature = words[words.length-1];
  145.     }
  146.     set_variable("p0",sCreature);
  147.  
  148. TRIGGER: ^Drawn by the flux of energy\\, ([A-Za-z\\,\\'\\- ]+) suddenly wanders into the nearby area\\.$
  149.     if (get_variable("pCSAutoHunt") != "on") return;
  150.     var sCreature = "";
  151.     var sDesc = args[1].toLowerCase();
  152.  
  153.     run_function("cs_creature_long_to_short",sDesc,"CrystalShip");
  154.     sCreature = get_variable("p0");
  155.     if (sCreature == "") {
  156.         display_notice("[CrystalShip] Warning, creature not recognized: " + sDesc,"red");
  157.         return;
  158.     }
  159.     run_function("cs_pilot_creature_arrived",sCreature,"CrystalShip");
  160.  
  161. TRIGGER: The energy vortex flashes and a vortex karibidean flies out of it.
  162.     if (get_variable("pCSAutoHunt") != "on") return;
  163.     run_function("cs_pilot_creature_arrived","karibidean","CrystalShip");
  164.  
  165. FUNCTION: cs_pilot_creature_arrived
  166.     var sCreature = args;
  167.  
  168.     if (get_variable("pCSAutoHunt") != "on") {
  169.         if (sCreature == "karibidean") {
  170.             send_command("shipt Target karibidean");
  171.             send_command("cs internal alarm","0");
  172.         }
  173.         return;
  174.     }
  175.  
  176.     // prevent resiphon
  177.     set_variable("pCSResiphon","0");
  178.  
  179.     // handle if there's already creatures in the queue
  180.     var lCSAutoCreatures = get_variable("lCSAutoCreatures");
  181.     if (lCSAutoCreatures != "") {
  182.         lCSAutoCreatures += "|" + sCreature;
  183.         set_variable("lCSAutoCreatures",lCSAutoCreatures);
  184.         display_notice("[CrystalShip] Alert! " + String(lCSAutoCreatures.split("|").length) + " creatures in play!","red");
  185.         send_command("cs internal alarm","0");
  186.         // if karibidean call it anyway
  187.         if (sCreature == "karibidean") send_command("shipt Target karibidean");
  188.         return;
  189.     }
  190.  
  191.     // create a queue
  192.     set_variable("lCSAutoCreatures",sCreature);
  193.  
  194.     // call target
  195.     if (sCreature == "karibidean") send_command("cs internal alarm","0");
  196.     send_command("shipt Target " + sCreature);
  197.  
  198.     // move to position 2 (to get stuck on a shockwave)
  199.     run_function("cs_pilot_move_to","2","CrystalShip");
  200.  
  201.     // warn the pilot if someone isn't firing within five seconds
  202.     set_variable("lCSTurretsFiring","");
  203.     setTimeout(function() {
  204.         var lCSTurretsFiring = get_variable("lCSTurretsFiring");
  205.         if (lCSTurretsFiring == "") {
  206.             display_notice("[CrystalShip] Warning: no one is firing!","red");
  207.             send_command("cs internal alarm",0);
  208.         } else if (lCSTurretsFiring.split("|").length < 3) {
  209.             display_notice("[CrystalShip] Warning: only these people are firing: " + lCSTurretsFiring.join(", "),"red");
  210.             send_command("cs internal alarm",0);
  211.         }
  212.     }, 5000);
  213.  
  214. TRIGGER: The floor shakes as <person> fires
  215.     p0 = <person>
  216.     if (get_variable("pCSAutoHunt") != "on") return;
  217.     var sPerson = get_variable("p0");
  218.  
  219.     var lCSTurretsFiring = get_variable("lCSTurretsFiring");
  220.     if (lCSTurretsFiring == "") {
  221.         set_variable("lCSTurretsFiring",sPerson);
  222.         return;
  223.     }
  224.     lCSTurretsFiring = lCSTurretsFiring.split("|");
  225.     if (lCSTurretsFiring.indexOf(sPerson) != -1) return;
  226.     lCSTurretsFiring.push(sPerson);
  227.     set_variable("lCSTurretsFiring",lCSTurretsFiring.join("|"));
  228.  
  229. TRIGGER: ^([A-Za-z\\,\\'\\- ]+) suddenly explodes\\.$
  230.     if (get_variable("pCSAutoHunt") != "on") return;
  231.  
  232.     var sCreature = "";
  233.     var sDesc = args[1].toLowerCase();
  234.  
  235.     run_function("cs_creature_long_to_short",sDesc,"CrystalShip");
  236.     sCreature = get_variable("p0");
  237.     if (sCreature == "") return;
  238.  
  239.     // remove from the queue
  240.     var lCSAutoCreatures = get_variable("lCSAutoCreatures").split("|");
  241.     var i = lCSAutoCreatures.indexof(sCreature);
  242.     if (i != -1) {
  243.         lCSAutoCreatures.splice(i,1);
  244.         set_variable("lCSAutoCreatures",lCSAutoCreatures.join("|"));
  245.     }
  246.  
  247.     // if anything else is in queue, call the first one
  248.     if (lCSAutoCreatures.length > 0) {
  249.         send_command("shipt Target " + lCSAutoCreatures[0]);
  250.         return;
  251.     }
  252.  
  253.     // if we're over the vortex, call for another siphon, unless shockwaves due to expire
  254.     if (get_variable("iCSAutoPosition") == "1") {
  255.         // are shockwaves expiring soon?
  256.         var seconds = new Date().getTime() / 1000;
  257.         var waves = Number(get_variable("iCSShockwavesEndingSoon"));
  258.         if (waves != 0 && waves >= seconds) {
  259.             send_command("shipt Shockwaves are expiring soon.");
  260.             set_variable("iCSShockwavesEndingSoon","0");
  261.         } else {
  262.             send_command("shipt Siphon");
  263.         }
  264.         return;
  265.     }
  266.  
  267.     // move back to the vortex; on arrival, we'll call for siphon again
  268.     run_function("cs_pilot_move_to", "1", "CrystalShip");
  269.  
  270. FUNCTION: cs_pilot_move_to
  271.     var iCurPosition = get_variable("iCSAutoPosition");
  272.     var iNewPosition = args;
  273.     var lCSAutoPath = get_variable("lCSAutoPath");
  274.  
  275.     if (lCSAutoPath == "") return;
  276.     lCSAutoPath = lCSAutoPath.split("|");
  277.  
  278.     var iDirIndex = 0;
  279.     var pReverse = 0;
  280.  
  281.     if (iCurPosition == iNewPosition) return;
  282.  
  283.     if (iNewPosition == iCurPosition + 1  || (iNewPosition == 1 && iCurPosition == 3)) {
  284.         iDirIndex = iCurPosition;
  285.         pReverse = 0;
  286.     } else {
  287.         iDirIndex = iNewPosition;
  288.         pReverse = 1;
  289.     }
  290.  
  291.     var sDirection = lCSAutoPath[iDirIndex-1];
  292.     if (pReverse == 1) {
  293.         if (sDirection == "e") sDirection = "w";
  294.         else if (sDirection == "w") sDirection = "e";
  295.         else if (sDirection == "n") sDirection = "s";
  296.         else if (sDirection == "s") sDirection = "n";
  297.         else if (sDirection == "ne") sDirection = "sw";
  298.         else if (sDirection == "nw") sDirection = "se";
  299.         else if (sDirection == "se") sDirection = "nw";
  300.         else if (sDirection == "sw") sDirection = "ne";
  301.     }
  302.     sDirection = "pilot steer" + sDirection;
  303.  
  304.     if (get_variable("pCSShocked") == "1") set_variable("sCSAfterShockCommand",sDirection);
  305.     else send_command(sDirection);
  306.     set_variable("iCSNextPosition",iNewPosition);
  307.  
  308. TRIGGER: The command chair is unresponsive to your requests.
  309.     set_variable("pCSShocked","1");
  310.  
  311. TRIGGER: ^You are thrust forward as .+ shudders violently and comes to a complete stop\\.$
  312.     set_variable("pCSShocked","1");
  313.  
  314. TRIGGER: I am clearing the command chair of all impairments."
  315.     run_function("cs_pilot_unshocked","","CrystalShip");
  316.  
  317. TRIGGER: ^With a ripple, .* frees itself from its shockwave.$
  318.     run_function("cs_pilot_unshocked","","CrystalShip");
  319.  
  320. FUNCTION: cs_pilot_unshocked
  321.     set_variable("pCSShocked","0");
  322.     if (get_variable("pCSAutoHunt") != "on") return;
  323.     var sCmd = get_variable("sCSAfterShockCommand");
  324.     if (sCmd != "") {
  325.         send_command(sCmd);
  326.         set_variable("sCSAfterShockCommand","");
  327.     }
  328.  
  329. TRIGGER: ^You steer .+ to the \\w+\\.$
  330.     if (get_variable("pCSAutoHunt") != "on") return;
  331.  
  332.     var iNewPosition = get_variable("iCSNextPosition");
  333.     if (iNewPosition != "") {
  334.         set_variable("iCSAutoPosition",iNewPosition);
  335.         set_variable("iCSNextPosition","");
  336.     }
  337.  
  338.     // after completing a move, we should either move again or siphon
  339.     var iPosition = get_variable("iCSAutoPosition");
  340.     if (get_variable("lCSAutoCreatures") == "") {
  341.         // go to vortex, or if there, siphon
  342.         if (iPosition == 1) send_command("shipt Siphon");
  343.         else run_function("cs_pilot_move_to", "1", "CrystalShip");
  344.     } else {
  345.         // move between 2 and 3, or if at 1 go to 2 (should never happen)
  346.         if (iPosition == 1) iPosition = 2; else iPosition = 5 - iPosition;
  347.         run_function("cs_pilot_move_to", iPosition, "CrystalShip");
  348.     }
  349.  
  350. ALIAS: cs c
  351.     shipt Clarity
  352.  
  353. ALIAS cs t<stuff> <target>
  354.     shipt Target @target
  355.  
  356. ALIAS: cs t <target>
  357.     shipt Target @target
  358.  
  359. ALIAS: cs d
  360.     pilot scoop
  361.  
  362. ALIAS: cs an
  363.     pilot anchor
  364.  
  365. ALIAS: cs x
  366.     pilot transverse
  367.  
  368. ALIAS: cs f
  369.     pilot forcefield
  370.  
  371. ALIAS: cs q
  372.     pilot silentrun start
  373.  
  374. ALIAS: cs n
  375.     pilot silentrun stop
  376.  
  377. ALIAS: cs sp
  378.     pilot spiral start
  379.  
  380. ALIAS: cs internal alarm
  381.     sound:alarm beep
  382.  
  383. TRIGGER: Exhaustion clouds your mind and you fail to properly link to the command chair
  384.     highlight
  385.     run_function("announce_tiredness", "chair", "CrystalShip");
  386.  
  387. FUNCTION: cs_command_chair_done
  388.     if (get_variable("sNumpadGroup") == undefined) {
  389.         var r = reflex_find_by_name("group", "NumpadDefaults", false, false, "CrystalShip");
  390.         if (r != null) reflex_enable(r);
  391.     } else {
  392.         var sCurGroup = get_variable("sCSPrevNumpadGroup");
  393.         var r = reflex_find_by_name("group", sCurGroup, false, false, "Numpad movement");
  394.         if (r != null) reflex_enable(r);
  395.         set_variable("sCSPrevNumpadGroup","");
  396.     }
  397.  
  398.  
Advertisement
Add Comment
Please, Sign In to add comment