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.50 by pippijn, Thu Mar 1 12:28:16 2007 UTC vs.
Revision 1.57 by root, Fri Apr 27 17:16:13 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;
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}
1008 insert_ob_in_ob (hitter, container); 1008 insert_ob_in_ob (hitter, container);
1009 } 1009 }
1010 1010
1011 return op; 1011 return op;
1012} 1012}
1013
1014 1013
1015void 1014void
1016tear_down_wall (object *op) 1015tear_down_wall (object *op)
1017{ 1016{
1018 int perc = 0; 1017 int perc = 0;
1438 return maxdam; 1437 return maxdam;
1439 } 1438 }
1440 1439
1441 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) 1440 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER)
1442 { 1441 {
1443 remove_friendly_object (op);
1444
1445 if (op->owner && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op)
1446 op->owner->contr->ranges[range_golem] = 0;
1447
1448 op->destroy (); 1442 op->destroy ();
1449 return maxdam; 1443 return maxdam;
1450 } 1444 }
1451 1445
1452 /* Now lets start dealing with experience we get for killing something */ 1446 /* Now lets start dealing with experience we get for killing something */
1529 skill = owner->current_weapon->skill; 1523 skill = owner->current_weapon->skill;
1530 else 1524 else
1531 LOG (llevError, "kill_object - unable to find skill that killed monster\n"); 1525 LOG (llevError, "kill_object - unable to find skill that killed monster\n");
1532 1526
1533 /* We have the skill we want to credit to - now find the object this goes 1527 /* 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! 1528 * to. Make sure skop is an actual skill, and not a skill tool!
1535 */ 1529 */
1536 if ((!skop || skop->type != SKILL) && skill) 1530 if ((!skop || skop->type != SKILL) && skill)
1537 { 1531 {
1538 int i; 1532 int i;
1539 1533
1670} 1664}
1671 1665
1672/* Find out if this is friendly fire (PVP and attacker is peaceful) or not 1666/* Find out if this is friendly fire (PVP and attacker is peaceful) or not
1673 * Returns 0 this is not friendly fire 1667 * Returns 0 this is not friendly fire
1674 */ 1668 */
1675
1676int 1669int
1677friendly_fire (object *op, object *hitter) 1670friendly_fire (object *op, object *hitter)
1678{ 1671{
1679 object *owner; 1672 object *owner;
1680 int friendlyfire; 1673 int friendlyfire;
1737 object *owner = hitter->owner; 1730 object *owner = hitter->owner;
1738 1731
1739 if (!owner) 1732 if (!owner)
1740 owner = hitter; 1733 owner = hitter;
1741 1734
1742 if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner) 1735 if (owner->type == PLAYER
1736 && (!op_on_battleground (op, 0, 0)
1737 && (op->contr->peaceful || owner->contr->peaceful))
1738 && op != owner)
1743 return 0; 1739 return 0;
1744 } 1740 }
1745#endif 1741#endif
1746 1742
1747 if (body_attack) 1743 if (body_attack)
1781 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) 1777 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0)
1782 { 1778 {
1783 /* FIXME: If a player is killed by a rune in a door, the 1779 /* FIXME: If a player is killed by a rune in a door, the
1784 * destroyed() check above doesn't return, and might get here. 1780 * destroyed() check above doesn't return, and might get here.
1785 */ 1781 */
1782
1783 /* FIXME: This for example happens when a dead door is on a mover and
1784 gets it's speed_left raised on each mover-tick.
1785 Doors are removed in a kinda funny way by giving them speed and speed_left
1786 and waiting for that to run out.
1787 */
1786 LOG (llevDebug, "victim %s already dead in hit_player()\n", op->debug_desc ()); 1788 LOG (llevDebug, "victim %s (%d) already dead in hit_player()\n", op->debug_desc (), op->stats.hp);
1787 return 0; 1789 return 0;
1788 } 1790 }
1789 1791
1790#ifdef ATTACK_DEBUG 1792#ifdef ATTACK_DEBUG
1791 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam); 1793 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam);
1898 1900
1899#ifdef ATTACK_DEBUG 1901#ifdef ATTACK_DEBUG
1900 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); 1902 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam);
1901#endif 1903#endif
1902 1904
1905 // for now, only do this for active objects, otherwise they
1906 // keep a refcount for a long time and I see no usefulness
1907 // for an non-active objetc to know its enemy.
1908 if (op->active)
1903 if (hitter->owner) 1909 if (hitter->owner)
1904 op->enemy = hitter->owner; 1910 op->enemy = hitter->owner;
1905 else if (QUERY_FLAG (hitter, FLAG_ALIVE)) 1911 else if (QUERY_FLAG (hitter, FLAG_ALIVE))
1906 op->enemy = hitter; 1912 op->enemy = hitter;
1907 1913
1908 if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) 1914 if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER)
1909 { 1915 {
1910 /* The unaggressives look after themselves 8) */ 1916 /* The unaggressives look after themselves 8) */
1911 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE); 1917 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE);
1948 /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note 1954 /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note
1949 * that before if the player was immune to ghosthit, the monster 1955 * that before if the player was immune to ghosthit, the monster
1950 * remained - that is no longer the case. 1956 * remained - that is no longer the case.
1951 */ 1957 */
1952 if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) 1958 if (QUERY_FLAG (hitter, FLAG_ONE_HIT))
1953 {
1954 if (QUERY_FLAG (hitter, FLAG_FRIENDLY))
1955 remove_friendly_object (hitter);
1956
1957 hitter->destroy (); 1959 hitter->destroy ();
1958 } 1960
1959 /* Lets handle creatures that are splitting now */ 1961 /* Lets handle creatures that are splitting now */
1960 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) 1962 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING))
1961 { 1963 {
1962 int i; 1964 int i;
1963 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); 1965 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY);
2189 op->speed_left = (float) -(FABS (op->speed) * max); 2191 op->speed_left = (float) -(FABS (op->speed) * max);
2190 2192
2191/* tmp->stats.food = (signed short) (max/FABS(op->speed)); */ 2193/* tmp->stats.food = (signed short) (max/FABS(op->speed)); */
2192} 2194}
2193 2195
2194
2195/* Attempts to kill 'op'. hitter is the attack object, dam is 2196/* Attempts to kill 'op'. hitter is the attack object, dam is
2196 * the computed damaged. 2197 * the computed damaged.
2197 */ 2198 */
2198void 2199void
2199deathstrike_player (object *op, object *hitter, int *dam) 2200deathstrike_player (object *op, object *hitter, int *dam)
2216 if (def_lev < 1) 2217 if (def_lev < 1)
2217 { 2218 {
2218 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name); 2219 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name);
2219 def_lev = 1; 2220 def_lev = 1;
2220 } 2221 }
2222
2221 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; 2223 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2;
2222 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", 2224 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n",
2223 atk_lev, def_lev); */ 2225 atk_lev, def_lev); */
2224 2226
2225 if (atk_lev >= def_lev) 2227 if (atk_lev >= def_lev)
2240 */ 2242 */
2241 *dam *= kill_lev / def_lev; 2243 *dam *= kill_lev / def_lev;
2242 } 2244 }
2243 } 2245 }
2244 else 2246 else
2245 {
2246 *dam = 0; /* no harm done */ 2247 *dam = 0; /* no harm done */
2247 }
2248} 2248}
2249 2249
2250/* thrown_item_effect() - handles any special effects of thrown 2250/* thrown_item_effect() - handles any special effects of thrown
2251 * items (like attacking living creatures--a potion thrown at a 2251 * items (like attacking living creatures--a potion thrown at a
2252 * monster). 2252 * monster).
2356#endif 2356#endif
2357 2357
2358 return adjust; 2358 return adjust;
2359} 2359}
2360 2360
2361
2362/* determine if the object is an 'aimed' missile */ 2361/* determine if the object is an 'aimed' missile */
2363int 2362int
2364is_aimed_missile (object *op) 2363is_aimed_missile (object *op)
2365{ 2364{
2366 2365
2372 if (op->type == ARROW || op->type == THROWN_OBJ) 2371 if (op->type == ARROW || op->type == THROWN_OBJ)
2373 return 1; 2372 return 1;
2374 else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION)) 2373 else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION))
2375 return 1; 2374 return 1;
2376 } 2375 }
2376
2377 return 0; 2377 return 0;
2378} 2378}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines