summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-09-27 23:21:26 -0300
committerJesusaves <cpntb1@ymail.com>2020-09-27 23:21:26 -0300
commitd0f528217d160222464e9847de1c735ac96902f8 (patch)
tree801a1c54c17056cedf9848e91bf0ada4e53656d9
parent7fc3f47e2660ae5b88a4dcdc1c1ca2e6f41ecd9e (diff)
downloadplugin-d0f528217d160222464e9847de1c735ac96902f8.tar.gz
plugin-d0f528217d160222464e9847de1c735ac96902f8.tar.bz2
plugin-d0f528217d160222464e9847de1c735ac96902f8.tar.xz
plugin-d0f528217d160222464e9847de1c735ac96902f8.zip
Force all parties to have EXP sharing by default, and this share to be uneven.
Initial version. Very very messy, totally **untested**, with zeny feature removed. And a compile error on battle_config >.> *sigh* But oh well, must submit this to MR list before deadline, so it can be reviewed properly and etc. - It is still 23:22 so \o/
-rw-r--r--src/Makefile.am4
-rw-r--r--src/echar/init.c6
-rw-r--r--src/echar/int_party.c47
-rw-r--r--src/echar/int_party.h15
-rw-r--r--src/emap/init.c2
-rw-r--r--src/emap/party.c79
-rw-r--r--src/emap/party.h13
7 files changed, 166 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 1727ae9..3527e73 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,6 +5,8 @@ CHAR_SRC = echar/char.c \
echar/config.c \
echar/config.h \
echar/init.c \
+ echar/int_party.c \
+ echar/int_party.h \
ecommon/config.c \
ecommon/config.h \
ecommon/enum/gender.h \
@@ -75,6 +77,8 @@ MAP_SRC = emap/atcommand.c \
emap/npc.h \
emap/parse.c \
emap/parse.h \
+ emap/party.c \
+ emap/party.h \
emap/pc.c \
emap/pc.h \
emap/permission.c \
diff --git a/src/echar/init.c b/src/echar/init.c
index 8b7a343..31faf8a 100644
--- a/src/echar/init.c
+++ b/src/echar/init.c
@@ -37,6 +37,7 @@
#include "ecommon/init.h"
#include "echar/char.h"
#include "echar/config.h"
+#include "echar/int_party.h"
#include "plugins/HPMHooking.h"
@@ -70,6 +71,11 @@ HPExport void plugin_init (void)
addHookPre(chr, mmo_gender, echar_mmo_gender);
addHookPre(chr, changecharsex, echar_changecharsex);
+ // Other stuff (alphabetically sorted as usual)
+ addHookPre(inter_party, check_lv, einter_party_check_lv);
+ addHookPre(inter_party, change_option, einter_party_change_option_pre);
+
+
addHookPost(chr, send_HC_ACK_CHARINFO_PER_PAGE, echar_send_HC_ACK_CHARINFO_PER_PAGE_post);
addHookPost(chr, mmo_char_send_characters, echar_mmo_char_send_characters_post);
addHookPost(chr, parse_char_connect, echar_parse_char_connect_post);
diff --git a/src/echar/int_party.c b/src/echar/int_party.c
new file mode 100644
index 0000000..21f117a
--- /dev/null
+++ b/src/echar/int_party.c
@@ -0,0 +1,47 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 - 2015 Evol developers
+
+#include "common/hercules.h"
+#include "common/nullpo.h"
+#include "char/int_party.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/mmo.h"
+#include "common/sql.h"
+
+
+#include "plugins/HPMHooking.h"
+
+HPExport struct HPMHooking_interface HPMHooking_s;
+
+#include "common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */
+
+int einter_party_check_lv(struct party_data **p)
+{
+ hookStop();
+ nullpo_ret(p);
+
+ // Force EXP sharing to be active
+ if ((*p)->party.exp == 0) {
+ (*p)->party.exp = 1;
+ mapif->party_optionchanged(0, &(*p)->party, 0, 0);
+ inter_party->tosql(&(*p)->party, PS_BASIC, 0);
+ }
+
+ return 1;
+}
+
+//Party setting change request
+// Overrides exp to always be true
+bool einter_party_change_option_pre(int *party_id __attribute__ ((unused)),
+ int *account_id __attribute__ ((unused)),
+ int *exp,
+ int *item __attribute__ ((unused)),
+ int *map_fd __attribute__ ((unused)))
+{
+ if (!exp)
+ (*exp) = 1;
+ return true;
+}
+
diff --git a/src/echar/int_party.h b/src/echar/int_party.h
new file mode 100644
index 0000000..390f430
--- /dev/null
+++ b/src/echar/int_party.h
@@ -0,0 +1,15 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 - 2015 Evol developers
+
+#ifndef EVOL_CHAR_PARTY
+#define EVOL_CHAR_PARTY
+
+int einter_party_check_lv(struct party_data **p);
+
+bool einter_party_change_option_pre(int *party_id,
+ int *account_id,
+ int *exp,
+ int *item,
+ int *map_fd);
+
+#endif // EVOL_CHAR_PARTY
diff --git a/src/emap/init.c b/src/emap/init.c
index f2e781a..95a7225 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -70,6 +70,7 @@
#include "emap/npc.h"
#include "emap/unit.h"
#include "emap/parse.h"
+#include "emap/party.h"
#include "emap/permission.h"
#include "emap/pc.h"
#include "emap/quest.h"
@@ -337,6 +338,7 @@ HPExport void plugin_init (void)
addHookPre(map, iwall_set, emap_iwall_set_pre);
addHookPre(map, iwall_get, emap_iwall_get_pre);
addHookPre(map, iwall_remove, emap_iwall_remove_pre);
+ addHookPre(party, exp_share, eparty_exp_share);
addHookPre(script, get_val_npc_num, eget_val_npcscope_num_pre);
addHookPre(script, get_val_ref_num, eget_val_npcscope_num_pre);
addHookPre(script, get_val_npc_str, eget_val_npcscope_str_pre);
diff --git a/src/emap/party.c b/src/emap/party.c
new file mode 100644
index 0000000..d268830
--- /dev/null
+++ b/src/emap/party.c
@@ -0,0 +1,79 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 - 2015 Evol developers
+
+#include "common/hercules.h"
+#include "common/nullpo.h"
+#include "common/timer.h"
+#include "common/socket.h" // last_tick
+#include "common/utils.h"
+#include "map/battle.h"
+#include "map/intif.h"
+#include "map/map.h"
+#include "map/party.h"
+#include "map/pc.h"
+
+
+#include "plugins/HPMHooking.h"
+
+HPExport struct HPMHooking_interface HPMHooking_s;
+
+#include "common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */
+
+// exp share and added zeny share [Valaris]
+int eparty_exp_share(struct party_data **p, struct block_list **src, unsigned int *baseexp, unsigned int *jobexp, int *zeny __attribute__ ((unused)))
+{
+ hookStop();
+ struct map_session_data* sd[MAX_PARTY];
+ unsigned int i, c, lvl;
+ unsigned int base_exp, job_exp;
+
+ nullpo_ret(p);
+ nullpo_ret(src);
+
+ // count the number of players eligible for exp sharing
+ for (i = c = 0; i < MAX_PARTY; i++) {
+ if( (sd[c] = (*p)->data[i].sd) == NULL || sd[c]->bl.m != (*src)->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle(sd[c])) )
+ continue;
+ c++;
+ lvl += sd[c]->status.base_level; // XXX
+ }
+ if (c < 1)
+ return 0;
+
+ // We don't care for pointers...
+ base_exp=*baseexp;
+ job_exp=*jobexp;
+
+ /* GP sharing defunct */
+ //zeny/=c;
+
+ // Apply bonuses
+ if (battle_config.party_even_share_bonus && c > 1) {
+ double bonus = 100 + battle_config.party_even_share_bonus*(c-1);
+ if (base_exp)
+ base_exp = (unsigned int) cap_value(base_exp * bonus/100, 0, UINT_MAX);
+ if (job_exp)
+ job_exp = (unsigned int) cap_value(job_exp * bonus/100, 0, UINT_MAX);
+ //if (zeny)
+ // zeny = (unsigned int) cap_value(zeny * bonus/100, INT_MIN, INT_MAX);
+ }
+
+ for (i = 0; i < c; i++) {
+ //pc->gainexp(sd[i], src, base_exp, job_exp, false);
+ // XXX
+ pc->gainexp(sd[i], (*src),
+ base_exp*sd[i]->status.base_level/lvl,
+ job_exp*sd[i]->status.base_level/lvl,
+ false);
+
+ //if (zeny) // zeny from mobs [Valaris]
+ // pc->getzeny(sd[i],zeny,LOG_TYPE_PICKDROP_MONSTER,NULL);
+ }
+ return 0;
+}
+
+// TODO: Override party_share_loot
+// party_share_type does not contains 2 ("random")
+// Use level as randomness criteria
+
+
diff --git a/src/emap/party.h b/src/emap/party.h
new file mode 100644
index 0000000..3148de1
--- /dev/null
+++ b/src/emap/party.h
@@ -0,0 +1,13 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 - 2015 Evol developers
+
+#ifndef EVOL_MAP_PARTY
+#define EVOL_MAP_PARTY
+
+int eparty_exp_share(struct party_data **p,
+ struct block_list **src,
+ unsigned int *baseexp,
+ unsigned int *jobexp,
+ int *zeny);
+
+#endif // EVOL_MAP_PARTY