version 1.5 | | version 1.6 |
---|
| | |
| | |
/* | | /* |
* static char *rcs_treasure_c = | | * static char *rcs_treasure_c = |
* "$Id: treasure.c,v 1.5 2000/12/05 04:56:36 cvs Exp $"; | | * "$Id: treasure.c,v 1.6 2000/12/27 07:53:33 cvs Exp $"; |
*/ | | */ |
| | |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
| | Copyright (C) 2000 Mark Wedel |
Copyright (C) 1992 Frank Tore Johansen | | Copyright (C) 1992 Frank Tore Johansen |
| | |
This program is free software; you can redistribute it and/or modify | | This program is free software; you can redistribute it and/or modify |
| | |
along with this program; if not, write to the Free Software | | along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| | |
The author can be reached via e-mail to frankj@ifi.uio.no. | | The author can be reached via e-mail to mwedel@scruz.net |
*/ | | */ |
| | |
#define ALLOWED_COMBINATION | | #define ALLOWED_COMBINATION |
| | |
* this is taken into consideration. | | * this is taken into consideration. |
* The second argument specifies for which object the treasure is | | * The second argument specifies for which object the treasure is |
* being generated. | | * being generated. |
* If flag isn't GT_ENVIRONMENT, monster_check_apply() is called. | | |
* If flag is GT_INVISIBLE, only invisible objects are generated (ie, only | | * If flag is GT_INVISIBLE, only invisible objects are generated (ie, only |
* abilities. This is used by summon spells, thus no summoned monsters | | * abilities. This is used by summon spells, thus no summoned monsters |
* start with equipment, but only their abilities). | | * start with equipment, but only their abilities). |
*/ | | */ |
| | |
| | |
| | static void put_treasure (object *op, object *creator, int flags) |
| | { |
| | object *tmp; |
| | |
| | if (flags & GT_ENVIRONMENT) { |
| | op->x = creator->x; |
| | op->y = creator->y; |
| | insert_ob_in_map_simple (op, creator->map); |
| | } else { |
| | op = insert_ob_in_ob (op, creator); |
| | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
| | (void) (*monster_check_apply_func) (creator, op); |
| | if ((flags & GT_UPDATE_INV) && (tmp = is_player_inv (creator)) != NULL) |
| | (*esrv_send_item_func) (tmp, op); |
| | } |
| | } |
| | |
void create_all_treasures(treasure *t, object *op, int flag, int difficulty, int tries) { | | void create_all_treasures(treasure *t, object *op, int flag, int difficulty, int tries) { |
object *tmp; | | object *tmp; |
| | |
| | |
create_treasure(find_treasurelist(t->name), op, flag, difficulty, tries); | | create_treasure(find_treasurelist(t->name), op, flag, difficulty, tries); |
} | | } |
else { | | else { |
if(t->item->clone.invisible != 0 || flag != GT_INVISIBLE) { | | if(t->item->clone.invisible != 0 || ! (flag & GT_INVISIBLE)) { |
tmp=arch_to_object(t->item); | | tmp=arch_to_object(t->item); |
if(t->nrof&&tmp->nrof<=1) | | if(t->nrof&&tmp->nrof<=1) |
tmp->nrof = RANDOM()%((int) t->nrof) + 1; | | tmp->nrof = RANDOM()%((int) t->nrof) + 1; |
fix_generated_item(tmp,op,difficulty,t->magic); | | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
if(flag != GT_ENVIRONMENT) { | | put_treasure (tmp, op, flag); |
fix_flesh_item(tmp, op); | | |
tmp = insert_ob_in_ob(tmp,op); | | |
(void) (*monster_check_apply_func)(op,tmp); | | |
} else { | | |
tmp->x=op->x,tmp->y=op->y; | | |
insert_ob_in_map(tmp,op->map,NULL); | | |
} | | |
} | | } |
} | | } |
if(t->next_yes!=NULL) | | if(t->next_yes!=NULL) |
| | |
object *tmp=arch_to_object(t->item); | | object *tmp=arch_to_object(t->item); |
if(t->nrof&&tmp->nrof<=1) | | if(t->nrof&&tmp->nrof<=1) |
tmp->nrof = RANDOM()%((int) t->nrof) + 1; | | tmp->nrof = RANDOM()%((int) t->nrof) + 1; |
fix_generated_item(tmp,op,difficulty,t->magic); | | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
if(flag != GT_ENVIRONMENT) { | | put_treasure (tmp, op, flag); |
fix_flesh_item(tmp, op); | | |
tmp = insert_ob_in_ob(tmp,op); | | |
(void) (*monster_check_apply_func)(op,tmp); | | |
} else { | | |
tmp->x=op->x,tmp->y=op->y; | | |
insert_ob_in_map(tmp,op->map,NULL); | | |
} | | |
} | | } |
} | | } |
| | |
| | |
* the given difficulty, and the given max possible bonus. | | * the given difficulty, and the given max possible bonus. |
*/ | | */ |
| | |
void set_magic(int difficulty,object *op, int max_magic) { | | static void set_magic (int difficulty, object *op, int max_magic, int flags) |
| | { |
int i; | | int i; |
i = magic_from_difficulty(difficulty); | | i = magic_from_difficulty(difficulty); |
| | if ((flags & GT_ONLY_GOOD) && i < 0) |
| | i = -i; |
if(i > max_magic) | | if(i > max_magic) |
i = max_magic; | | i = max_magic; |
set_abs_magic(op,i); | | set_abs_magic(op,i); |
| | |
* op->type. Right now, which stuff the creator passes on is object type | | * op->type. Right now, which stuff the creator passes on is object type |
* dependant. I know this is a spagetti manuever, but is there a cleaner | | * dependant. I know this is a spagetti manuever, but is there a cleaner |
* way to do this? b.t. */ | | * way to do this? b.t. */ |
| | /* |
void fix_generated_item(object *op,object *creator,int difficulty, int max_magic) { | | * ! (flags & GT_ENVIRONMENT): |
| | * Automatically calls fix_flesh_item(). |
| | * |
| | * flags & FLAG_STARTEQUIP: |
| | * Sets FLAG_STARTEQIUP on item if appropriate, or clears the item's |
| | * value. |
| | */ |
| | void fix_generated_item (object *op, object *creator, int difficulty, |
| | int max_magic, int flags) |
| | { |
int was_magic = op->magic; | | int was_magic = op->magic; |
| | |
if(!creator||creator->type==op->type) creator=op; /*safety & to prevent polymorphed | | if(!creator||creator->type==op->type) creator=op; /*safety & to prevent polymorphed |
| | |
| | |
if (difficulty<1) difficulty=1; | | if (difficulty<1) difficulty=1; |
if (op->arch == crown_arch) { | | if (op->arch == crown_arch) { |
set_magic(difficulty>25?30:difficulty+5, op, max_magic); | | set_magic(difficulty>25?30:difficulty+5, op, max_magic, flags); |
generate_artifact(op,difficulty); | | generate_artifact(op,difficulty); |
} else { | | } else { |
if(!op->magic && max_magic) | | if(!op->magic && max_magic) |
set_magic(difficulty,op,max_magic); | | set_magic(difficulty,op,max_magic, flags); |
if ((!was_magic && !(RANDOM()%CHANCE_FOR_ARTIFACT)) || op->type == HORN || | | if ((!was_magic && !(RANDOM()%CHANCE_FOR_ARTIFACT)) || op->type == HORN || |
difficulty >= 100000 ) | | difficulty >= 100000 ) |
generate_artifact(op, difficulty); | | generate_artifact(op, difficulty); |
| | |
} | | } |
if(op->arch!=ring_arch&&op->arch!=amulet_arch) /* It's a special artefact!*/ | | if(op->arch!=ring_arch&&op->arch!=amulet_arch) /* It's a special artefact!*/ |
break; | | break; |
if(!(RANDOM()%3)) | | if ( ! (flags & GT_ONLY_GOOD) && ! (RANDOM() % 3)) |
SET_FLAG(op, FLAG_CURSED); | | SET_FLAG(op, FLAG_CURSED); |
set_ring_bonus(op,QUERY_FLAG(op, FLAG_CURSED)?-DICE2:DICE2); | | set_ring_bonus(op,QUERY_FLAG(op, FLAG_CURSED)?-DICE2:DICE2); |
if(op->type!=RING) /* Amulets have only one ability */ | | if(op->type!=RING) /* Amulets have only one ability */ |
| | |
} | | } |
break; | | break; |
case SPELLBOOK: | | case SPELLBOOK: |
if(!strcmp(op->arch->name,"cleric_book")) | | if (op->slaying |
| | && (op->stats.sp = look_up_spell_name (op->slaying)) >= 0) |
| | { |
| | free_string (op->slaying); |
| | op->slaying = NULL; |
| | } |
| | else if(!strcmp(op->arch->name,"cleric_book")) |
do { | | do { |
do | | do |
op->stats.sp=RANDOM()%NROFREALSPELLS; | | op->stats.sp=RANDOM()%NROFREALSPELLS; |
| | |
free_string(op->name); | | free_string(op->name); |
op->name = add_string("potion"); | | op->name = add_string("potion"); |
op->level = spells[op->stats.sp].level/2+ RANDOM()%difficulty + RANDOM()%difficulty; | | op->level = spells[op->stats.sp].level/2+ RANDOM()%difficulty + RANDOM()%difficulty; |
if (RANDOM()%2) | | if ( ! (flags & GT_ONLY_GOOD) && RANDOM() % 2) |
SET_FLAG(op, FLAG_CURSED); | | SET_FLAG(op, FLAG_CURSED); |
} | | } |
| | |
| | if (flags & GT_STARTEQUIP) { |
| | if (op->nrof < 2 && op->type != CONTAINER |
| | && op->type != MONEY && ! QUERY_FLAG (op, FLAG_IS_THROWN)) |
| | SET_FLAG (op, FLAG_STARTEQUIP); |
| | else if (op->type != MONEY) |
| | op->value = 0; |
| | } |
| | |
| | if ( ! (flags & GT_ENVIRONMENT)) |
| | fix_flesh_item (op, creator); |
} | | } |
| | |
/* | | /* |
| | |
free_string(op->msg); | | free_string(op->msg); |
op->msg = add_refcount(change->msg); | | op->msg = add_refcount(change->msg); |
} | | } |
| | |
} | | } |
| | |
static int legal_artifact_combination(object *op, artifact *art) { | | static int legal_artifact_combination(object *op, artifact *art) { |