diff options
author | Haru <haru@dotalux.com> | 2018-04-03 00:04:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-03 00:04:17 +0200 |
commit | 237fd6d094d698f22dceccfb87e7957cdcf1af3d (patch) | |
tree | f967ad604e6e9ba91cc084fe4336c3dda1487ba9 | |
parent | 112c34e0e1b92397f0df7eea459fcbac946d340b (diff) | |
parent | 1f5fc491881f1a75c261e6c2321c6b92eb2d01bc (diff) | |
download | hercules-237fd6d094d698f22dceccfb87e7957cdcf1af3d.tar.gz hercules-237fd6d094d698f22dceccfb87e7957cdcf1af3d.tar.bz2 hercules-237fd6d094d698f22dceccfb87e7957cdcf1af3d.tar.xz hercules-237fd6d094d698f22dceccfb87e7957cdcf1af3d.zip |
Merge pull request #1965 from dastgir/2018/3-hateffect
Implemented HatEffect
-rw-r--r-- | db/constants.conf | 58 | ||||
-rw-r--r-- | db/re/item_db.conf | 4 | ||||
-rw-r--r-- | doc/script_commands.txt | 7 | ||||
-rw-r--r-- | src/map/clif.c | 59 | ||||
-rw-r--r-- | src/map/clif.h | 3 | ||||
-rw-r--r-- | src/map/pc.c | 1 | ||||
-rw-r--r-- | src/map/pc.h | 3 | ||||
-rw-r--r-- | src/map/script.c | 39 | ||||
-rw-r--r-- | src/map/unit.c | 1 |
9 files changed, 173 insertions, 2 deletions
diff --git a/db/constants.conf b/db/constants.conf index 8c3336f79..cc0fb3104 100644 --- a/db/constants.conf +++ b/db/constants.conf @@ -3877,4 +3877,62 @@ constants_db: { UDT_STATADD: 54 UDT_ROBE: 55 UDT_BODY2: 56 + + comment__: "HatEffect Constants" + HAT_EF_BLOSSOM_FLUTTERING: 1 + HAT_EF_MERMAID_LONGING: 2 + HAT_EF_RL_BANISHING_BUSTER: 3 + HAT_EF_LJOSALFAR: 4 + HAT_EF_CLOCKING: 5 + HAT_EF_SNOW: 6 + HAT_EF_MAKEBLUR: 7 + HAT_EF_SLEEPATTACK: 8 + HAT_EF_GUMGANG: 9 + HAT_EF_TALK_FROSTJOKE: 10 + HAT_EF_DEMONSTRATION: 11 + HAT_EF_FLUTTER_BUTTERFLY: 12 + HAT_EF_ANGEL_FLUTTERING: 13 + HAT_EF_BLESSING_OF_ANGELS: 14 + HAT_EF_ELECTRIC: 15 + HAT_EF_GREEN_FLOOR: 16 + HAT_EF_SHRINK: 17 + HAT_EF_VALHALLA_IDOL: 18 + HAT_EF_ANGEL_STAIRS: 19 + HAT_EF_GLOW_OF_NEW_YEAR: 20 + HAT_EF_BOTTOM_FORTUNEKISS: 21 + HAT_EF_PINKBODY: 22 + HAT_EF_DOUBLEGUMGANG: 23 + HAT_EF_GIANTBODY: 24 + HAT_EF_GREEN99_6: 25 + HAT_EF_CIRCLEPOWER: 26 + HAT_EF_BOTTOM_BLOODYLUST: 27 + HAT_EF_WATER_BELOW: 28 + HAT_EF_LEVEL99_150: 29 + HAT_EF_YELLOWFLY3: 30 + HAT_EF_KAGEMUSYA: 31 + HAT_EF_CHERRYBLOSSOM: 32 + HAT_EF_STRANGELIGHTS: 33 + HAT_EF_WL_TELEKINESIS_INTENSE: 34 + HAT_EF_AB_OFFERTORIUM_RING: 35 + HAT_EF_WHITEBODY2: 36 + HAT_EF_SAKURA: 37 + HAT_EF_CLOUD2: 38 + HAT_EF_FEATHER_FLUTTERING: 39 + HAT_EF_CAMELLIA_HAIR_PIN: 40 + HAT_EF_JP_EV_EFFECT01: 41 + HAT_EF_JP_EV_EFFECT02: 42 + HAT_EF_JP_EV_EFFECT03: 43 + HAT_EF_FLORAL_WALTZ: 44 + HAT_EF_MAGICAL_FEATHER: 45 + HAT_EF_HAT_EFFECT: 46 + HAT_EF_BAKURETSU_HADOU: 47 + HAT_EF_GOLD_SHOWER: 48 + HAT_EF_WHITEBODY: 49 + HAT_EF_WATER_BELOW2: 50 + HAT_EF_FIREWORK: 51 + HAT_EF_RETURN_TW_1ST_HAT: 52 + HAT_EF_C_FLUTTERBUTTERFLY_BL: 53 + HAT_EF_QSCARABA: 54 + HAT_EF_FSTONE: 55 + HAT_EF_MAGICCIRCLE: 56 } diff --git a/db/re/item_db.conf b/db/re/item_db.conf index 80baad89f..6c4e820e8 100644 --- a/db/re/item_db.conf +++ b/db/re/item_db.conf @@ -144605,8 +144605,8 @@ item_db: ( Type: "IT_ARMOR" Loc: "EQP_COSTUME_HEAD_LOW" ViewSprite: 1331 - OnEquipScript: <" sc_start SC_BLOSSOM_FLUTTERING, -1, 0; "> - OnUnequipScript: <" sc_end SC_BLOSSOM_FLUTTERING; "> + OnEquipScript: <" hateffect(HAT_EF_BLOSSOM_FLUTTERING, true); "> + OnUnequipScript: <" hateffect(HAT_EF_BLOSSOM_FLUTTERING, false); "> }, { Id: 20286 diff --git a/doc/script_commands.txt b/doc/script_commands.txt index e14e80444..d69322745 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3271,6 +3271,13 @@ produced). It's useful for when you want to check whether an item contains cards or if it's signed. --------------------------------------- + +*hateffect(<Hat Effect ID>, <State>) + +This will set a Hat Effect onto the player. The state field allows you to +enable (true) or disable (false) the effect on the player. + +--------------------------------------- //===================================== 2.1 - End of Item-Related Commands //===================================== diff --git a/src/map/clif.c b/src/map/clif.c index f5adde873..51de62a23 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1539,6 +1539,7 @@ bool clif_spawn(struct block_list *bl) clif->spiritcharm(sd); if (sd->status.look.robe != 0) clif->refreshlook(bl, bl->id, LOOK_ROBE, sd->status.look.robe, AREA); + clif->hat_effect(bl, NULL, AREA); } break; case BL_MOB: @@ -4395,6 +4396,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { clif->sendbgemblem_single(sd->fd,tsd); if (tsd->status.look.robe != 0) clif->refreshlook(&sd->bl, bl->id, LOOK_ROBE, tsd->status.look.robe, SELF); + clif->hat_effect(bl, &sd->bl, SELF); } break; case BL_MER: // Devotion Effects @@ -20226,6 +20228,60 @@ void clif_skill_scale(struct block_list *bl, int src_id, int x, int y, uint16 sk #endif } +/// Send hat effects to the client (ZC_HAT_EFFECT). +/// 0A3B <Length>.W <AID>.L <Status>.B { <HatEffectId>.W } +void clif_hat_effect(struct block_list *bl, struct block_list *tbl, enum send_target target) +{ +#if PACKETVER >= 20150422 + unsigned char *buf; + int len, i; + struct map_session_data *sd; + + nullpo_retv(bl); + + sd = BL_CAST(BL_PC, bl); + + nullpo_retv(sd); + + len = 9 + VECTOR_LENGTH(sd->hatEffectId) * 2; + + buf = (unsigned char*)aMalloc(len); + + WBUFW(buf, 0) = 0xa3b; + WBUFW(buf, 2) = len; + WBUFL(buf, 4) = bl->id; + WBUFB(buf, 8) = 1; + + for( i = 0; i < VECTOR_LENGTH(sd->hatEffectId); i++ ){ + WBUFW(buf, 9 + i * 2) = VECTOR_INDEX(sd->hatEffectId, i); + } + + if (tbl != NULL) { + clif->send(buf, len, tbl, target); + } else { + clif->send(buf, len, bl, target); + } + + aFree(buf); +#endif +} + +void clif_hat_effect_single(struct block_list *bl, uint16 effectId, bool enable){ +#if PACKETVER >= 20150422 + unsigned char buf[13]; + + nullpo_retv(bl); + + WBUFW(buf,0) = 0xa3b; + WBUFW(buf,2) = 13; + WBUFL(buf,4) = bl->id; + WBUFB(buf,8) = enable; + WBUFL(buf,9) = effectId; + + clif_send(buf, 13, bl, AREA); +#endif +} + /*========================================== * Main client packet processing function *------------------------------------------*/ @@ -21316,4 +21372,7 @@ void clif_defaults(void) { clif->clan_leave = clif_clan_leave; clif->clan_message = clif_clan_message; clif->pClanMessage = clif_parse_ClanMessage; + // -- Hat Effect + clif->hat_effect = clif_hat_effect; + clif->hat_effect_single = clif_hat_effect_single; } diff --git a/src/map/clif.h b/src/map/clif.h index acf79c373..ba1a31187 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1413,6 +1413,9 @@ struct clif_interface { void (*clan_leave) (struct map_session_data *sd); void (*clan_message) (struct clan *c, const char *mes, int len); void (*pClanMessage) (int fd, struct map_session_data* sd); + /* Hat Effect */ + void (*hat_effect) (struct block_list *bl, struct block_list *tbl, enum send_target target); + void (*hat_effect_single) (struct block_list *bl, uint16 effectId, bool enable); }; #ifdef HERCULES_CORE diff --git a/src/map/pc.c b/src/map/pc.c index cd4b2a54f..4404101b9 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1293,6 +1293,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim VECTOR_INIT(sd->script_queues); VECTOR_INIT(sd->storage.item); // initialize storage item vector. + VECTOR_INIT(sd->hatEffectId); sd->state.dialog = 0; diff --git a/src/map/pc.h b/src/map/pc.h index a01152df5..e699e5750 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -618,6 +618,9 @@ END_ZEROED_BLOCK; const char* delunit_prevfile; int delunit_prevline; + // HatEffect + VECTOR_DECL(int) hatEffectId; + }; #define EQP_WEAPON EQP_HAND_R diff --git a/src/map/script.c b/src/map/script.c index 45bf076fb..275601dcc 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -23965,6 +23965,42 @@ BUILDIN(clan_master) } /** + * hateffect(EffectID, Enable_State) + */ +BUILDIN(hateffect) +{ +#if PACKETVER >= 20150422 + struct map_session_data *sd = script_rid2sd(st); + int effectId, enabled = 0; + int i; + + if (sd == NULL) + return false; + + effectId = script_getnum(st, 2); + enabled = script_getnum(st, 3); + + for (i = 0; i < VECTOR_LENGTH(sd->hatEffectId); ++i) { + if (VECTOR_INDEX(sd->hatEffectId, i) == effectId) { + if (enabled == 1) { // Already Enabled + return true; + } else { // Remove + VECTOR_ERASE(sd->hatEffectId, i); + clif->hat_effect_single(&sd->bl, effectId, enabled); + return true; + } + } + } + + VECTOR_ENSURE(sd->hatEffectId, 1, 1); + VECTOR_PUSH(sd->hatEffectId, effectId); + + clif->hat_effect_single(&sd->bl, effectId, enabled); +#endif + return true; +} + +/** * Adds a built-in script function. * * @param buildin Script function data @@ -24679,6 +24715,9 @@ void script_parse_builtin(void) { BUILDIN_DEF2(rodex_sendmail2, "rodex_sendmail_acc2", "isss?????????????????????????????????????????"), BUILDIN_DEF(_,"s"), BUILDIN_DEF2(_, "_$", "s"), + + // -- HatEffect + BUILDIN_DEF(hateffect, "ii"), }; int i, len = ARRAYLENGTH(BUILDIN); RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up diff --git a/src/map/unit.c b/src/map/unit.c index c40aa7000..64bd17edc 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2766,6 +2766,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) } VECTOR_CLEAR(sd->script_queues); VECTOR_CLEAR(sd->storage.item); + VECTOR_CLEAR(sd->hatEffectId); sd->storage.received = false; if( sd->quest_log != NULL ) { aFree(sd->quest_log); |