version 1.62 | | version 1.63 |
---|
| | |
/* | | /* |
* static char *rcsid_spell_effect_c = | | * static char *rcsid_spell_effect_c = |
* "$Id: spell_effect.c,v 1.62 2001/09/26 21:34:08 garbled Exp $"; | | * "$Id: spell_effect.c,v 1.63 2001/10/15 21:12:08 garbled Exp $"; |
*/ | | */ |
| | |
| | |
| | |
new_draw_info_format(NDI_UNIQUE, 0, op, | | new_draw_info_format(NDI_UNIQUE, 0, op, |
"The %s glows with power.",query_name(wand)); | | "The %s glows with power.",query_name(wand)); |
| | |
wand->stats.food += RANDOM()%spells[wand->stats.sp].charges + 1; | | wand->stats.food += rndm(1, spells[wand->stats.sp].charges); |
if(wand->arch&&QUERY_FLAG(&wand->arch->clone, FLAG_ANIMATE)) | | if(wand->arch&&QUERY_FLAG(&wand->arch->clone, FLAG_ANIMATE)) |
{ | | { |
SET_FLAG(wand, FLAG_ANIMATE); | | SET_FLAG(wand, FLAG_ANIMATE); |
| | |
if (!numat) return; /* no valid matches? if so, return */ | | if (!numat) return; /* no valid matches? if so, return */ |
| | |
/* Next make a choice, and loop through until we get to it */ | | /* Next make a choice, and loop through until we get to it */ |
choice = RANDOM()%numat; | | choice = rndm(0, numat-1); |
for(at = first_archetype ; at != NULL; at = at->next) | | for(at = first_archetype ; at != NULL; at = at->next) |
if(QUERY_FLAG((&at->clone),FLAG_MONSTER) == QUERY_FLAG(op, FLAG_MONSTER) && | | if(QUERY_FLAG((&at->clone),FLAG_MONSTER) == QUERY_FLAG(op, FLAG_MONSTER) && |
at->more == NULL && EDITABLE((&at->clone))) | | at->more == NULL && EDITABLE((&at->clone))) |
| | |
if (difficulty<0) difficulty=0; | | if (difficulty<0) difficulty=0; |
new_ob = get_object(); | | new_ob = get_object(); |
do { | | do { |
choice = RANDOM()%numat; | | choice = rndm(0, numat-1); |
for(at = first_archetype ; at != NULL; at = at->next) { | | for(at = first_archetype ; at != NULL; at = at->next) { |
if(at->clone.type == op->type && !at->clone.invisible && | | if(at->clone.type == op->type && !at->clone.invisible && |
at->clone.value > 0 && at->clone.value < max_value && | | at->clone.value > 0 && at->clone.value < max_value && |
| | |
if(op->nrof && new_ob->nrof) { | | if(op->nrof && new_ob->nrof) { |
new_ob->nrof = op->nrof; | | new_ob->nrof = op->nrof; |
/* decrease the number of items */ | | /* decrease the number of items */ |
if (new_ob->nrof>2) new_ob->nrof -= RANDOM() % (op->nrof/2); | | if (new_ob->nrof>2) new_ob->nrof -= rndm(0, op->nrof/2-1); |
} | | } |
| | |
/* We don't want rings to keep sustenance/hungry status. There are propably | | /* We don't want rings to keep sustenance/hungry status. There are propably |
| | |
|| QUERY_FLAG(op, FLAG_NO_PASS) || op->type == TREASURE) | | || QUERY_FLAG(op, FLAG_NO_PASS) || op->type == TREASURE) |
return; | | return; |
| | |
tmp = RANDOM() % 8; | | tmp = rndm(0, 7); |
if (tmp) polymorph_item(who, op); | | if (tmp) polymorph_item(who, op); |
else polymorph_melt(who, op); | | else polymorph_melt(who, op); |
} | | } |
| | |
| | |
int cast_wow(object *op, int dir, int ability, SpellTypeFrom item) { | | int cast_wow(object *op, int dir, int ability, SpellTypeFrom item) { |
int sp; | | int sp; |
if(!(RANDOM()%4)) | | if(!rndm(0, 3)) |
return cast_cone(op,op,0,10,SP_WOW,spellarch[SP_WOW],0); | | return cast_cone(op,op,0,10,SP_WOW,spellarch[SP_WOW],0); |
do | | do |
sp=RANDOM()%NROFREALSPELLS; | | sp=rndm(0, NROFREALSPELLS-1); |
while (!spells[sp].books); | | while (!spells[sp].books); |
return cast_spell(op,op,dir,sp,ability,item,NULL); | | return cast_spell(op,op,dir,sp,ability,item,NULL); |
} | | } |
| | |
* a no magic spot. | | * a no magic spot. |
*/ | | */ |
if(blocked(op->map,op->x+freearr_x[dir]*dist, op->y+freearr_y[dir]*dist)){ | | if(blocked(op->map,op->x+freearr_x[dir]*dist, op->y+freearr_y[dir]*dist)){ |
int x=RANDOM()%MAP_WIDTH(op->map),y=RANDOM()%MAP_HEIGHT(op->map); | | int x=rndm(0, MAP_WIDTH(op->map)-1),y=rndm(0, MAP_HEIGHT(op->map)-1); |
| | |
if(blocked(op->map,x,y) || blocks_magic(op->map,x,y)) { | | if(blocked(op->map,x,y) || blocks_magic(op->map,x,y)) { |
new_draw_info(NDI_UNIQUE, 0,op,"You cast your spell, but nothing happens.\n"); | | new_draw_info(NDI_UNIQUE, 0,op,"You cast your spell, but nothing happens.\n"); |
| | |
level = ((op->head?op->head->level:SK_level(op)) / 4); | | level = ((op->head?op->head->level:SK_level(op)) / 4); |
if (level >= MAX_PET_MONSTERS) | | if (level >= MAX_PET_MONSTERS) |
level = MAX_PET_MONSTERS - 1; | | level = MAX_PET_MONSTERS - 1; |
switch(RANDOM()%3) { | | switch(rndm(0, 2)) { |
case 0: | | case 0: |
number = priest_num_called[level]; | | number = priest_num_called[level]; |
monster = priest_pet_monsters[level]; | | monster = priest_pet_monsters[level]; |
| | |
cancellation(tmp); | | cancellation(tmp); |
} | | } |
else /* Nullify this object. */ | | else /* Nullify this object. */ |
if(FABS(op->magic)<=(RANDOM()%6)) { | | if(FABS(op->magic)<=(rndm(0, 5))) { |
op->magic=0; | | op->magic=0; |
CLEAR_FLAG(op, FLAG_DAMNED); | | CLEAR_FLAG(op, FLAG_DAMNED); |
CLEAR_FLAG(op, FLAG_CURSED); | | CLEAR_FLAG(op, FLAG_CURSED); |
| | |
else | | else |
value *= 0.9; | | value *= 0.9; |
| | |
if ((obj->value>0) && RANDOM()%30) { | | if ((obj->value>0) && rndm(0, 29)) { |
#ifdef LOSSY_ALCHEMY | | #ifdef LOSSY_ALCHEMY |
int tmp = (value % large->value) / small->value; | | int tmp = (value % large->value) / small->value; |
| | |
*large_nuggets += value/ large->value; | | *large_nuggets += value/ large->value; |
if (tmp) | | if (tmp) |
*small_nuggets += RANDOM() % (tmp + 1); | | *small_nuggets += rndm(1, tmp); |
#else | | #else |
static int value_store; | | static int value_store; |
int count; | | int count; |
| | |
break; | | break; |
} | | } |
case 2: { | | case 2: { |
if(RANDOM()%150 == 0) { | | if(rndm(0, 149) == 0) { |
tmp->stats.hp--; /* weaken the rune */ | | tmp->stats.hp--; /* weaken the rune */ |
if(!tmp->stats.hp) { | | if(!tmp->stats.hp) { |
remove_ob(tmp); | | remove_ob(tmp); |
| | |
| | |
/* next, randomly select a race from the aligned_races string */ | | /* next, randomly select a race from the aligned_races string */ |
if(racenr>1) { | | if(racenr>1) { |
racenr = RANDOM()%racenr; | | racenr = rndm(0, racenr-1); |
strcpy(buf,god->race); | | strcpy(buf,god->race); |
race = strtok(buf,","); | | race = strtok(buf,","); |
for(i=0;i<racenr;i++) | | for(i=0;i<racenr;i++) |
| | |
* a valid entry, assuming nothing is available and quit. | | * a valid entry, assuming nothing is available and quit. |
*/ | | */ |
if (!mon_nr) return NULL; | | if (!mon_nr) return NULL; |
mon_nr = RANDOM() % mon_nr; | | mon_nr = rndm(0, mon_nr-1); |
for(tobl=list->member;tobl;tobl=tobl->next) { | | for(tobl=list->member;tobl;tobl=tobl->next) { |
otmp=tobl->ob; | | otmp=tobl->ob; |
if(!otmp||!QUERY_FLAG(otmp,FLAG_MONSTER)) continue; | | if(!otmp||!QUERY_FLAG(otmp,FLAG_MONSTER)) continue; |
| | |
int ii; | | int ii; |
| | |
for(ii=summon_level-(head->level)-5;ii>0;ii--) { | | for(ii=summon_level-(head->level)-5;ii>0;ii--) { |
switch(RANDOM()%3+1) { | | switch(rndm(1, 3)) { |
case 1: | | case 1: |
head->stats.wc--; | | head->stats.wc--; |
break; | | break; |
| | |
if(victim->stats.exp == 0) continue; | | if(victim->stats.exp == 0) continue; |
def_lev = MAX(1,victim->level); | | def_lev = MAX(1,victim->level); |
atk_lev = MAX(1,op->level); | | atk_lev = MAX(1,op->level); |
if(RANDOM() % atk_lev > def_lev) { | | if(rndm(0, atk_lev-1) > def_lev) { |
| | |
/* make this sucker peaceful. */ | | /* make this sucker peaceful. */ |
victim->stats.dam = 0; | | victim->stats.dam = 0; |