Merge pull request #220 from hydroflame/crime-commit-log

FIX #207 commitCrime now takes enable/disable log into account
This commit is contained in:
danielyxie 2018-05-10 12:15:01 -05:00 committed by GitHub
commit 7fe704de1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 93 additions and 29 deletions

@ -74,6 +74,55 @@ var hasCorporationSF=false, //Source-File 3
hasBn11SF=false; //Source-File 11
var possibleLogs = {
ALL: true,
scan: true,
hack: true,
sleep: true,
disableLog: true,
enableLog: true,
grow: true,
weaken: true,
nuke: true,
brutessh: true,
ftpcrack: true,
relaysmtp: true,
httpworm: true,
sqlinject: true,
spawn: true,
kill: true,
killall: true,
scp: true,
getHackingLevel: true,
getServerMoneyAvailable: true,
getServerSecurityLevel: true,
getServerBaseSecurityLevel: true,
getServerMinSecurityLevel: true,
getServerRequiredHackingLevel: true,
getServerMaxMoney: true,
getServerGrowth: true,
getServerNumPortsRequired: true,
getServerRam: true,
buyStock: true,
sellStock: true,
purchaseServer: true,
deleteServer: true,
universityCourse: true,
gymWorkout: true,
travelToCity: true,
purchaseTor: true,
purchaseProgram: true,
stopAction: true,
upgradeHomeRam: true,
workForCompany: true,
applyToCompany: true,
joinFaction: true,
workForFaction: true,
createProgram: true,
commitCrime: true,
shortStock: true,
sellShort: true,
}
var singularitySFLvl=1, wallStreetSFLvl=1;
@ -354,13 +403,23 @@ function NetscriptFunctions(workerScript) {
},
disableLog : function(fn) {
if (workerScript.checkingRam) {return 0;}
if(possibleLogs[fn]===undefined) {
throw makeRuntimeRejectMsg(workerScript, "Invalid argument to disableLog: "+fn);
}
workerScript.disableLogs[fn] = true;
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.disableLog == null) {
workerScript.scriptRef.log("Disabled logging for " + fn);
}
},
enableLog : function(fn) {
if (workerScript.checkingRam) {return 0;}
if(possibleLogs[fn]===undefined) {
throw makeRuntimeRejectMsg(workerScript, "Invalid argument to enableLog: "+fn);
}
delete workerScript.disableLogs[fn];
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.enableLog == null) {
workerScript.scriptRef.log("Enabled logging for " + fn);
}
},
nuke : function(ip){
if (workerScript.checkingRam) {
@ -3331,41 +3390,42 @@ function NetscriptFunctions(workerScript) {
}
crime = crime.toLowerCase();
let enableCommitCrimeLog = workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null
if (crime.includes("shoplift")) {
workerScript.scriptRef.log("Attempting to shoplift...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to shoplift...");}
return commitShopliftCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("rob") && crime.includes("store")) {
workerScript.scriptRef.log("Attempting to rob a store...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to rob a store...");}
return commitRobStoreCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("mug")) {
workerScript.scriptRef.log("Attempting to mug someone...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to mug someone...");}
return commitMugCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("larceny")) {
workerScript.scriptRef.log("Attempting to commit larceny...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit larceny...");}
return commitLarcenyCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("drugs")) {
workerScript.scriptRef.log("Attempting to deal drugs...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to deal drugs...");}
return commitDealDrugsCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("bond") && crime.includes("forge")) {
workerScript.scriptRef.log("Attempting to forge corporate bonds...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to forge corporate bonds...");}
return commitBondForgeryCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("traffick") && crime.includes("arms")) {
workerScript.scriptRef.log("Attempting to traffick illegal arms...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to traffick illegal arms...");}
return commitTraffickArmsCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("homicide")) {
workerScript.scriptRef.log("Attempting to commit homicide...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit homicide...");}
return commitHomicideCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("grand") && crime.includes("auto")) {
workerScript.scriptRef.log("Attempting to commit grand theft auto...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit grand theft auto...");}
return commitGrandTheftAutoCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("kidnap")) {
workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target...");}
return commitKidnapCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("assassinate")) {
workerScript.scriptRef.log("Attempting to assassinate a high-profile target...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to assassinate a high-profile target...");}
return commitAssassinationCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript})
} else if (crime.includes("heist")) {
workerScript.scriptRef.log("Attempting to pull off a heist...");
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to pull off a heist...");}
return commitHeistCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else {
throw makeRuntimeRejectMsg(workerScript, "Invalid crime passed into commitCrime(): " + crime);

@ -1585,6 +1585,7 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
this.workAgiExpGained *= 2;
this.workChaExpGained *= 2;
if (this.committingCrimeThruSingFn) {
if(this.singFnCrimeWorkerScript.disableLogs.ALL == null && this.singFnCrimeWorkerScript.disableLogs.commitCrime == null) {
this.singFnCrimeWorkerScript.scriptRef.log("Crime successful! Gained " +
numeral(this.workMoneyGained).format("$0.000a") + ", " +
formatNumber(this.workHackExpGained, 3) + " hack exp, " +
@ -1593,6 +1594,7 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
formatNumber(this.workDexExpGained, 3) + " dex exp, " +
formatNumber(this.workAgiExpGained, 3) + " agi exp, " +
formatNumber(this.workChaExpGained, 3) + " cha exp.");
}
} else {
dialogBoxCreate("Crime successful! <br><br>" +
"You gained:<br>"+
@ -1614,6 +1616,7 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
this.workAgiExpGained /= 2;
this.workChaExpGained /= 2;
if (this.committingCrimeThruSingFn) {
if(this.singFnCrimeWorkerScript.disableLogs.ALL == null && this.singFnCrimeWorkerScript.disableLogs.commitCrime == null) {
this.singFnCrimeWorkerScript.scriptRef.log("Crime failed! Gained " +
formatNumber(this.workHackExpGained, 3) + " hack exp, " +
formatNumber(this.workStrExpGained, 3) + " str exp, " +
@ -1621,6 +1624,7 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
formatNumber(this.workDexExpGained, 3) + " dex exp, " +
formatNumber(this.workAgiExpGained, 3) + " agi exp, " +
formatNumber(this.workChaExpGained, 3) + " cha exp.");
}
} else {
dialogBoxCreate("Crime failed! <br><br>" +
"You gained:<br>"+