summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/clif.c15
-rw-r--r--src/map/pc.h3
-rw-r--r--src/map/script.c9
3 files changed, 21 insertions, 6 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index cd3131181..037e168d0 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -12587,10 +12587,19 @@ static void clif_parse_NpcAmountInput(int fd, struct map_session_data *sd)
int npcid = RFIFOL(fd,2);
int amount = RFIFOL(fd,6);
- if (amount >= 0)
+ if (amount < sd->npc_amount_min) {
+ sd->npc_amount = sd->npc_amount_min;
+ sd->npc_input_capped_range = -1;
+ }
+ else if (amount > sd->npc_amount_max) {
+ sd->npc_amount = sd->npc_amount_max;
+ sd->npc_input_capped_range = 1;
+ }
+ else {
sd->npc_amount = amount;
- else
- sd->npc_amount = 0;
+ sd->npc_input_capped_range = 0;
+ }
+
npc->scriptcont(sd, npcid, false);
}
diff --git a/src/map/pc.h b/src/map/pc.h
index b2069d4df..41384b484 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -273,6 +273,9 @@ struct map_session_data {
int npc_item_flag; //Marks the npc_id with which you can change equipments during interactions with said npc (see script command enable_itemuse)
int npc_menu; // internal variable, used in npc menu handling
int npc_amount;
+ int npc_amount_min;
+ int npc_amount_max;
+ int npc_input_capped_range;
struct script_state *st;
char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine
int npc_timer_id; //For player attached npc timers. [Skotlex]
diff --git a/src/map/script.c b/src/map/script.c
index 2a4cbd4f2..391fb34c4 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -6983,10 +6983,13 @@ static BUILDIN(input)
// first invocation, display npc input box
sd->state.menu_or_input = 1;
st->state = RERUNLINE;
- if (is_string_variable(name))
+ if (is_string_variable(name)) {
clif->scriptinputstr(sd, st->oid);
- else
+ } else {
+ sd->npc_amount_min = min;
+ sd->npc_amount_max = max;
clif->scriptinput(sd, st->oid);
+ }
} else {
// take received text/value and store it in the designated variable
sd->state.menu_or_input = 0;
@@ -6997,7 +7000,7 @@ static BUILDIN(input)
} else {
int amount = sd->npc_amount;
script->set_reg(st, sd, uid, name, (const void *)h64BPTRSIZE(cap_value(amount,min,max)), script_getref(st,2));
- script_pushint(st, (amount > max ? 1 : amount < min ? -1 : 0));
+ script_pushint(st, sd->npc_input_capped_range);
}
st->state = RUN;
}