Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 59 additions & 19 deletions npc/custom/stylist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,72 @@
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.1
//= 1.2
//===== Description: =========================================
//= Changes your hair style, hair color, and cloth color.
//===== Additional Comments: =================================
//= 1.1 Switched to 'getbattleflag', credits to Saithis. [Euphy]
//= 1.2 Fix style start at min_style, add Job_Summoner [AnnieRuru]
//============================================================

prontera,170,180,1 script Stylist#custom_stylist 2_M_DYEINGER,{

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(PC_NAME),"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); break;
case 2: set .@style, ((.@style!=1)?.@style-1:.@styles[.@s]); break;
case 3: message strcharinfo(PC_NAME),"Choose a style between 1 - "+.@styles[.@s]+".";
input .@style,0,.@styles[.@s];
if (!.@style) set .@style, rand(1,.@styles[.@s]);
break;
case 4: set .@style, .@Revert; setlook .@Look[.@s], .@Revert; break;
.@choose = select("Hair style", "Hair color", "Cloth color") - 1;
.@part = .look[.@choose];
if (BaseClass != Job_Summoner)
callsub(L_styles, .@part, .minstyle[.@part], .maxstyle[.@part]);
else
callsub(L_styles, .@part, .summoner_minstyle[.@part], .summoner_maxstyle[.@part]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing end; ?

Suggested change
callsub(L_styles, .@part, .summoner_minstyle[.@part], .summoner_maxstyle[.@part]);
callsub(L_styles, .@part, .summoner_minstyle[.@part], .summoner_maxstyle[.@part]);
end;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/rathena/rathena/blob/master/npc/custom/battleground/bg_emp.txt#L79

you see, when I actually submit this script to Euphy,
I consider a little bit about changing my usual scripting style to suit rathena general behavior

OnRedDown:
	callsub L_EmpDown, "Red", .blue;
	end
OnBlueDown:
	callsub L_EmpDown, "Blue", .red;
	end;
L_EmpDown:
	mapannounce "bat_a01", strcharinfo(0) +" has destroyed "+ getarg(0) +" Team's Emperium.", bc_map;
	.winside = getarg(1);
	awake strnpcinfo(0);
	return;

this feels like OnRedDown and OnBlueDown has its own operation and nothing to do with each other

OnRedDown:  callsub L_EmpDown, "Red", .blue; end;
OnBlueDown: callsub L_EmpDown, "Blue", .red; end;
L_EmpDown:
	mapannounce "bat_a01", strcharinfo(0) +" has destroyed "+ getarg(0) +" Team's Emperium.", bc_map;
	.winside = getarg(1);
	awake strnpcinfo(0);
	return;

I am wondering what the end; is doing there

in the end, this 1 line method was accepted not only by Euphy, but also lots of rAthena developers
rathena/rathena#3025

I'm quite sure if the callsub was meant never has a return; there's no need for an end; there

L_styles:
.@lookpart = getarg(0);
.@minstyle = getarg(1);
.@maxstyle = getarg(2);
.@i = .@revert = getlook(.@lookpart);
while (true) {
setlook(.@lookpart, .@i);
message(strcharinfo(PC_NAME), sprintf(_("This is style #%d."), .@i));
if (.@i == .@maxstyle)
.@next = .@minstyle;
else
.@next = .@i + 1;
if (.@i == .@minstyle)
.@previous = .@maxstyle;
else
.@previous = .@i - 1;
switch(select(
sprintf(_(" ~ Next (%s%d%s)"), F_MesColor(C_BLUE), .@next, F_MesColor(C_BLACK)),
sprintf(_(" ~ Previous (%s%d%s)"), F_MesColor(C_BLUE), .@previous, F_MesColor(C_BLACK)),
" ~ Jump to...",
sprintf(_(" ~ Revert to original (%s%d%s)"), F_MesColor(C_BLUE), .@revert, F_MesColor(C_BLACK)))) {
case 1:
.@i = .@next;
break;
case 2:
.@i = .@previous;
break;
case 3:
message(strcharinfo(PC_NAME), sprintf(_("Choose a style between %d - %d."), .@minstyle, .@maxstyle));
input(.@i, .@minstyle, .@maxstyle);
break;
case 4:
.@i = .@revert;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing break;?

Suggested change
.@i = .@revert;
.@i = .@revert;
break;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read a few c++ guide, most guide says there's no need to have break at the last case statement

although I admit I didn't have a default case there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for good practices/habits.
Since most of the cases look similar, its good to have the break; for each of them.
Protect yourself from doing thing wrongly when you out of a sudden re-ordering the cases in future.

}
}
end;
OnInit:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I would prefer these:

Suggested change
OnInit:
setarray .look[0], LOOK_HAIR, LOOK_HAIR_COLOR, LOOK_CLOTHES_COLOR;
.minstyle[.look[0]] = .summoner_minstyle[.look[0]] = getbattleflag("min_hair_style");
.maxstyle[.look[0]] = .summoner_maxstyle[.look[0]] = getbattleflag("max_hair_style");
.minstyle[.look[1]] = .summoner_minstyle[.look[1]] = getbattleflag("min_hair_color");
.maxstyle[.look[1]] = .summoner_maxstyle[.look[1]] = getbattleflag("max_hair_color");
.minstyle[.look[2]] = .summoner_minstyle[.look[2]] = getbattleflag("min_cloth_color");
.maxstyle[.look[2]] = .summoner_maxstyle[.look[2]] = getbattleflag("max_cloth_color");
end;

if in the future there are any changes to the constant, I would only need to change 1 line....
cons: it may make the array harder to read/understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.minstyle[.look[0]] = .summoner_minstyle[.look[0]] = getbattleflag("min_hair_style");

totally defeats the purpose of this script

I thought I post in the issue,
explain our stylist outdated because of the introduction of summoner class

if we combine them, when they need to change summoner class have different max_cloth_style,
they wonder why the normal job also change at the same time

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, i meant this

	setarray .look[0], LOOK_HAIR, LOOK_HAIR_COLOR, LOOK_CLOTHES_COLOR;
	.minstyle[.look[0]] = ......
	.minstyle[.look[1]] = ......
	.minstyle[.look[2]] = ......
	.summoner_minstyle[.look[0]] = ......
	.summoner_minstyle[.look[1]] = ......
	.summoner_minstyle[.look[2]] = ......

beside the current emulator doesn't introduce a new setting for doram class, they are just sharing the same value at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but in stylist_db.conf. In there, Doram class can only go up to hairstyle 6. However, hair_style and hair_dye npcs don't even check class. Anyways, why not put 6 as default max hairstyle for Doram, just like stylist_db.conf? This way the script would be "plug n' play" for server owners with Doram class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the problem, we want the emulator to simulate official ragnarok online
and not everyone are happy with the official settings

that's why battle_config exist ... to change certain popular configuration without restarting server
that's why custom scripts exist ... script support/request is the most generate post on the forum

what I'm trying to say is, this script should emulate official settings,
but the configuration is there for server who wish to change the value
and not everyone use number 6 either, my test server crash at value no.2
and members can also download/purchase extra cloth in graphic release

setarray .look[0], LOOK_HAIR, LOOK_HAIR_COLOR, LOOK_CLOTHES_COLOR;

.minstyle[LOOK_HAIR] = getbattleflag("min_hair_style");
.maxstyle[LOOK_HAIR] = getbattleflag("max_hair_style");
.minstyle[LOOK_HAIR_COLOR] = getbattleflag("min_hair_color");
.maxstyle[LOOK_HAIR_COLOR] = getbattleflag("max_hair_color");
.minstyle[LOOK_CLOTHES_COLOR] = getbattleflag("min_cloth_color");
.maxstyle[LOOK_CLOTHES_COLOR] = getbattleflag("max_cloth_color");

.summoner_minstyle[LOOK_HAIR] = getbattleflag("min_hair_style");
.summoner_maxstyle[LOOK_HAIR] = getbattleflag("max_hair_style");
.summoner_minstyle[LOOK_HAIR_COLOR] = getbattleflag("min_hair_color");
.summoner_maxstyle[LOOK_HAIR_COLOR] = getbattleflag("max_hair_color");
.summoner_minstyle[LOOK_CLOTHES_COLOR] = getbattleflag("min_cloth_color");
.summoner_maxstyle[LOOK_CLOTHES_COLOR] = getbattleflag("max_cloth_color");
end;
}