Fixed Hunting Missions (#3832)

Fixed getmapxy getting the first player map and coordinates in every instance
Optimization of shop by using inarray script command
Changed some values to constants
This commit is contained in:
sigtus 2019-01-25 14:52:25 -03:00 committed by Atemo
parent caac76b037
commit ad960e47b5

View File

@ -23,7 +23,7 @@
//= Syntax updates and style cleaning. //= Syntax updates and style cleaning.
//============================================================ //============================================================
prontera,152,187,6 script Hunting Missions 951,{ prontera,152,187,6 script Hunting Missions 4_F_EDEN_MASTER,{
function Chk; function Chk;
mes "[Hunting Missions]"; mes "[Hunting Missions]";
mes "Hello, " + strcharinfo(0) + "!"; mes "Hello, " + strcharinfo(0) + "!";
@ -39,11 +39,11 @@ function Chk;
#Mission_Delay = 1; #Mission_Delay = 1;
close; close;
} }
mes rand(2) ? "Working hard, as always..." : "Not slacking, I hope..."; mes F_Rand("Working hard, as always...", "Not slacking, I hope...");
mes "Is there anything I can help"; mes "Is there anything I can help";
mes "you with?"; mes "you with?";
mes " "; mes " ";
mes "^777777~ You've completed " + callfunc("F_InsertPlural",Mission_Total,"mission",0,"^0055FF%d^777777 %s") + ". ~^000000"; mes "^777777~ You've completed " + F_InsertPlural(Mission_Total,"mission",0,"^0055FF%d^777777 %s") + ". ~^000000";
next; next;
switch(select( switch(select(
((!Mission0) ? " ~ New Mission::" : ": ~ Mission Status: ~ Abandon Mission") + ((!Mission0) ? " ~ New Mission::" : ": ~ Mission Status: ~ Abandon Mission") +
@ -65,12 +65,12 @@ function Chk;
emotion ET_SCRATCH; emotion ET_SCRATCH;
#Mission_Count = 0; #Mission_Count = 0;
} }
@hm_char_del_check = 1; @hm_char_del_check = true;
} }
close; close;
} }
if (#Mission_Delay > gettimetick(2) && .Delay) { if (#Mission_Delay > gettimetick(2) && .Delay) {
mes "I'm afraid you'll have to wait " + callfunc("Time2Str",#Mission_Delay) + " before taking another mission."; mes "I'm afraid you'll have to wait " + Time2Str(#Mission_Delay) + " before taking another mission.";
close; close;
} }
mes "You must hunt:"; mes "You must hunt:";
@ -99,7 +99,7 @@ function Chk;
if (.Reset < 0 && .Delay) if (.Reset < 0 && .Delay)
mes "Your delay time will not be reset."; mes "Your delay time will not be reset.";
else if (.Reset > 0) else if (.Reset > 0)
mes "It will cost " + callfunc("F_InsertComma",.Reset) + " Zeny."; mes "It will cost " + F_InsertComma(.Reset) + " Zeny.";
next; next;
switch(select(" ~ Abandon...: ~ ^777777Cancel^000000")) { switch(select(" ~ Abandon...: ~ ^777777Cancel^000000")) {
case 1: case 1:
@ -159,7 +159,7 @@ function Chk;
end; end;
Mission_Status: Mission_Status:
@f = 0; @f = false;
deletearray .@j[0], getarraysize(.@j); deletearray .@j[0], getarraysize(.@j);
for (.@i = 0; .@i < .Quests; .@i++) { for (.@i = 0; .@i < .Quests; .@i++) {
.@j[.@i] = getd("Mission" + .@i); .@j[.@i] = getd("Mission" + .@i);
@ -179,11 +179,11 @@ Mission_Status:
mes "[Hunting Missions]"; mes "[Hunting Missions]";
mes "Mission rewards:"; mes "Mission rewards:";
mes " > Mission Points: ^0055FF" + .@Mission_Points + "^000000"; mes " > Mission Points: ^0055FF" + .@Mission_Points + "^000000";
mes " > Base Experience: ^0055FF" + callfunc("F_InsertComma",.@Base_Exp) + "^000000"; mes " > Base Experience: ^0055FF" + F_InsertComma(.@Base_Exp) + "^000000";
mes " > Job Experience: ^0055FF" + callfunc("F_InsertComma",.@Job_Exp) + "^000000"; mes " > Job Experience: ^0055FF" + F_InsertComma(.@Job_Exp) + "^000000";
mes " > Zeny: ^0055FF" + callfunc("F_InsertComma",.@Zeny) + "^000000"; mes " > Zeny: ^0055FF" + F_InsertComma(.@Zeny) + "^000000";
if (@f) { if (@f) {
@f = 0; @f = false;
return; return;
} }
next; next;
@ -235,35 +235,32 @@ Mission_Info:
function Chk { function Chk {
if (getarg(0) < getarg(1)) { if (getarg(0) < getarg(1)) {
@f = 1; @f = true;
return "^FF0000"; return "^FF0000";
} else } else
return "^00FF00"; return "^00FF00";
} }
OnBuyItem: OnBuyItem:
@cost = 0; .@size = getarraysize(@bought_nameid);
for (.@i = 0; .@i < getarraysize(@bought_nameid); .@i++) for (.@i = 0; .@i < .@size; .@i++) {
for (.@j = 0; .@j < getarraysize(.Shop); .@j += 2) .@j = inarray(.Shop, @bought_nameid[.@i]);
if (@bought_nameid[.@i] == .Shop[.@j]) { .@cost += (.Shop[.@j+1] * @bought_quantity[.@i]);
set @cost, @cost + (.Shop[.@j+1] * @bought_quantity[.@i]); }
break;
}
mes "[Hunting Missions]"; mes "[Hunting Missions]";
if (@cost > #Mission_Points) if (.@cost > #Mission_Points)
mes "You don't have enough Mission Points."; mes "You don't have enough Mission Points.";
else { else {
for (.@i = 0; .@i < getarraysize(@bought_nameid); .@i++) { for (.@i = 0; .@i < .@size; .@i++) {
getitem @bought_nameid[.@i], @bought_quantity[.@i]; getitem @bought_nameid[.@i], @bought_quantity[.@i];
dispbottom "Purchased " + @bought_quantity[.@i] + "x " + getitemname(@bought_nameid[.@i]) + "."; dispbottom "Purchased " + @bought_quantity[.@i] + "x " + getitemname(@bought_nameid[.@i]) + ".";
} }
#Mission_Points -= @cost; #Mission_Points -= .@cost;
mes "Deal completed."; mes "Deal completed.";
emotion ET_MONEY; emotion ET_MONEY;
} }
@cost = 0; deletearray @bought_nameid[0], .@size;
deletearray @bought_nameid[0], getarraysize(@bought_nameid); deletearray @bought_quantity[0], .@size;
deletearray @bought_quantity[0], getarraysize(@bought_quantity);
close; close;
OnNPCKillEvent: OnNPCKillEvent:
@ -290,7 +287,7 @@ OnNPCKillEvent:
set .@HP, readparam(HP, $@partymembercid[.@i]); set .@HP, readparam(HP, $@partymembercid[.@i]);
if (.@Mission_Count && .@Mission0 && .@HP > 0) { if (.@Mission_Count && .@Mission0 && .@HP > 0) {
getmapxy(.@map2$,.@x2,.@y2,UNITTYPE_PC); getmapxy(.@map2$,.@x2,.@y2,UNITTYPE_PC,rid2name($@partymemberaid[.@i]));
if ((.@map1$ == .@map2$ || .Party == 1) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30 || .Party < 3)) { if ((.@map1$ == .@map2$ || .Party == 1) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30 || .Party < 3)) {
for (.@j = 0; .@j < .Quests; .@j++) { for (.@j = 0; .@j < .Quests; .@j++) {
.@my_mob_id = getvar( getd("Mission"+.@j),$@partymembercid[.@i] ); .@my_mob_id = getvar( getd("Mission"+.@j),$@partymembercid[.@i] );