From 2bf00395f1955d8e2d0a08b77d0fcfcf5bbbc7e6 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Thu, 29 May 2025 19:04:42 +0100 Subject: [PATCH] Vault guards are more reluctant to turn up if they keep dying This is primarily meant as a fix for a farming strategy, although it also makes sense in terms of the decisions the guards would likely make. --- src/vault.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/vault.c b/src/vault.c index dc95128d0..90157b7fa 100644 --- a/src/vault.c +++ b/src/vault.c @@ -320,12 +320,19 @@ invault(void) struct obj *otmp; boolean spotted; int trycount, vaultroom = (int) vault_occupied(u.urooms); + int vgdeathcount; if (!vaultroom) { u.uinvault = 0; return; } - ++u.uinvault; + /* after a couple of guards don't come back from their trips to + the vault, future guards become more reluctant to turn up (even + if summoned via whistle) */ + vgdeathcount = svm.mvitals[PM_GUARD].died; + if (vgdeathcount < 2 || + (vgdeathcount < 50 && !rn2(vgdeathcount * vgdeathcount))) + ++u.uinvault; if (u.uinvault < VAULT_GUARD_TIME || (u.uinvault % (VAULT_GUARD_TIME / 2)) != 0) return; @@ -409,6 +416,10 @@ invault(void) EGD(guard)->vroom = vaultroom; EGD(guard)->warncnt = 0; + /* ensure the guard doesn't respawn again next turn if killed + immediately */ + ++u.uinvault; + reset_faint(); /* if fainted - wake up */ /* if there are any boulders in the guard's way, destroy them; perhaps the guard knows a touch equivalent of force bolt;