1 | /* |
1 | /* |
2 | * static char *rcsid_monster_c = |
2 | * static char *rcsid_monster_c = |
3 | * "$Id: monster.C,v 1.5 2006/08/30 06:06:27 root Exp $"; |
3 | * "$Id: monster.C,v 1.6 2006/09/03 00:18:42 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
453 | * arch set uses it. |
453 | * arch set uses it. |
454 | */ |
454 | */ |
455 | if ( (op->race != NULL)&& strcmp(op->race,"doppleganger") == 0) |
455 | if ( (op->race != NULL)&& strcmp(op->race,"doppleganger") == 0) |
456 | { |
456 | { |
457 | op->face = enemy->face; |
457 | op->face = enemy->face; |
458 | if (op->name) |
|
|
459 | free_string(op->name); |
|
|
460 | add_refcount(op->name = enemy->name); |
458 | op->name = enemy->name; |
461 | } |
459 | } |
462 | |
460 | |
463 | /* Calculate range information for closest body part - this |
461 | /* Calculate range information for closest body part - this |
464 | * is used for the 'skill' code, which isn't that smart when |
462 | * is used for the 'skill' code, which isn't that smart when |
465 | * it comes to figuring it out - otherwise, giants throw boulders |
463 | * it comes to figuring it out - otherwise, giants throw boulders |
… | |
… | |
769 | * I'm not sure if it really make sense to pre-select spells (events |
767 | * I'm not sure if it really make sense to pre-select spells (events |
770 | * could be different by the time the monster goes again). |
768 | * could be different by the time the monster goes again). |
771 | */ |
769 | */ |
772 | if(head->spellitem==NULL) { |
770 | if(head->spellitem==NULL) { |
773 | if((spell_item=monster_choose_random_spell(head))==NULL) { |
771 | if((spell_item=monster_choose_random_spell(head))==NULL) { |
774 | LOG(llevMonster,"Turned off spells in %s\n",head->name); |
772 | LOG(llevMonster,"Turned off spells in %s\n",&head->name); |
775 | CLEAR_FLAG(head, FLAG_CAST_SPELL); /* Will be turned on when picking up book */ |
773 | CLEAR_FLAG(head, FLAG_CAST_SPELL); /* Will be turned on when picking up book */ |
776 | return 0; |
774 | return 0; |
777 | } |
775 | } |
778 | if (spell_item->type == SPELLBOOK) { |
776 | if (spell_item->type == SPELLBOOK) { |
779 | if (!spell_item->inv) { |
777 | if (!spell_item->inv) { |
780 | LOG(llevError,"spellbook %s does not contain a spell?\n", spell_item->name); |
778 | LOG(llevError,"spellbook %s does not contain a spell?\n", &spell_item->name); |
781 | return 0; |
779 | return 0; |
782 | } |
780 | } |
783 | spell_item=spell_item->inv; |
781 | spell_item=spell_item->inv; |
784 | } |
782 | } |
785 | } |
783 | } |
… | |
… | |
888 | break; |
886 | break; |
889 | } |
887 | } |
890 | |
888 | |
891 | if(!skill && !head->chosen_skill) { |
889 | if(!skill && !head->chosen_skill) { |
892 | LOG(llevDebug,"Error: Monster %s (%d) has FLAG_READY_SKILL without skill.\n", |
890 | LOG(llevDebug,"Error: Monster %s (%d) has FLAG_READY_SKILL without skill.\n", |
893 | head->name,head->count); |
891 | &head->name,head->count); |
894 | CLEAR_FLAG(head, FLAG_READY_SKILL); |
892 | CLEAR_FLAG(head, FLAG_READY_SKILL); |
895 | return 0; |
893 | return 0; |
896 | } |
894 | } |
897 | /* use skill */ |
895 | /* use skill */ |
898 | return do_skill(head, part, head->chosen_skill,dir,NULL); |
896 | return do_skill(head, part, head->chosen_skill,dir,NULL); |
… | |
… | |
960 | |
958 | |
961 | if ( at_least_one ) |
959 | if ( at_least_one ) |
962 | return 0; |
960 | return 0; |
963 | |
961 | |
964 | LOG(llevError,"Error: Monster %s (%d) HAS_READY_RANG() without wand/horn/rod.\n", |
962 | LOG(llevError,"Error: Monster %s (%d) HAS_READY_RANG() without wand/horn/rod.\n", |
965 | head->name,head->count); |
963 | &head->name,head->count); |
966 | CLEAR_FLAG(head, FLAG_READY_RANGE); |
964 | CLEAR_FLAG(head, FLAG_READY_RANGE); |
967 | return 0; |
965 | return 0; |
968 | } |
966 | } |
969 | |
967 | |
970 | int monster_use_bow(object *head, object *part, object *pl, int dir) { |
968 | int monster_use_bow(object *head, object *part, object *pl, int dir) { |
… | |
… | |
1642 | if(enemy->hide && (rv->distance <= 1) && (RANDOM()%100<=hide_discovery)) { |
1640 | if(enemy->hide && (rv->distance <= 1) && (RANDOM()%100<=hide_discovery)) { |
1643 | make_visible(enemy); |
1641 | make_visible(enemy); |
1644 | /* inform players of new status */ |
1642 | /* inform players of new status */ |
1645 | if(enemy->type==PLAYER && player_can_view(enemy,op)) |
1643 | if(enemy->type==PLAYER && player_can_view(enemy,op)) |
1646 | new_draw_info_format(NDI_UNIQUE,0, enemy, |
1644 | new_draw_info_format(NDI_UNIQUE,0, enemy, |
1647 | "You are discovered by %s!",op->name); |
1645 | "You are discovered by %s!",&op->name); |
1648 | return 1; /* detected enemy */ |
1646 | return 1; /* detected enemy */ |
1649 | } |
1647 | } |
1650 | else if (enemy->invisible) { |
1648 | else if (enemy->invisible) { |
1651 | /* Change this around - instead of negating the invisible, just |
1649 | /* Change this around - instead of negating the invisible, just |
1652 | * return true so that the mosnter that managed to detect you can |
1650 | * return true so that the mosnter that managed to detect you can |