Base chance of cherry / battery drop on the levels of player health and power.

This commit is contained in:
Steve 2018-03-16 22:25:45 +00:00
parent 36c1d9cfe3
commit 22cc851a2a
2 changed files with 11 additions and 2 deletions

View File

@ -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);
}

View File

@ -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;