diff options
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 157 |
1 files changed, 128 insertions, 29 deletions
diff --git a/src/map/script.c b/src/map/script.c index 3e493748d..9c859ca12 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 : @@ -14352,7 +14394,7 @@ BUILDIN(setequipoption) int i = -1; struct map_session_data *sd = script->rid2sd(st); - struct item_option *ito = NULL; + struct itemdb_option *ito = NULL; if (sd == NULL) { script_pushint(st, 0); @@ -15525,12 +15567,13 @@ BUILDIN(message) /*========================================== * npctalk (sends message to surrounding area) - * usage: npctalk "<message>"{,"<npc name>"}; + * usage: npctalk("<message>"{, "<npc name>"{, <show_name>}}); *------------------------------------------*/ BUILDIN(npctalk) { struct npc_data* nd; const char *str = script_getstr(st,2); + bool show_name = true; if (script_hasdata(st, 3)) { nd = npc->name2id(script_getstr(st, 3)); @@ -15538,12 +15581,20 @@ BUILDIN(npctalk) nd = map->id2nd(st->oid); } + if (script_hasdata(st, 4)) { + show_name = (script_getnum(st, 4) != 0) ? true : false; + } + if (nd != NULL) { char name[NAME_LENGTH], message[256]; safestrncpy(name, nd->name, sizeof(name)); strtok(name, "#"); // discard extra name identifier if present - safesnprintf(message, sizeof(message), "%s : %s", name, str); - clif->disp_overhead(&nd->bl, message); + if (show_name) { + safesnprintf(message, sizeof(message), "%s : %s", name, str); + } else { + safesnprintf(message, sizeof(message), "%s", str); + } + clif->disp_overhead(&nd->bl, message, AREA_CHAT_WOC, NULL); } return true; @@ -20066,15 +20117,29 @@ BUILDIN(unitstop) { /// Makes the unit say the message /// -/// unittalk <unit_id>,"<message>"; +/// unittalk(<unit_id>,"<message>"{, show_name{, <send_target>{, <target_id>}}}); BUILDIN(unittalk) { int unit_id; const char* message; - struct block_list* bl; + struct block_list *bl, *target_bl = NULL; + bool show_name = true; + enum send_target target = AREA_CHAT_WOC; unit_id = script_getnum(st,2); message = script_getstr(st, 3); + if (script_hasdata(st, 4)) { + show_name = (script_getnum(st, 4) != 0) ? true : false; + } + + if (script_hasdata(st, 5)) { + target = script_getnum(st, 5); + } + + if (script_hasdata(st, 6)) { + target_bl = map->id2bl(script_getnum(st, 6)); + } + bl = map->id2bl(unit_id); if( bl != NULL ) { struct StringBuf sbuf; @@ -20083,8 +20148,17 @@ BUILDIN(unittalk) { safestrncpy(blname, clif->get_bl_name(bl), sizeof(blname)); if(bl->type == BL_NPC) strtok(blname, "#"); - StrBuf->Printf(&sbuf, "%s : %s", blname, message); - clif->disp_overhead(bl, StrBuf->Value(&sbuf)); + if (show_name) { + StrBuf->Printf(&sbuf, "%s : %s", blname, message); + } else { + StrBuf->Printf(&sbuf, "%s", message); + } + + if (bl->type == BL_PC && target == SELF && (target_bl == NULL || bl == target_bl)) { + clif->notify_playerchat(bl, StrBuf->Value(&sbuf)); + } else { + clif->disp_overhead(bl, StrBuf->Value(&sbuf), target, target_bl); + } StrBuf->Destroy(&sbuf); } @@ -21160,6 +21234,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 +21247,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 +23956,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); @@ -24170,7 +24266,9 @@ BUILDIN(openstylist) if (sd == NULL) return false; - clif->open_ui(sd, STYLIST_UI); +#if PACKETVER >= 20150128 + clif->open_ui(sd, CZ_STYLIST_UI); +#endif return true; } @@ -24388,6 +24486,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"), @@ -24575,7 +24674,7 @@ void script_parse_builtin(void) { BUILDIN_DEF2(atcommand,"charcommand","s"), // [MouseJstr] BUILDIN_DEF(movenpc,"sii?"), // [MouseJstr] BUILDIN_DEF(message,"vs"), // [MouseJstr] - BUILDIN_DEF(npctalk,"s?"), // [Valaris] + BUILDIN_DEF(npctalk,"s??"), // [Valaris][Murilo BiO] BUILDIN_DEF(mobcount,"ss"), BUILDIN_DEF(getlook,"i"), BUILDIN_DEF(getsavepoint,"i"), @@ -24704,7 +24803,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(unitwarp,"isii"), BUILDIN_DEF(unitattack,"iv?"), BUILDIN_DEF(unitstop,"i"), - BUILDIN_DEF(unittalk,"is"), + BUILDIN_DEF(unittalk,"is???"), BUILDIN_DEF(unitemote,"ii"), BUILDIN_DEF(unitskilluseid,"ivi?"), // originally by Qamera [Celest] BUILDIN_DEF(unitskillusepos,"iviii"), // [Celest] |