From 9e476cce31c4e9e524e7a4b48ca0753c51c0ad37 Mon Sep 17 00:00:00 2001 From: Singe Horizontal <62802903+Singe-Horizontal@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:27:59 +0100 Subject: [PATCH] Fixed specialeffect with npc names (#7502) Fixes #7501 Co-authored-by: Lemongrass3110 --- src/map/script.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/map/script.cpp b/src/map/script.cpp index 838661f621..ef355a60ef 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -15359,20 +15359,25 @@ BUILDIN_FUNC(specialeffect) if( script_hasdata(st,4) ) { - TBL_NPC *nd = npc_name2id(script_getstr(st,4)); + const char* name = script_getstr( st, 4 ); + npc_data* nd = npc_name2id( name ); if(nd) - clif_specialeffect(&nd->bl, type, target); - } - else - { - if (target == SELF) { - TBL_PC *sd; - if (script_rid2sd(sd)) - clif_specialeffect_single(bl,type,sd->fd); - } else { - clif_specialeffect(bl, type, target); + bl = &nd->bl; + else{ + ShowError( "buildin_specialeffect: Unknown NPC \"%s\"\n", name ); + return SCRIPT_CMD_FAILURE; } } + + if (target == SELF) { + map_session_data* sd; + if (!script_rid2sd(sd)){ + return SCRIPT_CMD_FAILURE; + } + clif_specialeffect_single(bl,type,sd->fd); + } else { + clif_specialeffect(bl, type, target); + } return SCRIPT_CMD_SUCCESS; }