summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-08 23:10:12 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-08 23:10:12 +0300
commit64e7b33c9163e387c94f1a11de4e15435c35005c (patch)
treeeb6144e3f74b3c8e8977f2303f70956fd486146c
parentf1b746d7701b0480ad177be34e28b452c4f5e7f8 (diff)
downloadevol-hercules-64e7b33c9163e387c94f1a11de4e15435c35005c.tar.gz
evol-hercules-64e7b33c9163e387c94f1a11de4e15435c35005c.tar.bz2
evol-hercules-64e7b33c9163e387c94f1a11de4e15435c35005c.tar.xz
evol-hercules-64e7b33c9163e387c94f1a11de4e15435c35005c.zip
Add script command for request craft inventory.
New script command: requestcraft VAR$[, size] Example: @requestcraft .@var$, 9;
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script.c64
-rw-r--r--src/emap/script.h1
3 files changed, 66 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index ce98a96..c71a7b1 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -98,6 +98,7 @@ HPExport void plugin_init (void)
addScriptCommand("requestitems", "v*", requestItems);
addScriptCommand("requestitemindex", "v", requestItemIndex);
addScriptCommand("requestitemsindex", "v*", requestItemsIndex);
+ addScriptCommand("requestcraft", "v*", requestCraft);
addScriptCommand("getq", "i", getq);
addScriptCommand("setq", "ii", setq);
addScriptCommand("setnpcdir", "*", setNpcDir);
diff --git a/src/emap/script.c b/src/emap/script.c
index b953912..955e650 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -876,6 +876,70 @@ BUILDIN(requestItemsIndex)
return true;
}
+BUILDIN(requestCraft)
+{
+ getSessionData(client);
+ struct script_data* data;
+ int64 uid;
+ const char* name;
+
+ data = script_getdata(st, 2);
+ if (!data_isreference(data))
+ {
+ ShowError("script:requestitem: not a variable\n");
+ script->reportsrc(st);
+ st->state = END;
+ return false;
+ }
+ uid = reference_getuid(data);
+ name = reference_getname(data);
+
+ if (!is_string_variable(name))
+ {
+ ShowWarning("parameter is not variable\n");
+ script->reportsrc(st);
+ return false;
+ }
+
+ int count = 1;
+
+ if (script_hasdata(st, 3))
+ {
+ count = script_getnum(st, 3);
+ if (count < 0)
+ count = 1;
+ }
+
+ if (!sd->state.menu_or_input)
+ {
+ // first invocation, display npc input box
+ sd->state.menu_or_input = 1;
+ st->state = RERUNLINE;
+
+ // send item request with limit count
+ if (client || client->clientVersion >= 16)
+ send_npccommand2(sd, st->oid, 12, count, 0, 0);
+ else
+ clif->scriptinputstr(sd, st->oid);
+ }
+ else
+ {
+ // take received text/value and store it in the designated variable
+ sd->state.menu_or_input = 0;
+
+ if (!sd->npc_str)
+ {
+ ShowWarning("npc string not found\n");
+ script->reportsrc(st);
+ return false;
+ }
+
+ script->set_reg(st, sd, uid, name, (void*)sd->npc_str, script_getref(st, 2));
+ st->state = RUN;
+ }
+ return true;
+}
+
BUILDIN(setq)
{
int i;
diff --git a/src/emap/script.h b/src/emap/script.h
index 5db3897..007fa31 100644
--- a/src/emap/script.h
+++ b/src/emap/script.h
@@ -26,6 +26,7 @@ BUILDIN(requestItem);
BUILDIN(requestItems);
BUILDIN(requestItemIndex);
BUILDIN(requestItemsIndex);
+BUILDIN(requestCraft);
BUILDIN(getq);
BUILDIN(setq);
BUILDIN(setNpcDir);