ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/button.C
(Generate patch)

Comparing deliantra/server/common/button.C (file contents):
Revision 1.7 by root, Sun Sep 10 16:00:23 2006 UTC vs.
Revision 1.9 by root, Wed Sep 13 23:42:23 2006 UTC

1 1
2/* 2/*
3 * static char *rcsid_button_c = 3 * static char *rcsid_button_c =
4 * "$Id: button.C,v 1.7 2006/09/10 16:00:23 root Exp $"; 4 * "$Id: button.C,v 1.9 2006/09/13 23:42:23 root Exp $";
5 */ 5 */
6 6
7/* 7/*
8 CrossFire, A Multiplayer game for X-windows 8 CrossFire, A Multiplayer game for X-windows
9 9
364 return 1; 364 return 1;
365 } 365 }
366 return 0; 366 return 0;
367} 367}
368 368
369
370/* 369/*
371 * operate_altar checks if sacrifice was accepted and removes sacrificed 370 * operate_altar checks if sacrifice was accepted and removes sacrificed
372 * objects. If sacrifice was succeed return 1 else 0. Might be better to 371 * objects. If sacrifice was succeed return 1 else 0. Might be better to
373 * call check_altar_sacrifice (above) than depend on the return value, 372 * call check_altar_sacrifice (above) than depend on the return value,
374 * since operate_altar will remove the sacrifice also. 373 * since operate_altar will remove the sacrifice also.
375 * 374 *
376 * If this function returns 1, '*sacrifice' is modified to point to the 375 * If this function returns 1, '*sacrifice' is modified to point to the
377 * remaining sacrifice, or is set to NULL if the sacrifice was used up. 376 * remaining sacrifice, or is set to NULL if the sacrifice was used up.
378 */ 377 */
379
380int 378int
381operate_altar (object *altar, object **sacrifice) 379operate_altar (object *altar, object **sacrifice)
382{ 380{
383
384 if (!altar->map) 381 if (!altar->map)
385 { 382 {
386 LOG (llevError, "BUG: operate_altar(): altar has no map\n"); 383 LOG (llevError, "BUG: operate_altar(): altar has no map\n");
387 return 0; 384 return 0;
388 } 385 }
401 int number = NROF_SACRIFICE (altar) / (*sacrifice)->value; 398 int number = NROF_SACRIFICE (altar) / (*sacrifice)->value;
402 399
403 /* Round up any sacrifices. Altars don't make change either */ 400 /* Round up any sacrifices. Altars don't make change either */
404 if (NROF_SACRIFICE (altar) % (*sacrifice)->value) 401 if (NROF_SACRIFICE (altar) % (*sacrifice)->value)
405 number++; 402 number++;
403
406 *sacrifice = decrease_ob_nr (*sacrifice, number); 404 *sacrifice = decrease_ob_nr (*sacrifice, number);
407 } 405 }
408 else 406 else
409 *sacrifice = decrease_ob_nr (*sacrifice, NROF_SACRIFICE (altar)); 407 *sacrifice = decrease_ob_nr (*sacrifice, NROF_SACRIFICE (altar));
410 408
411 if (altar->msg) 409 if (altar->msg)
412 new_info_map (NDI_BLACK, altar->map, altar->msg); 410 new_info_map (NDI_BLACK, altar->map, altar->msg);
411
413 return 1; 412 return 1;
414} 413}
415 414
416void 415void
417trigger_move (object *op, int state) /* 1 down and 0 up */ 416trigger_move (object *op, int state) /* 1 down and 0 up */
758 if (!tmp || tmp->type == PLAYER) 757 if (!tmp || tmp->type == PLAYER)
759 return; 758 return;
760 759
761 switch (op->last_sp) 760 switch (op->last_sp)
762 { 761 {
763 case 0: /* furious--make all monsters mad */ 762 case 0: /* furious--make all monsters mad */
764 if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) 763 if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
765 CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); 764 CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE);
766 if (QUERY_FLAG (tmp, FLAG_FRIENDLY)) 765 if (QUERY_FLAG (tmp, FLAG_FRIENDLY))
767 { 766 {
768 CLEAR_FLAG (tmp, FLAG_FRIENDLY); 767 CLEAR_FLAG (tmp, FLAG_FRIENDLY);
769 remove_friendly_object (tmp); 768 remove_friendly_object (tmp);
770 tmp->attack_movement = 0; 769 tmp->attack_movement = 0;
771 /* lots of checks here, but want to make sure we don't 770 /* lots of checks here, but want to make sure we don't
772 * dereference a null value 771 * dereference a null value
773 */ 772 */
774 if (tmp->type == GOLEM && tmp->owner && tmp->owner->type == PLAYER && tmp->owner->contr->ranges[range_golem] == tmp) 773 if (tmp->type == GOLEM && tmp->owner && tmp->owner->type == PLAYER && tmp->owner->contr->ranges[range_golem] == tmp)
775 { 774 {
776 tmp->owner->contr->ranges[range_golem] = NULL; 775 tmp->owner->contr->ranges[range_golem] = NULL;
777 tmp->owner->contr->golem_count = 0; 776 tmp->owner->contr->golem_count = 0;
778 } 777 }
779 tmp->owner = 0; 778 tmp->owner = 0;
780 } 779 }
780 break;
781 case 1: /* angry -- get neutral monsters mad */
782 if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (tmp, FLAG_FRIENDLY))
783 CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE);
784 break;
785 case 2: /* calm -- pacify unfriendly monsters */
786 if (!QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
787 SET_FLAG (tmp, FLAG_UNAGGRESSIVE);
788 break;
789 case 3: /* make all monsters fall asleep */
790 if (!QUERY_FLAG (tmp, FLAG_SLEEP))
791 SET_FLAG (tmp, FLAG_SLEEP);
792 break;
793 case 4: /* charm all monsters */
794 if (op == source)
795 break; /* only if 'connected' */
796
797 for (tmp2 = get_map_ob (source->map, source->x, source->y); /* finding an owner */
798 tmp2->type != PLAYER; tmp2 = tmp2->above)
799 if (tmp2->above == NULL)
800 break;
801
802 if (tmp2->type != PLAYER)
781 break; 803 break;
782 case 1: /* angry -- get neutral monsters mad */
783 if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (tmp, FLAG_FRIENDLY))
784 CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE);
785 break;
786 case 2: /* calm -- pacify unfriendly monsters */
787 if (!QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
788 SET_FLAG (tmp, FLAG_UNAGGRESSIVE);
789 break;
790 case 3: /* make all monsters fall asleep */
791 if (!QUERY_FLAG (tmp, FLAG_SLEEP))
792 SET_FLAG (tmp, FLAG_SLEEP);
793 break;
794 case 4: /* charm all monsters */
795 if (op == source)
796 break; /* only if 'connected' */
797
798 for (tmp2 = get_map_ob (source->map, source->x, source->y); /* finding an owner */
799 tmp2->type != PLAYER; tmp2 = tmp2->above)
800 if (tmp2->above == NULL)
801 break;
802
803 if (tmp2->type != PLAYER)
804 break;
805 set_owner (tmp, tmp2); 804 set_owner (tmp, tmp2);
806 SET_FLAG (tmp, FLAG_MONSTER); 805 SET_FLAG (tmp, FLAG_MONSTER);
807 tmp->stats.exp = 0; 806 tmp->stats.exp = 0;
808 SET_FLAG (tmp, FLAG_FRIENDLY); 807 SET_FLAG (tmp, FLAG_FRIENDLY);
809 add_friendly_object (tmp); 808 add_friendly_object (tmp);
810 tmp->attack_movement = PETMOVE; 809 tmp->attack_movement = PETMOVE;
811 break; 810 break;
812 811
813 default: 812 default:
814 break; 813 break;
815
816 } 814 }
817} 815}
818 816
819/* this function returns the object it matches, or NULL if non. 817/* this function returns the object it matches, or NULL if non.
820 * It will descend through containers to find the object. 818 * It will descend through containers to find the object.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines