diff --git a/SeasonsOfLoneliness.cpp b/SeasonsOfLoneliness.cpp index fbc3cb9..21fd4b4 100644 --- a/SeasonsOfLoneliness.cpp +++ b/SeasonsOfLoneliness.cpp @@ -255,6 +255,7 @@ public: int PLAYER_HP=PLAYER_MAXHP; int BATTLE_CURRENT_TURN_ENTITY=-1; int CURRENT_ENCOUNTER_IND=-1; + int RAND_CALLS=0; std::vector BATTLE_DISPLAY_NUMBERS; bool PLAYER_TURN_COMPLETE=false; @@ -1106,10 +1107,10 @@ public: srand((int)(yOffset+y)*MAP_WIDTH+(int)(xOffset+x)); int tileX=0; int tileRot=0; - while (tileX<3&&rand()%4==0) { + while (tileX<3&&std::rand()%4==0) { tileX++; } - while (tileRot<3&&rand()%8<5) { + while (tileRot<3&&std::rand()%8<5) { tileRot++; } if ((int)(xOffset+x)>=0&&(int)(xOffset+x)=0&&(int)(yOffset+y)damage+rand()%power->damageRoll*sign(power->damage); Entity*ent=CURRENT_ENCOUNTER.entities[i]; - if (distancetoCoords({(ent->x+CURRENT_ENCOUNTER.x)*32,(ent->y+CURRENT_ENCOUNTER.y)*32},coords*32)<=power->range) { + if (ent->hp>0&&distancetoCoords({(ent->x+CURRENT_ENCOUNTER.x)*32,(ent->y+CURRENT_ENCOUNTER.y)*32},coords*32)<=power->range) { ent->hp=std::clamp(ent->hp-finalDamage,0,ent->maxhp); DisplayNumber*numb = new DisplayNumber(finalDamage,ent->x+CURRENT_ENCOUNTER.x,ent->y+CURRENT_ENCOUNTER.y,frameCount); BATTLE_DISPLAY_NUMBERS.push_back(numb); @@ -1401,9 +1403,10 @@ public: //Damaging effect. if (playerForce) { for (int i=0;idamage+rand()%power->damageRoll*sign(power->damage); Entity*ent=CURRENT_ENCOUNTER.entities[i]; std::cout<<"Distance was "<x+CURRENT_ENCOUNTER.x)*32,(ent->y+CURRENT_ENCOUNTER.y)*32},coords*32)<<"\n"; - if (distancetoCoords({(ent->x+CURRENT_ENCOUNTER.x)*32,(ent->y+CURRENT_ENCOUNTER.y)*32},coords*32)<=power->range) { + if (ent->hp>0&&distancetoCoords({(ent->x+CURRENT_ENCOUNTER.x)*32,(ent->y+CURRENT_ENCOUNTER.y)*32},coords*32)<=power->range) { ent->hp=std::clamp(ent->hp-finalDamage,0,ent->maxhp); DisplayNumber*numb = new DisplayNumber(finalDamage,ent->x+CURRENT_ENCOUNTER.x,ent->y+CURRENT_ENCOUNTER.y,frameCount); BATTLE_DISPLAY_NUMBERS.push_back(numb); @@ -1425,6 +1428,11 @@ public: int sign(int x) { return (x > 0) - (x < 0); } + + int rand() { + srand(time(NULL)+RAND_CALLS++); + return std::rand(); + } }; diff --git a/Seasons_of_Loneliness b/Seasons_of_Loneliness index 0cbc647..f7f8523 100755 Binary files a/Seasons_of_Loneliness and b/Seasons_of_Loneliness differ