1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
|
|
4 | * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
8 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
12 | * option) any later version. |
12 | * |
13 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * GNU General Public License for more details. |
17 | * |
18 | * |
18 | * You should have received a copy of the GNU General Public License |
19 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * and the GNU General Public License along with this program. If not, see |
|
|
21 | * <http://www.gnu.org/licenses/>. |
20 | * |
22 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
24 | */ |
23 | |
25 | |
24 | #include <global.h> |
26 | #include <global.h> |
25 | |
27 | |
… | |
… | |
33 | * state is a true/false flag that will actiavte objects that have FLAG_ACTIVATE_ON_PUSH/RELEASE set. |
35 | * state is a true/false flag that will actiavte objects that have FLAG_ACTIVATE_ON_PUSH/RELEASE set. |
34 | * The activator argument can be 0 or the source object for this activation. |
36 | * The activator argument can be 0 or the source object for this activation. |
35 | * the originator is the player or monster who did something. |
37 | * the originator is the player or monster who did something. |
36 | */ |
38 | */ |
37 | static void |
39 | static void |
38 | activate_connection_link (objectlink *ol, bool state, object *activator, object *originator) |
40 | activate_connection_link (objectlink *ol, int state, object *activator, object *originator) |
39 | { |
41 | { |
40 | for (; ol; ol = ol->next) |
42 | for (; ol; ol = ol->next) |
41 | { |
43 | { |
42 | if (!ol->ob) |
44 | if (!ol->ob) |
43 | { |
45 | { |
… | |
… | |
51 | * is getting moved out of memory, the status of buttons and levers |
53 | * is getting moved out of memory, the status of buttons and levers |
52 | * probably isn't important - it will get sorted out when the map is |
54 | * probably isn't important - it will get sorted out when the map is |
53 | * re-loaded. As such, just exit this function if that is the case. |
55 | * re-loaded. As such, just exit this function if that is the case. |
54 | */ |
56 | */ |
55 | |
57 | |
56 | if (QUERY_FLAG (ol->ob, FLAG_FREED)) |
58 | if (ol->ob->flag [FLAG_FREED]) |
57 | return; |
59 | return; |
58 | |
60 | |
59 | object *tmp = ol->ob; |
61 | object *tmp = ol->ob; |
60 | |
62 | |
61 | /* if the criteria isn't appropriate, don't do anything */ |
63 | /* if the criteria isn't appropriate, don't do anything */ |
62 | if (state && !QUERY_FLAG (tmp, FLAG_ACTIVATE_ON_PUSH)) |
64 | if (state && !tmp->flag [FLAG_ACTIVATE_ON_PUSH]) |
63 | continue; |
65 | continue; |
64 | |
66 | |
65 | if (!state && !QUERY_FLAG (tmp, FLAG_ACTIVATE_ON_RELEASE)) |
67 | if (!state && !tmp->flag [FLAG_ACTIVATE_ON_RELEASE]) |
66 | continue; |
68 | continue; |
67 | |
69 | |
68 | switch (tmp->type) |
70 | switch (tmp->type) |
69 | { |
71 | { |
70 | case GATE: |
72 | case GATE: |
… | |
… | |
75 | : sound_find (tmp->type == GATE ? "trigger_gate" : "trigger_hole")); |
77 | : sound_find (tmp->type == GATE ? "trigger_gate" : "trigger_hole")); |
76 | tmp->value = tmp->stats.maxsp ? !state : state; |
78 | tmp->value = tmp->stats.maxsp ? !state : state; |
77 | tmp->set_speed (0.5); |
79 | tmp->set_speed (0.5); |
78 | break; |
80 | break; |
79 | |
81 | |
80 | case CF_HANDLE: |
82 | case T_HANDLE: |
81 | SET_ANIMATION (tmp, (tmp->value = tmp->stats.maxsp ? !state : state)); |
83 | SET_ANIMATION (tmp, (tmp->value = tmp->stats.maxsp ? !state : state)); |
82 | update_object (tmp, UP_OBJ_FACE); |
84 | update_object (tmp, UP_OBJ_FACE); |
83 | break; |
85 | break; |
84 | |
86 | |
85 | case SIGN: |
87 | case SIGN: |
86 | if (!tmp->stats.food || tmp->last_eat < tmp->stats.food) |
88 | if (!tmp->stats.food || tmp->last_eat < tmp->stats.food) |
87 | { |
89 | { |
88 | tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("trigger_sign")); |
90 | tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("msg_voice")); |
|
|
91 | |
|
|
92 | if (originator && originator->contr) |
|
|
93 | originator->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n%s", &tmp->name, &tmp->msg)); |
|
|
94 | |
89 | new_info_map (NDI_UNIQUE | NDI_NAVY, tmp->map, tmp->msg); |
95 | new_info_map_except (NDI_UNIQUE | NDI_NAVY, tmp->map, originator, tmp->msg); |
|
|
96 | |
90 | if (tmp->stats.food) |
97 | if (tmp->stats.food) |
91 | tmp->last_eat++; |
98 | tmp->last_eat++; |
92 | } |
99 | } |
93 | break; |
100 | break; |
94 | |
101 | |
… | |
… | |
131 | } |
138 | } |
132 | break; |
139 | break; |
133 | |
140 | |
134 | case DIRECTOR: |
141 | case DIRECTOR: |
135 | case FIREWALL: |
142 | case FIREWALL: |
136 | if (!QUERY_FLAG (tmp, FLAG_ANIMATE) && tmp->type == FIREWALL) |
143 | if (!tmp->flag [FLAG_ANIMATE] && tmp->type == FIREWALL) |
137 | move_firewall (tmp); |
144 | move_firewall (tmp); |
138 | else |
145 | else |
139 | { |
146 | { |
140 | if ((tmp->stats.sp += tmp->stats.maxsp) > 8) /* next direction */ |
147 | tmp->stats.sp = absdir (tmp->stats.sp + tmp->stats.maxsp); /* next direction */ |
141 | tmp->stats.sp = ((tmp->stats.sp - 1) % 8) + 1; |
|
|
142 | |
|
|
143 | animate_turning (tmp); |
148 | animate_turning (tmp); |
144 | } |
149 | } |
145 | break; |
150 | break; |
146 | |
151 | |
147 | case TELEPORTER: |
152 | case TELEPORTER: |
… | |
… | |
199 | * the connection was 'state' or 'released'. So that you can activate objects |
204 | * the connection was 'state' or 'released'. So that you can activate objects |
200 | * who have FLAG_ACTIVATE_ON_PUSH/RELEASE set properly. |
205 | * who have FLAG_ACTIVATE_ON_PUSH/RELEASE set properly. |
201 | * |
206 | * |
202 | */ |
207 | */ |
203 | void |
208 | void |
204 | maptile::trigger (shstr_tmp id, bool state, object *activator, object *originator) |
209 | maptile::trigger (shstr_tmp id, int state, object *activator, object *originator) |
205 | { |
210 | { |
206 | if (INVOKE_MAP (TRIGGER, this, ARG_STRING (&id), ARG_INT (state), ARG_OBJECT (originator))) |
211 | if (INVOKE_MAP (TRIGGER, this, ARG_STRING (&id), ARG_INT (state), ARG_OBJECT (originator))) |
207 | return; |
212 | return; |
208 | |
213 | |
209 | if (oblinkpt *obp = find_link (id)) |
214 | if (oblinkpt *obp = find_link (id)) |
… | |
… | |
232 | |
237 | |
233 | object *tmp = ol->ob; |
238 | object *tmp = ol->ob; |
234 | |
239 | |
235 | if (tmp->type == BUTTON) |
240 | if (tmp->type == BUTTON) |
236 | { |
241 | { |
237 | sint32 total = 0; |
242 | weight_t total = 0; |
238 | |
243 | |
239 | for (object *ab = tmp->above; ab; ab = ab->above) |
244 | for (object *ab = tmp->above; ab; ab = ab->above) |
240 | /* Basically, if the move_type matches that on what the |
245 | /* Basically, if the move_type matches that on what the |
241 | * button wants, we count it. The second check is so that |
246 | * button wants, we count it. The second check is so that |
242 | * objects who don't move (swords, etc) will count. Note that |
247 | * objects who don't move (swords, etc) will count. Note that |
… | |
… | |
250 | |
255 | |
251 | any_down = any_down || tmp->value; |
256 | any_down = any_down || tmp->value; |
252 | } |
257 | } |
253 | else if (tmp->type == PEDESTAL) |
258 | else if (tmp->type == PEDESTAL) |
254 | { |
259 | { |
|
|
260 | bool is_match = is_match_expr (tmp->slaying); |
255 | tmp->value = 0; |
261 | tmp->value = 0; |
256 | |
262 | |
257 | for (object *ab = tmp->above; ab; ab = ab->above) |
263 | for (object *ab = tmp->above; ab; ab = ab->above) |
258 | { |
264 | { |
259 | object *head = ab->head_ (); |
265 | object *head = ab->head_ (); |
260 | |
266 | |
261 | /* Same note regarding move_type for buttons above apply here. */ |
267 | /* Same note regarding move_type for buttons above apply here. */ |
262 | if (((ab->move_type & tmp->move_on) || ab->move_type == 0) |
268 | if (((ab->move_type & tmp->move_on) || ab->move_type == 0)) |
|
|
269 | if (is_match |
|
|
270 | ? match (tmp->slaying, head, tmp, originator) |
263 | && (head->race == tmp->slaying |
271 | : (head->race == tmp->slaying |
264 | || (head->type == SPECIAL_KEY && head->slaying == tmp->slaying) |
272 | || (head->type == SPECIAL_KEY && head->slaying == tmp->slaying) |
265 | || (tmp->slaying == shstr_player && head->type == PLAYER))) |
273 | || (tmp->slaying == shstr_player && head->type == PLAYER))) |
|
|
274 | { |
266 | tmp->value = 1; |
275 | tmp->value = 1; |
|
|
276 | break; |
|
|
277 | } |
|
|
278 | } |
|
|
279 | |
|
|
280 | any_down = any_down || tmp->value; |
|
|
281 | } |
|
|
282 | else if (tmp->type == T_MATCH) |
|
|
283 | { |
|
|
284 | tmp->value = 0; |
|
|
285 | |
|
|
286 | for (object *ab = tmp->above; ab; ab = ab->above) |
|
|
287 | { |
|
|
288 | object *head = ab->head_ (); |
|
|
289 | |
|
|
290 | /* Same note regarding move_type for buttons above apply here. */ |
|
|
291 | if (((ab->move_type & tmp->move_on) || ab->move_type == 0)) |
|
|
292 | if (match (tmp->slaying, head, tmp, originator)) |
|
|
293 | { |
|
|
294 | tmp->value = 1; |
|
|
295 | break; |
|
|
296 | } |
267 | } |
297 | } |
268 | |
298 | |
269 | any_down = any_down || tmp->value; |
299 | any_down = any_down || tmp->value; |
270 | } |
300 | } |
271 | } |
301 | } |
… | |
… | |
317 | * |
347 | * |
318 | * 0.93.4: Linked objects (ie, objects that are connected) can not be |
348 | * 0.93.4: Linked objects (ie, objects that are connected) can not be |
319 | * sacrificed. This fixes a bug of trying to put multiple altars/related |
349 | * sacrificed. This fixes a bug of trying to put multiple altars/related |
320 | * objects on the same space that take the same sacrifice. |
350 | * objects on the same space that take the same sacrifice. |
321 | */ |
351 | */ |
322 | |
|
|
323 | int |
352 | int |
324 | check_altar_sacrifice (const object *altar, const object *sacrifice) |
353 | check_altar_sacrifice (object *altar, object *sacrifice, object *originator) |
325 | { |
354 | { |
326 | if (!QUERY_FLAG (sacrifice, FLAG_ALIVE) |
355 | if (sacrifice->flag [FLAG_UNPAID] |
327 | && !QUERY_FLAG (sacrifice, FLAG_IS_LINKED) |
356 | || sacrifice->flag [FLAG_IS_LINKED] |
328 | && sacrifice->type != PLAYER) |
357 | || sacrifice->is_player ()) |
|
|
358 | return 0; |
|
|
359 | |
|
|
360 | if (is_match_expr (ARCH_SACRIFICE (altar))) |
|
|
361 | return match (ARCH_SACRIFICE (altar), sacrifice, altar, originator); |
|
|
362 | |
|
|
363 | if (!sacrifice->flag [FLAG_ALIVE]) |
329 | { |
364 | { |
330 | if (ARCH_SACRIFICE (altar) == shstr_money |
365 | if (ARCH_SACRIFICE (altar) == shstr_money |
331 | && sacrifice->type == MONEY |
366 | && sacrifice->type == MONEY |
332 | && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar)) |
367 | && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar)) |
333 | return 1; |
368 | return 1; |
… | |
… | |
351 | * |
386 | * |
352 | * If this function returns 1, '*sacrifice' is modified to point to the |
387 | * If this function returns 1, '*sacrifice' is modified to point to the |
353 | * remaining sacrifice, or is set to NULL if the sacrifice was used up. |
388 | * remaining sacrifice, or is set to NULL if the sacrifice was used up. |
354 | */ |
389 | */ |
355 | int |
390 | int |
356 | operate_altar (object *altar, object **sacrifice) |
391 | operate_altar (object *altar, object **sacrifice, object *originator) |
357 | { |
392 | { |
358 | if (!altar->map) |
393 | if (!altar->map) |
359 | { |
394 | { |
360 | LOG (llevError, "BUG: operate_altar(): altar has no map\n"); |
395 | LOG (llevError, "BUG: operate_altar(): altar has no map\n"); |
361 | return 0; |
396 | return 0; |
362 | } |
397 | } |
363 | |
398 | |
364 | if (!altar->slaying || altar->value) |
399 | if (!altar->slaying || altar->value) |
365 | return 0; |
400 | return 0; |
366 | |
401 | |
367 | if (!check_altar_sacrifice (altar, *sacrifice)) |
402 | if (!check_altar_sacrifice (altar, *sacrifice, originator)) |
368 | return 0; |
403 | return 0; |
369 | |
404 | |
370 | /* check_altar_sacrifice should have already verified that enough money |
405 | /* check_altar_sacrifice should have already verified that enough money |
371 | * has been dropped. |
406 | * has been dropped. |
372 | */ |
407 | */ |
… | |
… | |
389 | new_info_map (NDI_BLACK, altar->map, altar->msg); |
424 | new_info_map (NDI_BLACK, altar->map, altar->msg); |
390 | |
425 | |
391 | return 1; |
426 | return 1; |
392 | } |
427 | } |
393 | |
428 | |
394 | void |
429 | static void |
395 | trigger_move (object *op, int state, object *originator) /* 1 down and 0 up */ |
430 | trigger_move (object *op, int state, object *originator) /* 1 down and 0 up */ |
396 | { |
431 | { |
397 | op->stats.wc = state; |
432 | op->stats.wc = state; |
398 | |
433 | |
399 | if (state) |
434 | if (state) |
… | |
… | |
421 | * TRIGGER: Returns 1 if handle could be moved, 0 if not. |
456 | * TRIGGER: Returns 1 if handle could be moved, 0 if not. |
422 | * |
457 | * |
423 | * TRIGGER_BUTTON, TRIGGER_PEDESTAL: Returns 0. |
458 | * TRIGGER_BUTTON, TRIGGER_PEDESTAL: Returns 0. |
424 | */ |
459 | */ |
425 | int |
460 | int |
426 | check_trigger (object *op, object *cause) |
461 | check_trigger (object *op, object *cause, object *originator) |
427 | { |
462 | { |
428 | object *tmp; |
463 | object *tmp; |
429 | int push = 0, tot = 0; |
464 | int push = 0, tot = 0; |
430 | int in_movement = op->stats.wc || op->speed; |
465 | int in_movement = op->stats.wc || op->has_active_speed (); |
431 | |
466 | |
432 | switch (op->type) |
467 | switch (op->type) |
433 | { |
468 | { |
434 | case TRIGGER_BUTTON: |
469 | case TRIGGER_BUTTON: |
435 | if (op->weight > 0) |
470 | if (op->weight > 0) |
… | |
… | |
509 | if (cause) |
544 | if (cause) |
510 | { |
545 | { |
511 | if (in_movement) |
546 | if (in_movement) |
512 | return 0; |
547 | return 0; |
513 | |
548 | |
514 | if (operate_altar (op, &cause)) |
549 | if (operate_altar (op, &cause)) /* TODO: originator? */ |
515 | { |
550 | { |
516 | if (NUM_ANIMATIONS (op) > 1) |
551 | if (NUM_ANIMATIONS (op) > 1) |
517 | { |
552 | { |
518 | SET_ANIMATION (op, 1); |
553 | SET_ANIMATION (op, 1); |
519 | update_object (op, UP_OBJ_FACE); |
554 | update_object (op, UP_OBJ_FACE); |
… | |
… | |
527 | op->last_sp = -op->last_sp; |
562 | op->last_sp = -op->last_sp; |
528 | } |
563 | } |
529 | else |
564 | else |
530 | { |
565 | { |
531 | /* for trigger altar with last_sp, the ON/OFF |
566 | /* for trigger altar with last_sp, the ON/OFF |
532 | * status (-> +/- value) is "simulated": |
567 | * status (-> +/- value) is "simulated": |
533 | */ |
568 | */ |
534 | op->value = !op->value; |
569 | op->value = !op->value; |
535 | trigger_move (op, 1, cause); |
570 | trigger_move (op, 1, cause); |
536 | op->last_sp = -op->last_sp; |
571 | op->last_sp = -op->last_sp; |
537 | op->value = !op->value; |
572 | op->value = !op->value; |
… | |
… | |
551 | } |
586 | } |
552 | |
587 | |
553 | /* If trigger_altar has "last_sp > 0" set on the map, |
588 | /* If trigger_altar has "last_sp > 0" set on the map, |
554 | * it will push the connected value only once per sacrifice. |
589 | * it will push the connected value only once per sacrifice. |
555 | * Otherwise (default), the connected value will be |
590 | * Otherwise (default), the connected value will be |
556 | * pushed twice: First by sacrifice, second by reset! -AV |
591 | * pushed twice: First by sacrifice, second by reset! -AV |
557 | */ |
592 | */ |
558 | if (!op->last_sp) |
593 | if (!op->last_sp) |
559 | trigger_move (op, 0, cause); |
594 | trigger_move (op, 0, cause); |
560 | else |
595 | else |
561 | { |
596 | { |
… | |
… | |
704 | return obp; |
739 | return obp; |
705 | |
740 | |
706 | return 0; |
741 | return 0; |
707 | } |
742 | } |
708 | |
743 | |
709 | /* This routine makes monsters who are |
744 | /* This routine makes monsters who are |
710 | * standing on the 'mood floor' change their |
745 | * standing on the 'mood floor' change their |
711 | * disposition if it is different. |
746 | * disposition if it is different. |
712 | * If floor is to be triggered must have |
747 | * If floor is to be triggered must have |
713 | * a speed of zero (default is 1 for all |
748 | * a speed of zero (default is 1 for all |
714 | * but the charm floor type). |
749 | * but the charm floor type). |
715 | * by b.t. thomas@nomad.astro.psu.edu |
750 | * by b.t. thomas@nomad.astro.psu.edu |
716 | */ |
751 | */ |
… | |
… | |
726 | return; |
761 | return; |
727 | |
762 | |
728 | object *tmp; |
763 | object *tmp; |
729 | |
764 | |
730 | for (tmp = ms.top; tmp; tmp = tmp->below) |
765 | for (tmp = ms.top; tmp; tmp = tmp->below) |
731 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
766 | if (tmp->flag [FLAG_MONSTER]) |
732 | break; |
767 | break; |
733 | |
768 | |
734 | /* doesn't effect players, and if there is a player on this space, won't also |
769 | /* doesn't effect players, and if there is a player on this space, won't also |
735 | * be a monster here. |
770 | * be a monster here. |
736 | */ |
771 | */ |
… | |
… | |
739 | return; |
774 | return; |
740 | |
775 | |
741 | switch (op->last_sp) |
776 | switch (op->last_sp) |
742 | { |
777 | { |
743 | case 0: /* furious--make all monsters mad */ |
778 | case 0: /* furious--make all monsters mad */ |
744 | if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) |
779 | if (tmp->flag [FLAG_UNAGGRESSIVE]) |
745 | CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); |
780 | tmp->clr_flag (FLAG_UNAGGRESSIVE); |
746 | |
781 | |
747 | if (QUERY_FLAG (tmp, FLAG_FRIENDLY)) |
782 | if (tmp->flag [FLAG_FRIENDLY]) |
748 | { |
783 | { |
749 | tmp->attack_movement = 0; |
784 | tmp->attack_movement = 0; |
750 | /* lots of checks here, but want to make sure we don't |
785 | /* lots of checks here, but want to make sure we don't |
751 | * dereference a null value |
786 | * dereference a null value |
752 | */ |
787 | */ |
… | |
… | |
761 | remove_friendly_object (tmp); |
796 | remove_friendly_object (tmp); |
762 | } |
797 | } |
763 | break; |
798 | break; |
764 | |
799 | |
765 | case 1: /* angry -- get neutral monsters mad */ |
800 | case 1: /* angry -- get neutral monsters mad */ |
766 | if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (tmp, FLAG_FRIENDLY)) |
801 | if (tmp->flag [FLAG_UNAGGRESSIVE] && !tmp->flag [FLAG_FRIENDLY]) |
767 | CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); |
802 | tmp->clr_flag (FLAG_UNAGGRESSIVE); |
768 | break; |
803 | break; |
769 | |
804 | |
770 | case 2: /* calm -- pacify unfriendly monsters */ |
805 | case 2: /* calm -- pacify unfriendly monsters */ |
771 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
806 | tmp->set_flag (FLAG_UNAGGRESSIVE); |
772 | break; |
807 | break; |
773 | |
808 | |
774 | case 3: /* make all monsters fall asleep */ |
809 | case 3: /* make all monsters fall asleep */ |
775 | SET_FLAG (tmp, FLAG_SLEEP); |
810 | tmp->set_flag (FLAG_SLEEP); |
776 | break; |
811 | break; |
777 | |
812 | |
778 | case 4: /* charm all monsters */ |
813 | case 4: /* charm all monsters */ |
779 | if (op == source) |
814 | if (op == source) |
780 | break; /* only if 'connected' */ |
815 | break; /* only if 'connected' */ |
781 | |
816 | |
782 | if (object *pl = source->ms ().player ()) |
817 | if (object *pl = source->ms ().player ()) |
783 | { |
818 | { |
784 | tmp->set_owner (pl); |
819 | tmp->set_owner (pl); |
785 | SET_FLAG (tmp, FLAG_MONSTER); |
820 | tmp->set_flag (FLAG_MONSTER); |
786 | |
821 | |
787 | tmp->stats.exp = 0; |
822 | tmp->stats.exp = 0; |
788 | |
823 | |
789 | add_friendly_object (tmp); |
824 | add_friendly_object (tmp); |
790 | tmp->attack_movement = PETMOVE; |
825 | tmp->attack_movement = PETMOVE; |
791 | } |
826 | } |
792 | break; |
827 | break; |
793 | |
828 | |
794 | case 6: // kill monsters |
829 | case 6: // kill monsters |
795 | if (!QUERY_FLAG (tmp, FLAG_FRIENDLY)) |
830 | if (!tmp->flag [FLAG_FRIENDLY]) |
796 | break; |
831 | break; |
797 | |
832 | |
798 | // FALL THROUGH |
833 | // FALL THROUGH |
799 | case 5: // kill all alives |
834 | case 5: // kill all alives |
800 | if (!tmp->flag [FLAG_PRECIOUS]) |
835 | if (!tmp->flag [FLAG_PRECIOUS]) |
… | |
… | |
840 | return tmp; |
875 | return tmp; |
841 | } |
876 | } |
842 | return NULL; |
877 | return NULL; |
843 | } |
878 | } |
844 | |
879 | |
845 | /* check_inv(), a function to search the inventory, |
880 | /* check_inv(), a function to search the inventory, |
846 | * of a player and then based on a set of conditions, |
881 | * of a player and then based on a set of conditions, |
847 | * the square will activate connected items. |
882 | * the square will activate connected items. |
848 | * Monsters can't trigger this square (for now) |
883 | * Monsters can't trigger this square (for now) |
849 | * Values are: last_sp = 1/0 obj/no obj triggers |
884 | * Values are: last_sp = 1/0 obj/no obj triggers |
850 | * last_heal = 1/0 remove/dont remove obj if triggered |
885 | * last_heal = 1/0 remove/dont remove obj if triggered |
851 | * -b.t. (thomas@nomad.astro.psu.edu |
886 | * -b.t. (thomas@nomad.astro.psu.edu |
852 | * |
887 | * |
853 | * Tue Dec 19 15:34:00 CET 2006 elmex: changed the function to ignore op |
888 | * Tue Dec 19 15:34:00 CET 2006 elmex: changed the function to ignore op |
854 | * because the check-inventory semantic essentially only applies when |
889 | * because the check-inventory semantic essentially only applies when |
855 | * something is above the inventory checker. |
890 | * something is above the inventory checker. |
856 | * The semantic prior this change was: trigger if something has moved on or off |
891 | * The semantic prior this change was: trigger if something has moved on or off |
… | |
… | |
859 | * away, and then leaves the inventory checker. That would've caused an always-enabled |
894 | * away, and then leaves the inventory checker. That would've caused an always-enabled |
860 | * state in the inventory checker. This won't happen anymore now. |
895 | * state in the inventory checker. This won't happen anymore now. |
861 | * |
896 | * |
862 | * Wed Jan 10 11:34:26 CET 2007 elmex: fixed this function, we now check |
897 | * Wed Jan 10 11:34:26 CET 2007 elmex: fixed this function, we now check |
863 | * whether op is on this mapspace or not, because the value (1|0) depends |
898 | * whether op is on this mapspace or not, because the value (1|0) depends |
864 | * on this information. also make sure to only push_button if op has |
899 | * on this information. also make sure to only push_button if op has |
865 | * a matching item (because when we do a push_button with value=0 timed gates |
900 | * a matching item (because when we do a push_button with value=0 timed gates |
866 | * will still open)! (i hope i got the semantics right this time) |
901 | * will still open)! (i hope i got the semantics right this time) |
867 | * |
902 | * |
868 | */ |
903 | */ |
869 | void |
904 | void |