Get Hate Random bugged?
Code:
if ($timer eq "fear") The timer is working.. it is correctly casting the spell.. But.. heres the problem 2 Players on Hatelist will only NUKE 1 player never the other... 3 Players on Hatelist will ONLY Nuke 2 of the players .. never the 3rd... and so on... Tested with 4 and it only would nuke 3 out of the 4. Is there something wrong with the GetHateRandom? Code:
Mob *HateList::GetRandom() the Random seems to be (Count -1) Then the For loop ... Removes another 1 from Random? Is this possibly why it always cuts 1 player off the list? |
Quote:
Then, it chooses between 0-4 when it does the for loop. That is precisely why. |
this part is what i'm asking secrets
Code:
int random = MakeRandomInt(0, count-1); I understand it would be 0 to 5 for a 6 man party But INSIDE the for loop ... it removes another 1! Code:
for (int i = 0; i < random-1; i++) Ive been testing it for awhile.. it never casts on the LAST person to aggro they never get picked by GetHateRandom |
Read what Secrets wrote again. It sounded like a confirmation to me.
Assuming a uniform distribution of random numbers over time, I would assume the next to last person on the list will be picked twice as often as anyone else, and the last person will never be picked. It's also not very efficient code. No need to walk the list when there's a Count() function that returns the number of elements in the list. |
Aye ya the last person to be added to the Hatelist never gets picked.
I'd re-write it to be all fancy and nice .. but I am not the best at C++ heh |
just remove the -1 after the random and it will work, there you don't have to rewrite anything.
|
Well ya I know that.. but he said it "could" be written better... not that I'm actually gonna do it... the simple fix is just removing the -1 lol
|
Updated my source and removed that number and its working nicely now.
If anyone wants to update it on the Github that would be awesome! |
I bet if you made a pull request someone would commit it.
|
All times are GMT -4. The time now is 08:26 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.