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.10 by root, Thu Sep 14 22:33:58 2006 UTC

1
2/*
3 * static char *rcsid_button_c =
4 * "$Id: button.C,v 1.7 2006/09/10 16:00:23 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 22*/
29 23
30#include <global.h> 24#include <global.h>
31#include <funcpoint.h> 25#include <funcpoint.h>
32 26
364 return 1; 358 return 1;
365 } 359 }
366 return 0; 360 return 0;
367} 361}
368 362
369
370/* 363/*
371 * operate_altar checks if sacrifice was accepted and removes sacrificed 364 * operate_altar checks if sacrifice was accepted and removes sacrificed
372 * objects. If sacrifice was succeed return 1 else 0. Might be better to 365 * 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, 366 * call check_altar_sacrifice (above) than depend on the return value,
374 * since operate_altar will remove the sacrifice also. 367 * since operate_altar will remove the sacrifice also.
375 * 368 *
376 * If this function returns 1, '*sacrifice' is modified to point to the 369 * 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. 370 * remaining sacrifice, or is set to NULL if the sacrifice was used up.
378 */ 371 */
379
380int 372int
381operate_altar (object *altar, object **sacrifice) 373operate_altar (object *altar, object **sacrifice)
382{ 374{
383
384 if (!altar->map) 375 if (!altar->map)
385 { 376 {
386 LOG (llevError, "BUG: operate_altar(): altar has no map\n"); 377 LOG (llevError, "BUG: operate_altar(): altar has no map\n");
387 return 0; 378 return 0;
388 } 379 }
401 int number = NROF_SACRIFICE (altar) / (*sacrifice)->value; 392 int number = NROF_SACRIFICE (altar) / (*sacrifice)->value;
402 393
403 /* Round up any sacrifices. Altars don't make change either */ 394 /* Round up any sacrifices. Altars don't make change either */
404 if (NROF_SACRIFICE (altar) % (*sacrifice)->value) 395 if (NROF_SACRIFICE (altar) % (*sacrifice)->value)
405 number++; 396 number++;
397
406 *sacrifice = decrease_ob_nr (*sacrifice, number); 398 *sacrifice = decrease_ob_nr (*sacrifice, number);
407 } 399 }
408 else 400 else
409 *sacrifice = decrease_ob_nr (*sacrifice, NROF_SACRIFICE (altar)); 401 *sacrifice = decrease_ob_nr (*sacrifice, NROF_SACRIFICE (altar));
410 402
411 if (altar->msg) 403 if (altar->msg)
412 new_info_map (NDI_BLACK, altar->map, altar->msg); 404 new_info_map (NDI_BLACK, altar->map, altar->msg);
405
413 return 1; 406 return 1;
414} 407}
415 408
416void 409void
417trigger_move (object *op, int state) /* 1 down and 0 up */ 410trigger_move (object *op, int state) /* 1 down and 0 up */
758 if (!tmp || tmp->type == PLAYER) 751 if (!tmp || tmp->type == PLAYER)
759 return; 752 return;
760 753
761 switch (op->last_sp) 754 switch (op->last_sp)
762 { 755 {
763 case 0: /* furious--make all monsters mad */ 756 case 0: /* furious--make all monsters mad */
764 if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) 757 if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
765 CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); 758 CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE);
766 if (QUERY_FLAG (tmp, FLAG_FRIENDLY)) 759 if (QUERY_FLAG (tmp, FLAG_FRIENDLY))
767 { 760 {
768 CLEAR_FLAG (tmp, FLAG_FRIENDLY); 761 CLEAR_FLAG (tmp, FLAG_FRIENDLY);
769 remove_friendly_object (tmp); 762 remove_friendly_object (tmp);
770 tmp->attack_movement = 0; 763 tmp->attack_movement = 0;
771 /* lots of checks here, but want to make sure we don't 764 /* lots of checks here, but want to make sure we don't
772 * dereference a null value 765 * dereference a null value
773 */ 766 */
774 if (tmp->type == GOLEM && tmp->owner && tmp->owner->type == PLAYER && tmp->owner->contr->ranges[range_golem] == tmp) 767 if (tmp->type == GOLEM && tmp->owner && tmp->owner->type == PLAYER && tmp->owner->contr->ranges[range_golem] == tmp)
775 { 768 {
776 tmp->owner->contr->ranges[range_golem] = NULL; 769 tmp->owner->contr->ranges[range_golem] = NULL;
777 tmp->owner->contr->golem_count = 0; 770 tmp->owner->contr->golem_count = 0;
778 } 771 }
779 tmp->owner = 0; 772 tmp->owner = 0;
780 } 773 }
774 break;
775 case 1: /* angry -- get neutral monsters mad */
776 if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (tmp, FLAG_FRIENDLY))
777 CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE);
778 break;
779 case 2: /* calm -- pacify unfriendly monsters */
780 if (!QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
781 SET_FLAG (tmp, FLAG_UNAGGRESSIVE);
782 break;
783 case 3: /* make all monsters fall asleep */
784 if (!QUERY_FLAG (tmp, FLAG_SLEEP))
785 SET_FLAG (tmp, FLAG_SLEEP);
786 break;
787 case 4: /* charm all monsters */
788 if (op == source)
789 break; /* only if 'connected' */
790
791 for (tmp2 = get_map_ob (source->map, source->x, source->y); /* finding an owner */
792 tmp2->type != PLAYER; tmp2 = tmp2->above)
793 if (tmp2->above == NULL)
794 break;
795
796 if (tmp2->type != PLAYER)
781 break; 797 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); 798 set_owner (tmp, tmp2);
806 SET_FLAG (tmp, FLAG_MONSTER); 799 SET_FLAG (tmp, FLAG_MONSTER);
807 tmp->stats.exp = 0; 800 tmp->stats.exp = 0;
808 SET_FLAG (tmp, FLAG_FRIENDLY); 801 SET_FLAG (tmp, FLAG_FRIENDLY);
809 add_friendly_object (tmp); 802 add_friendly_object (tmp);
810 tmp->attack_movement = PETMOVE; 803 tmp->attack_movement = PETMOVE;
811 break; 804 break;
812 805
813 default: 806 default:
814 break; 807 break;
815
816 } 808 }
817} 809}
818 810
819/* this function returns the object it matches, or NULL if non. 811/* this function returns the object it matches, or NULL if non.
820 * It will descend through containers to find the object. 812 * It will descend through containers to find the object.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines