Another NPC script, this time, with goto jumps.
As you can see, the script can either set a local variable, or a global variable.
It can also use text colors such as ^00AA00Magnifiers
Which is green color code. (RRGGBB)
These are a few inspirations which might allow you to create the most flexible dialog in the asset store! (While these are not perfect, the possibilities are huge!)
(I don’t know if this might help, but yeah!)
I think your dialog system is extremely unique, compared to the other competitors,
as this is the only hassle free, untangled solution, and writer friendly dialog system
I have come across in the asset store.
I hope you can make it even more powerful by implementing colors, if/then/else, local variable and global variable setups, and a while-loop.
//============================================================
//= Identifier Script
//============================================================
prontera,132,215,5 script Identifier 833,{
// Price
// =====
// This is the Price in Zeny for one identified Item
set @price, 500;
// Actual Script Begins Here
// =========================
mes "[Identifier]";
mes "Hello there!";
mes "I can identify all your unidentified items.";
mes "It's just "+@price+" Zeny each item.";
next;
menu "Sure.",-,
"No thanks...",L_Bye;
getinventorylist;
set @identify, 0;
for(set @i, 0; @i < @inventorylist_count; set @i, @i + 1) {
if (@inventorylist_identify[@i] == 0) set @identify, @identify + 1;
}
if (@identify == 0) goto L_Nothing;
mes "[Identifier]";
if (@identify < 2) {
mes "You've got one unidentified item in your inventory.";
mes "I'll identify it for "+@price+" Zeny.";
} else {
mes "You've got "+@identify+" unidentified items in your inventory.";
mes "I'll identify them for "+(@identify * @price)+" Zeny.";
}
mes "If you've got any ^00AA00Magnifiers^000000, I'll take those instead.";
mes "Shall I start now?";
next;
menu "Ok, let's go!",-,
"What a ripoff...",L_Bye;
getinventorylist;
set @identified, 0;
for(set @i, 0; @i < @inventorylist_count; set @i, @i + 1) {
if (@inventorylist_identify[@i] == 0) {
if (countitem(611) > 0) delitem 611,1;
else if (Zeny < @price) goto L_NoZeny;
else set Zeny, Zeny - @price;
delitem2 @inventorylist_id[@i],1,0,0,0,0,0,0,0;
getitem @inventorylist_id[@i],1;
set @identified, @identified + 1;
}
}
mes "[Identifier]";
mes "Well, I identified everything!";
mes "I've identified a total of "+@identified+" items for you.";
mes "Come again.";
close;
L_Nothing:
mes "[Identifier]";
mes "You don't have any unidentified Items.";
mes "Come again when you do.";
close;
L_NoZeny:
mes "[Identifier]";
mes "You don't have enough Zeny.";
close;
L_Bye:
mes "[Identifier]";
mes "Come again soon.";
close;
}
This one is an example of variable arrays, which is extremely useful.
prontera,163,172,3 script Stylist#custom_stylist 878,{
cutin "orleans_1",2;
mes "[Stylist]";
mes "I can change your style in a blink of an eye..!";
next;
cutin "orleans_2",2;
mes "[Stylist]";
mes "It is a pleasure for me to see the citizens in a better style..!";
next;
cutin "orleans_6",2;
mes "[Stylist]";
mes "How may I help you today..?";
setarray .@Styles[1],getbattleflag("max_cloth_color"),getbattleflag("max_hair_style"),getbattleflag("max_hair_color");
setarray .@Look[1],7,1,6;
set .@s, select(" ~ Cloth color: ~ Hairstyle: ~ Hair color");
set .@Revert, getlook(.@Look[.@s]);
set .@Style,1;
while(1) {
setlook .@Look[.@s], .@Style;
message strcharinfo(0),"This is style #"+.@Style+".";
set .@menu$, " ~ Next (^0055FF"+((.@Style!=.@Styles[.@s])?.@Style+1:1)+"^000000): ~ Previous (^0055FF"+((.@Style!=1)?.@Style-1:.@Styles[.@s])+"^000000): ~ Jump to...: ~ Revert to original (^0055FF"+.@Revert+"^000000)";
switch(select(.@menu$)) {
case 1:
set .@Style, ((.@Style!=.@Styles[.@s])?.@Style+1:1);
set .@sx, rand(1,7);
cutin .sface$[.@sx],2;
if (.@sx <= 3){
specialeffect2 457;
} else if (.@sx == 4) {
specialeffect2 890;
} else if (.@sx >= 5) {
specialeffect2 463;
}
specialeffect 4;
specialeffect2 5;
specialeffect2 53;
break;
case 2:
set .@Style, ((.@Style!=1)?.@Style-1:.@Styles[.@s]);
set .@sx, rand(1,7);
cutin .sface$[.@sx],2;
specialeffect 4;
specialeffect2 5;
specialeffect2 53;
break;
case 3:
message strcharinfo(0),"Choose a style between 1 - "+.@Styles[.@s]+".";
input .@Style,0,.@Styles[.@s];
if (!.@Style) set .@Style, rand(1,.@Styles[.@s]);
set .@sx, rand(1,7);
cutin .sface$[.@sx],2;
specialeffect 4;
specialeffect2 5;
specialeffect2 53;
break;
case 4: set .@Style, .@Revert;
setlook .@Look[.@s], .@Revert;
set .@sx, rand(1,7);
cutin .sface$[.@sx],2;
specialeffect 4;
specialeffect2 5;
specialeffect2 53;
break;
}
}
OnInit:
.sface$[1] = "orleans_1";
.sface$[2] = "orleans_2";
.sface$[3] = "orleans_3";
.sface$[4] = "orleans_4";
.sface$[5] = "orleans_5";
.sface$[6] = "orleans_6";
.sface$[7] = "orleans_7";
end;
}
This one is a part of my written script of an array and a while loop example.
cutin "job_ko01",0;
mes "[Muramasa]";
mes "Hmm?";
while(1){ //While(1) will always return true, hence the dialog will re-occur at the end of the dialog until close2; function is called to close the dialog.
next;
mes "[Muramasa]";
mes "Anything you need?";
next;
switch(select("About Oboro:About the Demon Blades:I seek your advice.:End Conversation.")){
case 1:
cutin "job_ko02",0;
mes "[Muramasa]";
mes "^008800Oboro^000000 is a colleague of mine from back in the old times..";
next;
cutin "job_ko01",0;
mes "[Muramasa]";
mes "I discovered him and his blades when we were young, enchanted by its beauty.";
next;
mes "[Muramasa]";
mes "He has always been a bit of an oddball since back then..";
next;
cutin "job_ko04",0;
mes "[Muramasa]";
mes "Despite his attitude, his craftsmanship techniques are unorthodox, and his skills were unparalleled.";
next;
cutin "job_ko02",0;
mes "[Muramasa]";
mes "I think it is better if you speak to him if you wish to know more.";
break;
end;
case 2:
cutin "job_ko01",0;
mes "[Muramasa]";
mes "Back in those times, all we care about is to create the blades of our dreams..";
next;
mes "[Muramasa]";
mes "Both ^008800Oboro^000000 and Me, partners each other soon after..";
next;
cutin "job_ko01",0;
mes "[Muramasa]";
mes "It is because of this one vision we both share, to create a living blade.";
next;
mes "[Muramasa]";
mes "He pursue it through the beauty within magical blades in the west.";
next;
mes "[Muramasa]";
mes "Blah blah blah..";
break;
end;
case 3:
cutin "job_ko01",0;
mes "[Muramasa]";
mes "Advices..? Hmm..";
next;
cutin "job_ko04",0;
mes "[Muramasa]";
mes "^FF8800" + .obquote$[rand(1,.maxobquotes)] + "^000000";
next;
mes "[Muramasa]";
mes "How is that..?";
break;
end;
case 4:
cutin "job_ko01",0;
mes "[Muramasa]";
mes "Well then, come again anytime.";
close2;
cutin "",255;
end;
}
}
}
OnInit:
.obquote$[1] = "By being lost, one is given the chance to rediscover their purposes.";
.obquote$[2] = "It is not defeat if you end up winning last, it is progress.";
.obquote$[3] = "With great power, comes great responsibilities.";
.obquote$[4] = "There is nothing bad in losing your past, it is an opportunity to discover your new side.";
.obquote$[5] = "By being lost, one discovers a new path.";
.obquote$[6] = "Dangers is parcels and part of adventure.";
.obquote$[7] = "Never underestimate the strengths in numbers.";
.maxobquotes = 7;
end;
}