version 1.14 | | version 1.15 |
---|
| | |
/* | | /* |
* static char *rcsid_apply_c = | | * static char *rcsid_apply_c = |
* "$Id: apply.c,v 1.14 2000/05/29 16:31:26 jec Exp $"; | | * "$Id: apply.c,v 1.15 2000/06/09 12:01:46 jec Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
| | |
int manual_apply (object *op, object *tmp, int aflag) | | int manual_apply (object *op, object *tmp, int aflag) |
{ | | { |
if (QUERY_FLAG (tmp, FLAG_UNPAID)) { | | if (QUERY_FLAG (tmp, FLAG_UNPAID) && ! QUERY_FLAG (tmp, FLAG_APPLIED)) { |
if (op->type == PLAYER) { | | if (op->type == PLAYER) { |
new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); | | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); |
return 1; | | return 1; |
| | |
| | |
/* who is the object using the object. | | /* who is the object using the object. |
* op is the object they are using. | | * op is the object they are using. |
* aflags is special flags (0 - normal/toggel, 1=always apply, 2=always unapply | | * aflags is special flags (0 - normal/toggle, AP_APPLY=always apply, |
* (see define.h, AP_* values) | | * AP_UNAPPLY=always unapply). |
| | * |
| | * Optional flags: |
| | * AP_NO_MERGE: don't merge an unapplied object with other objects |
| | * AP_IGNORE_CURSE: unapply cursed items |
| | * |
| | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
* | | * |
* apply_special() doesn't check for unpaid items. | | * apply_special() doesn't check for unpaid items. |
*/ | | */ |
int apply_special(object *who,object *op, int aflags) { /* wear/wield */ | | int apply_special (object *who, object *op, int aflags) |
| | { /* wear/wield */ |
| | int basic_flag = aflags & AP_BASIC_FLAGS; |
object *tmp; | | object *tmp; |
char buf[MAX_BUF]; | | char buf[MAX_BUF]; |
int i; | | int i; |
| | |
| | |
if(QUERY_FLAG(op,FLAG_APPLIED)) { | | if(QUERY_FLAG(op,FLAG_APPLIED)) { |
/* always apply, so no reason to unapply */ | | /* always apply, so no reason to unapply */ |
if (aflags == AP_APPLY) return 0; | | if (basic_flag == AP_APPLY) return 0; |
if (QUERY_FLAG(op, FLAG_CURSED) || QUERY_FLAG(op, FLAG_DAMNED)) | | if ( ! (aflags & AP_IGNORE_CURSE) |
| | && (QUERY_FLAG(op, FLAG_CURSED) || QUERY_FLAG(op, FLAG_DAMNED))) |
{ | | { |
new_draw_info_format(NDI_UNIQUE, 0, who, | | new_draw_info_format(NDI_UNIQUE, 0, who, |
"No matter how hard you try, you just can't\nremove %s.", | | "No matter how hard you try, you just can't\nremove %s.", |
| | |
} | | } |
if (buf[0] != '\0') | | if (buf[0] != '\0') |
new_draw_info(NDI_UNIQUE, 0,who,buf); | | new_draw_info(NDI_UNIQUE, 0,who,buf); |
del_tag = op->count; | | |
tmp=merge_ob(op,NULL); | | |
fix_player(who); | | fix_player(who); |
| | |
| | if ( ! (aflags & AP_NO_MERGE)) { |
| | tag_t del_tag = op->count; |
| | tmp = merge_ob (op, NULL); |
if(who->type==PLAYER) { | | if(who->type==PLAYER) { |
if (tmp) { /* it was merged */ | | if (tmp) { /* it was merged */ |
esrv_del_item (who->contr, del_tag); | | esrv_del_item (who->contr, del_tag); |
| | |
} | | } |
esrv_send_item(who, op); | | esrv_send_item(who, op); |
} | | } |
| | } |
| | |
return 0; | | return 0; |
} | | } |
if (aflags == AP_UNAPPLY) return 0; | | if (basic_flag == AP_UNAPPLY) return 0; |
i=0; | | i=0; |
/* This goes through and checks to see if the player already has something | | /* This goes through and checks to see if the player already has something |
* of that type applied - if so, unapply it. | | * of that type applied - if so, unapply it. |
| | |
| | |
int monster_apply_special (object *who, object *op, int aflags) | | int monster_apply_special (object *who, object *op, int aflags) |
{ | | { |
if (QUERY_FLAG (op, FLAG_UNPAID)) | | if (QUERY_FLAG (op, FLAG_UNPAID) && ! QUERY_FLAG (op, FLAG_APPLIED)) |
return 1; | | return 1; |
return apply_special (who, op, aflags); | | return apply_special (who, op, aflags); |
} | | } |