Jump to content
  • 0

Probability with two matrices


KillSwith

Question

Could someone help me how do I create a probability with 2 arrays?

The problem is this, I created a npc for ticket exchange per item, and using Luckywhell that posted here in the forum, the item configuration is like this: IDItem, Quantity, Enchant, Chance.

But the chance is according to the quantity of items, not by chance of each item, could you help me to solve this problem?

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Why don't you edit the core to read it by chance value then? I guess would be easier and better.

 

Without seeing the code, I can't really understand how exactly it calculates the chance and what's the problem.

 

Show the code, explain it better, show an example or so. 

Link to comment
Share on other sites

  • 0

if (Rnd.get(100) > 50) //50% chance to
do that in array1
else //50% chance to

do the other array2

Edited by Nightw0lf
Link to comment
Share on other sites

  • 0

https://pastebin.com/Q9fHL9CK

 

 

Example, the configuration looks like this: Item ID, Quantity, Enchant, and Chance

But even if I put the chance 000000001, if there are few items in the list, for example 4, the chance is going to be 1/4.

Edited by KillSwith
Link to comment
Share on other sites

  • 0

Ok, well, still you didn't provide important info. I had to find it on my own and looks like you are talking about Elfos' code, more or less?

Uppon config load it stores the info

 


public void add(double weight, E result)
{
    if (weight <= 0) return;
    total += weight;
    map.put(total, result);
}

public E next()
{
    double value = random.nextDouble() * total;
    return map.ceilingEntry(value).getValue();
}

 

So, the next return 0.0 - 1.0 * total . But still, I don't see any "chance calculation" over the code, else that's the chance itself? I guess?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Posts

    • Someone ask me for this, it should work on any client that has Kamael race, preview:     Installation - there are two ways to install depending on how you want to use it:   Method 1: If you want to completely replace the original, do:   Copy all lines from your armorgrp to Notepad++, press Ctrl+H, check the "match whole word" option and replace:   kamael.Mkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_MKamael_m001_w_ad00   Then replace:   MKamael.Mkamael_m000_t00_w   by:   AvengersKamaelWings.MKamael_m001_t00_w   Now repeat the same process with the female, replace:   kamael.Fkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_FKamael_m001_w_ad00   Then replace:   FKamael.Fkamael_m000_t00_w   by:   AvengersKamaelWings.FKamael_m001_t00_w   You're done, paste everything back into File Edit and save!   Method 2: If you only want to replace in specific sets, execute the above process only on the armorgrp of those sets.   Repack by: AvengersTeamBr Password: LadrãoDeFrango      
    • 用于解密、加密和编辑 .u 文件的工具。
    • It's always awesome when you find someone who not only delivers great quality but also does it way ahead of schedule. Makes you feel like you hit the jackpot, right? I'm new around here, just stumbled upon this forum, and seeing posts like yours really gives me hope that there are some real pros hanging out in this community.
    • Dear friends! We have good news to announce that the server that will open in June 1 will be the Main server and every 4 months we will make another season server and integrate ( merge ) it into the main that will always be open..  
  • Topics

×
×
  • Create New...