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

Comparing deliantra/server/server/spell_attack.C (file contents):
Revision 1.27 by root, Mon Jan 8 01:19:04 2007 UTC vs.
Revision 1.30 by pippijn, Thu Mar 1 12:28:16 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team
6 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 7 *
8 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 * (at your 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 GNU General Public License
19 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 21 *
22 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
23*/ 23 */
24 24
25/* This file contains all the spell attack code. Grouping this code 25/* This file contains all the spell attack code. Grouping this code
26 * together should hopefully make it easier to find the relevent bits 26 * together should hopefully make it easier to find the relevent bits
27 * of code 27 * of code
28 */ 28 */
163 */ 163 */
164 164
165void 165void
166move_bolt (object *op) 166move_bolt (object *op)
167{ 167{
168 object *tmp;
169 int mflags; 168 int mflags;
170 sint16 x, y; 169 sint16 x, y;
171 maptile *m; 170 maptile *m;
172 171
173 if (--op->duration < 0) 172 if (--op->duration < 0)
1483 tmp->update_stats (); 1482 tmp->update_stats ();
1484 return 1; 1483 return 1;
1485 1484
1486} 1485}
1487 1486
1488
1489/********************************************************************** 1487/**********************************************************************
1490 * mood change 1488 * mood change
1491 * Arguably, this may or may not be an attack spell. But since it 1489 * Arguably, this may or may not be an attack spell. But since it
1492 * effects monsters, it seems best to put it into this file 1490 * effects monsters, it seems best to put it into this file
1493 ***********************************************************************/ 1491 ***********************************************************************/
1522 else if (god && !strcmp (spell->race, "GOD_FRIEND")) 1520 else if (god && !strcmp (spell->race, "GOD_FRIEND"))
1523 race = god->race; 1521 race = god->race;
1524 else 1522 else
1525 race = spell->race; 1523 race = spell->race;
1526 1524
1527
1528 for (x = op->x - range; x <= op->x + range; x++) 1525 for (x = op->x - range; x <= op->x + range; x++)
1529 for (y = op->y - range; y <= op->y + range; y++) 1526 for (y = op->y - range; y <= op->y + range; y++)
1530 { 1527 {
1531
1532 done_one = 0; 1528 done_one = 0;
1533 m = op->map; 1529 m = op->map;
1534 nx = x; 1530 nx = x;
1535 ny = y; 1531 ny = y;
1536 mflags = get_map_flags (m, &m, x, y, &nx, &ny); 1532 mflags = get_map_flags (m, &m, x, y, &nx, &ny);
1539 1535
1540 /* If there is nothing living on this space, no need to go further */ 1536 /* If there is nothing living on this space, no need to go further */
1541 if (!(mflags & P_IS_ALIVE)) 1537 if (!(mflags & P_IS_ALIVE))
1542 continue; 1538 continue;
1543 1539
1540 // players can only affect spaces that they can actually see
1541 if (caster && caster->contr
1542 && caster->contr->visibility_at (m, nx, ny) < 70)
1543 continue;
1544
1544 for (tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above) 1545 for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below)
1545 if (QUERY_FLAG (tmp, FLAG_MONSTER)) 1546 if (QUERY_FLAG (tmp, FLAG_MONSTER))
1546 break; 1547 break;
1547 1548
1548 /* There can be living objects that are not monsters */ 1549 /* There can be living objects that are not monsters */
1549 if (!tmp || tmp->type == PLAYER) 1550 if (!tmp || tmp->type == PLAYER)
1556 head = tmp; 1557 head = tmp;
1557 1558
1558 /* Make sure the race is OK. Likewise, only effect undead if spell specifically allows it */ 1559 /* Make sure the race is OK. Likewise, only effect undead if spell specifically allows it */
1559 if (race && head->race && !strstr (race, head->race)) 1560 if (race && head->race && !strstr (race, head->race))
1560 continue; 1561 continue;
1562
1561 if (QUERY_FLAG (head, FLAG_UNDEAD) && !QUERY_FLAG (spell, FLAG_UNDEAD)) 1563 if (QUERY_FLAG (head, FLAG_UNDEAD) && !QUERY_FLAG (spell, FLAG_UNDEAD))
1562 continue; 1564 continue;
1563 1565
1564 /* Now do a bunch of stuff related to saving throws */ 1566 /* Now do a bunch of stuff related to saving throws */
1565 best_at = -1; 1567 best_at = -1;
1602 if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level)))) 1604 if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level))))
1603 /* Failed, no effect */ 1605 /* Failed, no effect */
1604 continue; 1606 continue;
1605 } 1607 }
1606 1608
1607 /* Done with saving throw. Now start effecting the monster */ 1609 /* Done with saving throw. Now start affecting the monster */
1608 1610
1609 /* aggravation */ 1611 /* aggravation */
1610 if (QUERY_FLAG (spell, FLAG_MONSTER)) 1612 if (QUERY_FLAG (spell, FLAG_MONSTER))
1611 { 1613 {
1612 CLEAR_FLAG (head, FLAG_SLEEP); 1614 CLEAR_FLAG (head, FLAG_SLEEP);
1720 * if this has an other_arch field, we insert that in 1722 * if this has an other_arch field, we insert that in
1721 * the surround spaces. 1723 * the surround spaces.
1722 */ 1724 */
1723 for (j = 0; j < 9; j++) 1725 for (j = 0; j < 9; j++)
1724 { 1726 {
1725 object *new_ob;
1726
1727 hx = nx + freearr_x[j]; 1727 hx = nx + freearr_x[j];
1728 hy = ny + freearr_y[j]; 1728 hy = ny + freearr_y[j];
1729 1729
1730 m = op->map; 1730 m = op->map;
1731 mflags = get_map_flags (m, &m, hx, hy, &hx, &hy); 1731 mflags = get_map_flags (m, &m, hx, hy, &hx, &hy);
2107 if (disease->stats.sp) 2107 if (disease->stats.sp)
2108 disease->stats.sp -= dam_mod; 2108 disease->stats.sp -= dam_mod;
2109 2109
2110 if (infect_object (walk, disease, 1)) 2110 if (infect_object (walk, disease, 1))
2111 { 2111 {
2112 object *flash; /* visual effect for inflicting disease */
2113
2114 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); 2112 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name);
2115 2113
2116 disease->destroy (); /* don't need this one anymore */ 2114 disease->destroy (); /* don't need this one anymore */
2117 walk->map->insert (get_archetype (ARCH_DETECT_MAGIC), x, y, op); 2115 walk->map->insert (get_archetype (ARCH_DETECT_MAGIC), x, y, op);
2118 return 1; 2116 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines