version 1.23 | | version 1.24 |
---|
| | |
/* | | /* |
* static char *rcsid_apply_c = | | * static char *rcsid_apply_c = |
* "$Id: apply.c,v 1.23 2000/11/14 22:50:33 avogl Exp $"; | | * "$Id: apply.c,v 1.24 2000/12/04 00:40:05 cvs Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
| | |
int apply_potion(object *op, object *tmp) | | int apply_potion(object *op, object *tmp) |
{ | | { |
int got_one=0; | | int got_one=0,i; |
| | object *force; |
| | |
#if 0 | | #if 0 |
/* we now need this to happen */ | | /* we now need this to happen */ |
| | |
} | | } |
depl = present_arch_in_ob(at, op); | | depl = present_arch_in_ob(at, op); |
if (depl!=NULL) { | | if (depl!=NULL) { |
int i; | | |
for (i = 0; i < 7; i++) | | for (i = 0; i < 7; i++) |
if (get_attr_value(&depl->stats, i)) { | | if (get_attr_value(&depl->stats, i)) { |
new_draw_info(NDI_UNIQUE,0,op, restore_msg[i]); | | new_draw_info(NDI_UNIQUE,0,op, restore_msg[i]); |
| | |
} | | } |
/* only players get this */ | | /* only players get this */ |
if(op->type==PLAYER&&tmp->attacktype&AT_GODPOWER) { /* improvement potion */ | | if(op->type==PLAYER&&tmp->attacktype&AT_GODPOWER) { /* improvement potion */ |
int i; | | |
| | |
for(i=1;i<MIN(11,op->level);i++) { | | for(i=1;i<MIN(11,op->level);i++) { |
if (QUERY_FLAG(tmp,FLAG_CURSED) || QUERY_FLAG(tmp,FLAG_DAMNED)) { | | if (QUERY_FLAG(tmp,FLAG_CURSED) || QUERY_FLAG(tmp,FLAG_DAMNED)) { |
| | |
return 1; | | return 1; |
} | | } |
| | |
/* protection/immunity granting potions */ | | |
if(tmp->immune||tmp->protected) { | | |
object *force; | | |
| | |
force=get_archetype("force"); | | |
if(QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) { | | |
force->vulnerable = tmp->immune | tmp->protected; | | |
/* Why set force->type to 0? This makes the result permanent */ | | |
/* force->type = 0; */ | | |
force->stats.food*=10; | | |
} else { | | |
force->immune=tmp->immune; | | |
force->protected=tmp->protected; | | |
} | | |
force->speed_left= -1; | | |
force = insert_ob_in_ob(force,op); | | |
SET_FLAG(force,FLAG_APPLIED); | | |
change_abil(op,force); | | |
decrease_ob(tmp); | | |
return 1; | | |
} | | |
| | |
/* A potion that casts a spell. Healing, restore spellpoint (power potion) | | /* A potion that casts a spell. Healing, restore spellpoint (power potion) |
* and heroism all fit into this category. | | * and heroism all fit into this category. |
| | |
return 1; | | return 1; |
} | | } |
| | |
| | /* Deal with protection potions */ |
| | force=NULL; |
| | for (i=0; i<NROFATTACKS; i++) { |
| | if (tmp->resist[i]) { |
| | if (!force) force=get_archetype("force"); |
| | memcpy(force->resist, tmp->resist, sizeof(tmp->resist)); |
| | break; /* Only need to find one protection since we copy entire batch */ |
| | } |
| | } |
| | /* This is a protection potion */ |
| | if (force) { |
| | /* cursed items last longer */ |
| | if(QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) { |
| | force->stats.food*=10; |
| | } |
| | force->speed_left= -1; |
| | force = insert_ob_in_ob(force,op); |
| | CLEAR_FLAG(tmp, FLAG_APPLIED); |
| | SET_FLAG(force,FLAG_APPLIED); |
| | change_abil(op,force); |
| | decrease_ob(tmp); |
| | return 1; |
| | } |
| | |
/* Only thing left are the stat potions */ | | /* Only thing left are the stat potions */ |
if(op->type==PLAYER) { /* only for players */ | | if(op->type==PLAYER) { /* only for players */ |
if((QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) | | if((QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) |
| | |
| | |
int prepare_weapon(object *op, object *improver, object *weapon) | | int prepare_weapon(object *op, object *improver, object *weapon) |
{ | | { |
int sacrifice_count; | | int sacrifice_count,i; |
char buf[MAX_BUF]; | | char buf[MAX_BUF]; |
| | |
if (weapon->level!=0) { | | if (weapon->level!=0) { |
new_draw_info(NDI_UNIQUE,0,op,"Weapon already prepared."); | | new_draw_info(NDI_UNIQUE,0,op,"Weapon already prepared."); |
return 0; | | return 0; |
} | | } |
/* If someone wants to do a weapon that makes them vulnerable, | | for (i=0; i<NROFATTACKS; i++) |
* let them. | | if (weapon->resist[i]) break; |
| | |
| | /* If we break out, i will be less than nrofattacks, preventing |
| | * improvement of items that already have protections. |
*/ | | */ |
if (weapon->immune || weapon->protected || | | if (i<NROFATTACKS || |
weapon->stats.hp || /* regeneration */ | | weapon->stats.hp || /* regeneration */ |
weapon->stats.sp || /* sp regeneration */ | | weapon->stats.sp || /* sp regeneration */ |
weapon->stats.exp || /* speed */ | | weapon->stats.exp || /* speed */ |
| | |
* the level of the character / 10 -- rounding upish, nor may | | * the level of the character / 10 -- rounding upish, nor may |
* the armour value of the piece of equipment exceed either | | * the armour value of the piece of equipment exceed either |
* the users level or 90) | | * the users level or 90) |
| | * Modified by MSW for partial resistance. Only support |
| | * changing of physical area right now. |
*/ | | */ |
| | |
int improve_armour(object *op, object *improver, object *armour) | | int improve_armour(object *op, object *improver, object *armour) |
{ | | { |
int new_armour; | | int new_armour; |
| | |
new_armour = armour->armour + armour->armour/25 + op->level/20 + 1; | | new_armour = armour->resist[ATNR_PHYSICAL] + armour->resist[ATNR_PHYSICAL]/25 + op->level/20 + 1; |
if (new_armour > 90) | | if (new_armour > 90) |
new_armour = 90; | | new_armour = 90; |
| | |
| | |
return 0; | | return 0; |
} | | } |
| | |
if (new_armour > armour->armour) { | | if (new_armour > armour->resist[ATNR_PHYSICAL]) { |
armour->armour = new_armour; | | armour->resist[ATNR_PHYSICAL] = new_armour; |
armour->weight += armour->weight * 0.05; | | armour->weight += armour->weight * 0.05; |
} else { | | } else { |
new_draw_info(NDI_UNIQUE, 0,op,"The armour value of this equipment"); | | new_draw_info(NDI_UNIQUE, 0,op,"The armour value of this equipment"); |
| | |
object *tmp; | | object *tmp; |
char buf[MAX_BUF]; | | char buf[MAX_BUF]; |
int i; | | int i; |
tag_t del_tag; | | |
| | |
if(who==NULL) { | | if(who==NULL) { |
LOG(llevError,"apply_special() from object without environment.\n"); | | LOG(llevError,"apply_special() from object without environment.\n"); |
| | |
*/ | | */ |
| | |
void eat_special_food(object *who, object *food) { | | void eat_special_food(object *who, object *food) { |
/* matrix for attacks we can gain protection/immunity too from eating | | /* Corresponding spell to cast to get protection to |
* be sure to perserve the ordering between at_type[] and sp_type[]! */ | | * the attactkype. This matches the order of ATNR values |
static int at_type[] = { AT_PHYSICAL, AT_MAGIC, AT_FIRE, AT_ELECTRICITY, | | * in attack.h |
AT_COLD, AT_DRAIN, AT_POISON, AT_SLOW, AT_PARALYZE, AT_CANCELLATION, | | */ |
AT_DEPLETE, AT_FEAR }; | | static int sp_type[NROFATTACKS] = { SP_ARMOUR, SP_PROT_MAGIC, SP_PROT_FIRE, |
static int sp_type[] = { SP_ARMOUR, SP_PROT_MAGIC, SP_PROT_FIRE, | | SP_PROT_ELEC, SP_PROT_COLD, SP_PROT_CONFUSE, -1 /*acid */, |
SP_PROT_ELEC, SP_PROT_COLD, SP_PROT_DRAIN, SP_PROT_POISON, | | SP_PROT_DRAIN, -1 /*weaponmagic*/, -1 /*ghosthit*/, SP_PROT_POISON, |
SP_PROT_SLOW, SP_PROT_PARALYZE, SP_PROT_CANCEL, SP_PROT_DEPLETE, | | SP_PROT_SLOW, SP_PROT_PARALYZE, -1 /* turn undead */, |
SP_HEROISM }; | | -1 /* fear */, SP_PROT_CANCEL, SP_PROT_DEPLETE, -1 /* death*/, |
| | -1 /* chaos */, -1 /*counterspell */, -1 /* godpower */, |
| | -1 /*holyword */, -1 /*blind*/, -1 /*internal */ }; |
| | |
/* matrix for stats we can increase by eating */ | | /* matrix for stats we can increase by eating */ |
int i; | | int i; |
| | |
cast_change_attr(who,who,99,mod_stat[i]); | | cast_change_attr(who,who,99,mod_stat[i]); |
| | |
/* check if we can protect the eater */ | | /* check if we can protect the eater */ |
if(food->protected) | | for (i=0; i<NROFATTACKS; i++) { |
for(i=0; i<(sizeof(at_type)/sizeof(int)); i++) | | if (food->resist[i]>0 && sp_type[i]!=-1) |
if(food->protected&at_type[i]) cast_change_attr(who,who,99,sp_type[i]); | | cast_change_attr(who,who,99,sp_type[i]); |
| | } |
| | |
/* check for hp, sp change */ | | /* check for hp, sp change */ |
if(food->stats.hp!=0) { | | if(food->stats.hp!=0) { |
| | |
} | | } |
| | |
void apply_changes_to_player(object *player, object *change) { | | void apply_changes_to_player(object *player, object *change) { |
object *op; | | |
switch (change->type) { | | switch (change->type) { |
case CLASS: | | case CLASS: |
{ | | { |