Cleanup of NPC logic

This commit is contained in:
Lemongrass3110 2022-12-01 00:28:38 +01:00
parent 0da07fff32
commit 2857e51abd

View File

@ -6,50 +6,57 @@
//= 1.0 Initial release [Lemongrass] //= 1.0 Initial release [Lemongrass]
//= 1.1 Replay version [eppc0330] //= 1.1 Replay version [eppc0330]
//= 1.2 Translation of the replay version [Lemongrass] //= 1.2 Translation of the replay version [Lemongrass]
//= 1.3 Cleanup of NPC logic [Lemongrass]
//============================================================ //============================================================
prontera,0,0,0 script Goldpoint Manager::GOLDPCCAFE 4_F_02,{ prontera,0,0,0 script Goldpoint Manager::GOLDPCCAFE 4_F_02,{
.@point = Goldpc_Points;
.@npcName$ = "[Goldpoint Manager]";
// ID:AMOUNT:PRICE // ID:AMOUNT:PRICE
setarray .items$[1], setarray .items$[1],
"25464:1:2", // World_Tour_Ticket 1 "25464:1:2", // World_Tour_Ticket 1
"23919:1:10", // K_Secret_Key 1 "23919:1:10", // K_Secret_Key 1
"23919:11:100",// K_Secret_Key 11 "23919:11:100",// K_Secret_Key 11
"23919:33:300";// K_Secret_Key 33 "23919:33:300";// K_Secret_Key 33
mes "[Goldpoint Manager]";
mes "You currently have ^0000ff"+Goldpc_Points+"^000000 points.";
mes "What reward do you want?";
next;
.@menu$ = "View current points"; .@menu$ = "View current points";
for(.@i = 1; .@i < getarraysize(.items$); .@i++) { for(.@i = 1; .@i < getarraysize(.items$); .@i++) {
explode(.@array$, .items$[.@i], ":"); explode(.@array$, .items$[.@i], ":");
.@cost = atoi(.@array$[2]); .@cost = atoi(.@array$[2]);
.@menu$ += ":"+(.@cost)+" points gift"+((.@point<.@cost)?" ^ff0000(not enough points)^000000":""); .@menu$ += ":" + .@cost + " points gift";
if( Goldpc_Points < .@cost ){
.@menu$ += " ^ff0000(not enough points)^000000";
}
} }
mes .@npcName$;
mes "You currently have ^0000ff"+.@point+"^000000 points.";
mes "What reward do you want?";
next;
.@s = select(.@menu$)-1; .@s = select(.@menu$)-1;
if(.@s == 0) { if(.@s == 0) {
mes .@npcName$; mes "[Goldpoint Manager]";
mes "You currently have ^0000ff"+.@point+"^000000 points."; mes "You currently have ^0000ff"+Goldpc_Points+"^000000 points.";
close; close;
} }
explode(.@array$, .items$[.@s], ":"); explode(.@array$, .items$[.@s], ":");
.@itemid = atoi(.@array$[0]); .@itemid = atoi(.@array$[0]);
.@amount = atoi(.@array$[1]); .@amount = atoi(.@array$[1]);
.@cost = atoi(.@array$[2]); .@cost = atoi(.@array$[2]);
if(.@point < .@cost) {
mes .@npcName$; if(Goldpc_Points < .@cost) {
mes "You have ^0000ff"+.@point+"^000000 points remaining."; mes "[Goldpoint Manager]";
mes "You have ^0000ff"+Goldpc_Points+"^000000 points remaining.";
mes "You cannot get the prize with this amount of points."; mes "You cannot get the prize with this amount of points.";
close; close;
} }
mes .@npcName$;
mes "[Goldpoint Manager]";
mes "You chose the "+.@cost+" points gift. We will reward you immediately."; mes "You chose the "+.@cost+" points gift. We will reward you immediately.";
mes "You have ^0000ff"+(.@point-.@cost)+"^000000 points remaining.";
Goldpc_Points -= .@cost; Goldpc_Points -= .@cost;
getitem .@itemid,.@amount; getitem .@itemid,.@amount;
mes "You have ^0000ff"+Goldpc_Points+"^000000 points remaining.";
close; close;
} }