Implement money drops on enemies

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 320e9bdf30
commit 7aba68c6c0
  1. BIN
      C++ProjectTemplate
  2. 4
      defines.h
  3. 168
      entity.h
  4. 123
      main.cpp
  5. 12
      object.h
  6. 2
      states.h

Binary file not shown.

@ -17,9 +17,7 @@ using namespace olc;
#define DEFAULT_CHANNELPOS {-99,-99}
#define CUSTOM_MESSAGE_WAIT_TIME 90
#define ㅎ
#define ㅍ
#define 아
#define 돈
#define α '`'
#define β '{'

@ -19,21 +19,109 @@ namespace boost{
class Entity{
struct pstats_t{
public:
int HP=0;
int maxHP=0;
int PP=0;
int maxPP=0;
int targetHP=0;
int targetPP=0;
int baseAtk=0;
int speed=0;
std::array<int,4>resistances={0,0,0,0};
int damageReduction=0; //A percentage of how much damage to reduce.
bool smart=false;
bool dumb=false;
};
struct stats_t{
private:
int HP=0;
public:
int maxHP=0;
private:
int PP=0;
public:
int maxPP=0;
private:
int targetHP=0;
int targetPP=0;
public:
int baseAtk=0;
int speed=0;
std::array<int,4>resistances={0,0,0,0};
int damageReduction=0; //A percentage of how much damage to reduce.
bool smart=false;
bool dumb=false;
stats_t(pstats_t stats) {
this->HP=stats.HP;
this->PP=stats.PP;
this->targetHP=stats.targetHP;
this->targetPP=stats.targetPP;
this->maxHP=stats.maxHP;
this->maxPP=stats.maxPP;
this->baseAtk=stats.baseAtk;
this->speed=stats.speed;
this->resistances=stats.resistances;
this->damageReduction=stats.damageReduction;
this->smart=stats.smart;
this->dumb=stats.dumb;
};
//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;
}
//Get the PP that the rolling counter is moving towards.
int GetTargetPP() {
return targetPP;
}
//Gets the current actual pp of the target.
int GetPP() {
return PP;
}
//Sets the rolling counter target to this health value.
void SetTargetHP(int hp) {
targetHP=hp;
}
//Sets the rolling counter target to this pp value.
void SetTargetPP(int pp) {
targetPP=pp;
}
//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);
}
//Subtracts from the rolling counter target from this pp value.
void SubtractPP(int pp) {
targetPP=std::clamp(targetPP-pp,0,maxPP);
}
//Adds to the rolling counter target from this pp value.
void AddPP(int pp) {
targetPP=std::clamp(targetPP+pp,0,maxPP);
}
//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;
}
//THIS IS FOR SPECIAL USE CASES ONLY! Normally you want to touch the rolling counter amount instead using SetTargetPP()!
void _SetDirectPP(int pp) {
PP=pp;
}
};
private:
int HP=0;
int targetHP=0;
int PP=0;
int targetPP=0;
pstats_t pstats;
public:
int maxHP=0;
int maxPP=0;
std::array<int,4>resistances={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;
stats_t stats;
int atb=0; //When this value reaches 1000, it's this entity's turn.
public:
Object* obj;
std::vector<Battle::Move*> moveSet;
std::map<Property,int> statusEffects;
@ -42,78 +130,80 @@ class Entity{
int channelTimeRemaining = 0; //The amount of channel time left until move can be performed.
vd2d channelPos = DEFAULT_CHANNELPOS; //Where our channel is happening.
std::vector<Item*> inventory; //Used mostly for enemy spoils.
int money=0; //Amount of money this entity will drop when defeated.
std::array<Item*,3> equipment = {nullptr,nullptr,nullptr}; //Equipment this character is using.
bool isPlayer=false; //Whether or not this is a player entity.
std::array<int,4> boosts = {0,0,0,0}; //Values to indicate how much the boosts of each stat ended up being. Order is ATK,HP,PP,SPD.
//Used for initializing players.
Entity(int HP,int maxHP,int PP,int maxPP,int baseAtk,std::array<int,4>resistances,int speed,std::vector<Battle::Move*>moveSet,std::vector<Item*>items={},std::array<Item*,3>equipment={},int damageReduction=0,bool smart=false,bool dumb=false)
:Entity(nullptr,HP,maxHP,PP,maxPP,baseAtk,resistances,speed,moveSet,items,equipment,damageReduction,smart,dumb){
Entity(pstats_t stats,std::vector<Battle::Move*>moveSet,std::vector<Item*>items={},int money=0,std::array<Item*,3>equipment={})
:Entity(nullptr,stats,moveSet,items,money,equipment){
isPlayer=true;
}
//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::array<int,4>resistances,int speed,std::vector<Battle::Move*>moveSet,std::vector<Item*>items={},std::array<Item*,3>equipment={},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){
Entity(Object*obj,pstats_t stats,std::vector<Battle::Move*>moveSet,std::vector<Item*>items={},int money=0,std::array<Item*,3>equipment={})
:obj(obj),stats({stats.HP,stats.PP,stats.targetHP,stats.targetPP,stats.maxHP,stats.maxPP,stats.baseAtk,stats.speed,stats.resistances,stats.damageReduction,stats.smart,stats.dumb}),equipment(equipment),moveSet(moveSet),inventory(items),money(money){
for (int i=0;i<4;i++) {
this->resistances[i]=resistances[i];
this->stats.resistances[i]=stats.resistances[i];
}
this->targetHP=HP;
this->targetPP=PP;
}
Property GetPrimaryStatusEffect() {
for (std::map<Property,int>::iterator it = statusEffects.begin();it!=statusEffects.end();++it) {
if (it->second!=0) {
return it->first;
}
}
return Property::NONE;
this->stats.SetTargetHP(stats.HP);
this->stats.SetTargetPP(stats.PP);
}
//Get the HP that the rolling counter is moving towards.
int GetTargetHP() {
return targetHP;
return stats.GetTargetHP();
}
//Gets the current actual health of the target.
int GetHP() {
return HP;
return stats.GetHP();
}
//Get the PP that the rolling counter is moving towards.
int GetTargetPP() {
return targetPP;
return stats.GetTargetPP();
}
//Gets the current actual pp of the target.
int GetPP() {
return PP;
return stats.GetPP();
}
//Sets the rolling counter target to this health value.
void SetTargetHP(int hp) {
targetHP=hp;
stats.SetTargetHP(hp);
}
//Sets the rolling counter target to this pp value.
void SetTargetPP(int pp) {
targetPP=pp;
stats.SetTargetPP(pp);
}
//Subtracts from the rolling counter target from this health value.
void SubtractHP(int hp) {
targetHP-=hp;
stats.SubtractHP(hp);
}
//Adds to the rolling counter target from this health value.
void AddHP(int hp) {
targetHP=std::clamp(targetHP+hp,0,maxHP);
stats.AddHP(hp);
}
//Subtracts from the rolling counter target from this pp value.
void SubtractPP(int pp) {
targetPP=std::clamp(targetPP-pp,0,maxPP);
stats.SubtractPP(pp);
}
//Adds to the rolling counter target from this pp value.
void AddPP(int pp) {
targetPP=std::clamp(targetPP+pp,0,maxPP);
stats.AddPP(pp);
}
//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;
stats._SetDirectHP(hp);
}
//THIS IS FOR SPECIAL USE CASES ONLY! Normally you want to touch the rolling counter amount instead using SetTargetPP()!
void _SetDirectPP(int pp) {
PP=pp;
stats._SetDirectPP(pp);
}
Property GetPrimaryStatusEffect() {
for (std::map<Property,int>::iterator it = statusEffects.begin();it!=statusEffects.end();++it) {
if (it->second!=0) {
return it->first;
}
}
return Property::NONE;
}
void RemoveItem(int index) {

@ -172,6 +172,9 @@ std::vector<std::string> MESSAGE_BOX_CHOICE_LIST={};
bool waitingForChoice=false;
int MESSAGE_BOX_DIALOG_CHOICE_CURSOR=0;
Object*INTERACTING_WITH=nullptr;
std::vector<std::pair<Item*,int>> SHOP_ITEMS={};
int MONEY=0;
int ENEMY_MONEY_SUM=0;
/*
[Choice1,Choice2,Choice3]
@ -387,6 +390,10 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
GAME_STATE=GameState::GAME_WORLD;
CLOSE_OVERWORLD_WINDOW=false;
}
if (INTERACTING_WITH!=nullptr) {
INTERACTING_WITH->DialogClosed();
INTERACTING_WITH=nullptr;
}
if (HEALING_OVERWORLD_MEMBERS) {
if (HEALING_OVERWORLD_MEMBER==0||HEALING_OVERWORLD_MEMBER==2) {
DisplayMessageBox("");
@ -871,7 +878,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
//DisplayMessageBox("Not implemented yet.");
BATTLE_STATE=BattleState::MOVE_SELECT;
SELECTED_MOVE_SQUARE={0,0};
PopulateMovementGrid(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->obj->GetPosWithOrigin(),CalculateSpeedGridMovementAmount(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->speed));
PopulateMovementGrid(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->obj->GetPosWithOrigin(),CalculateSpeedGridMovementAmount(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->stats.speed));
}break;
case 5:{ //Run selected.
DisplayMessageBox("Not implemented yet.");
@ -1496,23 +1503,23 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
target->AddPP(item->stats.ppRecovery);
}break;
case ItemAction::ATKINCREASE:{
target->baseAtk+=item->stats.atkIncrease;
target->stats.baseAtk+=item->stats.atkIncrease;
target->boosts[boost::ATK]+=item->stats.atkIncrease;
}break;
case ItemAction::HPINCREASE:{
target->maxHP+=item->stats.hpIncrease;
target->stats.maxHP+=item->stats.hpIncrease;
target->AddHP(item->stats.hpIncrease);
vi2d box = {(128-32*PARTY_MEMBER_COUNT)+OVERWORLD_TARGET_SELECTION*64+29,170};
DAMAGE_NUMBERS.push_back(new DamageNumber(-item->stats.hpIncrease,box+cameraPos));
target->boosts[boost::HP]+=item->stats.hpIncrease;
}break;
case ItemAction::PPINCREASE:{
target->maxPP+=item->stats.ppIncrease;
target->stats.maxPP+=item->stats.ppIncrease;
target->AddPP(item->stats.ppIncrease);
target->boosts[boost::PP]+=item->stats.ppIncrease;
}break;
case ItemAction::SPDINCREASE:{
target->speed+=item->stats.spdIncrease;
target->stats.speed+=item->stats.spdIncrease;
target->boosts[boost::SPD]+=item->stats.spdIncrease;
}break;
case ItemAction::LEARNMOVE:{
@ -1916,7 +1923,8 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
case GameState::OVERWORLD_EQUIP_MENU:
case GameState::OVERWORLD_EQUIP_PLAYER_MENU:
case GameState::OVERWORLD_STATUS_MENU:
case GameState::OVERWORLD_TARGET_MENU:{
case GameState::OVERWORLD_TARGET_MENU:
case GameState::SHOPKEEPER_MENU:{
DrawGameWorld();
if (GAME_STATE!=GameState::GAME_WORLD&&GAME_STATE!=GameState::OVERWORLD_TARGET_MENU) {
SetDrawTarget(layer::INTERFACE);
@ -2034,17 +2042,17 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
DrawStringPropDecal({(float)(WIDTH-8-GetTextSizeProp(displayStr2).x),(float)drawPos.y},displayStr2);
drawPos.y+=12;
displayStr1 = "HP: ";
displayStr2 = std::to_string(member->maxHP);
displayStr2 = std::to_string(member->stats.maxHP);
DrawStringPropDecal({(float)(drawPos.x-GetTextSizeProp(displayStr1).x),(float)drawPos.y},displayStr1);
DrawStringPropDecal({(float)(WIDTH-8-GetTextSizeProp(displayStr2).x),(float)drawPos.y},displayStr2);
drawPos.y+=12;
displayStr1 = "PP: ";
displayStr2 = std::to_string(member->maxPP);
displayStr2 = std::to_string(member->stats.maxPP);
DrawStringPropDecal({(float)(drawPos.x-GetTextSizeProp(displayStr1).x),(float)drawPos.y},displayStr1);
DrawStringPropDecal({(float)(WIDTH-8-GetTextSizeProp(displayStr2).x),(float)drawPos.y},displayStr2);
drawPos.y+=12;
displayStr1 = "SPD: ";
displayStr2 = std::to_string(member->speed);
displayStr2 = std::to_string(member->stats.speed);
DrawStringPropDecal({(float)(drawPos.x-GetTextSizeProp(displayStr1).x),(float)drawPos.y},displayStr1);
DrawStringPropDecal({(float)(WIDTH-8-GetTextSizeProp(displayStr2).x),(float)drawPos.y},displayStr2);
}
@ -2195,7 +2203,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
int newAttack=0;
int newDefense=0;
CalculateChangeInEquipmentStats(i,ITEM_SELECTION_CURSOR,equipAttack,equipDefense,newAttack,newDefense);
DrawStringPropDecal({(float)4+WIDTH*(1.0F/8),(float)(HEIGHT/2+4+12+i*10)},std::to_string(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->baseAtk+newAttack),(newAttack>equipAttack)?GREEN:(newAttack<equipAttack)?RED:WHITE,{0.5,1});
DrawStringPropDecal({(float)4+WIDTH*(1.0F/8),(float)(HEIGHT/2+4+12+i*10)},std::to_string(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->stats.baseAtk+newAttack),(newAttack>equipAttack)?GREEN:(newAttack<equipAttack)?RED:WHITE,{0.5,1});
DrawStringPropDecal({(float)4+WIDTH*(1.0F/4),(float)(HEIGHT/2+4+12+i*10)},std::to_string(newDefense),(newDefense>equipDefense)?GREEN:(newDefense<equipDefense)?RED:WHITE,{0.5,1});
if (newAttack!=equipAttack) {DrawRotatedDecal({(float)4+WIDTH*(1.0F/4)-14,(float)(HEIGHT/2+4+12+i*10+2+((newAttack<equipAttack)?4:0))},SPRITES["cursor.png"],newAttack>equipAttack?-M_PI_2:M_PI_2,{4,4},{0.5,0.5},newAttack>equipAttack?GREEN:RED);}
if (newDefense!=equipDefense) {DrawRotatedDecal({(float)4+WIDTH*(3.0F/8)-14,(float)(HEIGHT/2+4+12+i*10+2+((newDefense<equipDefense)?4:0))},SPRITES["cursor.png"],newDefense>equipDefense?-M_PI_2:M_PI_2,{4,4},{0.5,0.5},newDefense>equipDefense?GREEN:RED);}
@ -2655,7 +2663,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
void SetupPartyMemberStats() {
for (int i=0;i<7;i++) {
PARTY_MEMBER_STATS[i]=new Entity(120,120,30,30,8,{0,0,0,0},8,{MOVELIST[BattleMoveName::TESTMOVE1]});
PARTY_MEMBER_STATS[i]=new Entity({HP:120,maxHP:120,PP:30,maxPP:30,baseAtk:8,speed:8,resistances:{0,0,0,0}},{MOVELIST[BattleMoveName::TESTMOVE1]});
}
PARTY_MEMBER_STATS[PLAYER]->statusEffects[Property::MUSHROOMIZED]=4;
PARTY_MEMBER_STATS[PLAYER]->moveSet={
@ -2944,32 +2952,38 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
std::vector<Entity*>{
new Entity(new Standard_Obj(
NPC1_4,"Test Obj",3,2,ANIMATIONS["player.png"]),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
},
{},
0),
new Entity(new Standard_Obj(
NPC1_4,"Test Obj 2",1,3,ANIMATIONS["player.png"]),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
},
{},
0),
new Entity(new Standard_Obj(
NPC1_4,"Test Obj 3",2,2,ANIMATIONS["player.png"]),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
},
{},
0),
}));//ENCOUNTER_1
ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_2,{0,0},std::array<vd2d,4>{vd2d
{grid(1,1)},{grid(2,2)},{grid(3,2)},{grid(4,2)}},
std::vector<Entity*>{
new Entity(new Standard_Obj(
NPC1_4,"Test Obj",1,4,ANIMATIONS["player.png"],{2,2},GREEN,20),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},5,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
@ -2978,10 +2992,11 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
ITEMLIST[ItemName::EGG],
ITEMLIST[ItemName::PIZZA],
ITEMLIST[ItemName::MIRACLE_FOOD_LUNCH],
}),
},
35),
new Entity(new Standard_Obj(
NPC1_4,"Test Obj 2",1,2,ANIMATIONS["player.png"],{2,2},GREEN,20),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},5,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
@ -2990,10 +3005,11 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
ITEMLIST[ItemName::EGG],
ITEMLIST[ItemName::PIZZA],
ITEMLIST[ItemName::MIRACLE_FOOD_LUNCH],
}),
},
35),
new Entity(new Standard_Obj(
NPC1_4,"Test Obj 3",2,1,ANIMATIONS["player.png"],{2,2},GREEN,20),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},5,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
@ -3002,43 +3018,52 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
ITEMLIST[ItemName::EGG],
ITEMLIST[ItemName::PIZZA],
ITEMLIST[ItemName::MIRACLE_FOOD_LUNCH],
}),
},
35),
}));//ENCOUNTER_2
ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_3,{0,0},std::array<vd2d,4>{vd2d
{grid(1,1)},{grid(2,2)},{grid(3,2)},{grid(4,2)}},
std::vector<Entity*>{
new Entity(new Standard_Obj(
NPC1_4,"Test Obj",1,2,ANIMATIONS["player.png"],{1,1},MAGENTA),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
},
{},
0),
}));//ENCOUNTER_3
ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_4,{0,0},std::array<vd2d,4>{vd2d
{grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}},
std::vector<Entity*>{
new Entity(new Standard_Obj(
NPC1_4,"Test Obj",6,2,ANIMATIONS["player.png"],{1,1},MAGENTA),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
},
{},
0),
new Entity(new Standard_Obj(
NPC1_4,"Test Obj",7,2,ANIMATIONS["player.png"],{1,1},MAGENTA),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
},
{},
0),
new Entity(new Standard_Obj(
NPC1_4,"Test Obj",3,5,ANIMATIONS["player.png"],{1,1},MAGENTA),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
{HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
},
{},
0),
}));//ENCOUNTER_4
}
@ -3281,7 +3306,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
for (int i=0;i<ENCOUNTER_LIST[id]->objs.size();i++) {
Entity*ent=ENCOUNTER_LIST[id]->objs[i];
Object*newObj=new Standard_Obj(ent->obj->id,ent->obj->name,ent->obj->GetPos(),ent->obj->spr,ent->obj->GetScale(),ent->obj->color,ent->obj->animationSpd,ent->obj->temp);
ents.push_back(new Entity(newObj,ent->GetHP(),ent->maxHP,ent->GetPP(),ent->maxPP,ent->baseAtk,ent->resistances,ent->speed,ent->moveSet,ent->inventory,ent->equipment,ent->damageReduction,ent->smart,ent->dumb));
ents.push_back(new Entity(newObj,{ent->GetHP(),ent->GetPP(),ent->GetTargetHP(),ent->GetTargetPP(),ent->stats.maxHP,ent->stats.maxPP,ent->stats.baseAtk,ent->stats.speed,ent->stats.resistances,ent->stats.damageReduction,ent->stats.smart,ent->stats.dumb},ent->moveSet,ent->inventory,ent->money,ent->equipment));
}
Encounter*data=new Encounter(id,pos,ENCOUNTER_LIST[id]->playerPos,ents,chance);
data->chance=chance;
@ -3478,7 +3503,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
break;
} else {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->atb+=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->speed;
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->atb+=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->stats.speed;
}
}
} else {
@ -3535,7 +3560,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
break;
} else {
BATTLE_ENCOUNTER->objs[i]->atb+=BATTLE_ENCOUNTER->objs[i]->speed;
BATTLE_ENCOUNTER->objs[i]->atb+=BATTLE_ENCOUNTER->objs[i]->stats.speed;
}
}
} else {
@ -3575,21 +3600,21 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
target->AddPP(BATTLE_CUSTOM_ITEM->stats.ppRecovery);
}break;
case ItemAction::ATKINCREASE:{
target->baseAtk+=BATTLE_CUSTOM_ITEM->stats.atkIncrease;
target->stats.baseAtk+=BATTLE_CUSTOM_ITEM->stats.atkIncrease;
target->boosts[boost::ATK]+=BATTLE_CUSTOM_ITEM->stats.atkIncrease;
}break;
case ItemAction::HPINCREASE:{
target->maxHP+=BATTLE_CUSTOM_ITEM->stats.hpIncrease;
target->stats.maxHP+=BATTLE_CUSTOM_ITEM->stats.hpIncrease;
target->AddHP(BATTLE_CUSTOM_ITEM->stats.hpIncrease);
target->boosts[boost::HP]+=BATTLE_CUSTOM_ITEM->stats.hpIncrease;
}break;
case ItemAction::PPINCREASE:{
target->maxPP+=BATTLE_CUSTOM_ITEM->stats.ppIncrease;
target->stats.maxPP+=BATTLE_CUSTOM_ITEM->stats.ppIncrease;
target->AddPP(BATTLE_CUSTOM_ITEM->stats.ppIncrease);
target->boosts[boost::PP]+=BATTLE_CUSTOM_ITEM->stats.ppIncrease;
}break;
case ItemAction::SPDINCREASE:{
target->speed+=BATTLE_CUSTOM_ITEM->stats.spdIncrease;
target->stats.speed+=BATTLE_CUSTOM_ITEM->stats.spdIncrease;
target->boosts[boost::SPD]+=BATTLE_CUSTOM_ITEM->stats.spdIncrease;
}break;
case ItemAction::LEARNMOVE:{
@ -3750,6 +3775,10 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->_SetDirectPP(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->GetTargetPP());
}
ENEMY_MONEY_SUM=0;
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
ENEMY_MONEY_SUM+=BATTLE_ENCOUNTER->objs[i]->money;
}
BATTLE_STATE=BattleState::ENEMY_SPOILS;
BATTLE_ROLLING_COUNTER_WAITTIME=0;
}
@ -3791,7 +3820,13 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
BATTLE_SPOILS_MESSAGE+=BATTLE_SPOILS_LIST[0]->name+".";
PARTY_INVENTORY.push_back(BATTLE_SPOILS_LIST[0]);
BATTLE_SPOILS_LIST.erase(BATTLE_SPOILS_LIST.begin());
} else {
} else
if (ENEMY_MONEY_SUM>0) {
BATTLE_SPOILS_MESSAGE="You gained $"+std::to_string(ENEMY_MONEY_SUM)+".";
MONEY+=ENEMY_MONEY_SUM;
ENEMY_MONEY_SUM=0;
} else
{
BATTLE_STATE=BattleState::MOVE_CAMERA_BACK;
}
}
@ -4212,7 +4247,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
int attackerDamage = (attacker->selectedMove->baseDmg+
((attacker->selectedMove->randomDmg>0)?rand()%attacker->selectedMove->randomDmg:0)
+attacker->baseAtk
+attacker->stats.baseAtk
+equipDamage);
finalDamage += attackerDamage;
@ -4491,7 +4526,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
DrawDialogBox({WIDTH-WIDTH/3+WIDTH/6-1,HEIGHT/4+2},{(int)(WIDTH/6),HEIGHT/8},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawStringPropDecal(damageBoxPos+textStartingOffset,"Damage",WHITE,{0.7,0.8});
if (BATTLE_MOVELIST_DISPLAY.size()>0) {
label = (BATTLE_MOVELIST_DISPLAY[selectioncursor][gradeselectioncursor]->baseDmg!=0)?std::to_string(BATTLE_MOVELIST_DISPLAY[selectioncursor][gradeselectioncursor]->baseDmg+PARTY_MEMBER_STATS[partyMemberSlot]->baseAtk)+"~"+std::to_string(BATTLE_MOVELIST_DISPLAY[selectioncursor][gradeselectioncursor]->randomDmg+BATTLE_MOVELIST_DISPLAY[selectioncursor][gradeselectioncursor]->baseDmg+PARTY_MEMBER_STATS[partyMemberSlot]->baseAtk):"N/A";
label = (BATTLE_MOVELIST_DISPLAY[selectioncursor][gradeselectioncursor]->baseDmg!=0)?std::to_string(BATTLE_MOVELIST_DISPLAY[selectioncursor][gradeselectioncursor]->baseDmg+PARTY_MEMBER_STATS[partyMemberSlot]->stats.baseAtk)+"~"+std::to_string(BATTLE_MOVELIST_DISPLAY[selectioncursor][gradeselectioncursor]->randomDmg+BATTLE_MOVELIST_DISPLAY[selectioncursor][gradeselectioncursor]->baseDmg+PARTY_MEMBER_STATS[partyMemberSlot]->stats.baseAtk):"N/A";
DrawStringPropDecal({static_cast<float>(damageBoxPos.x+textStartingOffset.x+(WIDTH/6)-8-GetTextSizeProp(label).x*(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5))),static_cast<float>(damageBoxPos.y+textStartingOffset.y+8)},label,WHITE,{static_cast<float>(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5)),1.5});
}
@ -4607,8 +4642,8 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
Entity*member=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]];
HandleRollingCounters(i,player_rollhp_counter,player_rollhp_display,member,member->maxHP,member->GetHP(),member->GetTargetHP());
HandleRollingCounters(i,player_rollpp_counter,player_rollpp_display,member,member->maxPP,member->GetPP(),member->GetTargetPP(),true);
HandleRollingCounters(i,player_rollhp_counter,player_rollhp_display,member,member->stats.maxHP,member->GetHP(),member->GetTargetHP());
HandleRollingCounters(i,player_rollpp_counter,player_rollpp_display,member,member->stats.maxPP,member->GetPP(),member->GetTargetPP(),true);
if (player_rollwait_counter[i]==0) {
player_rollwait_counter[i]=BATTLE_ROLLING_COUNTER_WAITTIME*13;
@ -4693,7 +4728,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
void CalculateEquipmentStats(int partyMemberSlot,int&atk,int&def) {
atk=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[partyMemberSlot]]->baseAtk;
atk=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[partyMemberSlot]]->stats.baseAtk;
def=0;
for (int i=0;i<PARTY_MEMBER_STATS[PARTY_MEMBER_ID[partyMemberSlot]]->equipment.size();i++) {
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[partyMemberSlot]]->equipment[i]!=nullptr) {

@ -6,6 +6,7 @@
#include "defines.h"
#include "layers.h"
#include "item.h"
#include "states.h"
using namespace olc;
struct Interaction{
@ -59,6 +60,7 @@ class Object{
//When the player tries to interact with this object.
virtual Interaction Interact()=0;
virtual void ChoiceMade(int choice)=0;
virtual void DialogClosed()=0;
void SetScale(vd2d scale) {
this->scale=scale;
if (spr!=nullptr) {
@ -172,7 +174,8 @@ class Object{
class Standard_Obj : public Object{
DynamicObject(Standard_Obj)
Interaction Interact()override{return {};}
void ChoiceMade(int choice)override{}
void DialogClosed()override{};
void ChoiceMade(int choice)override{};
};
class TrashCan_Obj : public Object{
@ -180,11 +183,13 @@ class TrashCan_Obj : public Object{
Interaction Interact()override{
frameIndex=1;
return {{"You dig around the trash can.","Nope! Just looks like plain ol' trash."}};}
void ChoiceMade(int choice)override{}
void DialogClosed()override{};
void ChoiceMade(int choice)override{};
};
extern int MESSAGE_BOX_DIALOG_ANSWER;
extern bool GAME_FLAGS[128];
extern int GAME_STATE;
class Shopkeeper_Obj : public Object{
DynamicObject(Shopkeeper_Obj)
@ -214,5 +219,8 @@ class Shopkeeper_Obj : public Object{
}
}
}
void DialogClosed()override{
GAME_STATE = GameState::SHOPKEEPER_MENU;
}
};
#endif

@ -1,7 +1,7 @@
#ifndef STATES_H
#define STATES_H
namespace GameState{
enum{
enum State{
EDITOR,
TILE_SELECT,
OBJ_SELECT,

Loading…
Cancel
Save