So I'm trying to make a system where enemies have a chance to drop a powerup or weapon on dead and I have no idea how to program something like that. The weapons can only spawn as long as the player doesn't own that weapon. The powerups can always spawn. For this I could use a getRandomNumber code where the int needs to equal a given number (or another random int, if that's possible). The weapon owning part is already covered; all I need is the randomized part, for stopping the randomized part I can probably think of a code myself (if not then you'll see that). The loot can only spawn once the enemy is dead, the code for that is the following:
If this code returns true, then the enemy is dead. If it returns false, then there is an else for different codes that work whilst the enemy is alive (the difficulty isn't important for any of the randomized stuff, it's just for the health and damage of enemies)
public boolean Dead() { if (Easy == true) { if (EnemiesHealth <= 0) { return true; } } if (Normal == true) { if (EnemiesHealth <= 0) { return true; } } if (Hard == true) { if (EnemiesHealth <= 0) { return true; } } return false;