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.c101
1 files changed, 83 insertions, 18 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 410a707f1..952496486 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1428,8 +1428,8 @@ const char* script_parse_subexpr(const char* p,int limit)
p=script->skip_space(p);
while((
(op=C_OP3, opl=0, len=1,*p=='?') // ?:
- || (op=C_ADD, opl=9, len=1,*p=='+') // +
- || (op=C_SUB, opl=9, len=1,*p=='-') // -
+ || (op=C_ADD, opl=9, len=1,*p=='+' && p[1]!='+') // +
+ || (op=C_SUB, opl=9, len=1,*p=='-' && p[1]!='-') // -
|| (op=C_POW, opl=11,len=2,*p=='*' && p[1]=='*') // **
|| (op=C_MUL, opl=10,len=1,*p=='*') // *
|| (op=C_DIV, opl=10,len=1,*p=='/') // /
@@ -8597,7 +8597,8 @@ BUILDIN(disableitemuse)
* return the basic stats of sd
* chk pc->readparam for available type
*------------------------------------------*/
-BUILDIN(readparam) {
+BUILDIN(readparam)
+{
int type;
struct map_session_data *sd;
struct script_data *data = script_getdata(st, 2);
@@ -8609,7 +8610,11 @@ BUILDIN(readparam) {
}
if (script_hasdata(st, 3)) {
- sd = script->nick2sd(st, script_getstr(st, 3));
+ if (script_isstringtype(st, 3)) {
+ sd = script->nick2sd(st, script_getstr(st, 3));
+ } else {
+ sd = script->id2sd(st, script_getnum(st, 3));
+ }
} else {
sd = script->rid2sd(st);
}
@@ -8623,6 +8628,43 @@ BUILDIN(readparam) {
return true;
}
+BUILDIN(setparam)
+{
+ int type;
+ struct map_session_data *sd;
+ struct script_data *data = script_getdata(st, 2);
+ int val = script_getnum(st, 3);
+
+ if (data_isreference(data) && reference_toparam(data)) {
+ type = reference_getparamtype(data);
+ } else {
+ type = script->conv_num(st, data);
+ }
+
+ if (script_hasdata(st, 4)) {
+ if (script_isstringtype(st, 4)) {
+ sd = script->nick2sd(st, script_getstr(st, 4));
+ } else {
+ sd = script->id2sd(st, script_getnum(st, 4));
+ }
+ } else {
+ sd = script->rid2sd(st);
+ }
+
+ if (sd == NULL) {
+ script_pushint(st, 0);
+ return true;
+ }
+
+ if (pc->setparam(sd, type, val) == 0) {
+ script_pushint(st, 0);
+ return false;
+ }
+
+ script_pushint(st, 1);
+ return true;
+}
+
/*==========================================
* Return charid identification
* return by @num :
@@ -21160,6 +21202,7 @@ BUILDIN(instance_create)
const char *name;
int owner_id, res;
int type = IOT_PARTY;
+ struct map_session_data *sd = map->id2sd(st->rid);
name = script_getstr(st, 2);
owner_id = script_getnum(st, 3);
@@ -21172,22 +21215,43 @@ BUILDIN(instance_create)
}
res = instance->create(owner_id, name, (enum instance_owner_type) type);
- if( res == -4 ) { // Already exists
- script_pushint(st, -1);
- return true;
- } else if( res < 0 ) {
+ if (sd != NULL) {
+ switch (res) {
+ case -4: // Already exists
+ clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_DUPLICATE, name);
+ break;
+ case -3: // No free instances
+ clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_EXIST, name);
+ break;
+ case -2: // Invalid type
+ clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_RIGHT, name);
+ break;
+ case -1: // Unknown
+ clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_UNKNOWN, name);
+ break;
+ default:
+ if (res < 0)
+ ShowError("buildin_instance_create: failed to unknown reason [%d].\n", res);
+ }
+ } else {
const char *err;
- switch(res) {
- case -3: err = "No free instances"; break;
- case -2: err = "Invalid party ID"; break;
- case -1: err = "Invalid type"; break;
- default: err = "Unknown"; break;
+ switch (res) {
+ case -3:
+ err = "No free instances";
+ break;
+ case -2:
+ err = "Invalid party ID";
+ break;
+ case -1:
+ err = "Invalid type";
+ break;
+ default:
+ err = "Unknown";
+ break;
}
- ShowError("buildin_instance_create: %s [%d].\n", err, res);
- script_pushint(st, -2);
- return true;
+ if (res < 0)
+ ShowError("buildin_instance_create: %s [%d].\n", err, res);
}
-
script_pushint(st, res);
return true;
}
@@ -23860,7 +23924,7 @@ bool rodex_sendmail_sub(struct script_state* st, struct rodex_message *msg)
{
const char *sender_name, *title, *body;
- if (!strcmp(script->getfuncname(st), "rodex_sendmail_acc2"))
+ if (strcmp(script->getfuncname(st), "rodex_sendmail_acc") == 0 || strcmp(script->getfuncname(st), "rodex_sendmail_acc2") == 0)
msg->receiver_accountid = script_getnum(st, 2);
else
msg->receiver_id = script_getnum(st, 2);
@@ -24390,6 +24454,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(checkweight,"vi*"),
BUILDIN_DEF(checkweight2,"rr"),
BUILDIN_DEF(readparam,"i?"),
+ BUILDIN_DEF(setparam,"ii?"),
BUILDIN_DEF(getcharid,"i?"),
BUILDIN_DEF(getnpcid,"i?"),
BUILDIN_DEF(getpartyname,"i"),