Issue information

Issue ID
#4155
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Mar 30, 2010 0:38
Last Post
Hercules Elf Bot
Mar 5, 2012 15:00
Confirmation
N/A

Hercules Elf Bot - Mar 30, 2010 0:38

Originally posted by [b]theultramage[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=4155

The juice maker npc converts N fruits, N bottles and 3*N zeny into N juice bottles. You can specify the amount, or just say "make as many as possible". Here, eathena's script can malfunction in certain cases, rejecting the attempt completely.
CODE
            switch(select("As many as I can.:I want a certain amount.:Cancel.")) {
            case 1:
                set .@make,countitem(.@fruit);
                break;

The issue exists because in this case the script just takes the amount of fruits held by the player as the reference value for calculating all other requirements. Basically, if you have 100 fruits but 10 flasks, you will just be told to get lost.

The original aegis script deals with this properly, and even takes zeny into account:
CODE
            while(1)
                if ((fruit == 0) | (bottle == 0) | (money < 3))
                    exitwhile
                else
                    gap = gap + 1
                    fruit = fruit - 1
                    fruit_send = fruit_send + 1
                    bottle = bottle - 1
                    bottle_send = bottle_send + 1
                    money = money - 3
                    money_send = money_send + 3
                endif
            endwhile

Of course, this is pretty lame. It should be mathematically provable that the desired value should be min(fruits, bottles, zeny/3), and that's it. Note that eathena does not have a three-way minimum, but it can be emulated by two calls to binary min().