Skip to content

Commit

Permalink
Redo Gathers for Trap/Trimps
Browse files Browse the repository at this point in the history
  • Loading branch information
genbtc committed Nov 5, 2023
1 parent 8728547 commit 2a7bb4b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
4 changes: 2 additions & 2 deletions modules/buildings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ MODULES["buildings"] = {};
//These can be changed (in the console) if you know what you're doing:
MODULES["buildings"].nursCostRatio = 0.05; //nursery to warpstation/collector cost ratio. Also for extra gems.
MODULES["buildings"].storageMainCutoff = 0.85; //when to buy more storage. (85% )
MODULES["buildings"].storageLowlvlCutoff1 = 0.7; //when to buy more storage at zone 1
MODULES["buildings"].storageLowlvlCutoff2 = 0.5; //when to buy more storage from zone 2-10 (more leeway so it doesnt fill up)
MODULES["buildings"].storageLowlvlCutoff1 = 0.67; //when to buy more storage at zone 1
MODULES["buildings"].storageLowlvlCutoff2 = 0.70; //when to buy more storage from zone 2-10 (more leeway so it doesnt fill up)

var housingList = ['Hut', 'House', 'Mansion', 'Hotel', 'Resort', 'Gateway', 'Collector', 'Warpstation'];

Expand Down
60 changes: 31 additions & 29 deletions modules/gather.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
MODULES["gather"] = {};
//These can be changed (in the console) if you know what you're doing:
MODULES["gather"].minTraps = 5;
MODULES["gather"].minTraps = 500;
MODULES["gather"].minScienceAmount = 100;
MODULES["gather"].minScienceSeconds = 60;
MODULES["gather"].minBreedingTrimps = 6;
MODULES["gather"].alwaysGoFullTrap = true;

//OLD: "Auto Gather/Build"
function manualLabor() {
Expand All @@ -18,7 +20,7 @@ function manualLabor() {
var hasTurkimp = game.talents.turkimp2.purchased || game.global.turkimpTimer > 0;

//FRESH GAME NO HELIUM CODE.
if (game.global.world <=3 && game.global.totalHeliumEarned<=5000) {
if (game.global.world <= 3 && game.global.totalHeliumEarned<=5000) {
if (game.global.buildingsQueue.length == 0 && (game.global.playerGathering != 'trimps' || game.buildings.Trap.owned == 0)){
if (!game.triggers.wood.done || game.resources.food.owned < 10 || Math.floor(game.resources.food.owned) < Math.floor(game.resources.wood.owned))
setGather('food');
Expand All @@ -27,15 +29,17 @@ function manualLabor() {
}
}

if(watchJumpstartTraps || trapTrimpsOK && (breedingTrimps < 5 || trapperTrapUntilFull) && game.buildings.Trap.owned == 0 && canAffordBuilding('Trap')) {
var wannaTrapTrimps = (breedingTrimps < MODULES["gather"].minBreedingTrimps || trapperTrapUntilFull || watchJumpstartTraps);
//Traps and Trimps: //build trap when at 0 traps //try buying in the if
if(trapTrimpsOK && wannaTrapTrimps && game.buildings.Trap.owned == 0 && canAffordBuilding('Trap') && !safeBuyBuilding('Trap')) {
//safeBuyBuilding returns false if item is already in queue
if(!safeBuyBuilding('Trap'))
setGather('buildings');
setGather('buildings'); //then build if it bought
}
else if (watchJumpstartTraps || trapTrimpsOK && (breedingTrimps < 5 || trapperTrapUntilFull) && game.buildings.Trap.owned > 0) {
//BuildTrap/CheckTrap > 1
else if (trapTrimpsOK && wannaTrapTrimps && game.buildings.Trap.owned > 0) {
setGather('trimps');
if (trapperTrapUntilFull && (game.global.buildingsQueue.length == 0 || game.buildings.Trap.owned == 1) && !game.global.trapBuildAllowed && canAffordBuilding('Trap'))
safeBuyBuilding('Trap'); //get ahead on trap building since it is always needed for Trapper
if (trapperTrapUntilFull && (game.global.buildingsQueue.length == 0 || game.buildings.Trap.owned == 1) && !game.global.trapBuildAllowed && canAffordBuilding('Trap') && safeBuyBuilding('Trap')) //get ahead on trap building since it is always needed for Trapper
return;
}
else if (getPageSetting('ManualGather2') != 2 && game.resources.science.owned < MODULES["gather"].minScienceAmount && document.getElementById('scienceCollectBtn').style.display != 'none' && document.getElementById('science').style.visibility != 'hidden')
setGather('science');
Expand All @@ -48,8 +52,7 @@ function manualLabor() {
setGather('buildings');
}
//if we have some upgrades sitting around which we don't have enough science for, gather science
else if (game.resources.science.owned < scienceNeeded && document.getElementById('scienceCollectBtn').style.display != 'none' && document.getElementById('science').style.visibility != 'hidden') {
// debug('Science needed ' + scienceNeeded);
else if (game.resources.science.owned < getScienceNeeded() && document.getElementById('scienceCollectBtn').style.display != 'none' && document.getElementById('science').style.visibility != 'hidden') {
if ((getPlayerModifier() < getPerSecBeforeManual('Scientist') && hasTurkimp)||getPageSetting('ManualGather2') == 2){
//if manual is less than science production, switch on turkimp
setGather('metal');
Expand All @@ -60,7 +63,7 @@ function manualLabor() {
}
else if (trapTrimpsOK && targetBreed < getBreedTime(true)){
//combined to optimize code.
if (game.buildings.Trap.owned < 100 && canAffordBuilding('Trap')) {
if (game.buildings.Trap.owned < MODULES["gather"].minTraps && canAffordBuilding('Trap')) {
safeBuyBuilding('Trap');
setGather('buildings');
}
Expand Down Expand Up @@ -122,7 +125,7 @@ function manualLabor() {
}
}

//NEW: #2 "Auto Gather/Build"
//NEW: #2 "Auto Gather/Build" (+no science)
function manualLabor2() {
if (getPageSetting('ManualGather2')==0) return;
//vars
Expand All @@ -136,7 +139,7 @@ function manualLabor2() {
var hasTurkimp = game.talents.turkimp2.purchased || game.global.turkimpTimer > 0;

//FRESH GAME LOWLEVEL NOHELIUM CODE.
if (game.global.world <=3 && game.global.totalHeliumEarned<=5000) {
if (game.global.world <= 3 && game.global.totalHeliumEarned<=5000) {
if (game.global.buildingsQueue.length == 0 && (game.global.playerGathering != 'trimps' || game.buildings.Trap.owned == 0)){
if (!game.triggers.wood.done || game.resources.food.owned < 10 || Math.floor(game.resources.food.owned) < Math.floor(game.resources.wood.owned)) {
setGather('food');
Expand All @@ -149,18 +152,18 @@ function manualLabor2() {
}
}

//Traps and Trimps:
if(trapTrimpsOK && (breedingTrimps < 5 || trapperTrapUntilFull || watchJumpstartTraps) && game.buildings.Trap.owned == 0 && canAffordBuilding('Trap')) {
//safeBuyBuilding returns false if item is already in queue
if(!safeBuyBuilding('Trap'))
setGather('buildings');
var wannaTrapTrimps = (breedingTrimps < MODULES["gather"].minBreedingTrimps || trapperTrapUntilFull || watchJumpstartTraps);
//Traps and Trimps: //build trap when at 0 traps //try buying in the if
if(trapTrimpsOK && wannaTrapTrimps && game.buildings.Trap.owned == 0 && canAffordBuilding('Trap') && !safeBuyBuilding('Trap')) {
setGather('buildings'); //then build if it bought
return;
}
else if (trapTrimpsOK && (breedingTrimps < 5 || trapperTrapUntilFull || watchJumpstartTraps) && game.buildings.Trap.owned > 0) {
//BuildTrap/CheckTrap > 1
else if (trapTrimpsOK && wannaTrapTrimps && game.buildings.Trap.owned > 0) {
setGather('trimps');
if (trapperTrapUntilFull && (game.global.buildingsQueue.length == 0 || game.buildings.Trap.owned == 1) && !game.global.trapBuildAllowed && canAffordBuilding('Trap'))
safeBuyBuilding('Trap'); //get ahead on trap building since it is always needed for Trapper
return;
//get ahead on trap building since it is always needed for Trapper
if (trapperTrapUntilFull && (game.global.buildingsQueue.length == 0 || game.buildings.Trap.owned == 1) && !game.global.trapBuildAllowed && canAffordBuilding('Trap') && safeBuyBuilding('Trap'))
return;
}

//Buildings:
Expand All @@ -181,13 +184,12 @@ function manualLabor2() {
//if we have some upgrades sitting around which we don't have enough science for, gather science
if (document.getElementById('scienceCollectBtn').style.display != 'none' && document.getElementById('science').style.visibility != 'hidden') {
//if we have less than (100) science or less than a minute of science
if (game.resources.science.owned < MODULES["gather"].minScienceAmount ||
(game.resources.science.owned < getPsString('science', true) * MODULES["gather"].minScienceSeconds && game.global.turkimpTimer < 1))
if (getPageSetting('ManualGather2') != 2) {
setGather('science');
return;
}
if (game.resources.science.owned < scienceNeeded) {
if (getPageSetting('ManualGather2') != 2 && game.resources.science.owned < MODULES["gather"].minScienceAmount ||
(game.resources.science.owned < getPsString('science', true) * MODULES["gather"].minScienceSeconds && game.global.turkimpTimer < 1)) {
setGather('science');
return;
}
if (game.resources.science.owned < getScienceNeeded()) {
//if manual is less than science production and turkimp, metal. (or science is set as disallowed)
if ((getPlayerModifier() < getPerSecBeforeManual('Scientist') && hasTurkimp) || getPageSetting('ManualGather2') == 2)
setGather('metal');
Expand Down

0 comments on commit 2a7bb4b

Please sign in to comment.