Skip to content

Commit 8ff1aec

Browse files
committed
chareffect command - if no target given fall back to self
At the moment chareffect needs an target but that makes it very inflexible if you want to set up a shortcut you must make: "@chareffect effect name" so meaning if you want to use that shortcut on an other character you have to change the shortcut to an other name. That's quite a hassle and this mr fixes that, you can now setup a shortcut with: "@chareffect effect" and it will work on every character that uses the shortcut since if no name is given it uses yourself. Approved-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
1 parent daa5575 commit 8ff1aec

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/map/atcommand.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4754,16 +4754,26 @@ ATCE atcommand_chareffect(Session *s, dumb_ptr<map_session_data> sd,
47544754
{
47554755
CharName target;
47564756
int type = 0;
4757+
dumb_ptr<map_session_data> pl_sd;
47574758

4758-
if (!asplit(message, &type, &target))
4759+
if (extract(message, &type))
4760+
pl_sd = sd;
4761+
else if (asplit(message, &type, &target))
4762+
pl_sd = map_nick2sd(target);
4763+
else
47594764
return ATCE::USAGE;
47604765

4761-
dumb_ptr<map_session_data> pl_sd = map_nick2sd(target);
47624766
if (pl_sd == nullptr || (bool(pl_sd->status.option & Opt0::HIDE) && !pc_isGM(sd).detects(pc_isGM(pl_sd))))
4767+
{
4768+
clif_displaymessage(s, "Character not found."_s);
47634769
return ATCE::EXIST;
4770+
}
47644771

47654772
clif_specialeffect(pl_sd, type, 0);
4766-
clif_displaymessage(s, "Your Effect Has Changed."_s);
4773+
if (pl_sd == sd)
4774+
clif_displaymessage(s, "Your effect has changed."_s);
4775+
else
4776+
clif_displaymessage(s, "The effect of the target has changed."_s);
47674777

47684778
return ATCE::OKAY;
47694779
}
@@ -5999,7 +6009,7 @@ Map<XString, AtCommandInfo> atcommand_info =
59996009
{"charpvp"_s, {"<charname> <channel>"_s,
60006010
40, atcommand_charpvp,
60016011
"Set the pvp channel of another player"_s}},
6002-
{"chareffect"_s, {"<type> <target>"_s,
6012+
{"chareffect"_s, {"<type> [target]"_s,
60036013
40, atcommand_chareffect,
60046014
"Apply effect type with arg 0 to a player"_s}},
60056015
{"dropall"_s, {""_s,

0 commit comments

Comments
 (0)