diff options
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 161 |
1 files changed, 125 insertions, 36 deletions
diff --git a/src/map/script.c b/src/map/script.c index a1efbb3b8..38931bd11 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -771,7 +771,7 @@ const char* skip_word(const char* p) p += ( p[1] == '@' ? 2 : 1 ); break; } - while( ISALNUM(*p) || *p == '_' || *p == '\'' ) + while (ISALNUM(*p) || *p == '_') ++p; // postfix @@ -5482,8 +5482,6 @@ bool script_sprintf(struct script_state *st, int start, struct StringBuf *out) safestrncpy(buf, p, len); StrBuf->AppendStr(out, buf); } - - p = np; np++; // placeholder = "%%" ; (special case) @@ -6393,6 +6391,9 @@ int buildin_areawarp_sub(struct block_list *bl, va_list ap) pc->randomwarp(sd, CLR_TELEPORT); } else if (x3 != 0 && y3 != 0) { int max, tx, ty, j = 0; + int16 m; + + m = map->mapindex2mapid(index); // choose a suitable max number of attempts if( (max = (y3-y2+1)*(x3-x2+1)*3) > 1000 ) @@ -6403,7 +6404,7 @@ int buildin_areawarp_sub(struct block_list *bl, va_list ap) tx = rnd()%(x3-x2+1)+x2; ty = rnd()%(y3-y2+1)+y2; j++; - } while (map->getcell(index, bl, tx, ty, CELL_CHKNOPASS) && j < max); + } while (map->getcell(m, bl, tx, ty, CELL_CHKNOPASS) && j < max); pc->setpos(sd, index, tx, ty, CLR_OUTSIGHT); } else { @@ -6723,13 +6724,16 @@ BUILDIN(percentheal) } sd = script->rid2sd(st); - if( sd == NULL ) + if (sd == NULL) return true; #ifdef RENEWAL if( sd->sc.data[SC_EXTREMITYFIST2] ) sp = 0; #endif - pc->percentheal(sd,hp,sp); + if (sd->sc.data[SC_BITESCAR]) { + hp = 0; + } + pc->percentheal(sd, hp, sp); return true; } @@ -6738,18 +6742,18 @@ BUILDIN(percentheal) *------------------------------------------*/ BUILDIN(jobchange) { - int job, upper=-1; + int class, upper=-1; - job=script_getnum(st,2); + class = script_getnum(st,2); if( script_hasdata(st,3) ) upper=script_getnum(st,3); - if (pc->db_checkid(job)) { + if (pc->db_checkid(class)) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; - pc->jobchange(sd, job, upper); + pc->jobchange(sd, class, upper); } return true; @@ -6760,8 +6764,8 @@ BUILDIN(jobchange) *------------------------------------------*/ BUILDIN(jobname) { - int class_=script_getnum(st,2); - script_pushconststr(st, pc->job_name(class_)); + int class = script_getnum(st,2); + script_pushconststr(st, pc->job_name(class)); return true; } @@ -8012,6 +8016,90 @@ BUILDIN(makeitem) return true; } +/*========================================== +* makeitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,{"<map name>",<X>,<Y>,<range>}; +*------------------------------------------*/ +BUILDIN(makeitem2) +{ + struct map_session_data *sd = NULL; + struct item_data *i_data; + int nameid = 0, amount; + int16 x, y, m = -1, range; + struct item item_tmp; + + if (script_isstringtype(st, 2)) { + const char *name = script_getstr(st, 2); + struct item_data *item_data = itemdb->search_name(name); + if (item_data != NULL) + nameid = item_data->nameid; + } else { + nameid = script_getnum(st, 2); + } + + i_data = itemdb->exists(nameid); + if (i_data == NULL) { + ShowError("makeitem2: Unknown item %d requested.\n", nameid); + return true; + } + + if (script_hasdata(st, 11)) { + m = map->mapname2mapid(script_getstr(st, 11)); + } else { + sd = script->rid2sd(st); + if (sd == NULL) + return true; + m = sd->bl.m; + } + + if (m == -1) { + ShowError("makeitem2: Nonexistant map requested.\n"); + return true; + } + + x = (script_hasdata(st, 12) ? script_getnum(st, 12) : 0); + y = (script_hasdata(st, 13) ? script_getnum(st, 13) : 0); + + // pick random position on map + if (x <= 0 || x >= map->list[m].xs || y <= 0 || y >= map->list[m].ys) { + sd = map->id2sd(st->rid); + if ((x < 0 || y < 0) && sd == NULL) { + x = 0; + y = 0; + map->search_freecell(NULL, m, &x, &y, -1, -1, 1); + } else { + range = (script_hasdata(st, 14) ? cap_value(script_getnum(st, 14), 1, battle_config.area_size) : 3); + map->search_freecell(&sd->bl, sd->bl.m, &x, &y, range, range, 0); // Locate spot next to player. + } + } + + // if equip or weapon or egg type only drop one. + switch (i_data->type) { + case IT_ARMOR: + case IT_WEAPON: + case IT_PETARMOR: + case IT_PETEGG: + amount = 1; + break; + default: + amount = cap_value(script_getnum(st, 3), 1, MAX_AMOUNT); + break; + } + + memset(&item_tmp, 0, sizeof(item_tmp)); + item_tmp.nameid = nameid; + item_tmp.identify = script_getnum(st, 4); + item_tmp.refine = cap_value(script_getnum(st, 5), 0, MAX_REFINE); + item_tmp.attribute = script_getnum(st, 6); + item_tmp.card[0] = (short)script_getnum(st, 7); + item_tmp.card[1] = (short)script_getnum(st, 8); + item_tmp.card[2] = (short)script_getnum(st, 9); + item_tmp.card[3] = (short)script_getnum(st, 10); + + map->addflooritem(NULL, &item_tmp, amount, m, x, y, 0, 0, 0, 0); + + return true; +} + /// Counts / deletes the current item given by idx. /// Used by buildin_delitem_search /// Relies on all input data being already fully valid. @@ -8473,7 +8561,7 @@ BUILDIN(getpartyleader) switch (type) { case 1: script_pushint(st,p->party.member[i].account_id); break; case 2: script_pushint(st,p->party.member[i].char_id); break; - case 3: script_pushint(st,p->party.member[i].class_); break; + case 3: script_pushint(st,p->party.member[i].class); break; case 4: script_pushstrcopy(st,mapindex_id2name(p->party.member[i].map)); break; case 5: script_pushint(st,p->party.member[i].lv); break; default: script_pushstrcopy(st,p->party.member[i].name); break; @@ -9080,15 +9168,15 @@ BUILDIN(successrefitem) sd->status.char_id == (int)MakeDWord(sd->status.inventory[i].card[2],sd->status.inventory[i].card[3]) ) { // Fame point system [DracoRPG] switch (sd->inventory_data[i]->wlv) { - case 1: - pc->addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point - break; - case 2: - pc->addfame(sd,25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point - break; - case 3: - pc->addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point - break; + case 1: + pc->addfame(sd, RANKTYPE_BLACKSMITH, 1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point + break; + case 2: + pc->addfame(sd, RANKTYPE_BLACKSMITH, 25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point + break; + case 3: + pc->addfame(sd, RANKTYPE_BLACKSMITH, 1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point + break; } } } @@ -9889,7 +9977,7 @@ BUILDIN(setmount) flag = SETMOUNT_TYPE_AUTODETECT; } // Sanity checks and auto-detection - if ((sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) { + if ((sd->job & MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) { if (pc->checkskill(sd, RK_DRAGONTRAINING)) { // Rune Knight (Dragon) unsigned int option; @@ -9901,11 +9989,11 @@ BUILDIN(setmount) OPTION_DRAGON1); // default value pc->setridingdragon(sd, option); } - } else if ((sd->class_&MAPID_THIRDMASK) == MAPID_RANGER) { + } else if ((sd->job & MAPID_THIRDMASK) == MAPID_RANGER) { // Ranger (Warg) if (pc->checkskill(sd, RA_WUGRIDER)) pc->setridingwug(sd, true); - } else if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) { + } else if ((sd->job & MAPID_THIRDMASK) == MAPID_MECHANIC) { // Mechanic (Mado Gear) if (pc->checkskill(sd, NC_MADOLICENCE)) pc->setmadogear(sd, true); @@ -11679,22 +11767,22 @@ BUILDIN(homunculus_shuffle) //These two functions bring the eA MAPID_* class functionality to scripts. BUILDIN(eaclass) { - int class_; + int class; if (script_hasdata(st,2)) { - class_ = script_getnum(st,2); + class = script_getnum(st,2); } else { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; - class_ = sd->status.class_; + class = sd->status.class; } - script_pushint(st,pc->jobid2mapid(class_)); + script_pushint(st,pc->jobid2mapid(class)); return true; } BUILDIN(roclass) { - int class_ =script_getnum(st,2); + int job = script_getnum(st,2); int sex; if (script_hasdata(st,3)) { sex = script_getnum(st,3); @@ -11705,7 +11793,7 @@ BUILDIN(roclass) else sex = 1; //Just use male when not found. } - script_pushint(st,pc->mapid2jobid(class_, sex)); + script_pushint(st,pc->mapid2jobid(job, sex)); return true; } @@ -11801,12 +11889,12 @@ BUILDIN(changebase) if(vclass == JOB_WEDDING) { if (!battle_config.wedding_modifydisplay || //Do not show the wedding sprites - sd->class_&JOBL_BABY //Baby classes screw up when showing wedding sprites. [Skotlex] They don't seem to anymore. + sd->job & JOBL_BABY //Baby classes screw up when showing wedding sprites. [Skotlex] They don't seem to anymore. ) return true; } - if(sd->disguise == -1 && vclass != sd->vd.class_) + if (sd->disguise == -1 && vclass != sd->vd.class) pc->changelook(sd,LOOK_BASE,vclass); //Updated client view. Base, Weapon and Cloth Colors. return true; @@ -13753,14 +13841,14 @@ BUILDIN(undisguise) * @type unused *------------------------------------------*/ BUILDIN(classchange) { - int class_,type; + int class, type; struct block_list *bl=map->id2bl(st->oid); if(bl==NULL) return true; - class_=script_getnum(st,2); + class = script_getnum(st,2); type=script_getnum(st,3); - clif->class_change(bl,class_,type); + clif->class_change(bl, class, type); return true; } @@ -20745,6 +20833,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(getnameditem,"vv"), BUILDIN_DEF2(grouprandomitem,"groupranditem","i"), BUILDIN_DEF(makeitem,"visii"), + BUILDIN_DEF(makeitem2,"viiiiiiii????"), BUILDIN_DEF(delitem,"vi?"), BUILDIN_DEF(delitem2,"viiiiiiii?"), BUILDIN_DEF2(enableitemuse,"enable_items",""), |