… | |
… | |
33 | * state is a true/false flag that will actiavte objects that have FLAG_ACTIVATE_ON_PUSH/RELEASE set. |
33 | * 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. |
34 | * The activator argument can be 0 or the source object for this activation. |
35 | * the originator is the player or monster who did something. |
35 | * the originator is the player or monster who did something. |
36 | */ |
36 | */ |
37 | static void |
37 | static void |
38 | activate_connection_link (objectlink *ol, bool state, object *activator, object *originator) |
38 | activate_connection_link (objectlink *ol, int state, object *activator, object *originator) |
39 | { |
39 | { |
40 | for (; ol; ol = ol->next) |
40 | for (; ol; ol = ol->next) |
41 | { |
41 | { |
42 | if (!ol->ob) |
42 | if (!ol->ob) |
43 | { |
43 | { |
… | |
… | |
135 | case FIREWALL: |
135 | case FIREWALL: |
136 | if (!QUERY_FLAG (tmp, FLAG_ANIMATE) && tmp->type == FIREWALL) |
136 | if (!QUERY_FLAG (tmp, FLAG_ANIMATE) && tmp->type == FIREWALL) |
137 | move_firewall (tmp); |
137 | move_firewall (tmp); |
138 | else |
138 | else |
139 | { |
139 | { |
140 | if ((tmp->stats.sp += tmp->stats.maxsp) > 8) /* next direction */ |
140 | 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); |
141 | animate_turning (tmp); |
144 | } |
142 | } |
145 | break; |
143 | break; |
146 | |
144 | |
147 | case TELEPORTER: |
145 | case TELEPORTER: |
… | |
… | |
199 | * the connection was 'state' or 'released'. So that you can activate objects |
197 | * the connection was 'state' or 'released'. So that you can activate objects |
200 | * who have FLAG_ACTIVATE_ON_PUSH/RELEASE set properly. |
198 | * who have FLAG_ACTIVATE_ON_PUSH/RELEASE set properly. |
201 | * |
199 | * |
202 | */ |
200 | */ |
203 | void |
201 | void |
204 | maptile::trigger (shstr_tmp id, bool state, object *activator, object *originator) |
202 | maptile::trigger (shstr_tmp id, int state, object *activator, object *originator) |
205 | { |
203 | { |
206 | if (INVOKE_MAP (TRIGGER, this, ARG_STRING (&id), ARG_INT (state), ARG_OBJECT (originator))) |
204 | if (INVOKE_MAP (TRIGGER, this, ARG_STRING (&id), ARG_INT (state), ARG_OBJECT (originator))) |
207 | return; |
205 | return; |
208 | |
206 | |
209 | if (oblinkpt *obp = find_link (id)) |
207 | if (oblinkpt *obp = find_link (id)) |
… | |
… | |
250 | |
248 | |
251 | any_down = any_down || tmp->value; |
249 | any_down = any_down || tmp->value; |
252 | } |
250 | } |
253 | else if (tmp->type == PEDESTAL) |
251 | else if (tmp->type == PEDESTAL) |
254 | { |
252 | { |
|
|
253 | bool is_match = is_match_expr (tmp->slaying); |
255 | tmp->value = 0; |
254 | tmp->value = 0; |
256 | |
255 | |
257 | for (object *ab = tmp->above; ab; ab = ab->above) |
256 | for (object *ab = tmp->above; ab; ab = ab->above) |
258 | { |
257 | { |
259 | object *head = ab->head_ (); |
258 | object *head = ab->head_ (); |
260 | |
259 | |
261 | /* Same note regarding move_type for buttons above apply here. */ |
260 | /* Same note regarding move_type for buttons above apply here. */ |
262 | if (((ab->move_type & tmp->move_on) || ab->move_type == 0) |
261 | if (((ab->move_type & tmp->move_on) || ab->move_type == 0)) |
|
|
262 | if (is_match |
|
|
263 | ? match (tmp->slaying, head, tmp, originator) |
263 | && (head->race == tmp->slaying |
264 | : (head->race == tmp->slaying |
264 | || (head->type == SPECIAL_KEY && head->slaying == tmp->slaying) |
265 | || (head->type == SPECIAL_KEY && head->slaying == tmp->slaying) |
265 | || (tmp->slaying == shstr_player && head->type == PLAYER))) |
266 | || (tmp->slaying == shstr_player && head->type == PLAYER))) |
|
|
267 | { |
266 | tmp->value = 1; |
268 | tmp->value = 1; |
|
|
269 | break; |
|
|
270 | } |
267 | } |
271 | } |
268 | |
272 | |
269 | any_down = any_down || tmp->value; |
273 | any_down = any_down || tmp->value; |
270 | } |
274 | } |
271 | } |
275 | } |
… | |
… | |
319 | * sacrificed. This fixes a bug of trying to put multiple altars/related |
323 | * sacrificed. This fixes a bug of trying to put multiple altars/related |
320 | * objects on the same space that take the same sacrifice. |
324 | * objects on the same space that take the same sacrifice. |
321 | */ |
325 | */ |
322 | |
326 | |
323 | int |
327 | int |
324 | check_altar_sacrifice (const object *altar, const object *sacrifice) |
328 | check_altar_sacrifice (object *altar, object *sacrifice, object *originator) |
325 | { |
329 | { |
|
|
330 | if (sacrifice->flag [FLAG_UNPAID]) |
|
|
331 | return 0; |
|
|
332 | |
|
|
333 | if (is_match_expr (ARCH_SACRIFICE (altar))) |
|
|
334 | return match (ARCH_SACRIFICE (altar), altar, originator); |
|
|
335 | |
326 | if (!QUERY_FLAG (sacrifice, FLAG_ALIVE) |
336 | if (!QUERY_FLAG (sacrifice, FLAG_ALIVE) |
327 | && !QUERY_FLAG (sacrifice, FLAG_IS_LINKED) |
337 | && !QUERY_FLAG (sacrifice, FLAG_IS_LINKED) |
328 | && sacrifice->type != PLAYER) |
338 | && sacrifice->type != PLAYER) |
329 | { |
339 | { |
330 | if (ARCH_SACRIFICE (altar) == shstr_money |
340 | if (ARCH_SACRIFICE (altar) == shstr_money |
… | |
… | |
351 | * |
361 | * |
352 | * If this function returns 1, '*sacrifice' is modified to point to the |
362 | * 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. |
363 | * remaining sacrifice, or is set to NULL if the sacrifice was used up. |
354 | */ |
364 | */ |
355 | int |
365 | int |
356 | operate_altar (object *altar, object **sacrifice) |
366 | operate_altar (object *altar, object **sacrifice, object *originator) |
357 | { |
367 | { |
358 | if (!altar->map) |
368 | if (!altar->map) |
359 | { |
369 | { |
360 | LOG (llevError, "BUG: operate_altar(): altar has no map\n"); |
370 | LOG (llevError, "BUG: operate_altar(): altar has no map\n"); |
361 | return 0; |
371 | return 0; |
362 | } |
372 | } |
363 | |
373 | |
364 | if (!altar->slaying || altar->value) |
374 | if (!altar->slaying || altar->value) |
365 | return 0; |
375 | return 0; |
366 | |
376 | |
367 | if (!check_altar_sacrifice (altar, *sacrifice)) |
377 | if (!check_altar_sacrifice (altar, *sacrifice, originator)) |
368 | return 0; |
378 | return 0; |
369 | |
379 | |
370 | /* check_altar_sacrifice should have already verified that enough money |
380 | /* check_altar_sacrifice should have already verified that enough money |
371 | * has been dropped. |
381 | * has been dropped. |
372 | */ |
382 | */ |
… | |
… | |
421 | * TRIGGER: Returns 1 if handle could be moved, 0 if not. |
431 | * TRIGGER: Returns 1 if handle could be moved, 0 if not. |
422 | * |
432 | * |
423 | * TRIGGER_BUTTON, TRIGGER_PEDESTAL: Returns 0. |
433 | * TRIGGER_BUTTON, TRIGGER_PEDESTAL: Returns 0. |
424 | */ |
434 | */ |
425 | int |
435 | int |
426 | check_trigger (object *op, object *cause) |
436 | check_trigger (object *op, object *cause, object *originator) |
427 | { |
437 | { |
428 | object *tmp; |
438 | object *tmp; |
429 | int push = 0, tot = 0; |
439 | int push = 0, tot = 0; |
430 | int in_movement = op->stats.wc || op->speed; |
440 | int in_movement = op->stats.wc || op->speed; |
431 | |
441 | |
… | |
… | |
509 | if (cause) |
519 | if (cause) |
510 | { |
520 | { |
511 | if (in_movement) |
521 | if (in_movement) |
512 | return 0; |
522 | return 0; |
513 | |
523 | |
514 | if (operate_altar (op, &cause)) |
524 | if (operate_altar (op, &cause)) /* TODO: originator? */ |
515 | { |
525 | { |
516 | if (NUM_ANIMATIONS (op) > 1) |
526 | if (NUM_ANIMATIONS (op) > 1) |
517 | { |
527 | { |
518 | SET_ANIMATION (op, 1); |
528 | SET_ANIMATION (op, 1); |
519 | update_object (op, UP_OBJ_FACE); |
529 | update_object (op, UP_OBJ_FACE); |