Skip to content

Commit 6b9f47f

Browse files
authored
Merge pull request #724 (Add bullet brogue v1.1.1)
2 parents 82e55a0 + e08b0dc commit 6b9f47f

21 files changed

+4426
-149
lines changed

.github/workflows/test-seed-catalog.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ jobs:
2525
run: |
2626
python3 test/compare_seed_catalog.py test/seed_catalogs/seed_catalog_brogue.txt 40
2727
python3 test/compare_seed_catalog.py --extra_args "--variant rapid_brogue" test/seed_catalogs/seed_catalog_rapid_brogue.txt 10
28+
python3 test/compare_seed_catalog.py --extra_args "--variant bullet_brogue" test/seed_catalogs/seed_catalog_bullet_brogue.txt 5

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ jobs:
2626
run: |
2727
python3 test/run_regression_tests.py test/regression_test_ce_v1_14/
2828
python3 test/run_regression_tests.py --extra_args "--variant rapid_brogue" test/regression_test_rb_v1_6/
29+
python3 test/run_regression_tests.py --extra_args "--variant bullet_brogue" test/regression_test_bb_v1_1/

make/o.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$(sources:.c=.o): %.o: %.c src/brogue/Rogue.h src/brogue/Globals.h src/brogue/GlobalsBase.h vars/cppflags vars/cflags make/o.mk
22
$(CC) $(cppflags) $(cflags) -c $< -o $@
33

4-
src/variants/GlobalsBrogue.o src/variants/GlobalsRapidBrogue.o: vars/extra_version
5-
src/variants/GlobalsBrogue.o src/variants/GlobalsRapidBrogue.o: cppflags += -DBROGUE_EXTRA_VERSION='"$(extra_version)"'
4+
src/variants/GlobalsBrogue.o src/variants/GlobalsRapidBrogue.o src/variants/GlobalsBulletBrogue.o: vars/extra_version
5+
src/variants/GlobalsBrogue.o src/variants/GlobalsRapidBrogue.o src/variants/GlobalsBulletBrogue.o: cppflags += -DBROGUE_EXTRA_VERSION='"$(extra_version)"'

src/brogue/Architect.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,7 @@ boolean buildAMachine(enum machineTypes bp,
15061506
while ((theItem->flags & ITEM_CURSED)
15071507
|| ((feature->flags & MF_REQUIRE_GOOD_RUNIC) && (!(theItem->flags & ITEM_RUNIC))) // runic if requested
15081508
|| ((feature->flags & MF_NO_THROWING_WEAPONS) && theItem->category == WEAPON && theItem->quantity > 1) // no throwing weapons if prohibited
1509+
|| ((feature->flags & MF_REQUIRE_HEAVY_WEAPON) && (!itemIsHeavyWeapon(theItem) || !itemIsPositivelyEnchanted(theItem))) // must be a positively enchanted heavy weapon
15091510
|| itemIsADuplicate(theItem, p->spawnedItems, itemCount)) { // don't want to duplicates of rings, staffs, etc.
15101511
deleteItem(theItem);
15111512
theItem = generateItem(feature->itemCategory, feature->itemKind);
@@ -1734,6 +1735,15 @@ static void addMachines() {
17341735

17351736
analyzeMap(true);
17361737

1738+
// For bullet brogue, add a guaranteed weapon vault on l1
1739+
if (gameVariant == VARIANT_BULLET_BROGUE && rogue.depthLevel == 1) {
1740+
for (failsafe = 50; failsafe; failsafe--) {
1741+
if (buildAMachine(MT_REWARD_HEAVY_OR_RUNIC_WEAPON, -1, -1, 0, NULL, NULL, NULL)) {
1742+
break;
1743+
}
1744+
}
1745+
}
1746+
17371747
// Add the amulet holder if it's depth 26:
17381748
if (rogue.depthLevel == gameConst->amuletLevel) {
17391749
for (failsafe = 50; failsafe; failsafe--) {
@@ -1745,7 +1755,7 @@ static void addMachines() {
17451755

17461756
// Add reward rooms, if any:
17471757
machineCount = 0;
1748-
while (rogue.depthLevel <= gameConst->amuletLevel
1758+
while (rogue.depthLevel <= gameConst->deepestLevelForMachines
17491759
&& (rogue.rewardRoomsGenerated + machineCount) * gameConst->machinesPerLevelSuppressionMultiplier + gameConst->machinesPerLevelSuppressionOffset < rogue.depthLevel * gameConst->machinesPerLevelIncreaseFactor) {
17501760
// try to build at least one every four levels on average
17511761
machineCount++;

src/brogue/Items.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ static boolean itemIsThrowingWeapon(const item *theItem) {
163163
return false;
164164
}
165165

166+
boolean itemIsHeavyWeapon(const item *theItem) {
167+
if (theItem && theItem->category == WEAPON && !itemIsThrowingWeapon(theItem)
168+
&& weaponTable[theItem->kind].strengthRequired > 15) {
169+
return true;
170+
}
171+
return false;
172+
}
173+
174+
boolean itemIsPositivelyEnchanted(const item *theItem) {
175+
return theItem->enchant1 > 0;
176+
}
177+
166178
// Sets an item to the given type and category (or chooses randomly if -1) with all other stats
167179
item *makeItemInto(item *theItem, unsigned long itemCategory, short itemKind) {
168180
const itemTable *theEntry = NULL;

src/brogue/MainMenu.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -401,18 +401,25 @@ static void chooseGameVariant() {
401401
append(textBuf, tmpBuf, TEXT_MAX_LENGTH);
402402
append(textBuf, "Die faster and more often in this quarter-length version of the classic game!\n\n", TEXT_MAX_LENGTH);
403403

404-
brogueButton buttons[2];
404+
snprintf(tmpBuf, TEXT_MAX_LENGTH, "%sBullet Brogue%s\n", goldColorEscape, whiteColorEscape);
405+
append(textBuf, tmpBuf, TEXT_MAX_LENGTH);
406+
append(textBuf, "No time? Death wish? Bullet Brogue is for you. Not best for new players!\n\n", TEXT_MAX_LENGTH);
407+
408+
brogueButton buttons[3];
405409
initializeMainMenuButton(&(buttons[0]), " %sR%sapid Brogue ", 'r', 'R', NG_NOTHING);
406410
initializeMainMenuButton(&(buttons[1]), " %sB%srogue ", 'b', 'B', NG_NOTHING);
407-
411+
initializeMainMenuButton(&(buttons[2]), " Bu%sl%slet Brogue ", 'l', 'L', NG_NOTHING);
412+
408413
const SavedDisplayBuffer rbuf = saveDisplayBuffer();
409-
gameVariantChoice = printTextBox(textBuf, 20, 7, 45, &white, &black, buttons, 2);
414+
gameVariantChoice = printTextBox(textBuf, 20, 7, 45, &white, &black, buttons, 3);
410415
restoreDisplayBuffer(&rbuf);
411416

412-
if (gameVariantChoice == 1) {
413-
gameVariant = VARIANT_BROGUE;
414-
} else if (gameVariantChoice == 0) {
417+
if (gameVariantChoice == 0) {
415418
gameVariant = VARIANT_RAPID_BROGUE;
419+
} else if (gameVariantChoice == 1) {
420+
gameVariant = VARIANT_BROGUE;
421+
} else if (gameVariantChoice == 2) {
422+
gameVariant = VARIANT_BULLET_BROGUE;
416423
} else {
417424
rogue.nextGame = NG_NOTHING;
418425
}
@@ -689,7 +696,7 @@ boolean dialogChooseFile(char *path, const char *suffix, const char *prompt) {
689696
fileEntry *files;
690697
boolean retval = false, again;
691698
screenDisplayBuffer dbuf;
692-
699+
693700
const color *dialogColor = &interfaceBoxColor;
694701
char *membuf;
695702
char fileDate [11];
@@ -881,7 +888,7 @@ typedef struct gameStats {
881888
int currentMasteryStreak;
882889
} gameStats;
883890

884-
/// @brief Updates the given stats to include a run
891+
/// @brief Updates the given stats to include a run
885892
/// @param run The run to add
886893
/// @param stats The stats to update
887894
static void addRuntoGameStats(rogueRun *run, gameStats *stats) {
@@ -936,17 +943,17 @@ static void viewGameStats(void) {
936943
gameStats allTimeStats = {0};
937944
gameStats recentStats = {0};
938945

939-
rogueRun *runHistory = loadRunHistory();
946+
rogueRun *runHistory = loadRunHistory();
940947
rogueRun *run = runHistory;
941948

942949
// calculate stats
943950
while (run != NULL) {
944951
if (run->seed != 0) {
945952
addRuntoGameStats(run, &allTimeStats);
946953
addRuntoGameStats(run, &recentStats);
947-
} else { // when seed == 0 the run entry means the player reset their recent stats at this point
954+
} else { // when seed == 0 the run entry means the player reset their recent stats at this point
948955
memset(&recentStats, 0, sizeof(gameStats));
949-
}
956+
}
950957
run = run->nextRun;
951958
}
952959

src/brogue/Monsters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ creature *spawnHorde(short hordeID, pos loc, unsigned long forbiddenFlags, unsig
786786
creature *leader, *preexistingMonst;
787787
boolean tryAgain;
788788

789-
if (rogue.depthLevel > 1 && rand_percent(10)) {
789+
if (rogue.depthLevel > 1 && rand_percent(gameConst->monsterOutOfDepthChance)) {
790790
depth = rogue.depthLevel + rand_range(1, min(5, rogue.depthLevel / 2));
791791
if (depth > gameConst->amuletLevel) {
792792
depth = max(rogue.depthLevel, gameConst->amuletLevel);

src/brogue/Rogue.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ typedef struct windowpos {
198198
enum gameVariant {
199199
VARIANT_BROGUE,
200200
VARIANT_RAPID_BROGUE,
201+
VARIANT_BULLET_BROGUE,
201202
NUMBER_VARIANTS
202203
};
203204

@@ -2379,7 +2380,8 @@ typedef struct gameConstants {
23792380
const int minimumAltarLevel; // how deep before resurrection and commutation altars can be generated
23802381
const int minimumLavaLevel; // how deep before lava can be generated
23812382
const int minimumBrimstoneLevel; // how deep before brimstone can be generated
2382-
const int mutationsOccurAboveLevel; // how deep before monster mutations can be generated
2383+
const int mutationsOccurAboveLevel; // how deep before monster mutations can be generated
2384+
const int monsterOutOfDepthChance; // the percentage chance to use a deeper depth when generating monster hordes
23832385

23842386
const int extraItemsPerLevel; // how many extra items generated per level above vanilla
23852387
const int goldAdjustmentStartDepth; // depth from which gold is adjusted based on generation so far
@@ -2388,6 +2390,7 @@ typedef struct gameConstants {
23882390
const int machinesPerLevelSuppressionOffset; // offset for limiting number of machines generated so far against depth
23892391
const int machinesPerLevelIncreaseFactor; // scale factor for increasing number of machines generated so far against depth
23902392
const int maxLevelForBonusMachines; // deepest level that gets bonus machine generation chance
2393+
const int deepestLevelForMachines; // deepest level where can machines be generated
23912394

23922395
const int playerTransferenceRatio; // player transference heal is (enchant / gameConst->playerTransferenceRatio)
23932396
const int onHitHallucinateDuration; // duration of on-hit hallucination effect on player
@@ -2522,7 +2525,7 @@ typedef struct playerCharacter {
25222525
int gameExitStatusCode; // exit status code indicating if brogue exited successfully or with an error
25232526

25242527
// metered items
2525-
long long foodSpawned; // amount of nutrition units spawned so far this game
2528+
long long foodSpawned; // amount of nutrition units spawned so far this game
25262529
meteredItem *meteredItems;
25272530

25282531
// ring bonuses:
@@ -2594,7 +2597,7 @@ enum machineFeatureFlags {
25942597
MF_ALTERNATIVE_2 = Fl(17), // same as MF_ALTERNATIVE, but provides for a second set of alternatives of which only one will be chosen
25952598
MF_REQUIRE_GOOD_RUNIC = Fl(18), // generated item must be uncursed runic
25962599
MF_MONSTERS_DORMANT = Fl(19), // monsters are dormant, and appear when a dungeon feature with DFF_ACTIVATE_DORMANT_MONSTER spawns on their tile
2597-
// unused = Fl(20), //
2600+
MF_REQUIRE_HEAVY_WEAPON = Fl(20), // requires a positively-enchanted heavy weapon
25982601
MF_BUILD_IN_WALLS = Fl(21), // build in an impassable tile that is adjacent to the interior
25992602
MF_BUILD_ANYWHERE_ON_LEVEL = Fl(22), // build anywhere on the level that is not inside the machine
26002603
MF_REPEAT_UNTIL_NO_PROGRESS = Fl(23), // keep trying to build this feature set until no changes are made
@@ -2737,7 +2740,10 @@ enum machineTypes {
27372740
MT_PARALYSIS_TRAP_HIDDEN_AREA,
27382741
MT_TRICK_STATUE_AREA,
27392742
MT_WORM_AREA,
2740-
MT_SENTINEL_AREA
2743+
MT_SENTINEL_AREA,
2744+
2745+
// Variant-specific machines
2746+
MT_REWARD_HEAVY_OR_RUNIC_WEAPON
27412747
};
27422748

27432749
typedef struct autoGenerator {
@@ -3306,6 +3312,8 @@ extern "C" {
33063312
item *generateItem(unsigned short theCategory, short theKind);
33073313
short chooseKind(const itemTable *theTable, short numKinds);
33083314
item *makeItemInto(item *theItem, unsigned long itemCategory, short itemKind);
3315+
boolean itemIsHeavyWeapon(const item *theItem);
3316+
boolean itemIsPositivelyEnchanted(const item *theItem);
33093317
void updateEncumbrance(void);
33103318
short displayedArmorValue(void);
33113319
short armorValueIfUnenchanted(item *theItem);

src/brogue/RogueMain.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "Globals.h"
2727
#include "GlobalsBrogue.h"
2828
#include "GlobalsRapidBrogue.h"
29+
#include "GlobalsBulletBrogue.h"
2930

3031
#include <time.h>
3132

@@ -38,6 +39,7 @@ int rogueMain() {
3839
void printBrogueVersion() {
3940
printf("Brogue version: %s\n", brogueVersion);
4041
printf("Supports variant (rapid_brogue): %s\n", rapidBrogueVersion);
42+
printf("Supports variant (bullet_brogue): %s\n", bulletBrogueVersion);
4143
}
4244

4345
void executeEvent(rogueEvent *theEvent) {
@@ -174,6 +176,9 @@ void initializeGameVariant() {
174176
case VARIANT_RAPID_BROGUE:
175177
initializeGameVariantRapidBrogue();
176178
break;
179+
case VARIANT_BULLET_BROGUE:
180+
initializeGameVariantBulletBrogue();
181+
break;
177182
default:
178183
initializeGameVariantBrogue();
179184
}

src/platform/main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void printCommandlineHelp() {
3939
#ifdef BROGUE_CURSES
4040
"--term -t run in ncurses-based terminal mode\n"
4141
#endif
42-
"--variant variant_name run a variant game (options: rapid_brogue)\n"
42+
"--variant variant_name run a variant game (options: rapid_brogue, bullet_brogue)\n"
4343
"--stealth -S display stealth range\n"
4444
"--no-effects -E disable color effects\n"
4545
"--wizard -W run in wizard mode, invincible with powerful items\n"
@@ -176,6 +176,9 @@ int main(int argc, char *argv[])
176176
if (!strcmp("rapid_brogue", argv[i + 1])) {
177177
gameVariant = VARIANT_RAPID_BROGUE;
178178
}
179+
if (!strcmp("bullet_brogue", argv[i + 1])) {
180+
gameVariant = VARIANT_BULLET_BROGUE;
181+
}
179182
i++;
180183
continue;
181184
}

0 commit comments

Comments
 (0)