… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * 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 |
9 | * 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 |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * 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/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
… | |
… | |
338 | if (!on_same_map (ob, owner) && !owner->flag [FLAG_REMOVED]) |
339 | if (!on_same_map (ob, owner) && !owner->flag [FLAG_REMOVED]) |
339 | { |
340 | { |
340 | follow_owner (ob, owner); |
341 | follow_owner (ob, owner); |
341 | return; |
342 | return; |
342 | } |
343 | } |
|
|
344 | |
343 | /* Calculate Direction */ |
345 | /* Calculate Direction */ |
344 | if (owner->type == PLAYER && owner->contr->petmode == pet_sad) |
346 | if (owner->type == PLAYER && owner->contr->petmode == pet_sad) |
345 | { |
347 | { |
346 | /* in S&D mode, if we have no enemy, run randomly about. */ |
348 | /* in S&D mode, if we have no enemy, run randomly about. */ |
347 | for (i = 0; i < 15; i++) |
349 | for (i = 0; i < 15; i++) |
… | |
… | |
363 | struct rv_vector rv; |
365 | struct rv_vector rv; |
364 | |
366 | |
365 | get_rangevector (ob, ob->owner, &rv, 0); |
367 | get_rangevector (ob, ob->owner, &rv, 0); |
366 | dir = rv.direction; |
368 | dir = rv.direction; |
367 | } |
369 | } |
|
|
370 | |
368 | ob->direction = dir; |
371 | ob->direction = dir; |
369 | |
372 | |
370 | /* move_ob returns 0 if the object couldn't move. If that is the |
373 | /* move_ob returns 0 if the object couldn't move. If that is the |
371 | * case, lets do some other work. |
374 | * case, lets do some other work. |
372 | */ |
375 | */ |
… | |
… | |
389 | for (ob2 = GET_MAP_OB (m, dx, dy); ob2 != NULL; ob2 = ob2->above) |
392 | for (ob2 = GET_MAP_OB (m, dx, dy); ob2 != NULL; ob2 = ob2->above) |
390 | { |
393 | { |
391 | object *new_ob; |
394 | object *new_ob; |
392 | |
395 | |
393 | new_ob = ob2->head ? ob2->head : ob2; |
396 | new_ob = ob2->head ? ob2->head : ob2; |
|
|
397 | |
394 | if (new_ob == ob) |
398 | if (new_ob == ob) |
395 | break; |
399 | break; |
|
|
400 | |
396 | if (new_ob == ob->owner) |
401 | if (new_ob == ob->owner) |
397 | return; |
402 | return; |
|
|
403 | |
398 | if (new_ob->owner == ob->owner) |
404 | if (new_ob->owner == ob->owner) |
399 | break; |
405 | break; |
400 | |
406 | |
401 | /* Hmm. Did we try to move into an enemy monster? If so, |
407 | /* Hmm. Did we try to move into an enemy monster? If so, |
402 | * make it our enemy. |
408 | * make it our enemy. |
… | |
… | |
417 | } |
423 | } |
418 | } |
424 | } |
419 | } |
425 | } |
420 | /* Try a different course */ |
426 | /* Try a different course */ |
421 | dir = absdir (dir + 4 - (rndm (5)) - (rndm (5))); |
427 | dir = absdir (dir + 4 - (rndm (5)) - (rndm (5))); |
422 | (void) move_ob (ob, dir, ob); |
428 | move_ob (ob, dir, ob); |
423 | } |
429 | } |
424 | return; |
|
|
425 | } |
430 | } |
426 | |
431 | |
427 | /**************************************************************************** |
432 | /**************************************************************************** |
428 | * |
433 | * |
429 | * GOLEM SPELL CODE |
434 | * GOLEM SPELL CODE |
… | |
… | |
592 | { |
597 | { |
593 | /* for golems with race fields, we don't attack |
598 | /* for golems with race fields, we don't attack |
594 | * aligned races |
599 | * aligned races |
595 | */ |
600 | */ |
596 | |
601 | |
597 | if (victim->race && op->race && strstr (op->race, victim->race)) |
602 | if (victim->race && op->race && op->race.contains (victim->race)) |
598 | { |
603 | { |
599 | if (op->owner) |
604 | if (op->owner) |
600 | new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s avoids damaging %s.", &op->name, &victim->name); |
605 | new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s avoids damaging %s.", &op->name, &victim->name); |
601 | } |
606 | } |
602 | else if (victim == op->owner) |
607 | else if (victim == op->owner) |
… | |
… | |
636 | int |
641 | int |
637 | summon_golem (object *op, object *caster, int dir, object *spob) |
642 | summon_golem (object *op, object *caster, int dir, object *spob) |
638 | { |
643 | { |
639 | object *tmp, *god = NULL; |
644 | object *tmp, *god = NULL; |
640 | archetype *at; |
645 | archetype *at; |
641 | char buf[MAX_BUF]; |
|
|
642 | |
646 | |
643 | /* Because there can be different golem spells, player may want to |
647 | /* Because there can be different golem spells, player may want to |
644 | * 'lose' their old golem. |
648 | * 'lose' their old golem. |
645 | */ |
649 | */ |
646 | if (op->type == PLAYER && op->contr->golem) |
650 | if (op->type == PLAYER && op->contr->golem) |
… | |
… | |
736 | tmp->direction = dir; |
740 | tmp->direction = dir; |
737 | |
741 | |
738 | /* Holy spell - some additional tailoring */ |
742 | /* Holy spell - some additional tailoring */ |
739 | if (god) |
743 | if (god) |
740 | { |
744 | { |
741 | object *tmp2; |
|
|
742 | |
|
|
743 | sprintf (buf, "%s of %s", &spob->name, &god->name); |
745 | char *buf = format ("%s of %s", &spob->name, &god->name); |
744 | buf[0] = toupper (buf[0]); |
746 | buf[0] = toupper (buf[0]); |
745 | |
747 | |
746 | for (tmp2 = tmp; tmp2; tmp2 = tmp2->more) |
748 | for (object *tmp2 = tmp; tmp2; tmp2 = tmp2->more) |
747 | tmp2->name = buf; |
749 | tmp2->name = buf; |
748 | |
750 | |
749 | tmp->attacktype |= god->attacktype; |
751 | tmp->attacktype |= god->attacktype; |
750 | memcpy (tmp->resist, god->resist, sizeof (tmp->resist)); |
752 | memcpy (tmp->resist, god->resist, sizeof (tmp->resist)); |
751 | tmp->race = god->race; |
753 | tmp->race = god->race; |
… | |
… | |
895 | } |
897 | } |
896 | |
898 | |
897 | summon_arch = lasttr->item; |
899 | summon_arch = lasttr->item; |
898 | nrof = lasttr->nrof; |
900 | nrof = lasttr->nrof; |
899 | } |
901 | } |
900 | else if (spell_ob->race && !strcmp (spell_ob->race, "GODCULTMON")) |
902 | else if (spell_ob->race == shstr_GODCULTMON) |
901 | { |
903 | { |
902 | object *god = find_god (determine_god (op)), *mon, *owner; |
904 | object *god = find_god (determine_god (op)), *mon, *owner; |
903 | int summon_level, tries; |
905 | int summon_level, tries; |
904 | |
906 | |
905 | if (!god && ((owner = op->owner) != NULL)) |
907 | if (!god && ((owner = op->owner) != NULL)) |