Rand item with setarray amount

Wolfeh

New member
Messages
63
Points
0
Github
ItsWolfeh
Emulator
I'm trying to make a random reward that keeps the amount in the amount array. I've tried several variations/methods and this is the closest I have gotten:

    setarray .Prize[1],604,12129,617,12208,12103,12414;
    setarray .Prize[2],25,5,5,1,1,1;

getitem .Prize[rand(getarraysize(.Prize))],.Prize[2];

This actually doesn't work, .Prize[1] in place of the rand command works, only getting the first values in each array, but as soon as I put the rand in there it won't get the .Prize[1] array. It says in map-server:

[Error]: buildin_getitem: Nonexistant item 5 requested.
[Debug]: Source (NPC): Disguise Event at quiz_02 (303,259)

Item 5 being from .Prize[2], it just skips .Prize[1].

 
Last edited by a moderator:
Thank you!! Took me a bit of fiddling but I was able to work it out thanks to your informative post. End solution:

In script:

    .@r = rand(5);
    getitem(.Prize[.@r]), .PrizeAmt[.@r];

At the end of script:

OnInit:
    setarray(.Prize[0], Branch_Of_Dead_Tree, Fantastic_Cooking_Kits, Old_Violet_Box, Battle_Manual, Bloody_Dead_Branch, Guarana_Candy);
    setarray(.PrizeAmt[0],25,5,5,1,1,1);

 
Last edited by a moderator:
Back
Top