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.150 by root, Wed Nov 16 23:42:02 2016 UTC vs.
Revision 1.152 by root, Sun Jan 29 02:47:05 2017 UTC

137 137
138 op = stop_item (op); 138 op = stop_item (op);
139 if (!op) 139 if (!op)
140 return; 140 return;
141 141
142 /* Hacked the following so that type LIGHTER will work. 142 /* Hacked the following so that type LIGHTER will work.
143 * Also, objects which are potential "lights" that are hit by 143 * Also, objects which are potential "lights" that are hit by
144 * flame/elect attacks will be set to glow. "lights" are any 144 * flame/elect attacks will be set to glow. "lights" are any
145 * object with +/- glow_radius and an "other_arch" to change to. 145 * object with +/- glow_radius and an "other_arch" to change to.
146 * (and please note that we cant fail our save and reach this 146 * (and please note that we cant fail our save and reach this
147 * function if the object doesnt contain a material that can burn. 147 * function if the object doesnt contain a material that can burn.
148 * So forget lighting magical swords on fire with this!) -b.t. 148 * So forget lighting magical swords on fire with this!) -b.t.
149 */ 149 */
150 if (type & (AT_FIRE | AT_ELECTRICITY)) 150 if (type & (AT_FIRE | AT_ELECTRICITY))
151 { 151 {
152 // seems LAMPs and TORCHes are always IS_LIGHTABLE? 152 // seems LAMPs and TORCHes are always IS_LIGHTABLE?
340 340
341 if (op->destroyed ()) 341 if (op->destroyed ())
342 break; 342 break;
343 } 343 }
344 /* Here we are potentially destroying an object. If the object has 344 /* Here we are potentially destroying an object. If the object has
345 * NO_PASS set, it is also immune - you can't destroy walls. Note 345 * NO_PASS set, it is also immune - you can't destroy walls. Note
346 * that weak walls have is_alive set, which prevent objects from 346 * that weak walls have is_alive set, which prevent objects from
347 * passing over/through them. We don't care what type of movement 347 * passing over/through them. We don't care what type of movement
348 * the wall blocks - if it blocks any type of movement, can't be 348 * the wall blocks - if it blocks any type of movement, can't be
349 * destroyed right now. 349 * destroyed right now.
350 * Without the material check the server completely fails to work, 350 * Without the material check the server completely fails to work,
701static void 701static void
702thrown_item_effect (object *hitter, object *victim) 702thrown_item_effect (object *hitter, object *victim)
703{ 703{
704 if (!hitter->flag [FLAG_ALIVE]) 704 if (!hitter->flag [FLAG_ALIVE])
705 { 705 {
706 /* May not need a switch for just 2 types, but this makes it 706 /* May not need a switch for just 2 types, but this makes it
707 * easier for expansion. 707 * easier for expansion.
708 */ 708 */
709 switch (hitter->type) 709 switch (hitter->type)
710 { 710 {
711 case POTION: 711 case POTION:
770 attacker = hitter; 770 attacker = hitter;
771 } 771 }
772 else if (!hitter->flag [FLAG_ALIVE]) 772 else if (!hitter->flag [FLAG_ALIVE])
773 return 0; 773 return 0;
774 774
775 /* determine the condtions under which we make an attack. 775 /* determine the condtions under which we make an attack.
776 * Add more cases, as the need occurs. */ 776 * Add more cases, as the need occurs. */
777 777
778 if (!can_see_enemy (attacker, target)) 778 if (!can_see_enemy (attacker, target))
779 { 779 {
780 /* target is unseen */ 780 /* target is unseen */
868 int hitdam = base_dam; 868 int hitdam = base_dam;
869 869
870 if (!simple_attack) 870 if (!simple_attack)
871 { 871 {
872 /* If you hit something, the victim should *always* wake up. 872 /* If you hit something, the victim should *always* wake up.
873 * Before, invisible hitters could avoid doing this. 873 * Before, invisible hitters could avoid doing this.
874 * -b.t. */ 874 * -b.t. */
875 if (op->flag [FLAG_SLEEP]) 875 if (op->flag [FLAG_SLEEP])
876 op->clr_flag (FLAG_SLEEP); 876 op->clr_flag (FLAG_SLEEP);
877 877
878 /* If the victim can't see the attacker, it may alert others 878 /* If the victim can't see the attacker, it may alert others
909 909
910 /* Ok, because some of the brainfucks of the good *sigh* old *sigh* 910 /* Ok, because some of the brainfucks of the good *sigh* old *sigh*
911 * Crossfire we have to default the attacktype here to AT_PHYSICAL. 911 * Crossfire we have to default the attacktype here to AT_PHYSICAL.
912 * This check is important for the most simple monsters out there in the 912 * This check is important for the most simple monsters out there in the
913 * game content (maps, archs). For example orcs: They would have 913 * game content (maps, archs). For example orcs: They would have
914 * no attacktype at all. 914 * no attacktype at all.
915 * 915 *
916 * Some time in the future someone should just go into the game data 916 * Some time in the future someone should just go into the game data
917 * and fix every monster out there ;-/ Until then we will kill some 917 * and fix every monster out there ;-/ Until then we will kill some
918 * more trees in the african rain forests with this check. 918 * more trees in the african rain forests with this check.
919 */ 919 */
1034 */ 1034 */
1035 if (hit_something) 1035 if (hit_something)
1036 if (op->speed < 10.0) 1036 if (op->speed < 10.0)
1037 { 1037 {
1038 /* Stop arrow */ 1038 /* Stop arrow */
1039 if (!container) 1039 if (container)
1040 container->destroy ();
1041 else
1040 { 1042 {
1041 hitter = fix_stopped_arrow (hitter); 1043 hitter = fix_stopped_arrow (hitter);
1042 if (!hitter) 1044 if (!hitter)
1043 return 0; 1045 return 0;
1044 } 1046 }
1045 else
1046 container->destroy ();
1047 1047
1048 /* Try to stick arrow into victim */ 1048 /* Try to stick arrow into victim */
1049 if (!victim->destroyed () && stick_arrow (hitter, victim)) 1049 if (!victim->destroyed () && stick_arrow (hitter, victim))
1050 return 0; 1050 return 0;
1051 1051
1237 owner->play_sound (sound_find ("player_kills")); 1237 owner->play_sound (sound_find ("player_kills"));
1238 } 1238 }
1239 1239
1240 /* If a player kills another player, not on 1240 /* If a player kills another player, not on
1241 * battleground, the "killer" looses 1 luck. Since this is 1241 * battleground, the "killer" looses 1 luck. Since this is
1242 * not reversible, it's actually quite a pain IMHO. -AV 1242 * not reversible, it's actually quite a pain IMHO. -AV
1243 * Fix bug in that we were changing the luck of the hitter, not 1243 * Fix bug in that we were changing the luck of the hitter, not
1244 * player that the object belonged to - so if you killed another player 1244 * player that the object belonged to - so if you killed another player
1245 * with spells, pets, whatever, there was no penalty. 1245 * with spells, pets, whatever, there was no penalty.
1246 * Changed to make luck penalty configurable in settings. 1246 * Changed to make luck penalty configurable in settings.
1247 */ 1247 */
1377 * continues in the calling function. 1377 * continues in the calling function.
1378 */ 1378 */
1379 return maxdam; 1379 return maxdam;
1380} 1380}
1381 1381
1382/* Find out if this is friendly fire (PVP and attacker is peaceful) or not 1382/* Find out if this is friendly fire (PVP and attacker is peaceful) or not
1383 * Returns 0 this is not friendly fire 1383 * Returns 0 this is not friendly fire
1384 */ 1384 */
1385int 1385int
1386friendly_fire (object *op, object *hitter) 1386friendly_fire (object *op, object *hitter)
1387{ 1387{
1735 /* peterm: give poisoning some teeth. It should 1735 /* peterm: give poisoning some teeth. It should
1736 * be able to kill things better than it does: 1736 * be able to kill things better than it does:
1737 * damage should be dependent something--I choose to 1737 * damage should be dependent something--I choose to
1738 * do this: if it's a monster, the damage from the 1738 * do this: if it's a monster, the damage from the
1739 * poisoning goes as the level of the monster/2. 1739 * poisoning goes as the level of the monster/2.
1740 * If anything else, goes as damage. 1740 * If anything else, goes as damage.
1741 */ 1741 */
1742 1742
1743 if (hitter->flag [FLAG_ALIVE]) 1743 if (hitter->flag [FLAG_ALIVE])
1744 tmp->stats.dam += hitter->level / 2; 1744 tmp->stats.dam += hitter->level / 2;
1745 else 1745 else
1810 tmp = archetype::get (FORCE_NAME); 1810 tmp = archetype::get (FORCE_NAME);
1811 tmp = insert_ob_in_ob (tmp, op); 1811 tmp = insert_ob_in_ob (tmp, op);
1812 } 1812 }
1813 1813
1814 /* Duration added per hit and max. duration of confusion both depend 1814 /* Duration added per hit and max. duration of confusion both depend
1815 * on the player's resistance 1815 * on the player's resistance
1816 */ 1816 */
1817 tmp->set_speed (0.05); 1817 tmp->set_speed (0.05);
1818 tmp->subtype = FORCE_CONFUSION; 1818 tmp->subtype = FORCE_CONFUSION;
1819 tmp->duration = 8 + max (1, 5 * (100 - op->resist[ATNR_CONFUSION]) / 100); 1819 tmp->duration = 8 + max (1, 5 * (100 - op->resist[ATNR_CONFUSION]) / 100);
1820 tmp->name = shstr_confusion; 1820 tmp->name = shstr_confusion;
1858 1858
1859void 1859void
1860paralyze_player (object *op, object *hitter, int dam) 1860paralyze_player (object *op, object *hitter, int dam)
1861{ 1861{
1862 /* This is strange stuff... someone knows for what this is 1862 /* This is strange stuff... someone knows for what this is
1863 * written? Well, i think this can and should be removed 1863 * written? Well, i think this can and should be removed
1864 */ 1864 */
1865 1865
1866 /* 1866 /*
1867 if((tmp=present(PARAIMAGE,op->map,op->x,op->y))==NULL) { 1867 if((tmp=present(PARAIMAGE,op->map,op->x,op->y))==NULL) {
1868 tmp=clone_arch(PARAIMAGE); 1868 tmp=clone_arch(PARAIMAGE);
1927 * redone. 1927 * redone.
1928 */ 1928 */
1929 if (kill_lev >= def_lev) 1929 if (kill_lev >= def_lev)
1930 { 1930 {
1931 *dam = op->stats.hp + 10; /* take all hp. they can still save for 1/2 */ 1931 *dam = op->stats.hp + 10; /* take all hp. they can still save for 1/2 */
1932 /* I think this doesn't really do much. Because of 1932 /* I think this doesn't really do much. Because of
1933 * integer rounding, this only makes any difference if the 1933 * integer rounding, this only makes any difference if the
1934 * attack level is double the defender level. 1934 * attack level is double the defender level.
1935 */ 1935 */
1936 *dam *= kill_lev / def_lev; 1936 *dam *= kill_lev / def_lev;
1937 } 1937 }
1938 } 1938 }
2010 /* here also check for diseases */ 2010 /* here also check for diseases */
2011 check_physically_infect (op, hitter); 2011 check_physically_infect (op, hitter);
2012 break; 2012 break;
2013 2013
2014 /* Don't need to do anything for: 2014 /* Don't need to do anything for:
2015 magic, 2015 magic,
2016 fire, 2016 fire,
2017 electricity, 2017 electricity,
2018 cold */ 2018 cold */
2019 2019
2020 case ATNR_CONFUSION: 2020 case ATNR_CONFUSION:
2021 case ATNR_POISON: 2021 case ATNR_POISON:
2025 case ATNR_CANCELLATION: 2025 case ATNR_CANCELLATION:
2026 case ATNR_DEPLETE: 2026 case ATNR_DEPLETE:
2027 case ATNR_BLIND: 2027 case ATNR_BLIND:
2028 { 2028 {
2029 /* chance for inflicting a special attack depends on the 2029 /* chance for inflicting a special attack depends on the
2030 * difference between attacker's and defender's level 2030 * difference between attacker's and defender's level
2031 */ 2031 */
2032 int level_diff = min (110, max (0, op->level - hitter->level)); 2032 int level_diff = min (110, max (0, op->level - hitter->level));
2033 2033
2034 /* First, only creatures/players with speed can be affected. 2034 /* First, only creatures/players with speed can be affected.
2035 * Second, just getting hit doesn't mean it always affects 2035 * Second, just getting hit doesn't mean it always affects
2036 * you. Third, you still get a saving through against the 2036 * you. Third, you still get a saving through against the
2037 * effect. 2037 * effect.
2038 */ 2038 */
2039 if (op->has_active_speed () 2039 if (op->has_active_speed ()
2040 && (op->flag [FLAG_MONSTER] || op->type == PLAYER) 2040 && (op->flag [FLAG_MONSTER] || op->type == PLAYER)
2041 && !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) 2041 && !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1))
2042 && !did_make_save (op, level_diff, op->resist[attacknum] / 10)) 2042 && !did_make_save (op, level_diff, op->resist[attacknum] / 10))
2217 * does no damage. */ 2217 * does no damage. */
2218 break; 2218 break;
2219 2219
2220 case ATNR_HOLYWORD: 2220 case ATNR_HOLYWORD:
2221 { 2221 {
2222 /* This has already been handled by hit_player, 2222 /* This has already been handled by hit_player,
2223 * no need to check twice -- DAMN */ 2223 * no need to check twice -- DAMN */
2224 object *owner = hitter->owner ? (object *)hitter->owner : hitter; 2224 object *owner = hitter->owner ? (object *)hitter->owner : hitter;
2225 2225
2226 /* As with turn undead above, give a bonus on the saving throw */ 2226 /* As with turn undead above, give a bonus on the saving throw */
2227 if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) 2227 if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis])

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines