changes:: ambush

This commit is contained in:
Zeno Rogue 2020-03-05 18:48:59 +01:00
parent 6e3e9e3eca
commit 75bbbe6b42
2 changed files with 20 additions and 16 deletions

View File

@ -768,7 +768,8 @@ EX int size(cell *c, eItem what) {
} }
EX int ambush(cell *c, eItem what) { EX void ambush(cell *c, eItem what) {
LATE ( ambush(c, what); )
int maxdist = gamerange(); int maxdist = gamerange();
celllister cl(c, maxdist, 1000000, NULL); celllister cl(c, maxdist, 1000000, NULL);
cell *c0 = c; cell *c0 = c;
@ -821,19 +822,24 @@ EX int ambush(cell *c, eItem what) {
int dogs = size(c, what); int dogs = size(c, what);
int gaps = dogs; int gaps = dogs;
if(!N) return dogs0; int result = dogs0;
ambushed = true; if(N) {
int shift = hrand(N); ambushed = true;
dogs = min(dogs, N); int shift = hrand(N);
gaps = min(gaps, N); dogs = min(dogs, N);
for(int i=0; i<dogs; i++) { gaps = min(gaps, N);
int pos = (shift + (N * i) / gaps) % N; for(int i=0; i<dogs; i++) {
cell *nextdog = around[pos]; int pos = (shift + (N * i) / gaps) % N;
nextdog->monst = moHunterDog; cell *nextdog = around[pos];
nextdog->stuntime = 1; nextdog->monst = moHunterDog;
drawFlash(nextdog); nextdog->stuntime = 1;
drawFlash(nextdog);
}
result += dogs;
} }
return dogs + dogs0;
if(result)
addMessage(XLAT("You are ambushed!"));
} }
EX } EX }

View File

@ -80,9 +80,7 @@ EX bool collectItem(cell *c2, bool telekinesis IS(false)) {
} }
if(c2->land == laHunting && c2->item && !inv::activating) { if(c2->land == laHunting && c2->item && !inv::activating) {
int dogs = ambush::ambush(c2, c2->item); ambush::ambush(c2, c2->item);
if(dogs)
addMessage(XLAT("You are ambushed!"));
} }
if(isRevivalOrb(c2->item) && multi::revive_queue.size()) { if(isRevivalOrb(c2->item) && multi::revive_queue.size()) {