bWolfie 138 Posted February 22, 2019 Hello, I'm trying to make MATK = 1 for players while on a certain map (my_map). I've had success with all the other stats using this method, but MATK doesn't seem to change. static int status_calc_pc__post(int ret, struct map_session_data *sd, enum e_status_calc_opt opt) { nullpo_retr(-1, sd); if (strcmpi(map->list[sd->bl.m].name, "my_map") != 0) return ret; struct status_data *bstatus = &sd->base_status; bstatus->max_hp = 40; bstatus->matk_max = 1; bstatus->matk_min = 1; return ret; } Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted February 22, 2019 (edited) Spoiler #include "common/hercules.h" #include "map/pc.h" #include "map/status.h" #include "plugins/HPMHooking.h" #include "common/HPMDataCheck.h" HPExport struct hplugin_info pinfo = { "atk1", SERVER_TYPE_MAP, "0.1", HPM_VERSION, }; int status_get_matk_post( int retVal, struct block_list *bl, int flag ) { if ( retVal != 0 ) return retVal; return retVal; } int status_calc_pc_post( int retVal, struct map_session_data *sd, enum e_status_calc_opt opt ) { if ( retVal != 0 ) return retVal; if ( strcmp( mapindex_id2name(sd->mapindex), "guild_vs2" ) ) return 0; struct status_data *bstatus = &sd->base_status; clif->message( sd->fd, "Run" ); // struct status_data *bstatus = status->get_status_data(&sd->bl); bstatus->max_hp = 40; bstatus->matk_max = 1; bstatus->matk_min = 1; sd->battle_status.matk_max = 1; sd->battle_status.matk_min = 1; sd->base_status.matk_min = 1; sd->base_status.matk_max = 1; // sd->battle_status.max_hp = 99; bstatus->hit = 1; bstatus->flee = 1; ShowDebug( "%d %d", status_get_matk_min(&sd->bl), status_get_matk_max(&sd->bl) ); return 0; } HPExport void plugin_init(void) { addHookPost( status, calc_pc_, status_calc_pc_post ); } doesn't work, ShowDebug even shows I'm having 1 1 value ... yet still dealing over hundreds of damage to poring tell you what ... use my OnPCStatCalcEvent ... OnPCStatCalcEvent: bonus bMatkRate, -100; // bonus bMatk, -999; end; there is a reason why this modification is so famous ... Edited February 22, 2019 by AnnieRuru 1 bWolfie reacted to this Quote Share this post Link to post Share on other sites
0 hemagx 69 Posted February 24, 2019 (edited) Well I've done few changes to this, I used same method as @AnnieRuru but as a plugin, first hercules provides us with the amazing status->pc_calc_additional which is meant for plugins, it's placed right after Equipment parse so it would not overwrite the value the plugin set, and then the plugin set the matk rate to 0, and tada! I've also changed map check to check the id of the map instead, this is simpler, faster and also allowed a run time check for if you accidentally put a wrong map name (check server_online function), and it's tested :3 works as charm! /** * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * * Copyright (C) 2013-2019 Hercules Dev Team * Copyright (C) Hemagx <brahem@aotsw.com> * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /// Zero Matk Hercules Plugin #include "common/hercules.h" /* Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces) */ #include "common/core.h" #include "common/mapindex.h" #include "map/map.h" #include "map/pc.h" #include "map/status.h" #include "plugins/HPMHooking.h" #include "common/HPMDataCheck.h" /* should always be the last Hercules file included! (if you don't make it last, it'll intentionally break compile time) */ HPExport struct hplugin_info pinfo = { "Zero MATK", // Plugin name SERVER_TYPE_MAP,// Which server types this plugin works with? "0.1", // Plugin version HPM_VERSION, // HPM Version (don't change, macro is automatically updated) }; const char *map_name = "prontera"; int16 map_id = -1; // init it with invalid value to make sure on failure it would always cause our check to fail. static void status_calc_pc_additional_post(struct map_session_data *sd, enum e_status_calc_opt opt) { if (sd == NULL) // I don'r prefer usage of nullpo in hooks, unless we're replacing a function multiaple nullpo reports can turn confusing. return; if (sd->bl.m != map_id) return; sd->matk_rate = 0; return; } /* run when server starts */ HPExport void plugin_init (void) { addHookPost(status, calc_pc_additional, status_calc_pc_additional_post); } HPExport void server_online (void) { unsigned short map_index; if ((map_index = mapindex->name2id(map_name)) == 0) { ShowError("%s:plugin_init: Failed to get map index for map %s the plugin would now fail to start\n", pinfo.name, map_name); core->runflag = CORE_ST_STOP; } if ((map_id = map->mapindex2mapid(map_index)) == -1) { ShowError("%s:plugin_init: Failed to get map id for map %s the plugin would now fail to start\n", pinfo.name, map_name); core->runflag = CORE_ST_STOP; } } Edited February 24, 2019 by hemagx 2 AnnieRuru and Asheraf reacted to this Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted February 24, 2019 (edited) OnPCStatCalcEvent is very famous modification, if you do forum search in rathena or hercules, you can even get some custom stuffs that only applicable with this mod if (sd == NULL) // I don'r prefer usage of nullpo in hooks, unless we're replacing a function multiaple nullpo reports can turn confusing. well, personally, Pre-Hook needs nullpo, Post-Hook doesn't need ... though hahaha, yeah I go change that XD Edited February 24, 2019 by AnnieRuru Quote Share this post Link to post Share on other sites
Hello,
I'm trying to make MATK = 1 for players while on a certain map (my_map). I've had success with all the other stats using this method, but MATK doesn't seem to change.
Share this post
Link to post
Share on other sites