summaryrefslogtreecommitdiff
path: root/src/emap/party.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emap/party.c')
-rw-r--r--src/emap/party.c79
1 files changed, 79 insertions, 0 deletions
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
+
+