summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-05 20:24:11 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-05 20:24:11 +0300
commit30df3dc33ff6b36309efca4c23af82a68ee35ca6 (patch)
treed3e58ab441deee63b69cea794a336c224f136a8b
parent767fc78589716529874626d6adecbec9e0515680 (diff)
downloadevol-hercules-30df3dc33ff6b36309efca4c23af82a68ee35ca6.tar.gz
evol-hercules-30df3dc33ff6b36309efca4c23af82a68ee35ca6.tar.bz2
evol-hercules-30df3dc33ff6b36309efca4c23af82a68ee35ca6.tar.xz
evol-hercules-30df3dc33ff6b36309efca4c23af82a68ee35ca6.zip
Reimpliment packet 0x2e1 for old clients.
-rw-r--r--src/emap/clif.c101
-rw-r--r--src/emap/clif.h9
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/packets_struct.h24
4 files changed, 131 insertions, 4 deletions
diff --git a/src/emap/clif.c b/src/emap/clif.c
index 854d9f1..87e65b5 100644
--- a/src/emap/clif.c
+++ b/src/emap/clif.c
@@ -15,6 +15,7 @@
#include "common/strlib.h"
#include "common/cbasetypes.h"
//#include "common/utils.h"
+#include "common/random.h"
#include "common/timer.h"
#include "map/guild.h"
#include "map/mob.h"
@@ -352,7 +353,7 @@ bool eclif_send(const void* buf __attribute__ ((unused)),
if (*len >= 2)
{
const int packet = RBUFW (buf, 0);
- if (packet == 0x9dd || packet == 0x9dc || packet == 0x9db)
+ if (packet == 0x9dd || packet == 0x9dc || packet == 0x9db || packet == 0x8c8)
{
struct map_session_data *sd = BL_CAST(BL_PC, bl);
struct SessionExt *data = session_get_bysd(sd);
@@ -364,7 +365,7 @@ bool eclif_send(const void* buf __attribute__ ((unused)),
return true;
}
}
- if (packet == 0x915 || packet == 0x90f || packet == 0x914)
+ if (packet == 0x915 || packet == 0x90f || packet == 0x914 || packet == 0x2e1)
{
struct map_session_data *sd = BL_CAST(BL_PC, bl);
struct SessionExt *data = session_get_bysd(sd);
@@ -509,7 +510,7 @@ int eclif_send_actual(int *fd, void *buf, int *len)
return 0;
}
}
- if (packet == 0x9dd || packet == 0x9dc || packet == 0x9db)
+ if (packet == 0x9dd || packet == 0x9dc || packet == 0x9db || packet == 0x8c8)
{
struct SessionExt *data = session_get(*fd);
if (!data)
@@ -520,7 +521,7 @@ int eclif_send_actual(int *fd, void *buf, int *len)
return 0;
}
}
- if (packet == 0x915 || packet == 0x90f || packet == 0x914)
+ if (packet == 0x915 || packet == 0x90f || packet == 0x914 || packet == 0x2e1)
{
struct SessionExt *data = session_get(*fd);
if (!data)
@@ -612,6 +613,13 @@ static inline unsigned char clif_bl_type_old(struct block_list *bl) {
}
}
+//Modifies the type of damage according to status changes [Skotlex]
+//Aegis data specifies that: 4 endure against single hit sources, 9 against multi-hit.
+static inline int clif_calc_delay(int type, int div, int damage, int delay)
+{
+ return ( delay == 0 && damage > 0 ) ? ( div > 1 ? 9 : 4 ) : type;
+}
+
// this function must be used only by clients version < 16
void eclif_set_unit_idle_old(struct block_list* bl,
struct map_session_data *tsd,
@@ -817,6 +825,75 @@ void eclif_set_unit_walking_old(struct block_list* bl,
}
}
+void eclif_damage_old(struct block_list* src,
+ struct block_list* dst,
+ int sdelay,
+ int ddelay,
+ int64 in_damage,
+ short div,
+ unsigned char type,
+ int64 in_damage2)
+{
+ struct packet_damage_old p;
+ struct status_change *sc;
+ int damage,damage2;
+
+ nullpo_retv(src);
+ nullpo_retv(dst);
+
+ sc = status->get_sc(dst);
+
+ if(sc && sc->count && sc->data[SC_ILLUSION]) {
+ if(in_damage) in_damage = in_damage*(sc->data[SC_ILLUSION]->val2); //+ rnd()%100;
+ if(in_damage2) in_damage2 = in_damage2*(sc->data[SC_ILLUSION]->val2); //+ rnd()%100;
+ }
+
+ damage = (int)min(in_damage,INT_MAX);
+ damage2 = (int)min(in_damage2,INT_MAX);
+
+ type = clif_calc_delay(type,div,damage+damage2,ddelay);
+
+ p.PacketType = 0x2e1;
+ p.GID = src->id;
+ p.targetGID = dst->id;
+ p.startTime = (uint32)timer->gettick();
+ p.attackMT = sdelay;
+ p.attackedMT = ddelay;
+ p.count = div;
+ p.action = type;
+
+ if (battle->bc->hide_woe_damage && map_flag_gvg2(src->m) ) {
+ p.damage = damage?div:0;
+ p.leftDamage = damage2?div:0;
+ } else {
+ p.damage = damage;
+ p.leftDamage = damage2;
+ }
+// p.is_sp_damaged = 0; // [ToDo] IsSPDamage - Displays blue digits.
+
+ if(disguised(dst)) {
+ clif->send(&p,sizeof(p),dst,AREA_WOS);
+ p.targetGID = -dst->id;
+ clif->send(&p,sizeof(p),dst,SELF);
+ } else
+ clif->send(&p,sizeof(p),dst,AREA);
+
+ if(disguised(src)) {
+ p.GID = -src->id;
+ if (disguised(dst))
+ p.targetGID = dst->id;
+
+ if(damage > 0) p.damage = -1;
+ if(damage2 > 0) p.leftDamage = -1;
+
+ clif->send(&p,sizeof(p),src,SELF);
+ }
+
+ if(src == dst) {
+ unit->setdir(src,unit->getdir(src));
+ }
+}
+
void eclif_set_unit_idle_post(struct block_list* bl, TBL_PC *tsd,
enum send_target *target)
{
@@ -852,6 +929,22 @@ void eclif_set_unit_walking_post(struct block_list* bl, TBL_PC *tsd,
}
}
+int eclif_damage_post(int retVal,
+ struct block_list* src,
+ struct block_list* dst,
+ int *sdelay,
+ int *ddelay,
+ int64 *in_damage,
+ short *div,
+ unsigned char *type,
+ int64 *in_damage2)
+{
+ eclif_damage_old(src, dst,
+ *sdelay, *ddelay, *in_damage,
+ *div, *type, *in_damage2);
+ return retVal;
+}
+
void eclif_move(struct unit_data *ud)
{
TBL_PC *sd = BL_CAST(BL_PC, ud->bl);
diff --git a/src/emap/clif.h b/src/emap/clif.h
index 8879e33..31e6839 100644
--- a/src/emap/clif.h
+++ b/src/emap/clif.h
@@ -24,6 +24,15 @@ void eclif_set_unit_walking_pre(struct block_list* bl, TBL_PC *tsd,
struct unit_data* ud, enum send_target *target);
void eclif_set_unit_walking_post(struct block_list* bl, TBL_PC *tsd,
struct unit_data* ud, enum send_target *target);
+int eclif_damage_post(int retVal,
+ struct block_list* src,
+ struct block_list* dst,
+ int *sdelay,
+ int *ddelay,
+ int64 *in_damage,
+ short *div,
+ unsigned char *type,
+ int64 *in_damage2);
void eclif_move(struct unit_data *ud);
void eclif_parse_LoadEndAck_pre(int *fdPtr,
struct map_session_data *sd);
diff --git a/src/emap/init.c b/src/emap/init.c
index 0796748..ce98a96 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -217,6 +217,7 @@ HPExport void plugin_init (void)
addHookPost("clif->set_unit_idle", eclif_set_unit_idle_post);
addHookPost("clif->pLoadEndAck", eclif_parse_LoadEndAck_post);
addHookPost("clif->spawn", eclif_spawn_post);
+ addHookPost("clif->damage", eclif_damage_post);
addHookPost("status->set_viewdata", estatus_set_viewdata_post);
addHookPost("status->read_job_db_sub", estatus_read_job_db_sub);
addHookPost("status->calc_pc_", estatus_calc_pc__post);
diff --git a/src/emap/packets_struct.h b/src/emap/packets_struct.h
index 9a030ce..52b0dc5 100644
--- a/src/emap/packets_struct.h
+++ b/src/emap/packets_struct.h
@@ -222,4 +222,28 @@ struct packet_unit_walking_old {
#endif
} __attribute__((packed));
+struct packet_damage_old {
+ short PacketType;
+ unsigned int GID;
+ unsigned int targetGID;
+ unsigned int startTime;
+ int attackMT;
+ int attackedMT;
+#if PACKETVER < 20071113
+ short damage;
+#else
+ int damage;
+#endif
+//#if PACKETVER >= 20131223
+// unsigned char is_sp_damaged;
+//#endif
+ short count;
+ unsigned char action;
+#if PACKETVER < 20071113
+ short leftDamage;
+#else
+ int leftDamage;
+#endif
+} __attribute__((packed));
+
#endif /* EVOL_MAP_PACKETS_STRUCT_H */