Skip to content

Commit

Permalink
Add script function specialeffectnum
Browse files Browse the repository at this point in the history
  • Loading branch information
4144 committed Dec 5, 2019
1 parent 5de4c18 commit cfb0a96
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/effect_list.md
Expand Up @@ -21,7 +21,7 @@ The following is a compiled list of visual and sound effects which the client
can produce. Each list entry contains a number and a short description of the
effect. You can produce these effects ingame by using the `@effect` atcommand.
It's also possible to attach effects to item/npc scripts by using the
`specialeffect()` script command.
`specialeffect()` or `specialeffectnum()` script commands.

ID | Constant Name | Description
--: | :----------------------------- | :----------------------------------
Expand Down
9 changes: 9 additions & 0 deletions doc/script_commands.txt
Expand Up @@ -6231,6 +6231,15 @@ Example usage:

---------------------------------------

*specialeffectnum(<effect number>, <num1>, <num2>{, <send_target>{, <unit id>{, <account id>}}})
*specialeffectnum(<effect number>, <num1>, <num2>{, <send_target>{, "<NPC Name>"{, <account id>}}})

Works same as specialeffect but also send effect numbers to client.
For PACKETVER >= 20191127 support two numbers (num1, num2).
For older packet versions only num1 supported.

---------------------------------------

*removespecialeffect(<effect number>{, <send_target>{, <unit id>{, <account id>}}})
*removespecialeffect(<effect number>{, <send_target>{, "<NPC Name>"{, <account id>}}})

Expand Down
16 changes: 16 additions & 0 deletions src/map/clif.c
Expand Up @@ -9109,6 +9109,21 @@ static void clif_specialeffect_value(struct block_list *bl, int effect_id, uint6
#endif
}

static void clif_specialeffect_value_single(struct block_list *bl, int effect_id, uint64 num, int fd)
{
#if PACKETVER_MAIN_NUM >= 20060911 || defined(PACKETVER_RE) || defined(PACKETVER_ZERO)
WFIFOHEAD(fd, sizeof(struct PACKET_ZC_NOTIFY_EFFECT3));

struct PACKET_ZC_NOTIFY_EFFECT3 *packet = WFIFOP(fd, 0);
packet->packetType = HEADER_ZC_NOTIFY_EFFECT3;
packet->aid = bl->id;
packet->effectId = effect_id;
packet->num = num;

WFIFOSET(fd, sizeof(struct PACKET_ZC_NOTIFY_EFFECT3));
#endif
}

/// Remove special effects (ZC_REMOVE_EFFECT).
/// 0b0d <id>.L <effect id>.L
/// effect id:
Expand Down Expand Up @@ -24069,6 +24084,7 @@ void clif_defaults(void)
clif->specialeffect = clif_specialeffect;
clif->specialeffect_single = clif_specialeffect_single;
clif->specialeffect_value = clif_specialeffect_value;
clif->specialeffect_value_single = clif_specialeffect_value_single;
clif->removeSpecialEffect = clif_removeSpecialEffect;
clif->removeSpecialEffect_single = clif_removeSpecialEffect_single;
clif->millenniumshield = clif_millenniumshield;
Expand Down
1 change: 1 addition & 0 deletions src/map/clif.h
Expand Up @@ -1031,6 +1031,7 @@ struct clif_interface {
void (*specialeffect) (struct block_list* bl, int type, enum send_target target);
void (*specialeffect_single) (struct block_list* bl, int type, int fd);
void (*specialeffect_value) (struct block_list* bl, int effect_id, uint64 num, send_target target);
void (*specialeffect_value_single) (struct block_list *bl, int effect_id, uint64 num, int fd);
void (*removeSpecialEffect) (struct block_list *bl, int effectId, enum send_target target);
void (*removeSpecialEffect_single) (struct block_list *bl, int effectId, struct block_list *targetBl);
void (*millenniumshield) (struct block_list *bl, short shields );
Expand Down
51 changes: 51 additions & 0 deletions src/map/script.c
Expand Up @@ -15815,6 +15815,56 @@ static BUILDIN(specialeffect)
return true;
}

/*==========================================
* Special effects with num [4144]
*------------------------------------------*/
static BUILDIN(specialeffectnum)
{
struct block_list *bl = NULL;
int type = script_getnum(st, 2);
int num = script_getnum(st, 3);
int num2 = script_getnum(st, 4);
enum send_target target = AREA;

if (script_hasdata(st, 5)) {
target = script_getnum(st, 5);
}

if (script_hasdata(st, 6)) {
if (script_isstringtype(st, 6)) {
struct npc_data *nd = npc->name2id(script_getstr(st, 6));
if (nd != NULL) {
bl = &nd->bl;
}
} else {
bl = map->id2bl(script_getnum(st, 6));
}
} else {
bl = map->id2bl(st->oid);
}

if (bl == NULL) {
return true;
}

uint64 bigNum = ((uint64)num2) * 0xffffffff + num;
if (target == SELF) {
struct map_session_data *sd;
if (script_hasdata(st, 7)) {
sd = map->id2sd(script_getnum(st, 7));
} else {
sd = script->rid2sd(st);
}
if (sd != NULL) {
clif->specialeffect_value_single(bl, type, bigNum, sd->fd);
}
} else {
clif->specialeffect_value(bl, type, bigNum, target);
}

return true;
}

static BUILDIN(specialeffect2)
{
struct map_session_data *sd;
Expand Down Expand Up @@ -26369,6 +26419,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(skilleffect,"vi"), // skill effect [Celest]
BUILDIN_DEF(npcskilleffect,"viii"), // npc skill effect [Valaris]
BUILDIN_DEF(specialeffect,"i???"), // npc skill effect [Valaris]
BUILDIN_DEF(specialeffectnum,"iii???"), // npc skill effect with num [4144]
BUILDIN_DEF(removespecialeffect,"i???"),
BUILDIN_DEF_DEPRECATED(specialeffect2,"i??"), // skill effect on players[Valaris]
BUILDIN_DEF(nude,""), // nude command [Valaris]
Expand Down

0 comments on commit cfb0a96

Please sign in to comment.