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

Comparing deliantra/server/server/pets.C (file contents):
Revision 1.49 by root, Mon Dec 29 07:43:36 2008 UTC vs.
Revision 1.53 by root, Mon Oct 12 14:00:59 2009 UTC

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)
895 } 900 }
896 901
897 summon_arch = lasttr->item; 902 summon_arch = lasttr->item;
898 nrof = lasttr->nrof; 903 nrof = lasttr->nrof;
899 } 904 }
900 else if (spell_ob->race && !strcmp (spell_ob->race, "GODCULTMON")) 905 else if (spell_ob->race == shstr_GODCULTMON)
901 { 906 {
902 object *god = find_god (determine_god (op)), *mon, *owner; 907 object *god = find_god (determine_god (op)), *mon, *owner;
903 int summon_level, tries; 908 int summon_level, tries;
904 909
905 if (!god && ((owner = op->owner) != NULL)) 910 if (!god && ((owner = op->owner) != NULL))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines