summaryrefslogtreecommitdiff
path: root/npc/functions/main.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/functions/main.txt')
-rw-r--r--npc/functions/main.txt66
1 files changed, 66 insertions, 0 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt
index 6a0aeb72..d072ff60 100644
--- a/npc/functions/main.txt
+++ b/npc/functions/main.txt
@@ -521,6 +521,72 @@ function script sqldate {
return .@strdate$;
}
+// Makes a monster aggro
+// set_aggro( monster{, mode=MD_AGGRESSIVE} )
+function script set_aggro {
+ .@m=getarg(0);
+ .@x=getarg(1, MD_AGGRESSIVE);
+ .@op=getunitdata(.@m, UDT_MODE);
+ .@op=.@op|.@x;
+ setunitdata(.@m, UDT_MODE, .@op);
+ return;
+}
+
+// Special function which makes a date as a number
+// numdate( - )
+function script numdate {
+ .@strdate$=sprintf("%04d%02d%02d", gettime(GETTIME_YEAR), gettime(GETTIME_MONTH), gettime(GETTIME_DAYOFMONTH));
+ // Debug payload
+ if ($@OVERRIDE_NUMDATE)
+ return $@OVERRIDE_NUMDATE;
+ return atoi(.@strdate$);
+}
+
+// json_encode( {varname, varvalue}, {varname 2, varvalue 2}... )
+// returns string
+function script json_encode {
+ if (getargcount() < 2 || getargcount() % 2 != 0)
+ return Exception("json_encode arguments must be paired");
+
+ .@json$="{";
+ .@tab=true;
+
+ // For arguments
+ for (.@i=0;.@i < getargcount(); .@i++) {
+ // Close previous item
+ if (.@tab)
+ .@tab=false;
+ else
+ .@json$+=",";
+
+ // Input variable name
+ .@json$+="\""+getarg(.@i)+"\": ";
+
+ // Input variable value
+ if (isstr(getarg(.@i+1)))
+ .@json$+="\""+getarg(.@i+1)+"\"";
+ else
+ .@json$+=getarg(.@i+1);
+
+ // Advance
+ .@i++;
+ }
+
+ // Close the JSON
+ .@json$+="}";
+ return .@json$;
+}
+
+
+// api_send( code, data )
+// sends to API
+function script api_send {
+ .@cde=getarg(0);
+ .@fm$=escape_sql(getarg(1));
+ query_sql("INSERT INTO `api_export` (`type`, `data`) VALUES ('"+.@cde+"', \""+.@fm$+"\")");
+ return;
+}
+
// Linking functions
/////////////////////////////////////////////
function script getquestlink {