summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/unit.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index f8e887dc6..110fcb079 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1017,7 +1017,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
struct map_session_data *sd = NULL;
struct block_list * target = NULL;
unsigned int tick = gettick();
- int temp = 0;
+ int temp = 0, range;
nullpo_ret(src);
if(status_isdead(src))
@@ -1169,16 +1169,21 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
return 0;
}
+ if (src->type == BL_NPC) // NPC-objects can override cast distance
+ range = AREA_SIZE; // Maximum visible distance before NPC goes out of sight
+ else
+ range = skill_get_range2(src, skill_id, skill_lv); // Skill cast distance from database
+
//Check range when not using skill on yourself or is a combo-skill during attack
//(these are supposed to always have the same range as your attack)
if( src->id != target_id && (!temp || ud->attacktimer == INVALID_TIMER) ) {
if( skill_get_state(ud->skill_id) == ST_MOVE_ENABLE ) {
- if( !unit_can_reach_bl(src, target, skill_get_range2(src, skill_id,skill_lv) + 1, 1, NULL, NULL) )
+ if( !unit_can_reach_bl(src, target, range + 1, 1, NULL, NULL) )
return 0; // Walk-path check failed.
} else if( src->type == BL_MER && skill_id == MA_REMOVETRAP ) {
- if( !battle_check_range(battle_get_master(src), target, skill_get_range2(src, skill_id, skill_lv) + 1) )
+ if( !battle_check_range(battle_get_master(src), target, range + 1) )
return 0; // Aegis calc remove trap based on Master position, ignoring mercenary O.O
- } else if( !battle_check_range(src, target, skill_get_range2(src, skill_id,skill_lv) + (skill_id == RG_CLOSECONFINE?0:2)) ) {
+ } else if( !battle_check_range(src, target, range + (skill_id == RG_CLOSECONFINE?0:2)) ) {
return 0; // Arrow-path check failed.
}
}
@@ -1379,6 +1384,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
struct status_change *sc;
struct block_list bl;
unsigned int tick = gettick();
+ int range;
nullpo_ret(src);
@@ -1425,12 +1431,17 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
bl.x = skill_x;
bl.y = skill_y;
+ if (src->type == BL_NPC) // NPC-objects can override cast distance
+ range = AREA_SIZE; // Maximum visible distance before NPC goes out of sight
+ else
+ range = skill_get_range2(src, skill_id, skill_lv); // Skill cast distance from database
+
if( skill_get_state(ud->skill_id) == ST_MOVE_ENABLE )
{
- if( !unit_can_reach_bl(src, &bl, skill_get_range2(src, skill_id,skill_lv) + 1, 1, NULL, NULL) )
+ if( !unit_can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) )
return 0; //Walk-path check failed.
}
- else if( !battle_check_range(src, &bl, skill_get_range2(src, skill_id,skill_lv) + 1) )
+ else if( !battle_check_range(src, &bl, range + 1) )
return 0; //Arrow-path check failed.
unit_stop_attack(src);