Merge pull request #259 from hydroflame/streamline-crimes

streamline crimes code
This commit is contained in:
danielyxie 2018-06-04 09:04:46 -05:00 committed by GitHub
commit e31c8a1fc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 294 additions and 418 deletions

@ -2,146 +2,235 @@ import {CONSTANTS} from "./Constants.js";
import {Player} from "./Player.js"; import {Player} from "./Player.js";
import {dialogBoxCreate} from "../utils/DialogBox.js"; import {dialogBoxCreate} from "../utils/DialogBox.js";
/* Crimes.js */
function commitShopliftCrime(div=1, singParams=null) { function Crime(name, type, time, money, difficulty, karma, params) {
if (div <= 0) {div = 1;} this.name = name;
Player.crimeType = CONSTANTS.CrimeShoplift; this.type = type;
var time = 2000; this.time = time;
Player.startCrime(0, 0, 0, 2/div, 2/div, 0, 15000/div, time, singParams); //$7500/s, 1 exp/s this.money = money;
return time; this.difficulty = difficulty;
this.karma = karma;
this.hacking_success_weight = params.hacking_success_weight ? params.hacking_success_weight : 0;
this.strength_success_weight = params.strength_success_weight ? params.strength_success_weight : 0;
this.defense_success_weight = params.defense_success_weight ? params.defense_success_weight : 0;
this.dexterity_success_weight = params.dexterity_success_weight ? params.dexterity_success_weight : 0;
this.agility_success_weight = params.agility_success_weight ? params.agility_success_weight : 0;
this.charisma_success_weight = params.charisma_success_weight ? params.charisma_success_weight : 0;
this.hacking_exp = params.hacking_exp ? params.hacking_exp : 0;
this.strength_exp = params.strength_exp ? params.strength_exp : 0;
this.defense_exp = params.defense_exp ? params.defense_exp : 0;
this.dexterity_exp = params.dexterity_exp ? params.dexterity_exp : 0;
this.agility_exp = params.agility_exp ? params.agility_exp : 0;
this.charisma_exp = params.charisma_exp ? params.charisma_exp : 0;
this.intelligence_exp = params.intelligence_exp ? params.intelligence_exp : 0;
this.kills = params.kills ? params.kills : 0;
} }
function commitRobStoreCrime(div=1, singParams=null) { Crime.prototype.commit = function(div=1, singParams=null) {
if (div <= 0) {div = 1;} if (div <= 0) {div = 1;}
Player.crimeType = CONSTANTS.CrimeRobStore; Player.crimeType = this.type;
var time = 60000; Player.startCrime(
Player.startCrime(30/div, 0, 0, 45/div, 45/div, 0, 400000/div, time, singParams); //$6666,6/2, 0.5exp/s, 0.75exp/s this.hacking_exp/div,
return time; this.strength_exp/div,
this.defense_exp/div,
this.dexterity_exp/div,
this.agility_exp/div,
this.charisma_exp/div,
this.money/div, this.time, singParams);
return this.time;
} }
function commitMugCrime(div=1, singParams=null) { Crime.prototype.successRate = function() {
if (div <= 0) {div = 1;} var chance = (this.hacking_success_weight * Player.hacking_skill +
Player.crimeType = CONSTANTS.CrimeMug; this.strength_success_weight * Player.strength +
var time = 4000; this.defense_success_weight * Player.defense +
Player.startCrime(0, 3/div, 3/div, 3/div, 3/div, 0, 36000/div, time, singParams); //$9000/s, .66 exp/s this.dexterity_success_weight * Player.dexterity +
return time; this.agility_success_weight * Player.agility +
this.charisma_success_weight * Player.charisma +
CONSTANTS.IntelligenceCrimeWeight * Player.intelligence);
chance /= CONSTANTS.MaxSkillLevel;
chance /= this.difficulty;
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
} }
function commitLarcenyCrime(div=1, singParams=null) { const Crimes = {
if (div <= 0) {div = 1;} Shoplift: new Crime("Shoplift", CONSTANTS.CrimeShoplift, 2000, 15000, 1/20, 0.1, {
Player.crimeType = CONSTANTS.CrimeLarceny; dexterity_success_weight: 1,
var time = 90000; agility_success_weight: 1,
Player.startCrime(45/div, 0, 0, 60/div, 60/div, 0, 800000/div, time, singParams) // $8888.88/s, .5 exp/s, .66 exp/s
return time;
}
function commitDealDrugsCrime(div=1, singParams=null) { dexterity_exp: 2,
if (div <= 0) {div = 1;} agility_exp: 2,
Player.crimeType = CONSTANTS.CrimeDrugs; }),
var time = 10000;
Player.startCrime(0, 0, 0, 5/div, 5/div, 10/div, 120000/div, time, singParams); //$12000/s, .5 exp/s, 1 exp/s
return time;
}
function commitBondForgeryCrime(div=1, singParams=null) { RobStore: new Crime("Rob Store", CONSTANTS.CrimeRobStore, 60000, 400000, 1/5, 0.5, {
if (div <= 0) {div = 1;} hacking_exp: 30,
Player.crimeType = CONSTANTS.CrimeBondForgery; dexterity_exp: 45,
var time = 300000; agility_exp: 45,
Player.startCrime(100/div, 0, 0, 150/div, 0, 15/div, 4500000/div, time, singParams); //$15000/s, 0.33 hack exp/s, .5 dex exp/s, .05 cha exp
return time;
}
function commitTraffickArmsCrime(div=1, singParams=null) { hacking_success_weight: 0.5 ,
if (div <= 0) {div = 1;} dexterity_success_weight: 2,
Player.crimeType = CONSTANTS.CrimeTraffickArms; agility_success_weight: 1,
var time = 40000;
Player.startCrime(0, 20/div, 20/div, 20/div, 20/div, 40/div, 600000/div, time, singParams); //$15000/s, .5 combat exp/s, 1 cha exp/s
return time;
}
function commitHomicideCrime(div=1, singParams=null) { intelligence_exp: 0.25 * CONSTANTS.IntelligenceCrimeBaseExpGain,
if (div <= 0) {div = 1;} }),
Player.crimeType = CONSTANTS.CrimeHomicide;
var time = 3000;
Player.startCrime(0, 2/div, 2/div, 2/div, 2/div, 0, 45000/div, time, singParams); //$15000/s, 0.66 combat exp/s
return time;
}
function commitGrandTheftAutoCrime(div=1, singParams=null) { Mug: new Crime("Mug", CONSTANTS.CrimeMug, 4000, 36000, 1/5, 0.25, {
if (div <= 0) {div = 1;} strength_exp: 3,
Player.crimeType = CONSTANTS.CrimeGrandTheftAuto; defence_exp: 3,
var time = 80000; dexterity_exp: 3,
Player.startCrime(0, 20/div, 20/div, 20/div, 80/div, 40/div, 1600000/div, time, singParams); //$20000/s, .25 exp/s, 1 exp/s, .5 exp/s agility_exp: 3,
return time;
}
function commitKidnapCrime(div=1, singParams=null) { strength_success_weight: 1.5,
if (div <= 0) {div = 1;} defense_success_weight: 0.5,
Player.crimeType = CONSTANTS.CrimeKidnap; dexterity_success_weight: 1.5,
var time = 120000; agility_success_weight: 0.5,
Player.startCrime(0, 80/div, 80/div, 80/div, 80/div, 80/div, 3600000/div, time, singParams); //$30000/s. .66 exp/s }),
return time;
}
function commitAssassinationCrime(div=1, singParams=null) { Larceny: new Crime("Larceny", CONSTANTS.CrimeLarceny, 90000, 800000, 1/3, 1.5, {
if (div <= 0) {div = 1;} hacking_exp: 45,
Player.crimeType = CONSTANTS.CrimeAssassination; dexterity_exp: 60,
var time = 300000; agility_exp: 60,
Player.startCrime(0, 300/div, 300/div, 300/div, 300/div, 0, 12000000/div, time, singParams); //$40000/s, 1 exp/s
return time;
}
function commitHeistCrime(div=1, singParams=null) { hacking_skill_success_weight: 0.5,
if (div <= 0) {div = 1;} dexterity_success_weight: 1,
Player.crimeType = CONSTANTS.CrimeHeist; agility_success_weight: 1,
var time = 600000;
Player.startCrime(450/div, 450/div, 450/div, 450/div, 450/div, 450/div, 120000000/div, time, singParams); //$200000/s, .75exp/s
return time;
}
function determineCrimeSuccess(crime, moneyGained) { intelligence_exp: 0.5 * CONSTANTS.IntelligenceCrimeBaseExpGain,
}),
DealDrugs: new Crime("Deal Drugs", CONSTANTS.CrimeDrugs, 10000, 120000, 1, 0.5, {
dexterity_exp: 5,
agility_exp: 5,
charisma_exp: 10,
charisma_success_weight: 3,
dexterity_success_weight: 2,
agility_success_weight: 1,
}),
BondForgery: new Crime("Bond Forgery", CONSTANTS.CrimeBondForgery, 300000, 4500000, 1/2, 0.1, {
hacking_exp: 100,
dexterity_exp: 150,
charisma_exp: 15,
hacking_skill_success_weight: 0.1,
dexterity_success_weight: 2.5,
intelligence_exp: 2 * CONSTANTS.IntelligenceCrimeBaseExpGain,
}),
TraffickArms: new Crime("Traffick Arms", CONSTANTS.CrimeTraffickArms, 40000, 600000, 2, 1, {
strength_exp: 20,
defence_exp: 20,
dexterity_exp: 20,
agility_exp: 20,
charisma_exp: 40,
charisma_success_weight: 1,
strength_success_weight: 1,
defense_success_weight: 1,
dexterity_success_weight: 1,
agility_success_weight: 1,
}),
Homicide: new Crime("Homicide", CONSTANTS.CrimeHomicide, 3000, 45000, 1, 3, {
strength_exp: 2,
defence_exp: 2,
dexterity_exp: 2,
agility_exp: 2,
strength_success_weight: 2,
defense_success_weight: 2,
dexterity_success_weight: 0.5,
agility_success_weight: 0.5,
kills: 1,
}),
GrandTheftAuto: new Crime("Grand Theft Auto", CONSTANTS.CrimeGrandTheftAuto, 80000, 1600000, 8, 5, {
strength_exp: 20,
defence_exp: 20,
dexterity_exp: 20,
agility_exp: 80,
charisma_exp: 40,
hacking_skill_success_weight: 1,
strength_success_weight: 1,
dexterity_success_weight: 4,
agility_success_weight: 2,
charisma_success_weight: 2,
intelligence_exp: CONSTANTS.IntelligenceCrimeBaseExpGain,
}),
Kidnap: new Crime("Kidnap", CONSTANTS.CrimeKidnap, 120000, 3600000, 5, 6, {
strength_exp: 80,
defence_exp: 80,
dexterity_exp: 80,
agility_exp: 80,
charisma_exp: 80,
charisma_success_weight: 1,
strength_success_weight: 1,
dexterity_success_weight: 1,
agility_success_weight: 1,
intelligence_exp: 2 * CONSTANTS.IntelligenceCrimeBaseExpGain,
}),
Assassination: new Crime("Assassination", CONSTANTS.CrimeAssassination, 300000, 12000000, 8, 10, {
strength_exp: 300,
defence_exp: 300,
dexterity_exp: 300,
agility_exp: 300,
strength_success_weight: 1,
dexterity_success_weight: 2,
agility_success_weight: 1,
intelligence_exp: 5 * CONSTANTS.IntelligenceCrimeBaseExpGain,
kills: 1,
}),
Heist: new Crime("Heist", CONSTANTS.CrimeHeist, 600000, 120000000, 18, 15, {
hacking_exp: 450,
strength_exp: 450,
defence_exp: 450,
dexterity_exp: 450,
agility_exp: 450,
charisma_exp: 450,
hacking_skill_success_weight: 1,
strength_success_weight: 1,
defense_success_weight: 1,
dexterity_success_weight: 1,
agility_success_weight: 1,
charisma_success_weight: 1,
intelligence_exp: 10 * CONSTANTS.IntelligenceCrimeBaseExpGain,
}),
};
function determineCrimeSuccess(type, moneyGained) {
var chance = 0; var chance = 0;
switch (crime) { var found = false;
case CONSTANTS.CrimeShoplift: for(const i in Crimes) {
chance = determineCrimeChanceShoplift(); const crime = Crimes[i];
break; if(crime.type == type) {
case CONSTANTS.CrimeRobStore: chance = crime.successRate();
chance = determineCrimeChanceRobStore(); found = true;
break; break;
case CONSTANTS.CrimeMug: }
chance = determineCrimeChanceMug(); }
break; if(!found) {
case CONSTANTS.CrimeLarceny: console.log(crime);
chance = determineCrimeChanceLarceny(); dialogBoxCreate("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
break; return;
case CONSTANTS.CrimeDrugs:
chance = determineCrimeChanceDealDrugs();
break;
case CONSTANTS.CrimeBondForgery:
chance = determineCrimeChanceBondForgery();
break;
case CONSTANTS.CrimeTraffickArms:
chance = determineCrimeChanceTraffickArms();
break;
case CONSTANTS.CrimeHomicide:
chance = determineCrimeChanceHomicide();
break;
case CONSTANTS.CrimeGrandTheftAuto:
chance = determineCrimeChanceGrandTheftAuto();
break;
case CONSTANTS.CrimeKidnap:
chance = determineCrimeChanceKidnap();
break;
case CONSTANTS.CrimeAssassination:
chance = determineCrimeChanceAssassination();
break;
case CONSTANTS.CrimeHeist:
chance = determineCrimeChanceHeist();
break;
default:
console.log(crime);
dialogBoxCreate("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
return;
} }
if (Math.random() <= chance) { if (Math.random() <= chance) {
@ -154,134 +243,33 @@ function determineCrimeSuccess(crime, moneyGained) {
} }
} }
let intWgt = CONSTANTS.IntelligenceCrimeWeight; function findCrime(roughName) {
let maxLvl = CONSTANTS.MaxSkillLevel; if (roughName.includes("shoplift")) {
return Crimes.Shoplift;
function determineCrimeChanceShoplift() { } else if (roughName.includes("rob") && roughName.includes("store")) {
var chance = (Player.dexterity / maxLvl + return Crimes.RobStore;
Player.agility / maxLvl + } else if (roughName.includes("mug")) {
intWgt * Player.intelligence / maxLvl) * 20; return Crimes.Mug;
chance *= Player.crime_success_mult; } else if (roughName.includes("larceny")) {
return Math.min(chance, 1); return Crimes.Larceny;
} else if (roughName.includes("drugs")) {
return Crimes.DealDrugs;
} else if (roughName.includes("bond") && roughName.includes("forge")) {
return Crimes.BondForgery;
} else if (roughName.includes("traffick") && roughName.includes("arms")) {
return Crimes.TraffickArms;
} else if (roughName.includes("homicide")) {
return Crimes.Homicide;
} else if (roughName.includes("grand") && roughName.includes("auto")) {
return Crimes.GrandTheftAuto;
} else if (roughName.includes("kidnap")) {
return Crimes.Kidnap;
} else if (roughName.includes("assassinate")) {
return Crimes.Assassination;
} else if (roughName.includes("heist")) {
return Crimes.Heist;
}
return null;
} }
function determineCrimeChanceRobStore() { export {determineCrimeSuccess,findCrime,Crimes};
var chance = (0.5 * Player.hacking_skill / maxLvl +
2 * Player.dexterity / maxLvl +
1 * Player.agility / maxLvl +
intWgt * Player.intelligence / maxLvl) * 5;
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceMug() {
var chance = (1.5 * Player.strength / maxLvl +
0.5 * Player.defense / maxLvl +
1.5 * Player.dexterity / maxLvl +
0.5 * Player.agility / maxLvl +
intWgt * Player.intelligence / maxLvl) * 5;
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceLarceny() {
var chance = (0.5 * Player.hacking_skill / maxLvl +
Player.dexterity / maxLvl +
Player.agility / maxLvl +
intWgt * Player.intelligence / maxLvl) * 3;
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceDealDrugs() {
var chance = (3*Player.charisma / maxLvl +
2*Player.dexterity / maxLvl +
Player.agility / maxLvl +
intWgt * Player.intelligence / maxLvl);
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceBondForgery() {
var chance = (0.1*Player.hacking_skill / maxLvl +
2.5*Player.dexterity / maxLvl +
2*intWgt*Player.intelligence / maxLvl);
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceTraffickArms() {
var chance = (Player.charisma / maxLvl +
Player.strength / maxLvl +
Player.defense / maxLvl +
Player.dexterity / maxLvl +
Player.agility / maxLvl +
intWgt * Player.intelligence / maxLvl) / 2;
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceHomicide() {
var chance = (2 * Player.strength / maxLvl +
2 * Player.defense / maxLvl +
0.5 * Player.dexterity / maxLvl +
0.5 * Player.agility / maxLvl +
intWgt * Player.intelligence / maxLvl);
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceGrandTheftAuto() {
var chance = (Player.hacking_skill / maxLvl +
Player.strength / maxLvl +
4 * Player.dexterity / maxLvl +
2 * Player.agility / maxLvl +
2 * Player.charisma / maxLvl +
intWgt * Player.intelligence / maxLvl) / 8;
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceKidnap() {
var chance = (Player.charisma / maxLvl +
Player.strength / maxLvl +
Player.dexterity / maxLvl +
Player.agility / maxLvl +
intWgt * Player.intelligence / maxLvl) / 5;
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceAssassination() {
var chance = (Player.strength / maxLvl +
2 * Player.dexterity / maxLvl +
Player.agility / maxLvl +
intWgt * Player.intelligence / maxLvl) / 8;
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
function determineCrimeChanceHeist() {
var chance = (Player.hacking_skill / maxLvl +
Player.strength / maxLvl +
Player.defense / maxLvl +
Player.dexterity / maxLvl +
Player.agility / maxLvl +
Player.charisma / maxLvl +
intWgt * Player.intelligence / maxLvl) / 18;
chance *= Player.crime_success_mult;
return Math.min(chance, 1);
}
export {commitShopliftCrime, commitRobStoreCrime, commitMugCrime,
commitLarcenyCrime, commitDealDrugsCrime, commitBondForgeryCrime,
commitTraffickArmsCrime,
commitHomicideCrime, commitGrandTheftAutoCrime, commitKidnapCrime,
commitAssassinationCrime, commitHeistCrime, determineCrimeSuccess,
determineCrimeChanceShoplift, determineCrimeChanceRobStore,
determineCrimeChanceMug, determineCrimeChanceLarceny,
determineCrimeChanceDealDrugs, determineCrimeChanceBondForgery,
determineCrimeChanceTraffickArms,
determineCrimeChanceHomicide, determineCrimeChanceGrandTheftAuto,
determineCrimeChanceKidnap, determineCrimeChanceAssassination,
determineCrimeChanceHeist};

@ -3,18 +3,7 @@ import {CompanyPositions, initCompanies,
Companies, getJobRequirementText} from "./Company.js"; Companies, getJobRequirementText} from "./Company.js";
import {Corporation} from "./CompanyManagement.js"; import {Corporation} from "./CompanyManagement.js";
import {CONSTANTS} from "./Constants.js"; import {CONSTANTS} from "./Constants.js";
import {commitShopliftCrime, commitRobStoreCrime, commitMugCrime, import {Crimes} from "./Crimes.js";
commitLarcenyCrime, commitDealDrugsCrime, commitBondForgeryCrime,
commitTraffickArmsCrime,
commitHomicideCrime, commitGrandTheftAutoCrime, commitKidnapCrime,
commitAssassinationCrime, commitHeistCrime, determineCrimeSuccess,
determineCrimeChanceShoplift, determineCrimeChanceRobStore,
determineCrimeChanceMug, determineCrimeChanceLarceny,
determineCrimeChanceDealDrugs, determineCrimeChanceBondForgery,
determineCrimeChanceTraffickArms,
determineCrimeChanceHomicide, determineCrimeChanceGrandTheftAuto,
determineCrimeChanceKidnap, determineCrimeChanceAssassination,
determineCrimeChanceHeist} from "./Crimes.js";
import {Engine} from "./engine.js"; import {Engine} from "./engine.js";
import {beginInfiltration} from "./Infiltration.js"; import {beginInfiltration} from "./Infiltration.js";
import {hasBladeburnerSF} from "./NetscriptFunctions.js"; import {hasBladeburnerSF} from "./NetscriptFunctions.js";
@ -1058,18 +1047,18 @@ function displayLocationContent() {
case Locations.NewTokyoSlums: case Locations.NewTokyoSlums:
case Locations.IshimaSlums: case Locations.IshimaSlums:
case Locations.VolhavenSlums: case Locations.VolhavenSlums:
var shopliftChance = determineCrimeChanceShoplift(); var shopliftChance = Crimes.Shoplift.successRate();
var robStoreChance = determineCrimeChanceRobStore(); var robStoreChance = Crimes.RobStore.successRate();
var mugChance = determineCrimeChanceMug(); var mugChance = Crimes.Mug.successRate();
var larcenyChance = determineCrimeChanceLarceny(); var larcenyChance = Crimes.Larceny.successRate();
var drugsChance = determineCrimeChanceDealDrugs(); var drugsChance = Crimes.DealDrugs.successRate();
var bondChance = determineCrimeChanceBondForgery(); var bondChance = Crimes.BondForgery.successRate();
var armsChance = determineCrimeChanceTraffickArms(); var armsChance = Crimes.TraffickArms.successRate();
var homicideChance = determineCrimeChanceHomicide(); var homicideChance = Crimes.Homicide.successRate();
var gtaChance = determineCrimeChanceGrandTheftAuto(); var gtaChance = Crimes.GrandTheftAuto.successRate();
var kidnapChance = determineCrimeChanceKidnap(); var kidnapChance = Crimes.Kidnap.successRate();
var assassinateChance = determineCrimeChanceAssassination(); var assassinateChance = Crimes.Assassination.successRate();
var heistChance = determineCrimeChanceHeist(); var heistChance = Crimes.Heist.successRate();
slumsDescText.style.display = "block"; slumsDescText.style.display = "block";
slumsShoplift.style.display = "block"; slumsShoplift.style.display = "block";
@ -1864,62 +1853,62 @@ function initLocationButtons() {
}); });
slumsShoplift.addEventListener("click", function() { slumsShoplift.addEventListener("click", function() {
commitShopliftCrime(); Crimes.Shoplift.commit();
return false; return false;
}); });
slumsRobStore.addEventListener("click", function() { slumsRobStore.addEventListener("click", function() {
commitRobStoreCrime(); Crimes.RobStore.commit();
return false; return false;
}); });
slumsMug.addEventListener("click", function() { slumsMug.addEventListener("click", function() {
commitMugCrime(); Crimes.Mug.commit();
return false; return false;
}); });
slumsLarceny.addEventListener("click", function() { slumsLarceny.addEventListener("click", function() {
commitLarcenyCrime(); Crimes.Larceny.commit();
return false; return false;
}); });
slumsDealDrugs.addEventListener("click", function() { slumsDealDrugs.addEventListener("click", function() {
commitDealDrugsCrime(); Crimes.DealDrugs.commit();
return false; return false;
}); });
slumsBondForgery.addEventListener("click", function() { slumsBondForgery.addEventListener("click", function() {
commitBondForgeryCrime(); Crimes.BondForgery.commit();
return false; return false;
}); });
slumsTrafficArms.addEventListener("click", function() { slumsTrafficArms.addEventListener("click", function() {
commitTraffickArmsCrime(); Crimes.TraffickArms.commit();
return false; return false;
}); });
slumsHomicide.addEventListener("click", function() { slumsHomicide.addEventListener("click", function() {
commitHomicideCrime(); Crimes.Homicide.commit();
return false; return false;
}); });
slumsGta.addEventListener("click", function() { slumsGta.addEventListener("click", function() {
commitGrandTheftAutoCrime(); Crimes.GrandTheftAuto.commit();
return false; return false;
}); });
slumsKidnap.addEventListener("click", function() { slumsKidnap.addEventListener("click", function() {
commitKidnapCrime(); Crimes.Kidnap.commit();
return false; return false;
}); });
slumsAssassinate.addEventListener("click", function() { slumsAssassinate.addEventListener("click", function() {
commitAssassinationCrime(); Crimes.Assassination.commit();
return false; return false;
}); });
slumsHeist.addEventListener("click", function() { slumsHeist.addEventListener("click", function() {
commitHeistCrime(); Crimes.Heist.commit();
return false; return false;
}); });

@ -6,18 +6,7 @@ import {Augmentations, Augmentation,
augmentationExists, installAugmentations, augmentationExists, installAugmentations,
AugmentationNames} from "./Augmentations.js"; AugmentationNames} from "./Augmentations.js";
import {BitNodeMultipliers} from "./BitNode.js"; import {BitNodeMultipliers} from "./BitNode.js";
import {commitShopliftCrime, commitRobStoreCrime, commitMugCrime, import {determineCrimeSuccess, findCrime} from "./Crimes.js";
commitLarcenyCrime, commitDealDrugsCrime, commitBondForgeryCrime,
commitTraffickArmsCrime,
commitHomicideCrime, commitGrandTheftAutoCrime, commitKidnapCrime,
commitAssassinationCrime, commitHeistCrime, determineCrimeSuccess,
determineCrimeChanceShoplift, determineCrimeChanceRobStore,
determineCrimeChanceMug, determineCrimeChanceLarceny,
determineCrimeChanceDealDrugs, determineCrimeChanceBondForgery,
determineCrimeChanceTraffickArms,
determineCrimeChanceHomicide, determineCrimeChanceGrandTheftAuto,
determineCrimeChanceKidnap, determineCrimeChanceAssassination,
determineCrimeChanceHeist} from "./Crimes.js";
import {Bladeburner} from "./Bladeburner.js"; import {Bladeburner} from "./Bladeburner.js";
import {Companies, Company, CompanyPosition, import {Companies, Company, CompanyPosition,
CompanyPositions, companyExists} from "./Company.js"; CompanyPositions, companyExists} from "./Company.js";
@ -3343,7 +3332,7 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("Began creating program: " + name); workerScript.scriptRef.log("Began creating program: " + name);
return true; return true;
}, },
commitCrime : function(crime) { commitCrime : function(crimeRoughName) {
if (workerScript.checkingRam) { if (workerScript.checkingRam) {
if (workerScript.loadedFns.commitCrime) { if (workerScript.loadedFns.commitCrime) {
return 0; return 0;
@ -3395,49 +3384,16 @@ function NetscriptFunctions(workerScript) {
console.log("Invalid Player.city value"); console.log("Invalid Player.city value");
} }
crime = crime.toLowerCase(); const crime = findCrime(crimeRoughName.toLowerCase());
let enableCommitCrimeLog = workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null if(crime == null) { // couldn't find crime
if (crime.includes("shoplift")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to shoplift...");}
return commitShopliftCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("rob") && crime.includes("store")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to rob a store...");}
return commitRobStoreCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("mug")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to mug someone...");}
return commitMugCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("larceny")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit larceny...");}
return commitLarcenyCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("drugs")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to deal drugs...");}
return commitDealDrugsCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("bond") && crime.includes("forge")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to forge corporate bonds...");}
return commitBondForgeryCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("traffick") && crime.includes("arms")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to traffick illegal arms...");}
return commitTraffickArmsCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("homicide")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit homicide...");}
return commitHomicideCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("grand") && crime.includes("auto")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit grand theft auto...");}
return commitGrandTheftAutoCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
} else if (crime.includes("kidnap")) {
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")) {
if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to assassinate a high-profile target...");}
return commitAssassinationCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript})
} else if (crime.includes("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); throw makeRuntimeRejectMsg(workerScript, "Invalid crime passed into commitCrime(): " + crime);
} }
if(workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {
workerScript.scriptRef.log("Attempting to commit crime: "+crime.name+"...");
}
return crime.commit(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});
}, },
getCrimeChance : function(crime) { getCrimeChance : function(crimeRoughName) {
if (workerScript.checkingRam) { if (workerScript.checkingRam) {
if (workerScript.loadedFns.getCrimeChance) { if (workerScript.loadedFns.getCrimeChance) {
return 0; return 0;
@ -3455,34 +3411,12 @@ function NetscriptFunctions(workerScript) {
} }
} }
crime = crime.toLowerCase(); const crime = findCrime(crimeRoughName.toLowerCase());
if (crime.includes("shoplift")) { if(crime == null) {
return determineCrimeChanceShoplift();
} else if (crime.includes("rob") && crime.includes("store")) {
return determineCrimeChanceRobStore();
} else if (crime.includes("mug")) {
return determineCrimeChanceMug();
} else if (crime.includes("larceny")) {
return determineCrimeChanceLarceny();
} else if (crime.includes("drugs")) {
return determineCrimeChanceDealDrugs();
} else if (crime.includes("bond") && crime.includes("forge")) {
return determineCrimeChanceBondForgery();
} else if (crime.includes("traffick") && crime.includes("arms")) {
return determineCrimeChanceTraffickArms();
} else if (crime.includes("homicide")) {
return determineCrimeChanceHomicide();
} else if (crime.includes("grand") && crime.includes("auto")) {
return determineCrimeChanceGrandTheftAuto();
} else if (crime.includes("kidnap")) {
return determineCrimeChanceKidnap();
} else if (crime.includes("assassinate")) {
return determineCrimeChanceAssassination();
} else if (crime.includes("heist")) {
return determineCrimeChanceHeist();
} else {
throw makeRuntimeRejectMsg(workerScript, "Invalid crime passed into getCrimeChance(): " + crime); throw makeRuntimeRejectMsg(workerScript, "Invalid crime passed into getCrimeChance(): " + crime);
} }
return crime.successRate();
}, },
getOwnedAugmentations : function(purchased=false) { getOwnedAugmentations : function(purchased=false) {
if (workerScript.checkingRam) { if (workerScript.checkingRam) {

@ -8,7 +8,7 @@ import {Company, Companies, getNextCompanyPosition,
import {CONSTANTS} from "./Constants.js"; import {CONSTANTS} from "./Constants.js";
import {Corporation} from "./CompanyManagement.js"; import {Corporation} from "./CompanyManagement.js";
import {Programs} from "./CreateProgram.js"; import {Programs} from "./CreateProgram.js";
import {determineCrimeSuccess} from "./Crimes.js"; import {determineCrimeSuccess, Crimes} from "./Crimes.js";
import {Engine} from "./engine.js"; import {Engine} from "./engine.js";
import {Factions, Faction, import {Factions, Faction,
displayFactionContent} from "./Faction.js"; displayFactionContent} from "./Faction.js";
@ -1518,56 +1518,21 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
var statusText = ""; //TODO, unique message for each crime when you succeed var statusText = ""; //TODO, unique message for each crime when you succeed
if (determineCrimeSuccess(this.crimeType, this.workMoneyGained)) { if (determineCrimeSuccess(this.crimeType, this.workMoneyGained)) {
//Handle Karma and crime statistics //Handle Karma and crime statistics
switch(this.crimeType) { let crime = null;
case CONSTANTS.CrimeShoplift: for(const i in Crimes) {
this.karma -= 0.1; if(Crimes[i].type == this.crimeType) {
crime = Crimes[i];
break; break;
case CONSTANTS.CrimeRobStore: }
this.karma -= 0.5; }
this.gainIntelligenceExp(0.25 * CONSTANTS.IntelligenceCrimeBaseExpGain); if(crime == null) {
break; console.log(this.crimeType);
case CONSTANTS.CrimeMug: dialogBoxCreate("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
this.karma -= 0.25; }
break; this.karma -= crime.karma;
case CONSTANTS.CrimeLarceny: this.numPeopleKilled += crime.kills;
this.karma -= 1.5; if(crime.intelligence_exp > 0) {
this.gainIntelligenceExp(0.5 * CONSTANTS.IntelligenceCrimeBaseExpGain); this.gainIntelligenceExp(crime.intelligence_exp);
break;
case CONSTANTS.CrimeDrugs:
this.karma -= 0.5;
break;
case CONSTANTS.CrimeBondForgery:
this.karma -= 0.1;
this.gainIntelligenceExp(2 * CONSTANTS.IntelligenceCrimeBaseExpGain);
break;
case CONSTANTS.CrimeTraffickArms:
this.karma -= 1;
break;
case CONSTANTS.CrimeHomicide:
++this.numPeopleKilled;
this.karma -= 3;
break;
case CONSTANTS.CrimeGrandTheftAuto:
this.karma -= 5;
this.gainIntelligenceExp(CONSTANTS.IntelligenceCrimeBaseExpGain);
break;
case CONSTANTS.CrimeKidnap:
this.karma -= 6;
this.gainIntelligenceExp(2 * CONSTANTS.IntelligenceCrimeBaseExpGain);
break;
case CONSTANTS.CrimeAssassination:
++this.numPeopleKilled;
this.karma -= 10;
this.gainIntelligenceExp(5 * CONSTANTS.IntelligenceCrimeBaseExpGain);
break;
case CONSTANTS.CrimeHeist:
this.karma -= 15;
this.gainIntelligenceExp(10 * CONSTANTS.IntelligenceCrimeBaseExpGain);
break;
default:
console.log(this.crimeType);
dialogBoxCreate("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
return;
} }
//On a crime success, gain 2x exp //On a crime success, gain 2x exp