mikemarandola94
Member
Hi everyone. I'm pretty new here but I have a question that I was unable to find anywhere.
I am working on a multiplayer side-scroller roguelite, and I am having an issue randomizing rolls. I currently have two players I have created, and if they both swing their sword on the frame, they will get the same damage roll. How do I go about randomizing these rolls?
For context, here are my damage calculations.
this works great for getting a random number from 95% to 105% of their attack range.
However, the probem I am encountering is that if player1 and player 2 swing their sword on the same frame, they will both get the same number (if they dont have modifiers applied), and they will both always crit.
How do I get the rolls to be independent from each other?
I have tried adding
Thanks in advance!
I am working on a multiplayer side-scroller roguelite, and I am having an issue randomizing rolls. I currently have two players I have created, and if they both swing their sword on the frame, they will get the same damage roll. How do I go about randomizing these rolls?
For context, here are my damage calculations.
baseattackdamage
is a global variable to set the players to as they begin, and playerdamageincrease
will be the modifier from items.
GML:
critcheck = (irandom_range(0,100)/100)
damage = irandom_range(baseattackdamage*playerdamageincrease*.95,baseattackdamage*playerdamageincrease*1.05)
if critcheck < playercritchance {
doesitcrit = true;
damage = damage*playercritdamage;
}
if critcheck > playercritchance {
doesitcrit = false;
}
However, the probem I am encountering is that if player1 and player 2 swing their sword on the same frame, they will both get the same number (if they dont have modifiers applied), and they will both always crit.
How do I get the rolls to be independent from each other?
I have tried adding
randomise()
, random_set_seed(date_current_datetime())
, as well as random_get_seed()
, but none of this fixes that issue.Thanks in advance!