diff options
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 1235 |
1 files changed, 989 insertions, 246 deletions
diff --git a/src/map/script.c b/src/map/script.c index ceb16eb36..f63dd2097 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2786,6 +2786,14 @@ char *get_val_npcscope_str(struct script_state* st, struct reg_db *n, struct scr return NULL; } +char *get_val_pc_ref_str(struct script_state *st, struct reg_db *n, struct script_data *data) { + struct script_reg_str *p = NULL; + nullpo_retr(NULL, n); + + p = i64db_get(n->vars, reference_getuid(data)); + return p ? p->value : NULL; +} + char *get_val_instance_str(struct script_state* st, const char* name, struct script_data* data) { nullpo_retr(NULL, st); if (st->instance_id >= 0) { @@ -2803,6 +2811,14 @@ int get_val_npcscope_num(struct script_state* st, struct reg_db *n, struct scrip return 0; } +int get_val_pc_ref_num(struct script_state *st, struct reg_db *n, struct script_data *data) { + struct script_reg_num *p = NULL; + nullpo_retr(0, n); + + p = i64db_get(n->vars, reference_getuid(data)); + return p ? p->value : 0; +} + int get_val_instance_num(struct script_state* st, const char* name, struct script_data* data) { if (st->instance_id >= 0) return (int)i64db_iget(instance->list[st->instance_id].regs.vars, reference_getuid(data)); @@ -2825,7 +2841,7 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) { char postfix; struct map_session_data *sd = NULL; - if( !data_isreference(data) ) + if (!data_isreference(data)) return data;// not a variable/constant name = reference_getname(data); @@ -2840,10 +2856,10 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) { } //##TODO use reference_tovariable(data) when it's confirmed that it works [FlavioJS] - if( !reference_toconstant(data) && not_server_variable(prefix) ) { + if (!reference_toconstant(data) && not_server_variable(prefix) && reference_getref(data) == NULL) { sd = script->rid2sd(st); - if( sd == NULL ) {// needs player attached - if( postfix == '$' ) {// string variable + if (sd == NULL) {// needs player attached + if (postfix == '$') {// string variable ShowWarning("script_get_val: cannot access player variable '%s', defaulting to \"\"\n", name); data->type = C_CONSTSTR; data->u.str = ""; @@ -2861,32 +2877,44 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) { const char *str = NULL; switch (prefix) { - case '@': + case '@': + if (data->ref) { + str = script->get_val_ref_str(st, data->ref, data); + } else { str = pc->readregstr(sd, data->u.num); - break; - case '$': - str = mapreg->readregstr(data->u.num); - break; - case '#': - if (name[1] == '#') - str = pc_readaccountreg2str(sd, data->u.num);// global - else - str = pc_readaccountregstr(sd, data->u.num);// local - break; - case '.': - if (data->ref) - str = script->get_val_ref_str(st, data->ref, data); - else if (name[1] == '@') - str = script->get_val_scope_str(st, &st->stack->scope, data); - else - str = script->get_val_npc_str(st, &st->script->local, data); - break; - case '\'': - str = script->get_val_instance_str(st, name, data); - break; - default: + } + break; + case '$': + str = mapreg->readregstr(data->u.num); + break; + case '#': + if (data->ref) { + str = script->get_val_pc_ref_str(st, data->ref, data); + } else if (name[1] == '#') { + str = pc_readaccountreg2str(sd, data->u.num);// global + } else { + str = pc_readaccountregstr(sd, data->u.num);// local + } + break; + case '.': + if (data->ref) { + str = script->get_val_ref_str(st, data->ref, data); + } else if (name[1] == '@') { + str = script->get_val_scope_str(st, &st->stack->scope, data); + } else { + str = script->get_val_npc_str(st, &st->script->local, data); + } + break; + case '\'': + str = script->get_val_instance_str(st, name, data); + break; + default: + if (data->ref) { + str = script->get_val_pc_ref_str(st, data->ref, data); + } else { str = pc_readglobalreg_str(sd, data->u.num); - break; + } + break; } if (str == NULL || str[0] == '\0') { @@ -2906,36 +2934,48 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) { data->u.num = reference_getconstant(data); } else if( reference_toparam(data) ) { data->u.num = pc->readparam(sd, reference_getparamtype(data)); - } else - switch( prefix ) { - case '@': + } else { + switch (prefix) { + case '@': + if (data->ref) { + data->u.num = script->get_val_ref_num(st, data->ref, data); + } else { data->u.num = pc->readreg(sd, data->u.num); - break; - case '$': - data->u.num = mapreg->readreg(data->u.num); - break; - case '#': - if( name[1] == '#' ) - data->u.num = pc_readaccountreg2(sd, data->u.num);// global - else - data->u.num = pc_readaccountreg(sd, data->u.num);// local - break; - case '.': - if (data->ref) - data->u.num = script->get_val_ref_num(st, data->ref, data); - else if (name[1] == '@') - data->u.num = script->get_val_scope_num(st, &st->stack->scope, data); - else - data->u.num = script->get_val_npc_num(st, &st->script->local, data); - break; - case '\'': - data->u.num = script->get_val_instance_num(st, name, data); - break; - default: + } + break; + case '$': + data->u.num = mapreg->readreg(data->u.num); + break; + case '#': + if (data->ref) { + data->u.num = script->get_val_pc_ref_num(st, data->ref, data); + } else if (name[1] == '#') { + data->u.num = pc_readaccountreg2(sd, data->u.num);// global + } else { + data->u.num = pc_readaccountreg(sd, data->u.num);// local + } + break; + case '.': + if (data->ref) { + data->u.num = script->get_val_ref_num(st, data->ref, data); + } else if (name[1] == '@') { + data->u.num = script->get_val_scope_num(st, &st->stack->scope, data); + } else { + data->u.num = script->get_val_npc_num(st, &st->script->local, data); + } + break; + case '\'': + data->u.num = script->get_val_instance_num(st, name, data); + break; + default: + if (data->ref) { + data->u.num = script->get_val_pc_ref_num(st, data->ref, data); + } else { data->u.num = pc_readglobalreg(sd, data->u.num); - break; + } + break; } - + } } data->ref = NULL; @@ -3108,38 +3148,43 @@ void script_array_add_member(struct script_array *sa, unsigned int idx) { **/ struct reg_db *script_array_src(struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref) { struct reg_db *src = NULL; - nullpo_retr(NULL, name); - switch( name[0] ) { + + switch (name[0]) { /* from player */ - default: /* char reg */ - case '@':/* temp char reg */ - case '#':/* account reg */ + default: /* char reg */ + case '@':/* temp char reg */ + case '#':/* account reg */ + if (ref != NULL) { + src = ref; + } else { nullpo_retr(NULL, sd); src = &sd->regs; - break; - case '$':/* map reg */ - src = &mapreg->regs; - break; - case '.':/* npc/script */ - if (ref != NULL) { - src = ref; - } else { - nullpo_retr(NULL, st); - src = (name[1] == '@') ? &st->stack->scope : &st->script->local; - } - break; - case '\'':/* instance */ + } + break; + case '$':/* map reg */ + src = &mapreg->regs; + break; + case '.':/* npc/script */ + if (ref != NULL) { + src = ref; + } else { nullpo_retr(NULL, st); - if( st->instance_id >= 0 ) { - src = &instance->list[st->instance_id].regs; - } - break; + src = (name[1] == '@') ? &st->stack->scope : &st->script->local; + } + break; + case '\'':/* instance */ + nullpo_retr(NULL, st); + if (st->instance_id >= 0) { + src = &instance->list[st->instance_id].regs; + } + break; } - if( src ) { - if( !src->arrays ) + if (src) { + if (!src->arrays) { src->arrays = idb_alloc(DB_OPT_BASE); + } return src; } return NULL; @@ -3210,6 +3255,99 @@ void set_reg_npcscope_str(struct script_state* st, struct reg_db *n, int64 num, } } +void set_reg_pc_ref_str(struct script_state *st, struct reg_db *n, int64 num, const char *name, const char *str) +{ + struct script_reg_str *p = NULL; + unsigned int index = script_getvaridx(num); + + nullpo_retv(n); + + if ((p = i64db_get(n->vars, num)) != NULL) { + if (str[0]) { + if (p->value) { + aFree(p->value); + } else if (index) { + script->array_update(n, num, false); + } + p->value = aStrdup(str); + } else { + p->value = NULL; + if (index) { + script->array_update(n, num, true); + } + } + + if (!pc->reg_load) { + p->flag.update = 1; + } + } else if (str[0]) { + struct DBData prev; + if (index) { + script->array_update(n, num, false); + } + + p = ers_alloc(pc->str_reg_ers, struct script_reg_str); + p->value = aStrdup(str); + + if (!pc->reg_load) { + p->flag.update = 1; + } + p->flag.type = 1; + + if(n->vars->put(n->vars, DB->i642key(num), DB->ptr2data(p), &prev)) { + p = DB->data2ptr(&prev); + if (p->value) { + aFree(p->value); + } + ers_free(pc->str_reg_ers, p); + } + } +} + +void set_reg_pc_ref_num(struct script_state *st, struct reg_db *n, int64 num, const char *name, int val) +{ + struct script_reg_num *p = NULL; + unsigned int index = script_getvaridx(num); + + nullpo_retv(n); + + if ((p = i64db_get(n->vars, num)) != NULL) { + if (val) { + if (!p->value && index) { + script->array_update(n, num, false); + } + p->value = val; + } else { + p->value = 0; + if (index) { + script->array_update(n, num, true); + } + } + + if (!pc->reg_load) { + p->flag.update = 1; + } + } else if (val) { + struct DBData prev; + if (index) { + script->array_update(n, num, false); + } + + p = ers_alloc(pc->num_reg_ers, struct script_reg_num); + p->value = val; + + if (!pc->reg_load) { + p->flag.update = 1; + } + p->flag.type = 1; + + if(n->vars->put(n->vars, DB->i642key(num), DB->ptr2data(p), &prev)) { + p = DB->data2ptr(&prev); + ers_free(pc->num_reg_ers, p); + } + } +} + void set_reg_npcscope_num(struct script_state* st, struct reg_db *n, int64 num, const char* name, int val) { if (n) { @@ -3292,48 +3430,65 @@ int set_reg(struct script_state *st, struct map_session_data *sd, int64 num, con return 0; } - if( is_string_variable(name) ) {// string variable + if (is_string_variable(name)) {// string variable const char *str = (const char*)value; switch (prefix) { - case '@': + case '@': + if (ref) { + script->set_reg_ref_str(st, ref, num, name, str); + } else { pc->setregstr(sd, num, str); - return 1; - case '$': - return mapreg->setregstr(num, str); - case '#': - return (name[1] == '#') ? - pc_setaccountreg2str(sd, num, str) : - pc_setaccountregstr(sd, num, str); - case '.': - if (ref) - script->set_reg_ref_str(st, ref, num, name, str); - else if (name[1] == '@') - script->set_reg_scope_str(st, &st->stack->scope, num, name, str); - else - script->set_reg_npc_str(st, &st->script->local, num, name, str); - return 1; - case '\'': - set_reg_instance_str(st, num, name, str); - return 1; - default: - return pc_setglobalreg_str(sd, num, str); + } + return 1; + case '$': + mapreg->setregstr(num, str); + return 1; + case '#': + if (ref) { + script->set_reg_pc_ref_str(st, ref, num, name, str); + } else if (name[1] == '#') { + pc_setaccountreg2str(sd, num, str); + } else { + pc_setaccountregstr(sd, num, str); + } + return 1; + case '.': + if (ref) { + script->set_reg_ref_str(st, ref, num, name, str); + } else if (name[1] == '@') { + script->set_reg_scope_str(st, &st->stack->scope, num, name, str); + } else { + script->set_reg_npc_str(st, &st->script->local, num, name, str); + } + return 1; + case '\'': + set_reg_instance_str(st, num, name, str); + return 1; + default: + if (ref) { + script->set_reg_pc_ref_str(st, ref, num, name, str); + } else { + pc_setglobalreg_str(sd, num, str); + } + return 1; } } else {// integer variable // FIXME: This isn't safe, in 32bits systems we're converting a 64bit pointer // to a 32bit int, this will lead to overflows! [Panikon] int val = (int)h64BPTRSIZE(value); - if(script->str_data[script_getvarid(num)].type == C_PARAM) { - if( pc->setparam(sd, script->str_data[script_getvarid(num)].val, val) == 0 ) { - if( st != NULL ) { + if (script->str_data[script_getvarid(num)].type == C_PARAM) { + if (pc->setparam(sd, script->str_data[script_getvarid(num)].val, val) == 0) { + if (st != NULL) { ShowError("script:set_reg: failed to set param '%s' to %d.\n", name, val); script->reportsrc(st); // Instead of just stop the script execution we let the character close // the window if it was open. st->state = (sd->state.dialog) ? CLOSE : END; - if( st->state == CLOSE ) + if(st->state == CLOSE) { clif->scriptclose(sd, st->oid); + } } return 0; } @@ -3341,28 +3496,44 @@ int set_reg(struct script_state *st, struct map_session_data *sd, int64 num, con } switch (prefix) { - case '@': + case '@': + if (ref) { + script->set_reg_ref_num(st, ref, num, name, val); + } else { pc->setreg(sd, num, val); - return 1; - case '$': - return mapreg->setreg(num, val); - case '#': - return (name[1] == '#') ? - pc_setaccountreg2(sd, num, val) : - pc_setaccountreg(sd, num, val); - case '.': - if (ref) - script->set_reg_ref_num(st, ref, num, name, val); - else if (name[1] == '@') - script->set_reg_scope_num(st, &st->stack->scope, num, name, val); - else - script->set_reg_npc_num(st, &st->script->local, num, name, val); - return 1; - case '\'': - set_reg_instance_num(st, num, name, val); - return 1; - default: - return pc_setglobalreg(sd, num, val); + } + return 1; + case '$': + mapreg->setreg(num, val); + return 1; + case '#': + if (ref) { + script->set_reg_pc_ref_num(st, ref, num, name, val); + } else if (name[1] == '#') { + pc_setaccountreg2(sd, num, val); + } else { + pc_setaccountreg(sd, num, val); + } + return 1; + case '.': + if (ref) { + script->set_reg_ref_num(st, ref, num, name, val); + } else if (name[1] == '@') { + script->set_reg_scope_num(st, &st->stack->scope, num, name, val); + } else { + script->set_reg_npc_num(st, &st->script->local, num, name, val); + } + return 1; + case '\'': + set_reg_instance_num(st, num, name, val); + return 1; + default: + if (ref) { + script->set_reg_pc_ref_num(st, ref, num, name, val); + } else { + pc_setglobalreg(sd, num, val); + } + return 1; } } } @@ -5197,7 +5368,7 @@ int script_load_translation(const char *file, uint8 lang_id) VECTOR_TRUNCATE(msgstr); continue; } - + if (strncasecmp(line, "msgid \"", 7) == 0) { VECTOR_TRUNCATE(msgid); for (i = 7; i < len - 2; i++) { @@ -6610,61 +6781,67 @@ BUILDIN(warpparty) } /*========================================== * Warpguild - [Fredzilla] - * Syntax: warpguild "mapname",x,y,Guild_ID; + * Syntax: warpguild "mapname",x,y,Guild_ID,{"from_mapname"}; *------------------------------------------*/ BUILDIN(warpguild) { struct map_session_data *sd = NULL; - struct map_session_data *pl_sd; struct guild* g; - struct s_mapiterator* iter; int type; + int i; + int16 map_id = -1; - const char* str = script_getstr(st,2); - int x = script_getnum(st,3); - int y = script_getnum(st,4); - int gid = script_getnum(st,5); + const char *str = script_getstr(st, 2); + int x = script_getnum(st, 3); + int y = script_getnum(st, 4); + int gid = script_getnum(st, 5); + + if (script_hasdata(st, 6)) { + map_id = map->mapname2mapid(script_getstr(st, 6)); + } g = guild->search(gid); - if( g == NULL ) + if (g == NULL) return true; - type = ( strcmp(str,"Random")==0 ) ? 0 - : ( strcmp(str,"SavePointAll")==0 ) ? 1 - : ( strcmp(str,"SavePoint")==0 ) ? 2 + type = (strcmp(str, "Random") == 0) ? 0 + : (strcmp(str, "SavePointAll") == 0) ? 1 + : (strcmp(str, "SavePoint") == 0) ? 2 : 3; - if( type == 2 && ( sd = script->rid2sd(st) ) == NULL ) + if (type == 2 && (sd = script->rid2sd(st)) == NULL) {// "SavePoint" uses save point of the currently attached player return true; } - iter = mapit_getallusers(); - for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { - if( pl_sd->status.guild_id != gid ) - continue; + for (i = 0; i < MAX_GUILD; i++) { + if (g->member[i].online && g->member[i].sd != NULL) { + struct map_session_data *pl_sd = g->member[i].sd; - switch( type ) - { + if (map_id >= 0 && map_id != pl_sd->bl.m) + continue; + + switch (type) + { case 0: // Random - if(!map->list[pl_sd->bl.m].flag.nowarp) - pc->randomwarp(pl_sd,CLR_TELEPORT); + if (!map->list[pl_sd->bl.m].flag.nowarp) + pc->randomwarp(pl_sd, CLR_TELEPORT); break; case 1: // SavePointAll - if(!map->list[pl_sd->bl.m].flag.noreturn) - pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT); + if (!map->list[pl_sd->bl.m].flag.noreturn) + pc->setpos(pl_sd, pl_sd->status.save_point.map, pl_sd->status.save_point.x, pl_sd->status.save_point.y, CLR_TELEPORT); break; case 2: // SavePoint - if(!map->list[pl_sd->bl.m].flag.noreturn) - pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); + if (!map->list[pl_sd->bl.m].flag.noreturn) + pc->setpos(pl_sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT); break; case 3: // m,x,y - if(!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp) - pc->setpos(pl_sd,script->mapindexname2id(st,str),x,y,CLR_TELEPORT); + if (!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp) + pc->setpos(pl_sd, script->mapindexname2id(st, str), x, y, CLR_TELEPORT); break; + } } } - mapit->free(iter); return true; } @@ -8685,39 +8862,48 @@ BUILDIN(getguildmember) *------------------------------------------*/ BUILDIN(strcharinfo) { - int num; struct guild* g; struct party_data* p; - struct map_session_data *sd = script->rid2sd(st); - if (sd == NULL) //Avoid crashing.... + struct map_session_data *sd; + + if (script_hasdata(st, 4)) + sd = map->id2sd(script_getnum(st, 4)); + else + sd = script->rid2sd(st); + + if (sd == NULL) { + if(script_hasdata(st, 3)) { + script_pushcopy(st, 3); + } else { + script_pushconststr(st, ""); + } return true; + } - num=script_getnum(st,2); - switch(num) { - case 0: - script_pushstrcopy(st,sd->status.name); - break; - case 1: - if( ( p = party->search(sd->status.party_id) ) != NULL ) { - script_pushstrcopy(st,p->party.name); - } else { - script_pushconststr(st,""); - } - break; - case 2: - if( ( g = sd->guild ) != NULL ) { - script_pushstrcopy(st,g->name); - } else { - script_pushconststr(st,""); - } - break; - case 3: - script_pushconststr(st,map->list[sd->bl.m].name); - break; - default: - ShowWarning("buildin_strcharinfo: unknown parameter.\n"); - script_pushconststr(st,""); - break; + switch (script_getnum(st, 2)) { + case 0: + script_pushstrcopy(st, sd->status.name); + break; + case 1: + if ((p = party->search(sd->status.party_id)) != NULL) { + script_pushstrcopy(st, p->party.name); + } else { + script_pushconststr(st, ""); + } + break; + case 2: + if ((g = sd->guild) != NULL) { + script_pushstrcopy(st, g->name); + } else { + script_pushconststr(st, ""); + } + break; + case 3: + script_pushconststr(st, map->list[sd->bl.m].name); + break; + default: + ShowWarning("script:strcharinfo: unknown parameter.\n"); + script_pushconststr(st, ""); } return true; @@ -8734,41 +8920,51 @@ BUILDIN(strcharinfo) *------------------------------------------*/ BUILDIN(strnpcinfo) { - int num; char *buf,*name=NULL; - struct npc_data *nd = map->id2nd(st->oid); + struct npc_data *nd; + + if (script_hasdata(st, 4)) + nd = map->id2nd(script_getnum(st, 4)); + else + nd = map->id2nd(st->oid); + if (nd == NULL) { - script_pushconststr(st, ""); + if (script_hasdata(st, 3)) { + script_pushcopy(st, 3); + } else { + script_pushconststr(st, ""); + } return true; } - num = script_getnum(st,2); - switch(num) { - case 0: // display name + switch (script_getnum(st,2)) { + case 0: // display name + name = aStrdup(nd->name); + break; + case 1: // visible part of display name + if ((buf = strchr(nd->name,'#')) != NULL) { name = aStrdup(nd->name); - break; - case 1: // visible part of display name - if((buf = strchr(nd->name,'#')) != NULL) - { - name = aStrdup(nd->name); - name[buf - nd->name] = 0; - } else // Return the name, there is no '#' present - name = aStrdup(nd->name); - break; - case 2: // # fragment - if((buf = strchr(nd->name,'#')) != NULL) - name = aStrdup(buf+1); - break; - case 3: // unique name - name = aStrdup(nd->exname); - break; - case 4: // map name - if( nd->bl.m >= 0 ) // Only valid map indexes allowed (issue:8034) - name = aStrdup(map->list[nd->bl.m].name); - break; + name[buf - nd->name] = 0; + } else { // Return the name, there is no '#' present + name = aStrdup(nd->name); + } + break; + case 2: // # fragment + if ((buf = strchr(nd->name,'#')) != NULL) { + name = aStrdup(buf+1); + } + break; + case 3: // unique name + name = aStrdup(nd->exname); + break; + case 4: // map name + if (nd->bl.m >= 0) { // Only valid map indexes allowed (issue:8034) + name = aStrdup(map->list[nd->bl.m].name); + } + break; } - if(name) + if (name) script_pushstr(st, name); else script_pushconststr(st, ""); @@ -9019,6 +9215,35 @@ BUILDIN(getequipisenableref) return true; } +/** + * Checks if the equipped item allows options. + * *getequipisenableopt(<equipment_index>); + * + * @param equipment_index as the inventory index of the equipment. + * @return 1 on enabled 0 on disabled. + */ +BUILDIN(getequipisenableopt) +{ + int i = -1, index = script_getnum(st, 2); + struct map_session_data *sd = script->rid2sd(st); + + if (sd == NULL) { + script_pushint(st, -1); + ShowError("buildin_getequipisenableopt: player is not attached!"); + return false; + } + + if (index > 0 && index <= ARRAYLENGTH(script->equip)) + i = pc->checkequip(sd, script->equip[index - 1]); + + if (i >=0 && sd->inventory_data[i] && !sd->inventory_data[i]->flag.no_options && !sd->status.inventory[i].expire_time) + script_pushint(st, 1); + else + script_pushint(st, 0); + + return true; +} + /*========================================== * Chk if the item equiped at pos is identify (huh ?) * return (npc) @@ -10704,19 +10929,29 @@ BUILDIN(donpcevent) *------------------------------------------*/ BUILDIN(addtimer) { - int tick = script_getnum(st,2); + int tick = script_getnum(st, 2); const char* event = script_getstr(st, 3); struct map_session_data *sd; script->check_event(st, event); - sd = script->rid2sd(st); - if( sd == NULL ) - return true; - if (!pc->addeventtimer(sd,tick,event)) { - ShowWarning("buildin_addtimer: Event timer is full, can't add new event timer. (cid:%d timer:%s)\n",sd->status.char_id,event); + if (script_hasdata(st, 4)) + sd = map->id2sd(script_getnum(st, 4)); + else + sd = script->rid2sd(st); + + if (sd == NULL) { + script_pushint(st, 0); return false; } + + if (!pc->addeventtimer(sd, tick, event)) { + ShowWarning("script:addtimer: Event timer is full, can't add new event timer. (cid:%d timer:%s)\n", sd->status.char_id, event); + script_pushint(st, 0); + return false; + } + + script_pushint(st, 1); return true; } /*========================================== @@ -10727,12 +10962,17 @@ BUILDIN(deltimer) struct map_session_data *sd; event=script_getstr(st, 2); - sd = script->rid2sd(st); - if( sd == NULL ) + + if (script_hasdata(st, 3)) + sd = map->id2sd(script_getnum(st, 3)); + else + sd = script->rid2sd(st); + + if (sd == NULL) return true; script->check_event(st, event); - pc->deleventtimer(sd,event); + pc->deleventtimer(sd, event); return true; } /*========================================== @@ -10743,14 +10983,198 @@ BUILDIN(addtimercount) int tick; struct map_session_data *sd; - event=script_getstr(st, 2); - tick=script_getnum(st,3); - sd = script->rid2sd(st); - if( sd == NULL ) + event = script_getstr(st, 2); + tick = script_getnum(st, 3); + + if (script_hasdata(st, 4)) + sd = map->id2sd(script_getnum(st, 4)); + else + sd = script->rid2sd(st); + + if (sd == NULL) return true; script->check_event(st, event); - pc->addeventtimercount(sd,event,tick); + pc->addeventtimercount(sd, event, tick); + return true; +} + +enum gettimer_mode { + GETTIMER_COUNT = 0, + GETTIMER_TICK_NEXT = 1, + GETTIMER_TICK_LAST = 2, +}; + +BUILDIN(gettimer) +{ + struct map_session_data *sd; + const struct TimerData *td; + int i; + int tick; + const char *event = NULL; + int val = 0; + bool first = true; + short mode = script_getnum(st, 2); + + if (script_hasdata(st, 3)) + sd = map->id2sd(script_getnum(st, 3)); + else + sd = script->rid2sd(st); + + if (script_hasdata(st, 4)) { + event = script_getstr(st, 4); + script->check_event(st, event); + } + + if (sd == NULL) { + script_pushint(st, -1); + return true; + } + + switch (mode) { + case GETTIMER_COUNT: + // get number of timers + for (i = 0; i < MAX_EVENTTIMER; i++) { + if (sd->eventtimer[i] != INVALID_TIMER) { + if (event != NULL) { + td = timer->get(sd->eventtimer[i]); + Assert_retr(false, td != NULL); + + if (strcmp((char *)(td->data), event) == 0) { + val++; + } + } else { + val++; + } + } + } + break; + case GETTIMER_TICK_NEXT: + // get the number of tick before the next timer runs + for (i = 0; i < MAX_EVENTTIMER; i++) { + if (sd->eventtimer[i] != INVALID_TIMER) { + td = timer->get(sd->eventtimer[i]); + Assert_retr(false, td != NULL); + tick = max(0, DIFF_TICK32(td->tick, timer->gettick())); + + if (event != NULL) { + if ((first == true || tick < val) && strcmp((char *)(td->data), event) == 0) { + val = tick; + first = false; + } + } else if (first == true || tick < val) { + val = tick; + first = false; + } + } + } + break; + case GETTIMER_TICK_LAST: + // get the number of ticks before the last timer runs + for (i = MAX_EVENTTIMER - 1; i >= 0; i--) { + if (sd->eventtimer[i] != INVALID_TIMER) { + td = timer->get(sd->eventtimer[i]); + Assert_retr(false, td != NULL); + tick = max(0, DIFF_TICK32(td->tick, timer->gettick())); + + if (event != NULL) { + if (strcmp((char *)(td->data), event) == 0) { + val = max(val, tick); + } + } else { + val = max(val, tick); + } + } + } + break; + } + + script_pushint(st, val); + return true; +} + +int buildin_getunits_sub(struct block_list *bl, va_list ap) +{ + struct script_state *st = va_arg(ap, struct script_state *); + struct map_session_data *sd = va_arg(ap, struct map_session_data *); + int32 id = va_arg(ap, int32); + uint32 start = va_arg(ap, uint32); + uint32 *count = va_arg(ap, uint32 *); + uint32 limit = va_arg(ap, uint32); + const char *name = va_arg(ap, const char *); + struct reg_db *ref = va_arg(ap, struct reg_db *); + uint32 index = start + *count; + + if (index >= SCRIPT_MAX_ARRAYSIZE || *count > limit) { + return 1; + } + + script->set_reg(st, sd, reference_uid(id, index), name, + (const void *)h64BPTRSIZE(bl->id), ref); + + (*count)++; + return 0; +} + +BUILDIN(getunits) +{ + const char *mapname, *name; + int16 m, x1, y1, x2, y2; + int32 id; + uint32 start; + struct reg_db *ref; + enum bl_type type = script_getnum(st, 2); + struct script_data *data = script_getdata(st, 3); + uint32 count = 0, limit = script_getnum(st, 4); + struct map_session_data *sd = NULL; + + if (!data_isreference(data) || reference_toconstant(data)) { + ShowError("script:getunits: second argument must be a variable\n"); + script->reportdata(data); + st->state = END; + return false; + } + + id = reference_getid(data); + start = reference_getindex(data); + name = reference_getname(data); + ref = reference_getref(data); + + if (not_server_variable(*name)) { + sd = script->rid2sd(st); + if (sd == NULL) { + return true; // player variable but no player attached + } + } + + if (is_string_variable(name)) { + ShowError("script:getunits: second argument must be an integer variable\n"); + script->reportdata(data); + st->state = END; + return false; + } + + if (limit < 1 || limit > SCRIPT_MAX_ARRAYSIZE) { + limit = SCRIPT_MAX_ARRAYSIZE; + } + + mapname = script_getstr(st, 5); + m = map->mapname2mapid(mapname); + + if (script_hasdata(st, 9)) { + x1 = script_getnum(st, 6); + y1 = script_getnum(st, 7); + x2 = script_getnum(st, 8); + y2 = script_getnum(st, 9); + + map->foreachinarea(buildin_getunits_sub, m, x1, y1, x2, y2, type, + st, sd, id, start, &count, limit, name, ref); + } else { + map->foreachinmap(buildin_getunits_sub, m, type, + st, sd, id, start, &count, limit, name, ref); + } + + script_pushint(st, count); return true; } @@ -11591,14 +12015,16 @@ BUILDIN(getstatus) case 3: script_pushint(st, sd->sc.data[id]->val3); break; case 4: script_pushint(st, sd->sc.data[id]->val4); break; case 5: - { - const struct TimerData *td = timer->get(sd->sc.data[id]->timer); + if (sd->sc.data[id]->infinite_duration) { + script_pushint(st, INFINITE_DURATION); + } else { + const struct TimerData *td = timer->get(sd->sc.data[id]->timer); - if (td != NULL) { - // return the amount of time remaining - script_pushint(st, (int)(td->tick - timer->gettick())); // TODO: change this to int64 when we'll support 64 bit script values + if (td != NULL) { + // return the amount of time remaining + script_pushint(st, (int)(td->tick - timer->gettick())); // TODO: change this to int64 when we'll support 64 bit script values + } } - } break; default: script_pushint(st, 1); break; } @@ -13546,6 +13972,190 @@ BUILDIN(getiteminfo) return true; } +/** + * Returns the value of the current equipment being parsed using static variables - + * current_equip_item_index and current_equip_option_index. + * !!Designed to be used with item_options.conf only!! + * *getequippedoptioninfo(<info_type>); + * + * @param (int) Types - + * IT_OPT_INDEX ID of the item option. + * IT_OPT_VALUE Amount of the bonus to be added. + * @return value of the type or -1. + */ +BUILDIN(getequippedoptioninfo) +{ + int val = 0, type = script_getnum(st, 2); + struct map_session_data *sd = NULL; + + if ((sd = script->rid2sd(st)) == NULL || status->current_equip_item_index == -1 || status->current_equip_option_index == -1 + || !sd->status.inventory[status->current_equip_item_index].option[status->current_equip_option_index].index) { + script_pushint(st, -1); + return false; + } + + switch (type) { + case IT_OPT_INDEX: + val = sd->status.inventory[status->current_equip_item_index].option[status->current_equip_option_index].index; + break; + case IT_OPT_VALUE: + val = sd->status.inventory[status->current_equip_item_index].option[status->current_equip_option_index].value; + break; + default: + ShowError("buildin_getequippedoptioninfo: Invalid option data type %d (Max %d).\n", type, IT_OPT_MAX-1); + script_pushint(st, -1); + return false; + } + + script_pushint(st, val); + + return true; +} + +/** + * Gets the option information of an equipment. + * *getequipoptioninfo(<equip_index>,<slot>,<type>); + * + * @param equip_index as the Index of the Equipment. + * @param slot as the slot# of the Item Option (1 to MAX_ITEM_OPTIONS) + * @param type IT_OPT_INDEX or IT_OPT_VALUE. + * @return (int) value or -1 on failure. + */ +BUILDIN(getequipoption) +{ + int val = 0, equip_index = script_getnum(st, 2); + int slot = script_getnum(st, 3); + int opt_type = script_getnum(st, 4); + int i = -1; + struct map_session_data *sd = script->rid2sd(st); + + if (sd == NULL) { + script_pushint(st, -1); + ShowError("buildin_getequipoptioninfo: Player not attached!\n"); + return false; + } + + if (slot <= 0 || slot > MAX_ITEM_OPTIONS) { + script_pushint(st, -1); + ShowError("buildin_getequipoptioninfo: Invalid option slot %d (Min: 1, Max: %d) provided.\n", slot, MAX_ITEM_OPTIONS); + return false; + } + + if (equip_index > 0 && equip_index <= ARRAYLENGTH(script->equip)) { + if ((i = pc->checkequip(sd, script->equip[equip_index - 1])) == -1) { + ShowError("buildin_getequipoptioninfo: No equipment is equipped in the given index %d.\n", equip_index); + script_pushint(st, -1); + return false; + } + } else { + ShowError("buildin_getequipoptioninfo: Invalid equipment index %d provided.\n", equip_index); + script_pushint(st, 0); + return false; + } + + if (sd->status.inventory[i].nameid != 0) { + switch (opt_type) { + case IT_OPT_INDEX: + val = sd->status.inventory[i].option[slot-1].index; + break; + case IT_OPT_VALUE: + val = sd->status.inventory[i].option[slot-1].value; + break; + default: + ShowError("buildin_geteqiupoptioninfo: Invalid option data type %d provided.\n", opt_type); + script_pushint(st, -1); + break; + } + } + + script_pushint(st, val); + + return true; +} + +/** + * Set an equipment's option value. + * *setequipoption(<equip_index>,<slot>,<opt_index>,<value>); + * + * @param equip_index as the inventory index of the equipment. + * @param slot as the slot of the item option (1 to MAX_ITEM_OPTIONS) + * @param opt_index as the index of the option available as "Id" in db/item_options.conf. + * @param value as the value of the option type. + * For IT_OPT_INDEX see "Name" in item_options.conf + * For IT_OPT_VALUE, the value of the script bonus. + * @return 0 on failure, 1 on success. + */ +BUILDIN(setequipoption) +{ + int equip_index = script_getnum(st, 2); + int slot = script_getnum(st, 3); + int opt_index = script_getnum(st, 4); + int value = script_getnum(st, 5); + int i = -1; + + struct map_session_data *sd = script->rid2sd(st); + struct item_option *ito = NULL; + + if (sd == NULL) { + script_pushint(st, 0); + ShowError("buildin_setequipoption: Player not attached!\n"); + return false; + } + + if (slot <= 0 || slot > MAX_ITEM_OPTIONS) { + script_pushint(st, 0); + ShowError("buildin_setequipoption: Invalid option index %d (Min: 1, Max: %d) provided.\n", slot, MAX_ITEM_OPTIONS); + return false; + } + + if (equip_index > 0 && equip_index <= ARRAYLENGTH(script->equip)) { + if ((i = pc->checkequip(sd, script->equip[equip_index - 1])) == -1) { + ShowError("buildin_setequipoptioninfo: No equipment is equipped in the given index %d.\n", equip_index); + script_pushint(st, 0); + return false; + } + } else { + ShowError("buildin_setequipoptioninfo: Invalid equipment index %d provided.\n", equip_index); + script_pushint(st, 0); + return false; + } + + if (sd->status.inventory[i].nameid != 0) { + + if ((ito = itemdb->option_exists(opt_index)) == NULL) { + script_pushint(st, 0); + ShowError("buildin_setequipotion: Option index %d does not exist!\n", opt_index); + return false; + } else if (value < -INT16_MAX || value > INT16_MAX) { + script_pushint(st, 0); + ShowError("buildin_setequipotion: Option value %d exceeds maximum limit (%d to %d) for type!\n", value, -INT16_MAX, INT16_MAX); + return false; + } + /* Add Option Index */ + sd->status.inventory[i].option[slot-1].index = ito->index; + /* Add Option Value */ + sd->status.inventory[i].option[slot-1].value = value; + + /* Unequip and simulate deletion of the item. */ + pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE); // status calc will happen in pc->equipitem() below + clif->refine(sd->fd, 0, i, sd->status.inventory[i].refine); // notify client of a refine. + clif->delitem(sd, i, 1, DELITEM_MATERIALCHANGE); // notify client to simulate item deletion. + /* Log deletion of the item. */ + logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]); + /* Equip and simulate addition of the item. */ + clif->additem(sd, i, 1, 0); // notify client to simulate item addition. + /* Log addition of the item. */ + logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i], sd->inventory_data[i]); + pc->equipitem(sd, i, sd->status.inventory[i].equip); // force equip the item at the original position. + clif->misceffect(&sd->bl, 2); // show effect + } + + script_pushint(st, 1); + + return true; + +} + /*========================================== * Set some values of an item [Lupus] * Price, Weight, etc... @@ -13706,7 +14316,7 @@ BUILDIN(petloot) BUILDIN(getinventorylist) { struct map_session_data *sd = script->rid2sd(st); - char card_var[NAME_LENGTH]; + char card_var[SCRIPT_VARNAME_LENGTH]; int i,j=0,k; if(!sd) return true; @@ -13727,6 +14337,14 @@ BUILDIN(getinventorylist) sprintf(card_var, "@inventorylist_card%d",k+1); pc->setreg(sd,reference_uid(script->add_str(card_var), j),sd->status.inventory[i].card[k]); } + for (k = 0; k < MAX_ITEM_OPTIONS; k++) { + sprintf(card_var, "@inventorylist_opt_id%d", k + 1); + pc->setreg(sd, reference_uid(script->add_str(card_var), j), sd->status.inventory[i].option[k].index); + sprintf(card_var, "@inventorylist_opt_val%d", k + 1); + pc->setreg(sd, reference_uid(script->add_str(card_var), j), sd->status.inventory[i].option[k].value); + sprintf(card_var, "@inventorylist_opt_param%d", k + 1); + pc->setreg(sd, reference_uid(script->add_str(card_var), j), sd->status.inventory[i].option[k].param); + } pc->setreg(sd,reference_uid(script->add_str("@inventorylist_expire"), j),sd->status.inventory[i].expire_time); pc->setreg(sd,reference_uid(script->add_str("@inventorylist_bound"), j),sd->status.inventory[i].bound); j++; @@ -13739,7 +14357,7 @@ BUILDIN(getinventorylist) BUILDIN(getcartinventorylist) { struct map_session_data *sd = script->rid2sd(st); - char card_var[26]; + char card_var[SCRIPT_VARNAME_LENGTH]; int i,j=0,k; if(!sd) return true; @@ -13756,6 +14374,14 @@ BUILDIN(getcartinventorylist) sprintf(card_var, "@cartinventorylist_card%d",k+1); pc->setreg(sd,reference_uid(script->add_str(card_var), j),sd->status.cart[i].card[k]); } + for (k = 0; k < MAX_ITEM_OPTIONS; k++) { + sprintf(card_var, "@cartinventorylist_opt_id%d", k + 1); + pc->setreg(sd, reference_uid(script->add_str(card_var), j), sd->status.cart[i].option[k].index); + sprintf(card_var, "@cartinventorylist_opt_val%d", k + 1); + pc->setreg(sd, reference_uid(script->add_str(card_var), j), sd->status.cart[i].option[k].value); + sprintf(card_var, "@cartinventorylist_opt_param%d", k + 1); + pc->setreg(sd, reference_uid(script->add_str(card_var), j), sd->status.cart[i].option[k].param); + } pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_expire"), j),sd->status.cart[i].expire_time); pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_bound"), j),sd->status.cart[i].bound); j++; @@ -13840,15 +14466,26 @@ BUILDIN(undisguise) * Transform a bl to another class, * @type unused *------------------------------------------*/ -BUILDIN(classchange) { - int class, type; - struct block_list *bl=map->id2bl(st->oid); +BUILDIN(classchange) +{ + int class, type, target; + struct block_list *bl = map->id2bl(st->oid); - if(bl==NULL) return true; + if (bl == NULL) + return true; - class = script_getnum(st,2); - type=script_getnum(st,3); - clif->class_change(bl, class, type); + class = script_getnum(st, 2); + type = script_getnum(st, 3); + target = script_hasdata(st, 4) ? script_getnum(st, 4) : 0; + + if (target > 0) { + struct map_session_data *sd = script->charid2sd(st, target); + if (sd != NULL) { + clif->class_change(bl, class, type, sd); + } + } else { + clif->class_change(bl, class, type, NULL); + } return true; } @@ -15455,6 +16092,29 @@ BUILDIN(charat) { } //======================================================= +// chr <int> +//------------------------------------------------------- +BUILDIN(chr) +{ + char output[2]; + output[0] = script_getnum(st, 2); + output[1] = '\0'; + + script_pushstrcopy(st, output); + return true; +} + +//======================================================= +// ord <chr> +//------------------------------------------------------- +BUILDIN(ord) +{ + const char *chr = script_getstr(st, 2); + script_pushint(st, *chr); + return true; +} + +//======================================================= // setchar <string>, <char>, <index> //------------------------------------------------------- BUILDIN(setchar) @@ -19093,6 +19753,54 @@ BUILDIN(getvariableofnpc) return true; } +BUILDIN(getvariableofpc) +{ + const char* name; + struct script_data* data = script_getdata(st, 2); + struct map_session_data *sd = map->id2sd(script_getnum(st, 3)); + + if (!data_isreference(data)) { + ShowError("script:getvariableofpc: not a variable\n"); + script->reportdata(data); + script_pushnil(st); + st->state = END; + return false; + } + + name = reference_getname(data); + + switch (*name) + { + case '$': + case '.': + case '\'': + ShowError("script:getvariableofpc: illegal scope (not pc variable)\n"); + script->reportdata(data); + script_pushnil(st); + st->state = END; + return false; + } + + if (sd == NULL) + { + // player not found, return default value + if (script_hasdata(st, 4)) { + script_pushcopy(st, 4); + } else if (is_string_variable(name)) { + script_pushconststr(st, ""); + } else { + script_pushint(st, 0); + } + return true; + } + + if (!sd->regs.vars) + sd->regs.vars = i64db_alloc(DB_OPT_RELEASE_DATA); + + script->push_val(st->stack, C_NAME, reference_getuid(data), &sd->regs); + return true; +} + /// Opens a warp portal. /// Has no "portal opening" effect/sound, it opens the portal immediately. /// @@ -22412,7 +23120,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(areawarp,"siiiisii??"), BUILDIN_DEF(warpchar,"siii"), // [LuzZza] BUILDIN_DEF(warpparty,"siii?"), // [Fredzilla] [Paradox924X] - BUILDIN_DEF(warpguild,"siii"), // [Fredzilla] + BUILDIN_DEF(warpguild,"siii?"), // [Fredzilla] BUILDIN_DEF(setlook,"ii"), BUILDIN_DEF(changelook,"ii"), // Simulates but don't Store it BUILDIN_DEF2(__setr,"set","rv"), @@ -22453,8 +23161,8 @@ void script_parse_builtin(void) { BUILDIN_DEF(getguildmaster,"i"), BUILDIN_DEF(getguildmasterid,"i"), BUILDIN_DEF(getguildmember,"i?"), - BUILDIN_DEF(strcharinfo,"i"), - BUILDIN_DEF(strnpcinfo,"i"), + BUILDIN_DEF(strcharinfo,"i??"), + BUILDIN_DEF(strnpcinfo,"i??"), BUILDIN_DEF(charid2rid,"i"), BUILDIN_DEF(getequipid,"i"), BUILDIN_DEF(getequipname,"i"), @@ -22517,9 +23225,11 @@ void script_parse_builtin(void) { BUILDIN_DEF(clone,"siisi????"), BUILDIN_DEF(doevent,"s"), BUILDIN_DEF(donpcevent,"s"), - BUILDIN_DEF(addtimer,"is"), - BUILDIN_DEF(deltimer,"s"), - BUILDIN_DEF(addtimercount,"si"), + BUILDIN_DEF(addtimer,"is?"), + BUILDIN_DEF(deltimer,"s?"), + BUILDIN_DEF(addtimercount,"si?"), + BUILDIN_DEF(gettimer,"i??"), + BUILDIN_DEF(getunits,"iris????"), BUILDIN_DEF(initnpctimer,"??"), BUILDIN_DEF(stopnpctimer,"??"), BUILDIN_DEF(startnpctimer,"??"), @@ -22604,7 +23314,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(getcartinventorylist,""), BUILDIN_DEF(getskilllist,""), BUILDIN_DEF(clearitem,""), - BUILDIN_DEF(classchange,"ii"), + BUILDIN_DEF(classchange,"ii?"), BUILDIN_DEF(misceffect,"i"), BUILDIN_DEF(playbgm,"s"), BUILDIN_DEF(playbgmall,"s?????"), @@ -22670,6 +23380,8 @@ void script_parse_builtin(void) { BUILDIN_DEF(getstrlen,"s"), //strlen [Valaris] BUILDIN_DEF(charisalpha,"si"), //isalpha [Valaris] BUILDIN_DEF(charat,"si"), + BUILDIN_DEF(chr,"i"), + BUILDIN_DEF(ord,"s"), BUILDIN_DEF(setchar,"ssi"), BUILDIN_DEF(insertchar,"ssi"), BUILDIN_DEF(delchar,"si"), @@ -22691,6 +23403,10 @@ void script_parse_builtin(void) { BUILDIN_DEF(getiteminfo,"ii"), //[Lupus] returns Items Buy / sell Price, etc info BUILDIN_DEF(setiteminfo,"iii"), //[Lupus] set Items Buy / sell Price, etc info BUILDIN_DEF(getequipcardid,"ii"), //[Lupus] returns CARD ID or other info from CARD slot N of equipped item + BUILDIN_DEF(getequippedoptioninfo, "i"), + BUILDIN_DEF(getequipoption, "iii"), + BUILDIN_DEF(setequipoption, "iiii"), + BUILDIN_DEF(getequipisenableopt, "i"), // List of mathematics commands ---> BUILDIN_DEF(log10,"i"), BUILDIN_DEF(sqrt,"i"), //[zBuffer] @@ -22755,6 +23471,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(sleep2,"i"), BUILDIN_DEF(awake,"s"), BUILDIN_DEF(getvariableofnpc,"rs"), + BUILDIN_DEF(getvariableofpc,"ri?"), BUILDIN_DEF(warpportal,"iisii"), BUILDIN_DEF2(homunculus_evolution,"homevolution",""), //[orn] BUILDIN_DEF2(homunculus_mutate,"hommutate","?"), @@ -23063,6 +23780,14 @@ void script_hardcoded_constants(void) script->set_constant("EQP_SHADOW_ACC_R", EQP_SHADOW_ACC_R, false, false); script->set_constant("EQP_SHADOW_ACC_L", EQP_SHADOW_ACC_L, false, false); + script->constdb_comment("Item Option Types"); + script->set_constant("IT_OPT_INDEX", IT_OPT_INDEX, false, false); + script->set_constant("IT_OPT_VALUE", IT_OPT_VALUE, false, false); + script->set_constant("IT_OPT_PARAM", IT_OPT_PARAM, false, false); + + script->constdb_comment("Maximum Item Options"); + script->set_constant("MAX_ITEM_OPTIONS", MAX_ITEM_OPTIONS, false, false); + script->constdb_comment("Navigation constants, use with *navigateto*"); script->set_constant("NAV_NONE", NAV_NONE, false, false); script->set_constant("NAV_AIRSHIP_ONLY", NAV_AIRSHIP_ONLY, false, false); @@ -23073,6 +23798,20 @@ void script_hardcoded_constants(void) script->set_constant("NAV_KAFRA_AND_SCROLL", NAV_KAFRA_AND_SCROLL, false, false); script->set_constant("NAV_ALL", NAV_ALL, false, false); + script->constdb_comment("BL types"); + script->set_constant("BL_PC",BL_PC,false, false); + script->set_constant("BL_MOB",BL_MOB,false, false); + script->set_constant("BL_PET",BL_PET,false, false); + script->set_constant("BL_HOM",BL_HOM,false, false); + script->set_constant("BL_MER",BL_MER,false, false); + script->set_constant("BL_ITEM",BL_ITEM,false, false); + script->set_constant("BL_SKILL",BL_SKILL,false, false); + script->set_constant("BL_NPC",BL_NPC,false, false); + script->set_constant("BL_CHAT",BL_CHAT,false, false); + script->set_constant("BL_ELEM",BL_ELEM,false, false); + script->set_constant("BL_CHAR",BL_CHAR,false, false); + script->set_constant("BL_ALL",BL_ALL,false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); @@ -23219,10 +23958,12 @@ void script_defaults(void) script->get_val = get_val; script->get_val2 = get_val2; script->get_val_ref_str = get_val_npcscope_str; + script->get_val_pc_ref_str = get_val_pc_ref_str; script->get_val_scope_str = get_val_npcscope_str; script->get_val_npc_str = get_val_npcscope_str; script->get_val_instance_str = get_val_instance_str; script->get_val_ref_num = get_val_npcscope_num; + script->get_val_pc_ref_num = get_val_pc_ref_num; script->get_val_scope_num = get_val_npcscope_num; script->get_val_npc_num = get_val_npcscope_num; script->get_val_instance_num = get_val_instance_num; @@ -23301,10 +24042,12 @@ void script_defaults(void) script->errorwarning_sub = script_errorwarning_sub; script->set_reg = set_reg; script->set_reg_ref_str = set_reg_npcscope_str; + script->set_reg_pc_ref_str = set_reg_pc_ref_str; script->set_reg_scope_str = set_reg_npcscope_str; script->set_reg_npc_str = set_reg_npcscope_str; script->set_reg_instance_str = set_reg_instance_str; script->set_reg_ref_num = set_reg_npcscope_num; + script->set_reg_pc_ref_num = set_reg_pc_ref_num; script->set_reg_scope_num = set_reg_npcscope_num; script->set_reg_npc_num = set_reg_npcscope_num; script->set_reg_instance_num = set_reg_instance_num; |