version 1.5 | | version 1.6 |
---|
| | |
/* | | /* |
* static char *rcsid_c_range_c = | | * static char *rcsid_c_range_c = |
* "$Id: c_range.c,v 1.5 2001/10/30 02:30:20 michtoen Exp $"; | | * "$Id: c_range.c,v 1.6 2002/07/15 04:57:13 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
Copryight (C) 2000 Mark Wedel | | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
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 mwedel@scruz.net | | The authors can be reached via e-mail at crossfire-devel@real-time.com |
*/ | | */ |
| | |
/* This file deals with range related commands (casting, shooting, | | /* This file deals with range related commands (casting, shooting, |
| | |
| | |
int legal_range(object *op,int r) { | | int legal_range(object *op,int r) { |
int i; | | int i; |
object *tmp; | | |
| | |
switch(r) { | | switch(r) { |
case range_none: /* "Nothing" is always legal */ | | case range_none: /* "Nothing" is always legal */ |
return 1; | | return 1; |
case range_bow: /* bows */ | | case range_bow: |
for (tmp=op->inv; tmp!=NULL; tmp=tmp->below) | | case range_misc: |
if (tmp->type == BOW && QUERY_FLAG(tmp, FLAG_APPLIED)) | | if (op->contr->ranges[r]) return 1; |
return 1; | | else return 0; |
return 0; | | |
case range_magic: /* cast spells */ | | case range_magic: /* cast spells */ |
if (op->contr->nrofknownspells == 0) | | if (op->contr->nrofknownspells == 0) |
return 0; | | return 0; |
| | |
return 1; | | return 1; |
op->contr->chosen_spell = op->contr->known_spells[0]; | | op->contr->chosen_spell = op->contr->known_spells[0]; |
return 1; | | return 1; |
case range_wand: /* use wands */ | | |
for (tmp=op->inv; tmp!=NULL; tmp=tmp->below) | | case range_golem: /* Use scrolls */ |
if (tmp->type == WAND && QUERY_FLAG(tmp, FLAG_APPLIED)) { | | if (op->contr->golem) return 1; |
if (QUERY_FLAG(tmp, FLAG_BEEN_APPLIED) || QUERY_FLAG(tmp, FLAG_IDENTIFIED)) | | |
op->contr->known_spell = 1; | | |
else | | |
op->contr->known_spell = 0; | | |
op->contr->chosen_item_spell=tmp->stats.sp; | | |
return 1; | | |
} | | |
return 0; | | |
case range_rod: | | |
for (tmp=op->inv; tmp!=NULL; tmp=tmp->below) | | |
if (tmp->type == ROD && QUERY_FLAG(tmp, FLAG_APPLIED)) { | | |
if (QUERY_FLAG(tmp,FLAG_BEEN_APPLIED) || QUERY_FLAG(tmp, FLAG_IDENTIFIED)) | | |
op->contr->known_spell = 1; | | |
else | | |
op->contr->known_spell = 0; | | |
op->contr->chosen_item_spell=tmp->stats.sp; | | |
return 1; | | |
} | | |
return 0; | | |
case range_horn: | | |
for (tmp=op->inv; tmp!=NULL; tmp=tmp->below) | | |
if (tmp->type == HORN && QUERY_FLAG(tmp, FLAG_APPLIED)) { | | |
if (QUERY_FLAG(tmp,FLAG_BEEN_APPLIED) || QUERY_FLAG(tmp, FLAG_IDENTIFIED)) | | |
op->contr->known_spell = 1; | | |
else | | |
op->contr->known_spell = 0; | | |
op->contr->chosen_item_spell=tmp->stats.sp; | | |
return 1; | | |
} | | |
return 0; | | |
case range_scroll: /* Use scrolls */ | | |
return 0; | | return 0; |
| | |
case range_skill: | | case range_skill: |
if (op->chosen_skill) | | if (op->chosen_skill) |
return 1; | | return 1; |
else | | else |
return 0; | | return 0; |
} | | } |
| | /* No match above, must not be valid */ |
return 0; | | return 0; |
} | | } |
| | |
void change_spell(object *op,char k) { | | void change_spell(object *op,char k) { |
char buf[MAX_BUF]; | | /* Try disabling this so that the player can switch ranges and |
| | * still keep his golems. There seems to be some ways that |
| | * this currently happens but directly switching to another skill |
| | * by equipping items or the like. |
| | */ |
| | #if 0 |
if(op->contr->golem!=NULL) { | | if(op->contr->golem!=NULL) { |
remove_friendly_object(op->contr->golem); | | remove_friendly_object(op->contr->golem); |
remove_ob(op->contr->golem); | | remove_ob(op->contr->golem); |
free_object(op->contr->golem); | | free_object(op->contr->golem); |
op->contr->golem=NULL; | | op->contr->golem=NULL; |
} | | } |
| | #endif |
| | |
do { | | do { |
op->contr->shoottype += ((k == '+') ? 1 : -1); | | op->contr->shoottype += ((k == '+') ? 1 : -1); |
if(op->contr->shoottype >= range_size) | | if(op->contr->shoottype >= range_size) |
| | |
else if (op->contr->shoottype <= range_bottom) | | else if (op->contr->shoottype <= range_bottom) |
op->contr->shoottype = (rangetype)(range_size-1); | | op->contr->shoottype = (rangetype)(range_size-1); |
} while (!legal_range(op,op->contr->shoottype)); | | } while (!legal_range(op,op->contr->shoottype)); |
| | |
| | /* Legal range has already checked that we have an appropriate item |
| | * that uses the slot, so we don't need to be too careful about |
| | * checking the status of the object. |
| | */ |
switch(op->contr->shoottype) { | | switch(op->contr->shoottype) { |
case range_none: | | case range_none: |
strcpy(buf,"No ranged attack chosen."); | | new_draw_info(NDI_UNIQUE, 0,op, "No ranged attack chosen."); |
break; | | break; |
case range_bow: { | | |
object *tmp; | | case range_golem: |
for (tmp = op->inv; tmp; tmp = tmp->below) | | new_draw_info(NDI_UNIQUE, 0,op, "You regain control of your golem."); |
if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) | | |
break; | | break; |
sprintf (buf, "Switched to %s and %s.", query_name(tmp), | | |
tmp && tmp->race ? tmp->race : "nothing"); | | case range_bow: |
} | | new_draw_info_format(NDI_UNIQUE, 0,op, "Switched to %s and %s.", query_name(op->contr->ranges[range_bow]), |
| | op->contr->ranges[range_bow]->race ? op->contr->ranges[range_bow]->race : "nothing"); |
break; | | break; |
| | |
case range_magic: | | case range_magic: |
sprintf(buf,"Switched to spells (%s).", | | new_draw_info_format(NDI_UNIQUE, 0,op,"Switched to spells (%s).", |
spells[op->contr->chosen_spell].name); | | spells[op->contr->chosen_spell].name); |
break; | | break; |
case range_wand: | | |
sprintf(buf,"Switched to wand (%s).", | | case range_misc: |
op->contr->known_spell ? | | new_draw_info_format(NDI_UNIQUE, 0,op, "Switched to %s.", query_base_name(op->contr->ranges[range_misc], 0)); |
spells[op->contr->chosen_item_spell].name : "unknown"); | | |
break; | | |
case range_rod: | | |
sprintf(buf, "Switched to rod (%s).", | | |
op->contr->known_spell ? | | |
spells[op->contr->chosen_item_spell].name : "unknown"); | | |
break; | | |
case range_horn: | | |
sprintf(buf, "Switched to horn (%s).", | | |
op->contr->known_spell ? | | |
spells[op->contr->chosen_item_spell].name : "unknown"); | | |
break; | | break; |
| | |
case range_skill: | | case range_skill: |
sprintf (buf, "Switched to skill: %s", op->chosen_skill ? | | new_draw_info_format(NDI_UNIQUE, 0,op, "Switched to skill: %s", op->chosen_skill ? |
op->chosen_skill->name : "none"); | | op->chosen_skill->name : "none"); |
break; | | break; |
| | |
default: | | default: |
break; | | break; |
} | | } |
new_draw_info(NDI_UNIQUE, 0,op,buf); | | |
} | | } |
| | |
| | |