From 980daa1d8cdf909e6d9b13f3224dba16d74cea93 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Tue, 14 Jun 2016 01:10:33 +1000 Subject: [PATCH] Ensure that Battlemage's initial three spell schools are unique. --- objects.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/objects.c b/objects.c index 2890f1e..6969287 100644 --- a/objects.c +++ b/objects.c @@ -1945,12 +1945,23 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum // select actual random schools to use. for (i = 0; i < nschools; i++) { if (where->owner && hasjob(where->owner, J_BATTLEMAGE)) { - switch (rnd(1,5)) { - case 1: school[i] = SS_FIRE; break; - case 2: school[i] = SS_COLD; break; - case 3: school[i] = SS_AIR; break; - case 4: school[i] = SS_TRANSLOCATION; break; - case 5: school[i] = SS_WILD; break; + int isnew = B_FALSE; + while (!isnew) { + switch (rnd(1,5)) { + case 1: school[i] = SS_FIRE; break; + case 2: school[i] = SS_COLD; break; + case 3: school[i] = SS_AIR; break; + case 4: school[i] = SS_TRANSLOCATION; break; + case 5: school[i] = SS_WILD; break; + } + isnew = B_TRUE; + // make sure it's not a school we already have + for (n = 0; n < i; n++) { + if (school[n] == school[i]) { + isnew = B_FALSE; + break; + } + } } } else if (where->owner && hasjobcat(where->owner, JC_MAGE)) { school[i] = getrandomspellschool(where->owner, B_TRUE);