Files
sweetgum-server/scripts/npc/1043002.js

266 lines
10 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var status = 0;
var service = -1; // 0 = hairstyle change, 1 = hair color change
var hairPrice = 1000000;
var hairColorPrice = 50000;
/* ── HAIRSTYLE ───────────────────────────────────────────────── */
var selectedCategory = -1;
var hairnew = Array();
/*
HAIR CATEGORIES
Classic I (30xxx): original male hairs — 91 hairs
Classic II (31xxx): original female hairs — 92 hairs
Royal I (32xxx): mid-era hairs — 27 hairs
Royal II (33xxx): mid-era hairs — 76 hairs
Royal III (34xxx): mid-era hairs — 86 hairs
Modern I (36xxx / 37xxx): newer hairs — 126 hairs
Modern II (38xxx / 39xxx): newer hairs — 91 hairs
Modern III (40xxx / 41xxx / 42xxx): newest hairs — 91 hairs
Only base (black) IDs are stored here (units digit = 0).
Each hair has 8 color variants (units digit 07).
*/
var classic1Hairs = Array(
30000, 30020, 30030, 30040, 30050, 30060, 30100, 30110,
30120, 30130, 30140, 30150, 30160, 30170, 30180, 30190,
30200, 30210, 30220, 30230, 30240, 30250, 30260, 30270,
30280, 30290, 30300, 30310, 30320, 30330, 30340, 30350,
30360, 30370, 30380, 30400, 30410, 30420, 30430, 30440,
30450, 30460, 30470, 30480, 30490, 30510, 30520, 30530,
30540, 30550, 30560, 30570, 30580, 30590, 30600, 30610,
30620, 30630, 30640, 30650, 30660, 30670, 30680, 30690,
30700, 30710, 30720, 30730, 30740, 30750, 30760, 30770,
30780, 30790, 30800, 30810, 30820, 30830, 30840, 30850,
30860, 30870, 30880, 30890, 30900, 30910, 30920, 30930,
30940, 30950, 30990
);
var classic2Hairs = Array(
31000, 31010, 31020, 31030, 31040, 31050, 31060, 31070,
31080, 31090, 31100, 31110, 31120, 31130, 31140, 31150,
31160, 31170, 31180, 31190, 31200, 31210, 31220, 31230,
31240, 31250, 31260, 31270, 31280, 31290, 31300, 31310,
31320, 31330, 31340, 31350, 31360, 31400, 31410, 31420,
31430, 31440, 31450, 31460, 31470, 31480, 31490, 31510,
31520, 31530, 31540, 31550, 31560, 31570, 31580, 31590,
31600, 31610, 31620, 31630, 31640, 31650, 31660, 31670,
31680, 31690, 31700, 31710, 31720, 31730, 31740, 31750,
31760, 31770, 31780, 31790, 31800, 31810, 31820, 31830,
31840, 31850, 31860, 31870, 31880, 31890, 31910, 31920,
31930, 31940, 31950, 31990
);
var royal1Hairs = Array(
32050, 32160, 32310, 32320, 32330, 32340, 32350,
32360, 32370, 32380, 32390, 32400, 32410, 32420, 32430,
32440, 32450, 32460, 32470, 32480, 32490, 32500, 32520,
32530, 32540, 32550
);
var royal2Hairs = Array(
33000, 33030, 33040, 33050, 33060, 33070, 33080, 33090,
33100, 33110, 33120, 33130, 33150, 33160, 33170, 33180,
33190, 33210, 33220, 33240, 33250, 33260, 33270, 33280,
33290, 33310, 33330, 33350, 33360, 33370, 33380, 33390,
33400, 33410, 33430, 33440, 33450, 33460, 33470, 33480,
33500, 33510, 33520, 33530, 33540, 33550, 33580, 33590,
33600, 33610, 33620, 33630, 33640, 33660, 33670, 33680,
33690, 33700, 33710, 33720, 33730, 33740, 33750, 33760,
33770, 33780, 33790, 33800, 33810, 33820, 33830, 33930,
33940, 33950, 33960, 33990
);
var royal3Hairs = Array(
34000, 34010, 34020, 34030, 34040, 34050, 34060, 34070,
34080, 34090, 34100, 34110, 34120, 34130, 34140, 34150,
34160, 34170, 34180, 34190, 34210, 34220, 34230, 34240,
34250, 34260, 34270, 34310, 34320, 34330, 34340, 34350,
34360, 34370, 34380, 34400, 34410, 34420, 34430, 34440,
34450, 34470, 34480, 34490, 34510, 34540, 34560, 34580,
34590, 34600, 34610, 34620, 34630, 34640, 34650, 34660,
34670, 34680, 34690, 34700, 34710, 34720, 34730, 34740,
34750, 34760, 34770, 34780, 34790, 34800, 34810, 34820,
34830, 34840, 34850, 34860, 34870, 34880, 34890, 34900,
34910, 34940, 34950, 34960, 34970, 34980
);
var modern1Hairs = Array(
36010, 36020, 36030, 36040, 36050, 36060, 36070, 36080,
36090, 36100, 36110, 36130, 36140, 36150, 36160, 36170,
36180, 36190, 36200, 36210, 36220, 36230, 36240, 36250,
36260, 36270, 36280, 36330, 36340, 36350, 36380, 36390,
36400, 36410, 36420, 36460, 36470, 36480, 36490, 36500,
36510, 36520, 36530, 36600, 36610, 37000, 37010, 37020,
37030, 37040, 37060, 37070, 37080, 37090, 37100, 37110,
37120, 37130, 37140, 37150, 37160, 37170, 37200, 37210,
37220, 37230, 37240, 37250, 37260, 37270, 37300, 37310,
37320, 37330, 37340, 37350, 37370, 37380, 37400, 37450,
37460, 37470, 37490, 37500, 37510, 37520, 37530, 37590,
37600, 37610, 37620, 37630, 37640, 37650, 37660, 37670,
37680, 37690, 37700, 37710, 37720, 37730, 37740, 37750,
37760, 37770, 37780, 37790, 37800, 37810, 37820, 37830,
37840, 37850, 37860, 37880, 37900, 37910, 37920, 37930,
37940, 37950, 37960, 37970, 37980, 37990
);
var modern2Hairs = Array(
38000, 38010, 38020, 38030, 38040, 38050, 38060, 38070,
38080, 38090, 38100, 38110, 38120, 38130, 38140, 38150,
38160, 38180, 38240, 38250, 38260, 38270, 38280, 38290,
38300, 38310, 38320, 38330, 38350, 38390, 38400, 38410,
38420, 38430, 38440, 38450, 38460, 38470, 38480, 38490,
38500, 38510, 38520, 38540, 38560, 38570, 38580, 38590,
38600, 38610, 38620, 38630, 38640, 38650, 38660, 38670,
38680, 38690, 38700, 38710, 38730, 38740, 38750, 38760,
38770, 38790, 38800, 38810, 38820, 38840, 38860, 38880,
38890, 38900, 38910, 38930, 38940, 39040, 39050, 39060,
39070, 39080, 39090, 39190, 39200, 39210, 39220, 39230,
39240, 39250, 39260
);
var modern3Hairs = Array(
40000, 40010, 40020, 40030, 40040, 40050, 40060, 40070,
40080, 40090, 40100, 40110, 40120, 40250, 40260, 40270,
40280, 40290, 40300, 40310, 40320, 40330, 40350, 40360,
40370, 40390, 40400, 40410, 40420, 40440, 40450, 40460,
40480, 40490, 40520, 40530, 40540, 40550, 40560, 41060,
41070, 41080, 41090, 41100, 41110, 41120, 41150, 41160,
41170, 41180, 41190, 41200, 41220, 41340, 41350, 41360,
41370, 41380, 41390, 41400, 41410, 41420, 41440, 41460,
41470, 41480, 41490, 41510, 41520, 41530, 41560, 41570,
41580, 41610, 41620, 41630, 41640, 41650, 41660, 41670,
41680, 41690, 41700, 41710, 42060, 42070, 42080, 42090,
42100, 42110, 42120
);
var hairCategories = [
classic1Hairs,
classic2Hairs,
royal1Hairs,
royal2Hairs,
royal3Hairs,
modern1Hairs,
modern2Hairs,
modern3Hairs
];
var categoryNames = [
"Classic I",
"Classic II",
"Royal I",
"Royal II",
"Royal III",
"Modern I",
"Modern II",
"Modern III"
];
/* ── HAIR COLOR ──────────────────────────────────────────────── */
var hairColors = Array();
// Returns the base (black) hair ID by zeroing the units digit.
// e.g. 37143 -> 37140, works for any hair ID range.
function getBaseHair() {
var hair = cm.getPlayer().getHair();
return Math.floor(hair / 10) * 10;
}
function buildHairColors() {
var base = getBaseHair();
hairColors = Array();
for (var i = 0; i < 8; i++) {
hairColors.push(base + i);
}
}
/* ── ENTRY POINT ─────────────────────────────────────────────── */
function start() {
status = -1;
action(1, 0, 0);
}
/* ── MAIN FLOW ───────────────────────────────────────────────── */
function action(mode, type, selection) {
if (mode < 1) {
cm.dispose();
return;
}
status++;
/* ── STATUS 0: top-level menu ── */
if (status == 0) {
cm.sendSimple(
"Hello~ I'm Avery, Sweetgum's hair prince. " +
"What can I help you with today?\r\n\r\n" +
"#L0#New Hairstyle (#b" + hairPrice + " Mesos#k)#l\r\n" +
"#L1#Change Hair Color (#b" + hairColorPrice + " Mesos#k)#l"
);
/* ── STATUS 1: branch on chosen service ── */
} else if (status == 1) {
service = selection;
if (service == 0) {
// Hairstyle — show category menu
var text = "Select a hair category:\r\n\r\n";
for (var i = 0; i < categoryNames.length; i++) {
text += "#L" + i + "#" + categoryNames[i] + "#l\r\n";
}
cm.sendSimple(text);
} else if (service == 1) {
// Hair color — show the 8 color variants for the player's current hair
buildHairColors();
cm.sendStyle(
"Please choose the hair color you'd like~ (#b" + hairColorPrice + " Mesos#k)",
hairColors
);
}
/* ── STATUS 2 ── */
} else if (status == 2) {
if (service == 0) {
// Hairstyle — player picked a category, now show hair styles
selectedCategory = selection;
hairnew = Array();
var selectedArray = hairCategories[selectedCategory];
for (var i = 0; i < selectedArray.length; i++) {
hairnew.push(selectedArray[i]);
}
cm.sendStyle("Please choose the hairstyle you'd like~", hairnew);
} else if (service == 1) {
// Hair color — player picked a color, apply it
if (cm.getMeso() < hairColorPrice) {
cm.sendOk("You need " + hairColorPrice + " mesos to change your hair color.");
cm.dispose();
return;
}
cm.gainMeso(-hairColorPrice);
cm.setHair(hairColors[selection]);
cm.sendOk("Enjoy your new hair color~");
cm.dispose();
}
/* ── STATUS 3: hairstyle only — player picked a style, apply it ── */
} else if (status == 3) {
if (cm.getMeso() < hairPrice) {
cm.sendOk("You need " + hairPrice + " mesos to receive a new hairstyle.");
cm.dispose();
return;
}
cm.gainMeso(-hairPrice);
cm.setHair(hairnew[selection]);
cm.sendOk("Enjoy your new and improved hairstyle! You will need to re-purchase your color after changing hairs~");
cm.dispose();
}
}