diff --git a/doc/mapflags.txt b/doc/mapflags.txt index 4b744fc41d9..14455171741 100644 --- a/doc/mapflags.txt +++ b/doc/mapflags.txt @@ -319,10 +319,6 @@ This mapflag can also be used to adjust the damage of one skill by a percentage: SKILLDMG_BOSS = against boss monster SKILLDMG_OTHER = against other (homunculus, mercenary, pet, elemental) -Notes: - - You MUST enable ADJUST_SKILL_DAMAGE in 'src/config/core.hpp' for this mapflag to take effect. - - Each map can contain up to UINT16_MAX adjustments. - --------------------------------------- ================== diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 6a16747efa0..004397f63f8 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -7001,7 +7001,7 @@ specified. *setmapflag "",{,{,}}; This command marks a specified map with the given map flag, which will alter the -behavior of the map. A full list of mapflags is located in 'src/map/script_constants.h' with +behavior of the map. A full list of mapflags is located in 'src/map/script_constants.hpp' with the 'mf_' prefix, and documentation can be found in 'doc/mapflags.txt'. The map flags alter the behavior of the map regarding teleporting (mf_nomemo, @@ -7013,7 +7013,14 @@ skills or open up trade deals (mf_notrade, mf_novending, mf_noskill, mf_noicewal current weather effects (mf_snow, mf_fog, mf_sakura, mf_leaves, mf_rain, mf_clouds, mf_fireworks) and whether night will be in effect on this map (mf_nightenabled). -The optional parameter 'zone' is used to set the zone for restricted mapflags. +The optional parameter is used to set the zone for 'restricted' mapflags, +GM level bypass for 'nocommand', base/job experience for 'bexp'/'jexp', and +flag for 'battleground'. + +For 'skill_damage' mapflag: + - Setting the flag here will adjust the global (all skills) damage on the map. + - is the -100 to 100000 damage adjustment value of the skills. + - See 'getmapflag' for the different values. --------------------------------------- @@ -7032,12 +7039,12 @@ This command checks the status of a given mapflag and returns the mapflag's stat 0 means OFF, and 1 means ON. See 'setmapflag' for a list of mapflags. The optional parameter 'type' is used in the 'skill_damage' mapflag: - 0: if mapflag is set (default) - 1: damage against players - 2: damage against mobs - 3: damage against bosses - 4: damage against other - 5: caster type + SKILLDMG_MAX: if mapflag is set (default) + SKILLDMG_PC: damage against players + SKILLDMG_MOB: damage against mobs + SKILLDMG_BOSS: damage against bosses + SKILLDMG_OTHER: damage against other + SKILLDMG_CASTER: caster type --------------------------------------- diff --git a/npc/mapflag/skill_damage.txt b/npc/mapflag/skill_damage.txt index d27f3fa00ae..5c9ccacfd0d 100644 --- a/npc/mapflag/skill_damage.txt +++ b/npc/mapflag/skill_damage.txt @@ -11,9 +11,6 @@ //= skill_damage_db.txt for 'Map' type 16 will be applied. //= See the mapflag documentation for details about extra //= parameters. -//= -//= You MUST enable ADJUST_SKILL_DAMAGE in 'src/config/core.hpp' -//= for this mapflag to take effect. //===== Additional Comments: ================================= //= 1.0 Initial script. [Cydh] //============================================================ diff --git a/src/config/core.hpp b/src/config/core.hpp index 5472bf488f9..e332f277525 100644 --- a/src/config/core.hpp +++ b/src/config/core.hpp @@ -43,11 +43,6 @@ /// Uncomment to enable real-time server stats (in and out data and ram usage). //#define SHOW_SERVER_STATS -/// Uncomment to enable skills damage adjustments -/// By enabling this, db/skill_damage_db.txt and the skill_damage mapflag will adjust the -/// damage rate of specified skills. -//#define ADJUST_SKILL_DAMAGE - /// Uncomment to enable the job base HP/SP table (job_basehpsp_db.txt) #define HP_SP_TABLES diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 455c2d8fe8a..5d815727bf0 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -4054,15 +4054,17 @@ ACMD_FUNC(mapinfo) { } /* Skill damage adjustment info [Cydh] */ -#ifdef ADJUST_SKILL_DAMAGE - if (map_getmapflag(m_id, MF_SKILL_DAMAGE)) { + union u_mapflag_args args = {}; + + args.flag_val = SKILLDMG_MAX; // Check if it's enabled first + if (map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args)) { clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments: sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d" - ,map[m_id].damage_adjust.rate[SKILLDMG_PC] - ,map[m_id].damage_adjust.rate[SKILLDMG_MOB] - ,map[m_id].damage_adjust.rate[SKILLDMG_BOSS] - ,map[m_id].damage_adjust.rate[SKILLDMG_OTHER] - ,map[m_id].damage_adjust.caster); + ,(args.flag_val = SKILLDMG_PC && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args)) + ,(args.flag_val = SKILLDMG_MOB && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args)) + ,(args.flag_val = SKILLDMG_BOSS && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args)) + ,(args.flag_val = SKILLDMG_OTHER && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args)) + ,(args.flag_val = SKILLDMG_CASTER && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args))); clif_displaymessage(fd, atcmd_output); if (map[m_id].skill_damage.size()) { clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster"); @@ -4079,7 +4081,6 @@ ACMD_FUNC(mapinfo) { } } } -#endif strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags: if (map_getmapflag(m_id, MF_PVP)) @@ -8147,7 +8148,7 @@ ACMD_FUNC(fakename) ACMD_FUNC(mapflag) { char flag_name[CHAT_SIZE_MAX]; short flag = 0, i, j; - StringBuf buf; + std::string buf; nullpo_retr(-1, sd); @@ -8157,7 +8158,9 @@ ACMD_FUNC(mapflag) { clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map: clif_displaymessage(sd->fd,"----------------------------------"); for( i = MF_MIN; i < MF_MAX; i++ ){ - if( map_getmapflag_name(static_cast(i), flag_name) && map_getmapflag( sd->bl.m, static_cast(i) ) ){ + union u_mapflag_args args = {}; + + if( map_getmapflag_name(static_cast(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast(i), &args ) ){ clif_displaymessage(sd->fd, flag_name); } } @@ -8175,9 +8178,23 @@ ACMD_FUNC(mapflag) { enum e_mapflag mapflag = map_getmapflag_by_name(flag_name); if( mapflag != MF_INVALID ){ - map_setmapflag(sd->bl.m, static_cast(mapflag), flag != 0); - sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag); - clif_displaymessage(sd->fd,atcmd_output); + std::vector disabled_mf = { MF_NOSAVE, + MF_PVP_NIGHTMAREDROP, + MF_RESTRICTED, + MF_NOCOMMAND, + MF_BEXP, + MF_JEXP, + MF_BATTLEGROUND, + MF_SKILL_DAMAGE }; + + if (flag && std::find(disabled_mf.begin(), disabled_mf.end(), mapflag) != disabled_mf.end()) { + sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name); + clif_displaymessage(sd->fd,atcmd_output); + } else { + map_setmapflag(sd->bl.m, mapflag, flag != 0); + sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag); + clif_displaymessage(sd->fd,atcmd_output); + } return 0; }else{ clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag. @@ -8188,25 +8205,22 @@ ACMD_FUNC(mapflag) { clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags: clif_displaymessage(sd->fd,"----------------------------------"); - StringBuf_Init(&buf); for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){ if( map_getmapflag_name( static_cast(i), flag_name ) ){ - StringBuf_AppendStr( &buf, flag_name ); + buf.append(flag_name); - if( (i + 1) < MF_MAX ){ - StringBuf_AppendStr( &buf, ", " ); - } + if( (i + 1) < MF_MAX ) + buf.append(", "); j++; } if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){ - clif_displaymessage(sd->fd, StringBuf_Value(&buf) ); - StringBuf_Clear(&buf); + clif_displaymessage(sd->fd, buf.c_str() ); + buf.clear(); j = 0; } } - StringBuf_Destroy(&buf); clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) return 0; diff --git a/src/map/battle.cpp b/src/map/battle.cpp index b03f2c2ea83..ee4401d9ad1 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -2156,7 +2156,6 @@ static int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) return 0; } -#ifdef ADJUST_SKILL_DAMAGE static enum e_skill_damage_type battle_skill_damage_type( struct block_list* bl ){ switch( bl->type ){ case BL_PC: @@ -2192,11 +2191,14 @@ static int battle_skill_damage_skill(struct block_list *src, struct block_list * if (!(damage->caster&src->type)) return 0; - if ((damage->map&1 && (!map_getmapflag(m, MF_PVP) && !map_flag_gvg2(m) && !map_getmapflag(m, MF_BATTLEGROUND) && !map_getmapflag(m, MF_SKILL_DAMAGE) && !map_getmapflag(m, MF_RESTRICTED))) || + union u_mapflag_args args = {}; + + args.flag_val = SKILLDMG_MAX; // Check if it's enabled first + if ((damage->map&1 && (!map_getmapflag(m, MF_PVP) && !map_flag_gvg2(m) && !map_getmapflag(m, MF_BATTLEGROUND) && !map_getmapflag_sub(m, MF_SKILL_DAMAGE, &args) && !map_getmapflag(m, MF_RESTRICTED))) || (damage->map&2 && map_getmapflag(m, MF_PVP)) || (damage->map&4 && map_flag_gvg2(m)) || (damage->map&8 && map_getmapflag(m, MF_BATTLEGROUND)) || - (damage->map&16 && map_getmapflag(m, MF_SKILL_DAMAGE)) || + (damage->map&16 && map_getmapflag_sub(m, MF_SKILL_DAMAGE, &args)) || (map_getmapflag(m, MF_RESTRICTED) && damage->map&(8*map[m].zone))) { return damage->rate[battle_skill_damage_type(target)]; @@ -2215,8 +2217,10 @@ static int battle_skill_damage_skill(struct block_list *src, struct block_list * static int battle_skill_damage_map(struct block_list *src, struct block_list *target, uint16 skill_id) { int rate = 0; struct map_data *mapd = &map[src->m]; + union u_mapflag_args args = {}; - if (!mapd || !map_getmapflag(src->m, MF_SKILL_DAMAGE)) + args.flag_val = SKILLDMG_MAX; // Check if it's enabled first + if (!mapd || !map_getmapflag_sub(src->m, MF_SKILL_DAMAGE, &args)) return 0; // Damage rate for all skills at this map @@ -2248,7 +2252,6 @@ static int battle_skill_damage(struct block_list *src, struct block_list *target skill_id = skill_dummy2skill_id(skill_id); return battle_skill_damage_skill(src, target, skill_id) + battle_skill_damage_map(src, target, skill_id); } -#endif /** * Calculates Minstrel/Wanderer bonus for Chorus skills. @@ -5103,9 +5106,7 @@ struct Damage battle_calc_weapon_final_atk_modifiers(struct Damage wd, struct bl struct status_change *tsc = status_get_sc(target); struct status_data *sstatus = status_get_status_data(src); struct status_data *tstatus = status_get_status_data(target); -#ifdef ADJUST_SKILL_DAMAGE int skill_damage = 0; -#endif //Reject Sword bugreport:4493 by Daegaladh if(wd.damage && tsc && tsc->data[SC_REJECTSWORD] && @@ -5187,10 +5188,8 @@ struct Damage battle_calc_weapon_final_atk_modifiers(struct Damage wd, struct bl } // Skill damage adjustment -#ifdef ADJUST_SKILL_DAMAGE if ((skill_damage = battle_skill_damage(src, target, skill_id)) != 0) ATK_ADDRATE(wd.damage, wd.damage2, skill_damage); -#endif return wd; } @@ -5679,10 +5678,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src, struct bl */ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) { - int i, nk; -#ifdef ADJUST_SKILL_DAMAGE - int skill_damage = 0; -#endif + int i, nk, skill_damage = 0; short s_ele = 0; TBL_PC *sd; @@ -6396,10 +6392,8 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list ad.damage = battle_calc_bg_damage(src,target,ad.damage,skill_id,ad.flag); // Skill damage adjustment -#ifdef ADJUST_SKILL_DAMAGE if ((skill_damage = battle_skill_damage(src,target,skill_id)) != 0) MATK_ADDRATE(skill_damage); -#endif battle_absorb_damage(target, &ad); @@ -6416,9 +6410,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list */ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) { -#ifdef ADJUST_SKILL_DAMAGE int skill_damage = 0; -#endif short i, nk; short s_ele; @@ -6792,10 +6784,8 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * md.damage = battle_calc_bg_damage(src,target,md.damage,skill_id,md.flag); // Skill damage adjustment -#ifdef ADJUST_SKILL_DAMAGE if ((skill_damage = battle_skill_damage(src,target,skill_id)) != 0) md.damage += (int64)md.damage * skill_damage / 100; -#endif battle_absorb_damage(target, &md); diff --git a/src/map/map.cpp b/src/map/map.cpp index 7d5f0fea88f..0de12514a1b 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -3470,9 +3470,7 @@ void map_flags_init(void) map_setmapflag_sub(i, MF_JEXP, true, &args); // per map job exp multiplicator // skill damage -#ifdef ADJUST_SKILL_DAMAGE - memset(&map[i].damage_adjust, 0, sizeof(map[i].damage_adjust)); -#endif + map[i].damage_adjust = {}; // adjustments if( battle_config.pk_mode ) @@ -4279,7 +4277,6 @@ int cleanup_sub(struct block_list *bl, va_list ap) return 1; } -#ifdef ADJUST_SKILL_DAMAGE /** * Add new skill damage adjustment entry for a map * @param m: Map data @@ -4312,7 +4309,6 @@ void map_skill_damage_add(struct map_data *m, uint16 skill_id, int rate[SKILLDMG entry.caster = caster; m->skill_damage.push_back(entry); } -#endif /** * PvP timer handling @@ -4410,7 +4406,6 @@ int map_getmapflag_sub(int16 m, enum e_mapflag mapflag, union u_mapflag_args *ar case MF_NOEXP: return util::map_get(map[m].flag, MF_NOBASEEXP, 0) && util::map_get(map[m].flag, MF_NOJOBEXP, 0); case MF_SKILL_DAMAGE: -#ifdef ADJUST_SKILL_DAMAGE nullpo_retr(-1, args); switch (args->flag_val) { @@ -4419,12 +4414,11 @@ int map_getmapflag_sub(int16 m, enum e_mapflag mapflag, union u_mapflag_args *ar case SKILLDMG_BOSS: case SKILLDMG_OTHER: return map[m].damage_adjust.rate[args->flag_val]; + case SKILLDMG_CASTER: + return map[m].damage_adjust.caster; default: return util::map_get(map[m].flag, mapflag, 0); } -#else - return 0; -#endif default: return util::map_get(map[m].flag, mapflag, 0); } @@ -4638,29 +4632,29 @@ bool map_setmapflag_sub(int16 m, enum e_mapflag mapflag, bool status, union u_ma map[m].flag[MF_NOBASEEXP] = status; map[m].flag[MF_NOJOBEXP] = status; break; -#ifdef ADJUST_SKILL_DAMAGE case MF_SKILL_DAMAGE: if (!status) { - memset(&map[m].damage_adjust, 0, sizeof(map[m].damage_adjust)); + map[m].damage_adjust = {}; map[m].skill_damage.clear(); } else { nullpo_retr(false, args); - if (!args->skill_damage.caster) { - ShowError("map_setmapflag: Skill damage adjustment without casting type for map %s.\n", map[m].name); - return false; - } + if (!args->flag_val) { // Signifies if it's a single skill or global damage adjustment + if (!args->skill_damage.caster) { + ShowError("map_setmapflag: Skill damage adjustment without casting type for map %s.\n", map[m].name); + return false; + } - for (int i = 0; i < SKILLDMG_MAX; i++) { - map[m].damage_adjust.rate[i] = cap_value(args->skill_damage.rate[i], -100, 100000); + for (int i = 0; i < SKILLDMG_MAX; i++) { + map[m].damage_adjust.rate[i] = cap_value(args->skill_damage.rate[i], -100, 100000); - if (map[m].flag.find(mapflag) != map[m].flag.end() && map[m].damage_adjust.rate[i]) - map[m].damage_adjust.caster = args->skill_damage.caster; + if (map[m].flag.find(mapflag) != map[m].flag.end() && map[m].damage_adjust.rate[i]) + map[m].damage_adjust.caster = args->skill_damage.caster; + } } } map[m].flag[mapflag] = status; break; -#endif default: map[m].flag[mapflag] = status; break; @@ -4757,11 +4751,7 @@ void do_final(void) if (map[i].moblist[j]) aFree(map[i].moblist[j]); } map_free_questinfo(i); - map[i].flag.clear(); - map[i].drop_list.clear(); -#ifdef ADJUST_SKILL_DAMAGE - map[i].skill_damage.clear(); -#endif + map[i].damage_adjust = {}; } mapindex_final(); diff --git a/src/map/map.hpp b/src/map/map.hpp index 8fee021f097..160ac16299c 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -595,18 +595,17 @@ enum e_skill_damage_type : uint8 { SKILLDMG_MOB, SKILLDMG_BOSS, SKILLDMG_OTHER, - SKILLDMG_MAX + SKILLDMG_MAX, + SKILLDMG_CASTER, ///< Only used on getter for caster value }; -#ifdef ADJUST_SKILL_DAMAGE -/// Struct for MF_SKILLDAMAGE +/// Struct for MF_SKILL_DAMAGE struct s_skill_damage { unsigned int map; ///< Maps (used for skill_damage_db.txt) uint16 skill_id; ///< Skill ID (used for mapflag) uint16 caster; ///< Caster type int rate[SKILLDMG_MAX]; ///< Used for when all skills are adjusted }; -#endif /// Enum for item drop type for MF_PVP_NIGHTMAREDROP enum e_nightmare_drop_type : uint8 { @@ -626,9 +625,7 @@ struct s_drop_list { union u_mapflag_args { struct point nosave; struct s_drop_list nightmaredrop; -#ifdef ADJUST_SKILL_DAMAGE struct s_skill_damage skill_damage; -#endif int flag_val; }; @@ -739,10 +736,8 @@ struct map_data { struct point save; std::vector drop_list; uint32 zone; // zone number (for item/skill restrictions) -#ifdef ADJUST_SKILL_DAMAGE struct s_skill_damage damage_adjust; // Used for overall skill damage adjustment std::vector skill_damage; // Used for single skill damage adjustment -#endif struct npc_data *npc[MAX_NPC_PER_MAP]; struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer] @@ -954,9 +949,7 @@ void map_removemobs(int16 m); // [Wizputer] void map_addmap2db(struct map_data *m); void map_removemapdb(struct map_data *m); -#ifdef ADJUST_SKILL_DAMAGE void map_skill_damage_add(struct map_data *m, uint16 skill_id, int rate[SKILLDMG_MAX], uint16 caster); -#endif enum e_mapflag map_getmapflag_by_name(char* name); bool map_getmapflag_name(enum e_mapflag mapflag, char* output); diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 94e235d2c3e..e2cefec648b 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -4052,17 +4052,15 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con break; case MF_SKILL_DAMAGE: { -#ifdef ADJUST_SKILL_DAMAGE char skill_name[SKILL_NAME_LENGTH]; char caster_constant[NAME_LENGTH]; + union u_mapflag_args args = {}; memset(skill_name, 0, sizeof(skill_name)); if (!state) - map_setmapflag(m, MF_SKILL_DAMAGE, false); + map_setmapflag_sub(m, MF_SKILL_DAMAGE, false, &args); else { - union u_mapflag_args args = {}; - if (sscanf(w4, "%30[^,],%23[^,],%11d,%11d,%11d,%11d[^\n]", skill_name, caster_constant, &args.skill_damage.rate[SKILLDMG_PC], &args.skill_damage.rate[SKILLDMG_MOB], &args.skill_damage.rate[SKILLDMG_BOSS], &args.skill_damage.rate[SKILLDMG_OTHER]) >= 3) { if (ISDIGIT(caster_constant[0])) args.skill_damage.caster = atoi(caster_constant); @@ -4088,14 +4086,12 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con else if (skill_name2id(skill_name) <= 0) ShowWarning("npc_parse_mapflag: Invalid skill name '%s' for Skill Damage mapflag. Skipping (file '%s', line '%d').\n", skill_name, filepath, strline(buffer, start - buffer)); else { // Adjusted damage for specified skill - map_setmapflag(m, MF_SKILL_DAMAGE, true); + args.flag_val = 1; + map_setmapflag_sub(m, MF_SKILL_DAMAGE, true, &args); map_skill_damage_add(&map[m], skill_name2id(skill_name), args.skill_damage.rate, args.skill_damage.caster); } } } -#else - ShowWarning("npc_parse_mapflag: skill_damage: ADJUST_SKILL_DAMAGE is inactive (src/config/core.hpp). Skipping this mapflag..\n"); -#endif break; } diff --git a/src/map/script.cpp b/src/map/script.cpp index aa05b45d4eb..aa2f9af309b 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -12250,7 +12250,6 @@ BUILDIN_FUNC(getmapflag) int16 m; int mf; const char *str; - union u_mapflag_args args = {}; str=script_getstr(st,2); @@ -12267,9 +12266,12 @@ BUILDIN_FUNC(getmapflag) return SCRIPT_CMD_FAILURE; } -#ifdef ADJUST_SKILL_DAMAGE - FETCH(4, args.flag_val); -#endif + union u_mapflag_args args = {}; + + if (mf == MF_SKILL_DAMAGE && !script_hasdata(st, 4)) + args.flag_val = SKILLDMG_MAX; + else + FETCH(4, args.flag_val); script_pushint(st, map_getmapflag_sub(m, static_cast(mf), &args)); @@ -12281,7 +12283,6 @@ BUILDIN_FUNC(setmapflag) int16 m; int mf; const char *str; - union u_mapflag_args args = {}; str = script_getstr(st,2); @@ -12298,12 +12299,31 @@ BUILDIN_FUNC(setmapflag) return SCRIPT_CMD_FAILURE; } - if( mf == MF_SKILL_DAMAGE ){ - ShowError( "buildin_setmapflag: Skill damage adjust is not supported. Please use setmapflagskilldmg.\n" ); - return SCRIPT_CMD_FAILURE; - } + union u_mapflag_args args = {}; - FETCH(4, args.flag_val); + switch(mf) { + case MF_SKILL_DAMAGE: + if (script_hasdata(st, 4) && script_hasdata(st, 5)) + args.skill_damage.rate[script_getnum(st, 5)] = script_getnum(st, 4); + else { + ShowWarning("buildin_setmapflag: Unable to set skill_damage mapflag as flag data is missing.\n"); + return SCRIPT_CMD_FAILURE; + } + break; + case MF_NOSAVE: // Assume setting "SavePoint" + args.nosave.map = 0; + args.nosave.x = -1; + args.nosave.y = -1; + break; + case MF_PVP_NIGHTMAREDROP: // Assume setting standard drops + args.nightmaredrop.drop_id = -1; + args.nightmaredrop.drop_per = 300; + args.nightmaredrop.drop_type = NMDT_EQUIP; + break; + default: + FETCH(4, args.flag_val); + break; + } map_setmapflag_sub(m, static_cast(mf), true, &args); diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp index 939aea5fe44..e0b059ab8d5 100644 --- a/src/map/script_constants.hpp +++ b/src/map/script_constants.hpp @@ -7269,6 +7269,14 @@ export_constant(BL_MER); export_constant(BL_ELEM); + /* skill damage mapflag types */ + export_constant(SKILLDMG_PC); + export_constant(SKILLDMG_MOB); + export_constant(SKILLDMG_BOSS); + export_constant(SKILLDMG_OTHER); + export_constant(SKILLDMG_MAX); + export_constant(SKILLDMG_CASTER); + #undef export_constant #undef export_constant2 #undef export_parameter diff --git a/src/map/skill.cpp b/src/map/skill.cpp index 8c0595d070d..735910b9515 100755 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -21455,7 +21455,6 @@ static bool skill_parse_row_changematerialdb(char* split[], int columns, int cur return true; } -#ifdef ADJUST_SKILL_DAMAGE /** * Reads skill damage adjustment * @author [Lilith] @@ -21472,17 +21471,16 @@ static bool skill_parse_row_skilldamage(char* split[], int columns, int current) id = skill_db_isset(id, __FUNCTION__); - memset(&skill_db[id]->damage,0,sizeof(struct s_skill_damage)); + skill_db[id]->damage = {}; skill_db[id]->damage.caster |= atoi(split[1]); skill_db[id]->damage.map |= atoi(split[2]); - for(int offset = 3, int i = 0; i < SKILLDMG_MAX && offset < columns; i++, offset++ ){ + for(int offset = 3, i = 0; i < SKILLDMG_MAX && offset < columns; i++, offset++ ){ skill_db[id]->damage.rate[i] = cap_value(atoi(split[offset]), -100, INT_MAX); } return true; } -#endif /** * Init dummy skill db also init Skill DB allocation @@ -21590,9 +21588,8 @@ static void skill_readdb(void) sv_readdb(dbsubpath1, "skill_improvise_db.txt" , ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill_parse_row_improvisedb, i > 0); sv_readdb(dbsubpath1, "skill_changematerial_db.txt" , ',', 5, 5+2*MAX_SKILL_CHANGEMATERIAL_SET, MAX_SKILL_CHANGEMATERIAL_DB, skill_parse_row_changematerialdb, i > 0); sv_readdb(dbsubpath1, "skill_nonearnpc_db.txt" , ',', 2, 3, -1, skill_parse_row_nonearnpcrangedb, i > 0); -#ifdef ADJUST_SKILL_DAMAGE sv_readdb(dbsubpath1, "skill_damage_db.txt" , ',', 4, 3+SKILLDMG_MAX, -1, skill_parse_row_skilldamage, i > 0); -#endif + aFree(dbsubpath1); aFree(dbsubpath2); } diff --git a/src/map/skill.hpp b/src/map/skill.hpp index 7f8a0c3bca8..ee17bb56b07 100644 --- a/src/map/skill.hpp +++ b/src/map/skill.hpp @@ -225,9 +225,7 @@ struct s_skill_db { uint8 unit_nonearnpc_type; //type of NPC [Cydh] // skill_damage_db.txt -#ifdef ADJUST_SKILL_DAMAGE struct s_skill_damage damage; -#endif // skill_copyable_db.txt struct s_copyable { // [Cydh]