Skip to content

Instantly share code, notes, and snippets.

@Windows10CE
Created July 17, 2019 14:44
Show Gist options
  • Save Windows10CE/800da10b1d792ebb99a8a534ee001fe2 to your computer and use it in GitHub Desktop.
Save Windows10CE/800da10b1d792ebb99a8a534ee001fe2 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Text;
namespace HacknetCalc
{
class Program
{
static void Main(string[] args)
{
if (!Directory.Exists("Hackerscripts"))
Directory.CreateDirectory("Hackerscripts");
if (!Directory.Exists("Missions"))
Directory.CreateDirectory("Missions");
if (!Directory.Exists("Actions"))
Directory.CreateDirectory("Actions");
for (int x = 0; x <= 9801; x++)
if (!File.Exists($"Hackerscripts/{x}.txt"))
File.WriteAllLines($"Hackerscripts/{x}.txt", new string[] { "config playerComp playerComp 0.2 $#%#$", $"writel {x} $#%#$", "disconnect $#%#$" });
for (int d = 1; d <= 5; d++)
{
string startSubject = d != 3 ? $"Digit {d}" : "Operator";
string startBody = d == 3 ? "Select either + or *" : "Select a digit 0-9";
File.WriteAllLines($"Missions/{d}start.xml", new string[] {
$"<mission id=\"{d}start\" activeCheck=\"true\" shouldIgnoreSenderVerification=\"true\">",
"<goals>",
"<goal type=\"getstring\" target=\"reset\"/>",
"</goals>",
"<nextMission IsSilent=\"false\">NONE</nextMission>",
"<branchMissions>",
$"<branch>Missions/{d}_0.xml</branch>",
$"<branch>Missions/{d}_1.xml</branch>",
$"<branch>Missions/{d}_2.xml</branch>",
$"<branch>Missions/{d}_3.xml</branch>",
$"<branch>Missions/{d}_4.xml</branch>",
$"<branch>Missions/{d}_5.xml</branch>",
$"<branch>Missions/{d}_6.xml</branch>",
$"<branch>Missions/{d}_7.xml</branch>",
$"<branch>Missions/{d}_8.xml</branch>",
$"<branch>Missions/{d}_9.xml</branch>",
"</branchMissions>",
"<email>",
"<sender>Calc</sender>",
$"<subject>{startSubject}</subject>",
$"<body>{startBody}</body>",
"<attachments>",
"</attachments>",
"</email>",
"</mission>"
});
string nextMission = d == 5 ? "End" : $"{d+1}start";
if (d != 3)
for (int i = 0; i <= 9; i++)
File.WriteAllLines($"Missions/{d}_{i}.xml", new string[] {
$"<mission id=\"{d}{i}\" activeCheck=\"true\" shouldIgnoreSenderVerification=\"true\">",
"<goals>",
$"<goal type=\"getstring\" target=\"{i}\"/>",
"</goals>",
$"<missionEnd>addFlags:{d}_{i}</missionEnd>",
$"<nextMission IsSilent=\"false\">Missions/{nextMission}.xml</nextMission>",
"<email>",
"<sender>Calc</sender>",
$"<subject>Error</subject>",
$"<body>Error</body>",
"<attachments>",
"</attachments>",
"</email>",
"</mission>"
});
else
for (int i = 0; i <= 9; i++)
{
if (i < 2)
{
string op = i == 0 ? "+" : "*";
string oper = i == 0 ? "plus" : "mult";
File.WriteAllLines($"Missions/{d}_{i}.xml", new string[] {
$"<mission id=\"{d}{i}\" activeCheck=\"true\" shouldIgnoreSenderVerification=\"true\">",
"<goals>",
$"<goal type=\"getstring\" target=\"{op}\"/>",
"</goals>",
$"<missionEnd>addFlags:{oper}</missionEnd>",
$"<nextMission IsSilent=\"false\">Missions/{nextMission}.xml</nextMission>",
"<email>",
"<sender>Calc</sender>",
$"<subject>Error</subject>",
$"<body>Error</body>",
"<attachments>",
"</attachments>",
"</email>",
"</mission>"
});
} else
File.WriteAllLines($"Missions/{d}_{i}.xml", new string[] {
$"<mission id=\"{d}{i}\" activeCheck=\"true\" shouldIgnoreSenderVerification=\"true\">",
"<goals>",
$"<goal type=\"delay\" time=\"0.2\"/>",
"</goals>",
$"<nextMission IsSilent=\"false\">Missions/3start.xml</nextMission>",
"<email>",
"<sender>Calc</sender>",
$"<subject>Error</subject>",
$"<body>Error</body>",
"<attachments>",
"</attachments>",
"</email>",
"</mission>"
});
}
}
File.WriteAllLines("Missions/End.xml", new string[]
{
"<mission id=\"end\" activeCheck=\"true\" shouldIgnoreSenderVerification=\"true\">",
"<goals>",
"<goal type=\"delay\" time=\"0.2\"/>",
"</goals>",
"<missionEnd>loadConditionalActions:Actions/Compute.xml</missionEnd>",
"<nextMission IsSilent=\"false\">NONE</nextMission>",
"<email>",
"<sender>Calc</sender>",
"<subject>Thanks for using this shit lmao</subject>",
"<body>God this took way too long, make sure to make a new save if you want to use this again</body>",
"<attachments>",
"</attachments>",
"</email>",
"</mission>"
});
File.AppendAllLines("Actions/Compute.xml", new string[] { "<Instantly>" });
for (int x = 0; x <= 1; x++)
for (int i = 0; i <= 99; i++)
for (int ii = 0; ii <= 99; ii++)
{
string y = i < 10 ? "0" : i.ToString()[1].ToString();
string yy = i.ToString()[0].ToString();
string yyy = ii < 10 ? "0" : ii.ToString()[1].ToString();
string yyyy = ii.ToString()[0].ToString();
int s = 0;
string opFlag = x == 0 ? "plus" : "mult";
var builder = new StringBuilder();
builder.Append($"<HasFlag requiredFlags=\"1_{y},2_{yy},{opFlag},4_{yyy},5_{yyyy}\">/n/<LaunchHackScript Filepath=\"Hackscripts/");
if (x == 0)
s = i + ii;
else
s = i * ii;
builder.Append($"{s}.txt\" Delay=\"0.2\" SourceComp=\"playerComp\" TargetComp=\"playerComp\" RequireLogsOnSource=\"false\" RequireSourceIntact=\"true\"/>/n/</HasFlag>");
File.AppendAllLines("Actions/Compute.xml", builder.ToString().Split("/n/"));
}
File.AppendAllLines("Actions/Compute.xml", new string[] { "</Instantly>" });
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment