From 421d04e98ebcb8ad352acf8ee5238131e8d2f78e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 29 Feb 2020 03:52:50 +0100 Subject: [PATCH] wandering monsters --- landgen.cpp | 68 +++++++++++++++++++++++++++++--------------------- monstergen.cpp | 19 ++++++++++++++ 2 files changed, 59 insertions(+), 28 deletions(-) diff --git a/landgen.cpp b/landgen.cpp index eaed8d2e..ddd18ad1 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -229,6 +229,44 @@ EX bool is_zebra_trapdoor(cell *c) { return (randomPatternsMode ? RANDPAT : (zebra40(c)&2)); } +EX void gen_eclectic_monster(cell *c) { + cell *c2 = c->move(hrand(c->type)); + if(c2->wall == waRed1 || c2->wall == waRed2 || c2->wall == waRed3) + c->monst = moRedTroll; + + else if(c2->wall == waDeadwall) + c->monst = pick(moMiner, moTroll); + + else if(c2->wall == waSmallTree || c2->wall == waBigTree) + c->monst = moFireFairy; + + else if(c2->wall == waSandstone || c2->wall == waCharged) + c->monst = moMetalBeast, c->hitpoints = 2; + + else if(c2->wall == waPalace) + c->monst = moPalace, c->hitpoints = 2; + + else if(c2->wall == waIcewall) + c->monst = pick(moWolf, moIceGolem); + + else if(c2->wall == waNone && !c2->monst && hrand(100) < 5) { + cell *c1 = c; + c1->monst = moPair; + c2->monst = moPair; + c1->mondir = neighborId(c1, c2); + c2->mondir = neighborId(c2, c1); + } + + else { + + /* more wolves! */ + forCellEx(c3, c) if(c3->wall == waIcewall) { + c->monst = moWolf; + return; + } + } + } + EX void giantLandSwitch(cell *c, int d, cell *from) { bool fargen = d == min(BARLEV, 9); switch(c->land) { @@ -2521,34 +2559,8 @@ EX void giantLandSwitch(cell *c, int d, cell *from) { forCellEx(c1, c) if(!c1->wall) locked = false; if(locked) c->item = itEclectic; - if(c->wall == waNone && hrand_monster(2500) < 30 + items[itEclectic] + yendor::hardness() && !safety) { - cell *c2 = c->move(hrand(c->type)); - if(c2->wall == waRed1 || c2->wall == waRed2 || c2->wall == waRed3) - c->monst = moRedTroll; - - else if(c2->wall == waDeadwall) - c->monst = pick(moMiner, moTroll); - - else if(c2->wall == waSmallTree || c2->wall == waBigTree) - c->monst = moFireFairy; - - else if(c2->wall == waSandstone || c2->wall == waCharged) - c->monst = moMetalBeast, c->hitpoints = 2; - - else if(c2->wall == waPalace) - c->monst = moPalace, c->hitpoints = 2; - - else if(c2->wall == waIcewall) - c->monst = pick(moWolf, moIceGolem); - - else if(c2->wall == waNone && !c2->monst && hrand(100) < 5) { - cell *c1 = c; - c1->monst = moPair; - c2->monst = moPair; - c1->mondir = neighborId(c1, c2); - c2->mondir = neighborId(c2, c1); - } - } + if(c->wall == waNone && hrand_monster(2500) < 30 + items[itEclectic] + yendor::hardness() && !safety) + gen_eclectic_monster(c); } break; diff --git a/monstergen.cpp b/monstergen.cpp index a0d2206b..7ac0b490 100644 --- a/monstergen.cpp +++ b/monstergen.cpp @@ -457,7 +457,22 @@ EX void wandering() { continue; } #endif + + else if(c->land == laFrog && !c->monst && wchance(items[itFrog], 25)) { + eMonster m = pick(moFrog, moPhaser, moVaulter); + if(canReachPlayer(c, m)) { + c->monst = m; + playSeenSound(c); + continue; + } + } + else if(c->land == laWet && among(c->wall, waDeepWater, waShallow) && !c->monst && wchance(items[itWet], 15) && canReachPlayer(c, moShark)) { + c->monst = hrand(100) < 10 ? moRusalka : moPike; + playSeenSound(c); + continue; + } + else if(c->wall == waSea && !c->monst) { if(c->land == laCaribbean && wchance(items[itPirate], 15) && canReachPlayer(c, moPirate)) { c->monst = moCShark; @@ -659,6 +674,10 @@ EX void wandering() { c->hitpoints = 3; } + else if(c->land == laEclectic && wchance(items[itEclectic], 20)) { + gen_eclectic_monster(c); + } + else if(c->land == laCaribbean && wchance(items[itPirate], 30)) c->monst = moPirate;