PDA

View Full Version : Bags of money (ala Skyrim sorta!)



Majora
01-27-2013, 04:19 PM
Can anyone write me a quick little script? It'll be an on-pickup item script where link will be awarded a random number of rupees between two definable values. I have an item in my quest that looks like a little bag of money (i.e. like the item in Skyrim).

Higher amounts should be rarer of course. For instance, getting anywhere from 5-20 rupees should happen like 80% of the time. getting 21-50 rupees should occur 10% of the time. Getting 50-99 rupees should occur 5% of the time, and getting an even 100 should occur 1% of the time. Getting 0-4 rupees should happen 4% of the time.

Just a rough guideline. you may implement this however you wish but the bottom line: on item pickup, random amount of rupees is given, with higher values being rarer.

Zim
01-28-2013, 12:30 AM
I tested this on my ZC and this code seems to do exactly what you asked for (approximately).
D0 is minimum amount of rupees given by the rupee pickup and D1 is the maximum it will give.


item script RupeeScore
{
void run(int minrupees,int maxrupees)
{
int rupees=minrupees+Rand(maxrupees);if(rupees>maxrupees)rupees=maxrupees;
int percentage=Choose(1,2,3);
if(percentage==1||percentage==2)
{
int mindiv=Rand(4);if(mindiv==0)mindiv=1;int split=Ceiling(maxrupees/5)/mindiv;
Game->Counter[1]+=Ceiling(split);
}
if(percentage==3)
{
percentage=Choose(1,2,3);
if(percentage==1)
{
int mindiv=Rand(4);if(mindiv==0)mindiv=1;int split=Ceiling(maxrupees/5)/mindiv;
if(split<minrupees)split=minrupees;
Game->Counter[1]+=Ceiling(split);
}
if(percentage==2)
{
int mindiv=Rand(2);if(mindiv==0)mindiv=1;int split=Ceiling(maxrupees/2)/mindiv;
if(split<minrupees)split=minrupees;
Game->Counter[1]+=Ceiling(split);
}
if(percentage==3)
{
percentage=Choose(1,2,3);
if(percentage==1)
{
int mindiv=Rand(5);if(mindiv==0)mindiv=1;int split=Ceiling(rupees/mindiv);
if(split<minrupees)split=minrupees;
Game->Counter[1]+=Ceiling(split);
}
if(percentage==2)
{
int mindiv=Rand(10);if(mindiv==0)mindiv=1;int split=Ceiling(rupees/mindiv);
if(split<minrupees)split=minrupees;
Game->Counter[1]+=Ceiling(split);
}
if(percentage==3)
{
int mindiv=Rand(10);int split=Ceiling(rupees/mindiv);
if(split<minrupees)split=minrupees;
if(rupees!=maxrupees){Game->Counter[1]+=Ceiling(split);}
if(rupees==maxrupees){Game->Counter[1]+=maxrupees;}
}
}
}
}
}


Keese! Keese Keese!

I could write in a thing to display the amount of rupees the script gives also if you'd prefer that.. Also the thought of making the counter go up by 1 until the amount it gives is reached might be desirable, although then you might run into some of those bugs similar to spending the same rupees twice dealios if the player gets other rupees by other methods before the counter hits it's mark and whatnot.
It's fine the way it is though.