diff options
author | shennetsind <ind@henn.et> | 2013-02-14 23:12:19 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-02-14 23:12:19 -0200 |
commit | ef49bfc4445d464f19f84d78a2e6a1a5a3d9f0ac (patch) | |
tree | df150223d48b5379d47a365c05a143691c79cdf6 /src | |
parent | 7d33212f95653edd621961487f5622611d62ae88 (diff) | |
download | hercules-ef49bfc4445d464f19f84d78a2e6a1a5a3d9f0ac.tar.gz hercules-ef49bfc4445d464f19f84d78a2e6a1a5a3d9f0ac.tar.bz2 hercules-ef49bfc4445d464f19f84d78a2e6a1a5a3d9f0ac.tar.xz hercules-ef49bfc4445d464f19f84d78a2e6a1a5a3d9f0ac.zip |
New Mapflag adjust_skill_damage
Made as a improvement of the original ADJUST_SKILL_DAMAGE -- special thanks to Muad_Dib! .
This mapflag allows you to modify the damage of any skill in any map, for example
"prontera mapflag adjust_skill_damage MG_FIREBOLT 200"
doubles the damage of Firebolt in prontera
Another Example:
"prontera mapflag adjust_skill_damage MG_FIREBOLT 50"
Halves the damage of Firebolt in prontera.
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src')
-rw-r--r-- | src/map/battle.c | 22 | ||||
-rw-r--r-- | src/map/map.c | 41 | ||||
-rw-r--r-- | src/map/map.h | 10 | ||||
-rw-r--r-- | src/map/npc.c | 25 |
4 files changed, 82 insertions, 16 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 2ad066d33..5bc3df6f8 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -1606,7 +1606,20 @@ static int battle_range_type( return BF_SHORT; return BF_LONG; } +static inline int battle_adjust_skill_damage(int m, unsigned short skill_id) { + if( map[m].skill_count ) { + int i; + ARR_FIND(0, map[m].skill_count, i, map[m].skills[i]->skill_id == skill_id ); + + if( i < map[m].skill_count ) { + return map[m].skills[i]->modifier; + } + + } + + return 0; +} static int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) { int i; @@ -3094,6 +3107,9 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo if (skill_id && (i = pc_skillatk_bonus(sd, skill_id))) ATK_ADDRATE(i); + if( (i = battle_adjust_skill_damage(sd->bl.m,skill_id)) ) + ATK_RATE(i); + if( skill_id != PA_SACRIFICE && skill_id != MO_INVESTIGATE && skill_id != CR_GRANDCROSS && skill_id != NPC_GRANDDARKNESS && skill_id != PA_SHIELDCHAIN && !flag.cri ) { //Elemental/Racial adjustments if( sd->right_weapon.def_ratio_atk_ele & (1<<tstatus->def_ele) || @@ -4075,6 +4091,9 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list //Damage bonuses if ((i = pc_skillatk_bonus(sd, skill_id))) ad.damage += ad.damage*i/100; + + if( (i = battle_adjust_skill_damage(sd->bl.m,skill_id)) ) + MATK_RATE(i); //Ignore Defense? if (!flag.imdef && ( @@ -4456,6 +4475,9 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * if (sd && (i = pc_skillatk_bonus(sd, skill_id))) md.damage += md.damage*i/100; + if( (i = battle_adjust_skill_damage(sd->bl.m,skill_id)) ) + md.damage = md.damage * i / 100; + if(md.damage < 0) md.damage = 0; else if(md.damage && tstatus->mode&MD_PLANT){ diff --git a/src/map/map.c b/src/map/map.c index 1ffffdf59..dde922f39 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2894,8 +2894,8 @@ int map_delmap(char* mapname) return 0; } -void map_data_clean(void) { - int i; +void do_final_maps(void) { + int i, v = 0; for( i = 0; i < map_num; i++ ) { @@ -2912,21 +2912,34 @@ void map_data_clean(void) { } if( map[i].unit_count ) { - int v; for(v = 0; v < map[i].unit_count; v++) { aFree(map[i].units[v]); } - aFree(map[i].units); + if( map[i].units ) { + aFree(map[i].units); + map[i].units = NULL; + } map[i].unit_count = 0; } + if( map[i].skill_count ) { + for(v = 0; v < map[i].skill_count; v++) { + aFree(map[i].skills[v]); + } + if( map[i].skills ) { + aFree(map[i].skills); + map[i].skills = NULL; + } + map[i].skill_count = 0; + } + } } /// Initializes map flags and adjusts them depending on configuration. void map_flags_init(void) { - int i; + int i, v = 0; for( i = 0; i < map_num; i++ ) { // mapflags @@ -2940,13 +2953,22 @@ void map_flags_init(void) { memset(map[i].drop_list, 0, sizeof(map[i].drop_list)); // pvp nightmare drop list if( map[i].unit_count ) { - int v; for(v = 0; v < map[i].unit_count; v++) { aFree(map[i].units[v]); } aFree(map[i].units); - map[i].unit_count = 0; } + map[i].units = NULL; + map[i].unit_count = 0; + + if( map[i].skill_count ) { + for(v = 0; v < map[i].skill_count; v++) { + aFree(map[i].skills[v]); + } + aFree(map[i].skills); + } + map[i].skills = NULL; + map[i].skill_count = 0; // adjustments if( battle_config.pk_mode ) @@ -3637,10 +3659,9 @@ void do_final(void) do_final_battleground(); do_final_duel(); do_final_elemental(); - + do_final_maps(); + map_db->destroy(map_db, map_db_final); - - map_data_clean(); mapindex_final(); if(enable_grf) diff --git a/src/map/map.h b/src/map/map.h index a9699efc2..861a55d0a 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -496,8 +496,8 @@ struct iwall_data { bool shootable; }; -struct adjust_unit_duration { - int skill_id; +struct mapflag_skill_adjust { + unsigned short skill_id; unsigned short modifier; }; @@ -594,8 +594,12 @@ struct map_data { int instance_id; int instance_src_map; - struct adjust_unit_duration **units; + /* adjust_unit_duration mapflag */ + struct mapflag_skill_adjust **units; unsigned short unit_count; + /* adjust_skill_damage mapflag */ + struct mapflag_skill_adjust **skills; + unsigned short skill_count; }; /// Stores information about a remote map (for multi-mapserver setups). diff --git a/src/map/npc.c b/src/map/npc.c index 265fbb01f..671b4485a 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3412,11 +3412,30 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", atoi(mod), w4, map[m].name, filepath, strline(buffer,start-buffer)); } else { int idx = map[m].unit_count; - RECREATE(map[m].units, struct adjust_unit_duration*, ++map[m].unit_count); - CREATE(map[m].units[idx],struct adjust_unit_duration,1); - map[m].units[idx]->skill_id = skill_id; + RECREATE(map[m].units, struct mapflag_skill_adjust*, ++map[m].unit_count); + CREATE(map[m].units[idx],struct mapflag_skill_adjust,1); + map[m].units[idx]->skill_id = (unsigned short)skill_id; map[m].units[idx]->modifier = (unsigned short)atoi(mod); } + } else if (!strcmpi(w3,"adjust_skill_damage")) { + char *mod; + int skill_id; + + strtok(w4,"\t");/* makes w4 contain only 4th param */ + + if( !(mod = strtok(NULL,"\t")) ) {/* makes mod contain only the 5th param */ + ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer)); + } else if( !( skill_id = skill_name2id(w4) ) ) { + ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", w4, map[m].name, filepath, strline(buffer,start-buffer)); + } else if ( atoi(mod) < 1 || atoi(mod) > USHRT_MAX ) { + ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", atoi(mod), w4, map[m].name, filepath, strline(buffer,start-buffer)); + } else { + int idx = map[m].skill_count; + RECREATE(map[m].skills, struct mapflag_skill_adjust*, ++map[m].skill_count); + CREATE(map[m].skills[idx],struct mapflag_skill_adjust,1); + map[m].skills[idx]->skill_id = (unsigned short)skill_id; + map[m].skills[idx]->modifier = (unsigned short)atoi(mod); + } } else ShowError("npc_parse_mapflag: unrecognized mapflag '%s' (file '%s', line '%d').\n", w3, filepath, strline(buffer,start-buffer)); |