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

Comparing deliantra/server/server/attack.C (file contents):
Revision 1.44 by root, Mon Jan 15 15:41:09 2007 UTC vs.
Revision 1.50 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 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 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 to <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23*/ 23 */
24#include <assert.h> 24#include <assert.h>
25#include <global.h> 25#include <global.h>
26#include <living.h> 26#include <living.h>
27#include <material.h> 27#include <material.h>
28#include <skills.h> 28#include <skills.h>
84 materialtype_t *mt; 84 materialtype_t *mt;
85 85
86 if (op->materialname == NULL) 86 if (op->materialname == NULL)
87 { 87 {
88 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) 88 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next)
89 if (op->material & mt->material) 89 if (op->materials & mt->material)
90 break; 90 break;
91 } 91 }
92 else 92 else
93 mt = name_to_material (op->materialname); 93 mt = name_to_material (op->materialname);
94 94
131 saves++; 131 saves++;
132 } 132 }
133 133
134 if (saves == attacks || attacks == 0) 134 if (saves == attacks || attacks == 0)
135 return TRUE; 135 return TRUE;
136
136 if ((saves == 0) || (rndm (1, attacks) > saves)) 137 if (saves == 0 || (rndm (1, attacks) > saves))
137 return FALSE; 138 return FALSE;
139
138 return TRUE; 140 return TRUE;
139} 141}
140 142
141/* This function calls did_make_save_item. It then performs the 143/* This function calls did_make_save_item. It then performs the
142 * appropriate actions to the item (such as burning the item up, 144 * appropriate actions to the item (such as burning the item up,
373 * that weak walls have is_alive set, which prevent objects from 375 * that weak walls have is_alive set, which prevent objects from
374 * passing over/through them. We don't care what type of movement 376 * passing over/through them. We don't care what type of movement
375 * the wall blocks - if it blocks any type of movement, can't be 377 * the wall blocks - if it blocks any type of movement, can't be
376 * destroyed right now. 378 * destroyed right now.
377 */ 379 */
378 else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block) 380 else if (tmp->materialname && op->stats.dam > 0 && !tmp->move_block)
379 { 381 {
380 save_throw_object (tmp, type, op); 382 save_throw_object (tmp, type, op);
381 383
382 if (op->destroyed ()) 384 if (op->destroyed ())
383 break; 385 break;
1086 return 0; 1088 return 0;
1087 } 1089 }
1088 1090
1089 if (dam < 0) 1091 if (dam < 0)
1090 { 1092 {
1091 LOG (llevError, "hit_player_attacktype called with negative damage: %d\n", dam); 1093 LOG (llevError, "hit_player_attacktype called with negative damage %d (hitter %s, target %s)\n", dam, hitter->debug_desc (), op->debug_desc2 ());
1092 return 0; 1094 return 0;
1093 } 1095 }
1094 1096
1095 /* AT_INTERNAL is supposed to do exactly dam. Put a case here so 1097 /* AT_INTERNAL is supposed to do exactly dam. Put a case here so
1096 * people can't mess with that or it otherwise get confused. */ 1098 * people can't mess with that or it otherwise get confused. */
1201 if (tmp->invisible) 1203 if (tmp->invisible)
1202 continue; 1204 continue;
1203 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) 1205 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10))
1204 /* >= 10% acid res. on items will protect these */ 1206 /* >= 10% acid res. on items will protect these */
1205 continue; 1207 continue;
1206 if (!(tmp->material & M_IRON)) 1208 if (!(tmp->materials & M_IRON))
1207 continue; 1209 continue;
1208 if (tmp->magic < -4) /* Let's stop at -5 */ 1210 if (tmp->magic < -4) /* Let's stop at -5 */
1209 continue; 1211 continue;
1210 if (tmp->type == RING 1212 if (tmp->type == RING
1211 /* removed boots and gloves from exclusion list in PR */ 1213 /* removed boots and gloves from exclusion list in PR */
1600 if (owner->type != PLAYER || owner->contr->party == NULL) 1602 if (owner->type != PLAYER || owner->contr->party == NULL)
1601 change_exp (owner, exp, skill, 0); 1603 change_exp (owner, exp, skill, 0);
1602 else 1604 else
1603 { 1605 {
1604 int shares = 0, count = 0; 1606 int shares = 0, count = 0;
1605 player *pl;
1606 partylist *party = owner->contr->party; 1607 partylist *party = owner->contr->party;
1607 1608
1608 add_kill_to_party (party, query_name (owner), query_name (op), exp); 1609 add_kill_to_party (party, query_name (owner), query_name (op), exp);
1609 1610
1610 for_all_players (pl) 1611 for_all_players (pl)
1796 * in case 0>dam>1, we try to "simulate" a float value-effect */ 1797 * in case 0>dam>1, we try to "simulate" a float value-effect */
1797 dam = dam * (100 - op->resist[ATNR_MAGIC]); 1798 dam = dam * (100 - op->resist[ATNR_MAGIC]);
1798 if (dam >= 100) 1799 if (dam >= 100)
1799 dam /= 100; 1800 dam /= 100;
1800 else 1801 else
1801 dam = (dam > (rndm (0, 99))) ? 1 : 0; 1802 dam = (dam > rndm (0, 99)) ? 1 : 0;
1802 } 1803 }
1803 1804
1804 /* AT_CHAOS here is a weapon or monster. Spells are handled by hit_map 1805 /* AT_CHAOS here is a weapon or monster. Spells are handled by hit_map
1805 * If the attacktype still has chaos, shuffle it, then clear the Chaos bit 1806 * If the attacktype still has chaos, shuffle it, then clear the Chaos bit
1806 */ 1807 */
1889 1890
1890 /* basically: maxdam /= area; we try to "simulate" a float 1891 /* basically: maxdam /= area; we try to "simulate" a float
1891 value-effect */ 1892 value-effect */
1892 remainder = 100 * (maxdam % area) / area; 1893 remainder = 100 * (maxdam % area) / area;
1893 maxdam /= area; 1894 maxdam /= area;
1894 if (RANDOM () % 100 < remainder) 1895 if (rndm (100) < remainder)
1895 maxdam++; 1896 maxdam++;
1896 } 1897 }
1897 1898
1898#ifdef ATTACK_DEBUG 1899#ifdef ATTACK_DEBUG
1899 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); 1900 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines