summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c53
1 files changed, 46 insertions, 7 deletions
diff --git a/src/map/script.c b/src/map/script.c
index d653800cc..d11b6741a 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -5625,7 +5625,7 @@ const char *script_getfuncname(struct script_state *st) {
* already initialized)
* @retval false if an error occurs.
*/
-bool script_sprintf(struct script_state *st, int start, struct StringBuf *out)
+bool script_sprintf_helper(struct script_state *st, int start, struct StringBuf *out)
{
const char *format = NULL;
const char *p = NULL, *np = NULL;
@@ -5678,7 +5678,7 @@ bool script_sprintf(struct script_state *st, int start, struct StringBuf *out)
}
// placeholder = "%n" ; (ignored)
if (*np == 'n') {
- ShowWarning("script_sprintf: Format %%n not supported! Skipping...\n");
+ ShowWarning("script_sprintf_helper: Format %%n not supported! Skipping...\n");
script->reportsrc(st);
lastarg = nextarg;
p = np + 1;
@@ -5881,7 +5881,7 @@ BUILDIN(mesf)
StrBuf->Init(&buf);
- if (!script_sprintf(st, 2, &buf)) {
+ if (!script->sprintf_helper(st, 2, &buf)) {
StrBuf->Destroy(&buf);
return false;
}
@@ -12815,12 +12815,12 @@ enum mapinfo_info {
BUILDIN(getmapinfo)
{
enum mapinfo_info mode = script_getnum(st, 2);
- int16 m;
+ int16 m = -1;
if (script_hasdata(st, 3)) {
if (script_isstringtype(st, 3)) {
const char *str = script_getstr(st, 3);
- m = map->mapname2mapid(str);
+ m = map->mapindex2mapid(strdb_iget(mapindex->db, str));
} else {
m = script_getnum(st, 3);
}
@@ -16793,7 +16793,7 @@ BUILDIN(sprintf)
struct StringBuf buf;
StrBuf->Init(&buf);
- if (!script_sprintf(st, 2, &buf)) {
+ if (!script->sprintf_helper(st, 2, &buf)) {
StrBuf->Destroy(&buf);
script_pushconststr(st, "");
return false;
@@ -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
@@ -25180,7 +25219,7 @@ void script_defaults(void)
script->search_str = script_search_str;
script->setd_sub = setd_sub;
script->attach_state = script_attach_state;
- script->sprintf = script_sprintf;
+ script->sprintf_helper = script_sprintf_helper;
script->queue = script_hqueue_get;
script->queue_add = script_hqueue_add;