Base chance of cherry / battery drop on the levels of player health and power.
This commit is contained in:
parent
36c1d9cfe3
commit
22cc851a2a
|
@ -154,12 +154,20 @@ static void dropBattery(int x, int y)
|
|||
|
||||
void addRandomItems(int x, int y)
|
||||
{
|
||||
if (rand() % 100 < 25)
|
||||
int cherryChance, batteryChance;
|
||||
|
||||
cherryChance = 100 - getPercent(world.bob->health, world.bob->healthMax);
|
||||
batteryChance = 100 - getPercent(world.bob->power, world.bob->powerMax);
|
||||
|
||||
cherryChance = MIN(cherryChance, 50);
|
||||
batteryChance = MIN(batteryChance, 50);
|
||||
|
||||
if (rand() % 100 < cherryChance)
|
||||
{
|
||||
dropRandomCherry(x, y);
|
||||
}
|
||||
|
||||
if (rand() % 100 < 50)
|
||||
if (rand() % 100 < batteryChance)
|
||||
{
|
||||
dropBattery(x, y);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ extern Sprite *getSprite(char *name);
|
|||
extern Item *initBattery(void);
|
||||
extern Item *initCherry(void);
|
||||
extern int rrnd(int low, int high);
|
||||
extern int getPercent(float current, float total);
|
||||
|
||||
extern World world;
|
||||
|
||||
|
|
Loading…
Reference in New Issue