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.48 by root, Thu Jan 18 22:20:00 2007 UTC vs.
Revision 1.54 by elmex, Sun Apr 15 15:59:57 2007 UTC

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>
29
30#ifndef __CEXTRACT__
31# include <sproto.h>
32#endif
33
34#include <sounds.h> 29#include <sounds.h>
30#include <sproto.h>
35 31
36typedef struct att_msg_str 32typedef struct att_msg_str
37{ 33{
38 char *msg1; 34 char *msg1;
39 char *msg2; 35 char *msg2;
84 materialtype_t *mt; 80 materialtype_t *mt;
85 81
86 if (op->materialname == NULL) 82 if (op->materialname == NULL)
87 { 83 {
88 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) 84 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next)
89 if (op->material & mt->material) 85 if (op->materials & mt->material)
90 break; 86 break;
91 } 87 }
92 else 88 else
93 mt = name_to_material (op->materialname); 89 mt = name_to_material (op->materialname);
94 90
375 * that weak walls have is_alive set, which prevent objects from 371 * that weak walls have is_alive set, which prevent objects from
376 * passing over/through them. We don't care what type of movement 372 * passing over/through them. We don't care what type of movement
377 * the wall blocks - if it blocks any type of movement, can't be 373 * the wall blocks - if it blocks any type of movement, can't be
378 * destroyed right now. 374 * destroyed right now.
379 */ 375 */
380 else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block) 376 else if (tmp->materialname && op->stats.dam > 0 && !tmp->move_block)
381 { 377 {
382 save_throw_object (tmp, type, op); 378 save_throw_object (tmp, type, op);
383 379
384 if (op->destroyed ()) 380 if (op->destroyed ())
385 break; 381 break;
654 { 650 {
655 i = 4; 651 i = 4;
656 map = hitter->map; 652 map = hitter->map;
657 if (out_of_map (map, hitter->x, hitter->y)) 653 if (out_of_map (map, hitter->x, hitter->y))
658 return; 654 return;
655
659 next = GET_MAP_OB (map, hitter->x, hitter->y); 656 next = GET_MAP_OB (map, hitter->x, hitter->y);
660 if (next) 657 if (next)
661 while (next) 658 while (next)
662 { 659 {
663 if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) 660 if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE))
664 i *= 3; 661 i *= 3;
665 tmp = next; 662 tmp = next;
666 next = tmp->above; 663 next = tmp->above;
667 } 664 }
665
668 if (i < 0) 666 if (i < 0)
669 return; 667 return;
668
670 if (rndm (0, i) != 0) 669 if (rndm (0, i) != 0)
671 return; 670 return;
672 } 671 }
673 else if (rndm (0, 5) != 0) 672 else if (rndm (0, 5) != 0)
674 return; 673 return;
674
675 sprintf (buf, "Your %s%s %s.", &hitter->name, buf2, &op->name); 675 sprintf (buf, "Your %s%s %s.", &hitter->name, buf2, &op->name);
676 play_sound_map (op->map, op->x, op->y, SOUND_PLAYER_HITS4); 676 play_sound_map (op->map, op->x, op->y, SOUND_PLAYER_HITS4);
677 new_draw_info (NDI_BLACK, 0, hitter->owner, buf); 677 new_draw_info (NDI_BLACK, 0, hitter->owner, buf);
678 } 678 }
679} 679}
1203 if (tmp->invisible) 1203 if (tmp->invisible)
1204 continue; 1204 continue;
1205 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) 1205 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10))
1206 /* >= 10% acid res. on items will protect these */ 1206 /* >= 10% acid res. on items will protect these */
1207 continue; 1207 continue;
1208 if (!(tmp->material & M_IRON)) 1208 if (!(tmp->materials & M_IRON))
1209 continue; 1209 continue;
1210 if (tmp->magic < -4) /* Let's stop at -5 */ 1210 if (tmp->magic < -4) /* Let's stop at -5 */
1211 continue; 1211 continue;
1212 if (tmp->type == RING 1212 if (tmp->type == RING
1213 /* removed boots and gloves from exclusion list in PR */ 1213 /* removed boots and gloves from exclusion list in PR */
1529 skill = owner->current_weapon->skill; 1529 skill = owner->current_weapon->skill;
1530 else 1530 else
1531 LOG (llevError, "kill_object - unable to find skill that killed monster\n"); 1531 LOG (llevError, "kill_object - unable to find skill that killed monster\n");
1532 1532
1533 /* We have the skill we want to credit to - now find the object this goes 1533 /* We have the skill we want to credit to - now find the object this goes
1534 * to. Make sure skop is an actual skill, and not a skill tool! 1534 * to. Make sure skop is an actual skill, and not a skill tool!
1535 */ 1535 */
1536 if ((!skop || skop->type != SKILL) && skill) 1536 if ((!skop || skop->type != SKILL) && skill)
1537 { 1537 {
1538 int i; 1538 int i;
1539 1539
1602 if (owner->type != PLAYER || owner->contr->party == NULL) 1602 if (owner->type != PLAYER || owner->contr->party == NULL)
1603 change_exp (owner, exp, skill, 0); 1603 change_exp (owner, exp, skill, 0);
1604 else 1604 else
1605 { 1605 {
1606 int shares = 0, count = 0; 1606 int shares = 0, count = 0;
1607 player *pl;
1608 partylist *party = owner->contr->party; 1607 partylist *party = owner->contr->party;
1609 1608
1610 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);
1611 1610
1612 for_all_players (pl) 1611 for_all_players (pl)
1782 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) 1781 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0)
1783 { 1782 {
1784 /* FIXME: If a player is killed by a rune in a door, the 1783 /* FIXME: If a player is killed by a rune in a door, the
1785 * destroyed() check above doesn't return, and might get here. 1784 * destroyed() check above doesn't return, and might get here.
1786 */ 1785 */
1786
1787 /* FIXME: This for example happens when a dead door is on a mover and
1788 gets it's speed_left raised on each mover-tick.
1789 Doors are removed in a kinda funny way by giving them speed and speed_left
1790 and waiting for that to run out.
1791 */
1787 LOG (llevDebug, "victim %s already dead in hit_player()\n", op->debug_desc ()); 1792 LOG (llevDebug, "victim %s (%d) already dead in hit_player()\n", op->debug_desc (), op->stats.hp);
1788 return 0; 1793 return 0;
1789 } 1794 }
1790 1795
1791#ifdef ATTACK_DEBUG 1796#ifdef ATTACK_DEBUG
1792 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam); 1797 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam);
1916 if (magic && did_make_save (op, op->level, 0)) 1921 if (magic && did_make_save (op, op->level, 0))
1917 maxdam = maxdam / 2; 1922 maxdam = maxdam / 2;
1918 1923
1919 attack_message (maxdam, maxattacktype, op, hitter); 1924 attack_message (maxdam, maxattacktype, op, hitter);
1920 1925
1926 if (op->type == DOOR && maxdam > 0) { LOG (llevDebug, "DOOR WAS HIT: %d BY %s\n", maxdam, hitter->debug_desc ()); }
1921 op->stats.hp -= maxdam; 1927 op->stats.hp -= maxdam;
1922 1928
1923 /* Eneq(@csd.uu.se): Check to see if monster runs away. */ 1929 /* Eneq(@csd.uu.se): Check to see if monster runs away. */
1924 if ((op->stats.hp >= 0) && 1930 if ((op->stats.hp >= 0) &&
1925 (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) && 1931 (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) &&
2190 op->speed_left = (float) -(FABS (op->speed) * max); 2196 op->speed_left = (float) -(FABS (op->speed) * max);
2191 2197
2192/* tmp->stats.food = (signed short) (max/FABS(op->speed)); */ 2198/* tmp->stats.food = (signed short) (max/FABS(op->speed)); */
2193} 2199}
2194 2200
2195
2196/* Attempts to kill 'op'. hitter is the attack object, dam is 2201/* Attempts to kill 'op'. hitter is the attack object, dam is
2197 * the computed damaged. 2202 * the computed damaged.
2198 */ 2203 */
2199void 2204void
2200deathstrike_player (object *op, object *hitter, int *dam) 2205deathstrike_player (object *op, object *hitter, int *dam)
2217 if (def_lev < 1) 2222 if (def_lev < 1)
2218 { 2223 {
2219 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name); 2224 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name);
2220 def_lev = 1; 2225 def_lev = 1;
2221 } 2226 }
2227
2222 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; 2228 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2;
2223 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", 2229 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n",
2224 atk_lev, def_lev); */ 2230 atk_lev, def_lev); */
2225 2231
2226 if (atk_lev >= def_lev) 2232 if (atk_lev >= def_lev)
2241 */ 2247 */
2242 *dam *= kill_lev / def_lev; 2248 *dam *= kill_lev / def_lev;
2243 } 2249 }
2244 } 2250 }
2245 else 2251 else
2246 {
2247 *dam = 0; /* no harm done */ 2252 *dam = 0; /* no harm done */
2248 }
2249} 2253}
2250 2254
2251/* thrown_item_effect() - handles any special effects of thrown 2255/* thrown_item_effect() - handles any special effects of thrown
2252 * items (like attacking living creatures--a potion thrown at a 2256 * items (like attacking living creatures--a potion thrown at a
2253 * monster). 2257 * monster).
2357#endif 2361#endif
2358 2362
2359 return adjust; 2363 return adjust;
2360} 2364}
2361 2365
2362
2363/* determine if the object is an 'aimed' missile */ 2366/* determine if the object is an 'aimed' missile */
2364int 2367int
2365is_aimed_missile (object *op) 2368is_aimed_missile (object *op)
2366{ 2369{
2367 2370
2373 if (op->type == ARROW || op->type == THROWN_OBJ) 2376 if (op->type == ARROW || op->type == THROWN_OBJ)
2374 return 1; 2377 return 1;
2375 else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION)) 2378 else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION))
2376 return 1; 2379 return 1;
2377 } 2380 }
2381
2378 return 0; 2382 return 0;
2379} 2383}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines