Bisuke Posted November 12, 2014 Group: Members Topic Count: 51 Topics Per Day: 0.01 Content Count: 177 Reputation: 10 Joined: 04/02/12 Last Seen: November 2, 2024 Share Posted November 12, 2014 I'm currently coding my own mining system, I just want to ask on how to make an npc that gives a random loot with different chances? Example Stone 55% Iron Ore 35% Iron 25% Elunium 3% Oridecon 5% Gold 1% If i click my npc randomly it'll generate a drop that is based on the rates. My code is something like this set @chance,rand(1,200); if(@chance == 1) getitem 998,1; if(@chance == 2) getitem 998,1; if(@chance == 3) getitem 998,1; if(@chance == 4) getitem 998,1; if(@chance == 5) getitem 998,1; if(@chance == 6) getitem 998,1; if(@chance == 7) getitem 998,1; if(@chance == 8) getitem 998,1; I assigned items on every numbers which made my code very hard to modify. Can someone help me make the code more efficient and easy to modify, like adding new drops with new rates? Thanks! Quote Link to comment Share on other sites More sharing options...
Stickhead Posted November 12, 2014 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 13 Reputation: 0 Joined: 11/20/11 Last Seen: September 15, 2018 Share Posted November 12, 2014 .@i = rand(100); // = 100%if( .@i < 1 ) setarray .@Item[0],969,1;else if( .@i < 5 ) setarray .@Item[0],984,1;else if( .@i < 3 ) setarray .@Item[0],985,1;else if( .@i < 25 ) setarray .@Item[0],998,1; else if( .@i < 35 ) setarray .@Item[0],1002,1; else if( .@i < 55 ) setarray .@Item[0],7049,1; how to change the value of the reward? .@Item[0],7049,5; // Gives 5 Stones Credit to Emistry use search bar or google for better result next time Quote Link to comment Share on other sites More sharing options...
Bisuke Posted November 13, 2014 Group: Members Topic Count: 51 Topics Per Day: 0.01 Content Count: 177 Reputation: 10 Joined: 04/02/12 Last Seen: November 2, 2024 Author Share Posted November 13, 2014 Thanks to this! Quote Link to comment Share on other sites More sharing options...
Question
Bisuke
I'm currently coding my own mining system, I just want to ask on how to make an npc that gives a random loot with different chances?
Example
Stone 55%
Iron Ore 35%
Iron 25%
Elunium 3%
Oridecon 5%
Gold 1%
If i click my npc randomly it'll generate a drop that is based on the rates.
My code is something like this
I assigned items on every numbers which made my code very hard to modify.
Can someone help me make the code more efficient and easy to modify, like adding new drops with new rates?
Thanks!
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.