summaryrefslogtreecommitdiff
path: root/src/map/battle.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/battle.c')
-rw-r--r--src/map/battle.c87
1 files changed, 49 insertions, 38 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index d65bb910f..b8143213a 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -12,6 +12,7 @@
#include "../common/socket.h"
#include "../common/strlib.h"
#include "../common/utils.h"
+#include "../common/HPM.h"
#include "map.h"
#include "path.h"
@@ -335,11 +336,11 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
if( atk_elem == ELE_FIRE && battle->get_current_skill(target) == GN_WALLOFTHORN ) {
struct skill_unit *su = (struct skill_unit*)target;
struct skill_unit_group *sg;
- struct block_list *src;
+ struct block_list *sgsrc;
if( !su || !su->alive
|| (sg = su->group) == NULL || sg->val3 == -1
- || (src = map->id2bl(sg->src_id)) == NULL || status->isdead(src)
+ || (sgsrc = map->id2bl(sg->src_id)) == NULL || status->isdead(sgsrc)
)
return 0;
@@ -347,7 +348,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
int x,y;
x = sg->val3 >> 16;
y = sg->val3 & 0xffff;
- skill->unitsetting(src,su->group->skill_id,su->group->skill_lv,x,y,1);
+ skill->unitsetting(sgsrc,su->group->skill_id,su->group->skill_lv,x,y,1);
sg->val3 = -1;
sg->limit = DIFF_TICK32(timer->gettick(),sg->tick)+300;
}
@@ -2332,11 +2333,12 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
break;
case SR_RAMPAGEBLASTER:
skillratio += 20 * skill_lv * (sd?sd->spiritball_old:5) - 100;
- if( sc && sc->data[SC_EXPLOSIONSPIRITS] ){
+ if( sc && sc->data[SC_EXPLOSIONSPIRITS] ) {
skillratio += sc->data[SC_EXPLOSIONSPIRITS]->val1 * 20;
RE_LVL_DMOD(120);
- }else
+ } else {
RE_LVL_DMOD(150);
+ }
break;
case SR_KNUCKLEARROW:
if( flag&4 ){ // ATK [(Skill Level x 150) + (1000 x Target current weight / Maximum weight) + (Target Base Level x 5) x (Caster Base Level / 150)] %
@@ -2600,10 +2602,10 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if( sc->data[SC_SAFETYWALL] && (flag&(BF_SHORT|BF_MAGIC))==BF_SHORT )
{
struct skill_unit_group* group = skill->id2group(sc->data[SC_SAFETYWALL]->val3);
- uint16 skill_id = sc->data[SC_SAFETYWALL]->val2;
+ uint16 src_skill_id = sc->data[SC_SAFETYWALL]->val2;
if (group) {
d->dmg_lv = ATK_BLOCK;
- if(skill_id == MH_STEINWAND){
+ if(src_skill_id == MH_STEINWAND){
if (--group->val2<=0)
skill->del_unitgroup(group,ALC_MARK);
return 0;
@@ -3209,11 +3211,9 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
memset(&ad,0,sizeof(ad));
memset(&flag,0,sizeof(flag));
- if(src==NULL || target==NULL)
- {
- nullpo_info(NLP_MARK);
- return ad;
- }
+ nullpo_retr(ad, src);
+ nullpo_retr(ad, target);
+
//Initial Values
ad.damage = 1;
ad.div_=skill->get_num(skill_id,skill_lv);
@@ -3521,10 +3521,8 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
memset(&md,0,sizeof(md));
- if( src == NULL || target == NULL ){
- nullpo_info(NLP_MARK);
- return md;
- }
+ nullpo_retr(md, src);
+ nullpo_retr(md, target);
//Some initial values
md.amotion=skill->get_inf(skill_id)&INF_GROUND_SKILL?0:sstatus->amotion;
@@ -3642,12 +3640,12 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
md.damage = 7 * md.damage / 20;
}*/
}else{
- float vitfactor = 0.0f, temp;
+ float vitfactor = 0.0f, ftemp;
if( (vitfactor=(status_get_vit(target)-120.0f)) > 0)
vitfactor = (vitfactor * (matk + atk) / 10) / status_get_vit(target);
- temp = max(0, vitfactor) + (targetVit * (matk + atk)) / 10;
- md.damage = (int64)(temp * 70 * skill_lv / 100);
+ ftemp = max(0, vitfactor) + (targetVit * (matk + atk)) / 10;
+ md.damage = (int64)(ftemp * 70 * skill_lv / 100);
}
md.damage -= totaldef;
}
@@ -3947,11 +3945,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
memset(&wd,0,sizeof(wd));
memset(&flag,0,sizeof(flag));
- if(src==NULL || target==NULL)
- {
- nullpo_info(NLP_MARK);
- return wd;
- }
+ nullpo_retr(wd, src);
+ nullpo_retr(wd, target);
+
//Initial flag
flag.rh=1;
flag.weapon=1;
@@ -4559,7 +4555,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
short index = sd?sd->equip_index[EQI_HAND_R]:0;
GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) );
wd.damage = wd.damage * 70 / 100;
- n_ele = true;
+ //n_ele = true; // FIXME: This is has no effect if it's after GET_NORMAL_ATTACK (was this intended, or was it supposed to be put above?)
if (sd && index >= 0 &&
sd->inventory_data[index] &&
@@ -5267,6 +5263,11 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
delay += 100;/* gradual increase so the numbers don't clip in the client */
}
}
+
+#ifdef __clang_analyzer__
+ // Tell Clang's static analyzer that we want to += it even the value is currently unused (it'd be used if we added new checks)
+ (void)delay;
+#endif // __clang_analyzer
/* something caused reflect */
if( trdamage ) {
@@ -5815,6 +5816,10 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
m = target->m;
+ if (flag&BCT_ENEMY && ( map->getcell(m,src->x,src->y,CELL_CHKBASILICA) || map->getcell(m,target->x,target->y,CELL_CHKBASILICA) ) ) {
+ return -1;
+ }
+
//t_bl/s_bl hold the 'master' of the attack, while src/target are the actual
//objects involved.
if( (t_bl = battle->get_master(target)) == NULL )
@@ -5826,11 +5831,11 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
if ( s_bl->type == BL_PC ) {
switch( t_bl->type ) {
case BL_MOB: // Source => PC, Target => MOB
- if (pc->has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVM) )
+ if (pc_has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVM) )
return 0;
break;
case BL_PC:
- if (pc->has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVP))
+ if (pc_has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVP))
return 0;
break;
default:/* anything else goes */
@@ -6066,9 +6071,11 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
}
if( flag&(BCT_PARTY|BCT_ENEMY) ) {
int s_party = status->get_party_id(s_bl);
+ int s_guild = status->get_guild_id(s_bl);
+
if( s_party && s_party == status->get_party_id(t_bl)
&& !(map->list[m].flag.pvp && map->list[m].flag.pvp_noparty)
- && !(map_flag_gvg(m) && map->list[m].flag.gvg_noparty)
+ && !(map_flag_gvg(m) && map->list[m].flag.gvg_noparty && !( s_guild && s_guild == status->get_guild_id(t_bl) ))
&& (!map->list[m].flag.battleground || sbg_id == tbg_id) )
state |= BCT_PARTY;
else
@@ -6456,7 +6463,7 @@ static const struct _battle_data {
{ "duel_time_interval", &battle_config.duel_time_interval, 60, 0, INT_MAX, },
{ "duel_only_on_same_map", &battle_config.duel_only_on_same_map, 0, 0, 1, },
{ "skip_teleport_lv1_menu", &battle_config.skip_teleport_lv1_menu, 0, 0, 1, },
- { "mob_max_skilllvl", &battle_config.mob_max_skilllvl, 100, 1, INT_MAX, },
+ { "mob_max_skilllvl", &battle_config.mob_max_skilllvl, 100, 1, INT_MAX, },
{ "allow_skill_without_day", &battle_config.allow_skill_without_day, 0, 0, 1, },
{ "allow_es_magic_player", &battle_config.allow_es_magic_pc, 0, 0, 1, },
{ "skill_caster_check", &battle_config.skill_caster_check, 1, 0, 1, },
@@ -6525,24 +6532,25 @@ static const struct _battle_data {
{ "atcommand_mobinfo_type", &battle_config.atcommand_mobinfo_type, 0, 0, 1 },
{ "homunculus_max_level", &battle_config.hom_max_level, 99, 0, MAX_LEVEL, },
{ "homunculus_S_max_level", &battle_config.hom_S_max_level, 150, 0, MAX_LEVEL, },
- { "mob_size_influence", &battle_config.mob_size_influence, 0, 0, 1, },
+ { "mob_size_influence", &battle_config.mob_size_influence, 0, 0, 1, },
/**
* Hercules
**/
{ "skill_trap_type", &battle_config.skill_trap_type, 0, 0, 1, },
{ "item_restricted_consumption_type", &battle_config.item_restricted_consumption_type,1, 0, 1, },
- { "max_walk_path", &battle_config.max_walk_path, 17, 1, MAX_WALKPATH, },
- { "item_enabled_npc", &battle_config.item_enabled_npc, 1, 0, 1, },
- { "gm_ignore_warpable_area", &battle_config.gm_ignore_warpable_area, 0, 2, 100, },
- { "packet_obfuscation", &battle_config.packet_obfuscation, 1, 0, 3, },
- { "client_accept_chatdori", &battle_config.client_accept_chatdori, 0, 0, INT_MAX, },
- { "snovice_call_type", &battle_config.snovice_call_type, 0, 0, 1, },
- { "guild_notice_changemap", &battle_config.guild_notice_changemap, 2, 0, 2, },
+ { "max_walk_path", &battle_config.max_walk_path, 17, 1, MAX_WALKPATH, },
+ { "item_enabled_npc", &battle_config.item_enabled_npc, 1, 0, 1, },
+ { "gm_ignore_warpable_area", &battle_config.gm_ignore_warpable_area, 0, 2, 100, },
+ { "packet_obfuscation", &battle_config.packet_obfuscation, 1, 0, 3, },
+ { "client_accept_chatdori", &battle_config.client_accept_chatdori, 0, 0, INT_MAX, },
+ { "snovice_call_type", &battle_config.snovice_call_type, 0, 0, 1, },
+ { "guild_notice_changemap", &battle_config.guild_notice_changemap, 2, 0, 2, },
{ "feature.banking", &battle_config.feature_banking, 1, 0, 1, },
{ "feature.auction", &battle_config.feature_auction, 0, 0, 2, },
{ "idletime_criteria", &battle_config.idletime_criteria, 0x25, 1, INT_MAX, },
{ "mon_trans_disable_in_gvg", &battle_config.mon_trans_disable_in_gvg, 0, 0, 1, },
+ { "case_sensitive_aegisnames", &battle_config.case_sensitive_aegisnames, 1, 0, 1, },
};
#ifndef STATS_OPT_OUT
/**
@@ -6701,8 +6709,11 @@ int battle_set_value(const char* w1, const char* w2)
int i;
ARR_FIND(0, ARRAYLENGTH(battle_data), i, strcmpi(w1, battle_data[i].str) == 0);
- if (i == ARRAYLENGTH(battle_data))
+ if (i == ARRAYLENGTH(battle_data)) {
+ if( HPM->parseConf(w1,w2,HPCT_BATTLE) ) /* if plugin-owned, succeed */
+ return 1;
return 0; // not found
+ }
if (val < battle_data[i].min || val > battle_data[i].max)
{