#ifndef ENCOUNTERS_H #define ENCOUNTERS_H #include "pixelGameEngine.h" using namespace olc; #include "defines.h" #include "object.h" #include "battle.h" #include "item.h" namespace encounter{ enum{ ENCOUNTER_1, ENCOUNTER_2, ENCOUNTER_3, ENCOUNTER_4, }; } class Entity{ private: int HP=0; int targetHP=0; public: int maxHP=0; int PP=0; int targetPP=0; int maxPP=0; std::arrayresistances={0,0,0,0}; int speed=0; int baseAtk=0; int damageReduction=0; //A percentage of how much damage to reduce. bool smart=false; bool dumb=false; int atb=0; //When this value reaches 1000, it's this entity's turn. Object* obj; std::vector moveSet; int selectedTarget = 0; Battle::Move*selectedMove = nullptr; //The index of the selected move. int channelTimeRemaining = 0; //The amount of channel time left until move can be performed. vd2d channelPos = {0,0}; //Where our channel is happening. std::vector inventory; //Used mostly for enemy spoils. std::array equipment; //Equipment this character is using. //Used for initializing players. Entity(int HP,int maxHP,int PP,int maxPP,int baseAtk,std::arrayresistances,int speed,std::vectormoveSet,std::vectoritems={},std::arrayequipment={},int damageReduction=0,bool smart=false,bool dumb=false) :Entity(nullptr,HP,maxHP,PP,maxPP,baseAtk,resistances,speed,moveSet,items,equipment,damageReduction,smart,dumb){} //Use this for initializing enemies as it lets you specify an object. Entity(Object*obj,int HP,int maxHP,int PP,int maxPP,int baseAtk,std::arrayresistances,int speed,std::vectormoveSet,std::vectoritems={},std::arrayequipment={},int damageReduction=0,bool smart=false,bool dumb=false) :obj(obj),HP(HP),maxHP(maxHP),PP(PP),maxPP(maxPP),baseAtk(baseAtk),speed(speed),equipment(equipment),moveSet(moveSet),damageReduction(damageReduction),inventory(items),smart(smart),dumb(dumb){ for (int i=0;i<4;i++) { this->resistances[i]=resistances[i]; } this->targetHP=HP; this->targetPP=PP; } //Get the HP that the rolling counter is moving towards. int GetTargetHP() { return targetHP; } //Gets the current actual health of the target. int GetHP() { return HP; } //Sets the rolling counter target to this health value. void SetTargetHP(int hp) { targetHP=hp; } //Subtracts from the rolling counter target from this health value. void SubtractHP(int hp) { targetHP-=hp; } //Adds to the rolling counter target from this health value. void AddHP(int hp) { targetHP=std::clamp(targetHP+hp,0,maxHP); } //THIS IS FOR SPECIAL USE CASES ONLY! Normally you want to touch the rolling counter amount instead using SetTargetHP()! void _SetDirectHP(int hp) { HP=hp; } }; class Encounter{ public: vd2d pos; int chance; //Chance of the encounter existing. std::vectorobjs; std::array playerPos; int id; Encounter(int id,vd2d pos,std::array playerPos,std::vectorobjs,int chance=25) :id(id),pos(pos),objs(objs),chance(chance),playerPos(playerPos){} bool IsEncounterAlive() { for (int i=0;iGetHP()>0) { return true; } } return false; } bool IsInRange(vd2d pos) { vd2d diff=pos-this->pos; return diff.x>=0&&diff.x<=WIDTH&&diff.y>=0&&diff.y<=HEIGHT; } }; #endif