Battle Properties implemented

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent fca95e62d2
commit 4e293ff983
  1. BIN
      C++ProjectTemplate
  2. 0
      SeasonI.h
  3. 18
      battle.h
  4. 0
      battleproperty.c
  5. 212
      battleproperty.h
  6. 9
      encounters.h
  7. 75
      main.cpp

Binary file not shown.

@ -1,8 +1,8 @@
#ifndef BATTLE_H
#define BATTLE_H
#include "effect.h"
#include "pixelGameEngine.h"
#include "battleproperty.h"
using namespace olc;
enum class BattleMoveName{
@ -57,20 +57,6 @@ enum class Resistance{
HEAT,
};
enum class Property{
PETRIFY,
PARALYZE,
DIAMONDIZE,
CRYING,
SLOW,
MUSHROOMIZED,
CONFUSE,
POISON,
REGEN,
DEFENSE_UP,
REVIVE,
};
namespace Battle{
struct Move{
std::string name="";
@ -86,7 +72,7 @@ namespace Battle{
std::string attackMsg="$USER uses $POWER";
Effect*eff=nullptr;
bool pctDamage=false; //Uses % damage for the base damage instead of flat damage.
std::vector<std::pair<Property,int>> properties={}; //The int is used to determine the chance of something occurring.
std::map<Property,int> properties={}; //The int is used to determine the chance of something occurring.
//Properties order is WET, DRY, COLD, HEAT
bool overworld=false; //Whether or not a move can be used on the overworld.
std::string GetPowerName() {

@ -0,0 +1,212 @@
#ifndef BATTLE_PROPERTY_H
#define BATTLE_PROPERTY_H
#include "pixelGameEngine.h"
#include "defines.h"
using namespace olc;
class BattleProperty{
public:
std::string displayName;
std::string effectName;
BattleProperty(std::string displayName,std::string effectName)
:displayName(displayName),effectName(effectName){}
virtual void OnApplication()=0; //What happens when the effect is immediately applied.
virtual void OnTurnStart()=0; //Effects on turn start.
virtual void OnTurnEnd()=0; //Effects on turn end.
};
class Property_PETRIFY:public BattleProperty{
public:
Property_PETRIFY()
:BattleProperty("PETRIFY","Petrified"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_PARALYZE:public BattleProperty{
public:
Property_PARALYZE()
:BattleProperty("PARALYZE","Paralyzed"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_DIAMONDIZE:public BattleProperty{
public:
Property_DIAMONDIZE()
:BattleProperty("DIAMONDIZE","Diamondized"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_CRYING:public BattleProperty{
public:
Property_CRYING()
:BattleProperty("CRYING","Crying"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_SLOW:public BattleProperty{
public:
Property_SLOW()
:BattleProperty("SLOW","Slowed"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_MUSHROOMIZED:public BattleProperty{
public:
Property_MUSHROOMIZED()
:BattleProperty("MUSHROOMIZED","Mushroomized"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_CONFUSE:public BattleProperty{
public:
Property_CONFUSE()
:BattleProperty("CONFUSE","Confused"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_POISON:public BattleProperty{
public:
Property_POISON()
:BattleProperty("POISON","Poisoned"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_REGEN:public BattleProperty{
public:
Property_REGEN()
:BattleProperty("REGEN","Regenerating"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_DEFENSE_UP:public BattleProperty{
public:
Property_DEFENSE_UP()
:BattleProperty("DEFENSE_UP","Hardened"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_REVIVE:public BattleProperty{
public:
Property_REVIVE()
:BattleProperty("REVIVE","Revived"){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
class Property_NONE:public BattleProperty{
public:
Property_NONE()
:BattleProperty("NONE",""){}
void OnApplication(){
}
void OnTurnStart(){
}
void OnTurnEnd(){
}
};
enum class Property{
PETRIFY,
PARALYZE,
DIAMONDIZE,
CRYING,
SLOW,
MUSHROOMIZED,
CONFUSE,
POISON,
REGEN,
DEFENSE_UP,
REVIVE,
NONE
};
#endif

@ -36,6 +36,7 @@ class Entity{
int atb=0; //When this value reaches 1000, it's this entity's turn.
Object* obj;
std::vector<Battle::Move*> moveSet;
std::map<Property,int> statusEffects;
int selectedTarget = NO_TARGET;
Battle::Move*selectedMove = nullptr; //The index of the selected move.
int channelTimeRemaining = 0; //The amount of channel time left until move can be performed.
@ -57,6 +58,14 @@ class Entity{
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;
}
//Get the HP that the rolling counter is moving towards.
int GetTargetHP() {
return targetHP;

@ -17,14 +17,16 @@
#include "encounters.h"
#include "particle.h"
#include "effect.h"
#include "battleproperty.h"
using namespace olc;
std::vector<Object*> OBJECTS;
const vd2d NO_NEIGHBOR = {-999,-999};
PixelGameEngine*GAME;
vd2d cameraPos={0,0};
PixelGameEngine*GAME;
std::vector<Item*> PARTY_INVENTORY;
enum{
@ -69,7 +71,6 @@ public:
SeasonI()
{
sAppName = "Season I: Winters of Loneliness";
}
public:
@ -181,7 +182,7 @@ public:
std::map<std::string,Decal*> SPRITES;
std::map<std::string,Animation*> ANIMATIONS={};
std::map<int,Object*> OBJ_INFO={};
std::map<Property,BattleProperty*> BATTLE_PROPERTIES={};
std::vector<Particle*> PARTICLES={};
std::vector<DamageNumber*> DAMAGE_NUMBERS={};
std::map<std::pair<int,int>,vd2d> MOVEMENT_GRID={};
@ -218,6 +219,7 @@ public:
SetupAnimations();
SetupObjectInfo();
SetupEncounters();
SetupBattleProperties();
SetGameFlag(Flag::TEST_FLAG1,false);
SetGameFlag(Flag::TEST_FLAG2,false);
@ -1192,7 +1194,8 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
}break;
case 4:{//Status is selected.
GAME_STATE=GameState::OVERWORLD_STATUS_MENU;
OVERWORLD_POWER_SELECTION_MEMBER=0;
}break;
}
}
@ -1255,6 +1258,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
}
if (LeftPressed()) {
OVERWORLD_POWER_SELECTION_MEMBER=-1;
if (PARTY_MEMBER_COUNT==1) {
GAME_STATE=GameState::OVERWORLD_MENU;
} else {
@ -1459,6 +1463,27 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
}
}break;
case GameState::OVERWORLD_STATUS_MENU:{
if (LeftPressed()) {
OVERWORLD_POWER_SELECTION_MEMBER-=1;
if (OVERWORLD_POWER_SELECTION_MEMBER<0) {
OVERWORLD_POWER_SELECTION_MEMBER=PARTY_MEMBER_COUNT-1;
}
if (OVERWORLD_POWER_SELECTION_MEMBER==0) {
KEY_LASTPRESSED=NONE;
}
}
if (RightPressed()) {
OVERWORLD_POWER_SELECTION_MEMBER=(OVERWORLD_POWER_SELECTION_MEMBER+1)%PARTY_MEMBER_COUNT;
if (OVERWORLD_POWER_SELECTION_MEMBER==PARTY_MEMBER_COUNT-1) {
KEY_LASTPRESSED=NONE;
}
}
if (UpPressed()) {
OVERWORLD_POWER_SELECTION_MEMBER=-1;
GAME_STATE=GameState::OVERWORLD_MENU;
}
}break;
case GameState::EDITOR:{
if (IsTextEntryEnabled()) {
return;
@ -1842,6 +1867,19 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
DrawStringPropDecal({72,HEIGHT*(5.F/8)+12},defStr,WHITE,{0.85,2});
DrawStringPropDecal({72+GetTextSizeProp(defStr).x*0.85F,HEIGHT*(5.F/8)+12},std::to_string(newDefense),(newDefense>equipDefense)?GREEN:(newDefense<equipDefense)?RED:WHITE,{0.85,2});
}
if (GAME_STATE==GameState::OVERWORLD_STATUS_MENU) {
DrawDialogBox({4,4},{(int)(WIDTH-8),(int)(HEIGHT/2)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
int nameWidth=GetTextSizeProp(PARTY_MEMBER_OBJ[OVERWORLD_POWER_SELECTION_MEMBER]->name).x/2;
DrawStringPropDecal({(float)(WIDTH-12-nameWidth),4},PARTY_MEMBER_OBJ[OVERWORLD_POWER_SELECTION_MEMBER]->name,WHITE,{0.5,1});
DrawRotatedDecal({(float)(WIDTH-nameWidth-16),7},SPRITES["cursor.png"],M_PI,{(float)SPRITES["cursor.png"]->sprite->width/2,(float)SPRITES["cursor.png"]->sprite->height/2},{(sinf(frameCount/10.F*M_PI)>0)?0.5F:0.25F,(sinf(frameCount/10.F*M_PI)>0)?0.5F:0.25F});
DrawRotatedDecal({(float)(WIDTH-8),7},SPRITES["cursor.png"],0,{(float)SPRITES["cursor.png"]->sprite->width/2,(float)SPRITES["cursor.png"]->sprite->height/2},{(sinf(frameCount/10.F*M_PI)>0)?0.5F:0.25F,(sinf(frameCount/10.F*M_PI)>0)?0.5F:0.25F});
vi2d drawPos={8,8};
DrawStringPropDecal(drawPos,PARTY_MEMBER_OBJ[OVERWORLD_POWER_SELECTION_MEMBER]->name);
drawPos.y+=12;
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[OVERWORLD_POWER_SELECTION_MEMBER]]->GetPrimaryStatusEffect()!=Property::NONE) {
}
}
if (GAME_STATE==GameState::OVERWORLD_POWER_MENU||GAME_STATE==GameState::OVERWORLD_POWER_PLAYER_MENU||GAME_STATE==GameState::OVERWORLD_GRADE_MENU) {
DrawBattleMoveList(OVERWORLD_POWER_SELECTION_MEMBER);
}
@ -2827,6 +2865,21 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}));//ENCOUNTER_4
}
void SetupBattleProperties() {
BATTLE_PROPERTIES[Property::PETRIFY]=new Property_PETRIFY();
BATTLE_PROPERTIES[Property::PARALYZE]=new Property_PARALYZE();
BATTLE_PROPERTIES[Property::DIAMONDIZE]=new Property_DIAMONDIZE();
BATTLE_PROPERTIES[Property::CRYING]=new Property_CRYING();
BATTLE_PROPERTIES[Property::SLOW]=new Property_SLOW();
BATTLE_PROPERTIES[Property::MUSHROOMIZED]=new Property_MUSHROOMIZED();
BATTLE_PROPERTIES[Property::CONFUSE]=new Property_CONFUSE();
BATTLE_PROPERTIES[Property::POISON]=new Property_POISON();
BATTLE_PROPERTIES[Property::REGEN]=new Property_REGEN();
BATTLE_PROPERTIES[Property::DEFENSE_UP]=new Property_DEFENSE_UP();
BATTLE_PROPERTIES[Property::REVIVE]=new Property_REVIVE();
BATTLE_PROPERTIES[Property::NONE]=new Property_NONE();
}
Object* AddObjectToWorld(Object*obj) {
std::vector<Object*>::const_iterator it = OBJECTS.begin();
if (obj->id==PLAYER&&!obj->temp) {
@ -3164,13 +3217,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
//Returns 0 if not found.
int getProperty(Property prop,Battle::Move*move) {
for (int i=0;i<move->properties.size();i++) {
std::pair<Property,int> p = move->properties[i];
if (p.first==prop) {
return p.second;
}
}
return 0;
return move->properties[prop];
}
void HandleBattle() {
@ -3372,6 +3419,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
if (CURRENT_EFFECT==nullptr&&BATTLE_ANIMATION_TIMER==90||CURRENT_EFFECT!=nullptr&&BATTLE_ANIMATION_TIMER>CURRENT_EFFECT->maxLifeTime) {
if (CURRENT_TURN<0) {
for (std::map<Property,int>::iterator it=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->statusEffects.begin();it!=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->statusEffects.end();++it) {
BATTLE_PROPERTIES[it->first]->OnApplication();
}
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget!=NO_TARGET) {
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->friendly) {
if (PARTY_MEMBER_STATS[-PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget-1]->GetHP()>0) {
@ -3409,6 +3459,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
}
} else {
for (std::map<Property,int>::iterator it=BATTLE_ENCOUNTER->objs[CURRENT_TURN]->statusEffects.begin();it!=BATTLE_ENCOUNTER->objs[CURRENT_TURN]->statusEffects.end();++it) {
BATTLE_PROPERTIES[it->first]->OnApplication();
}
if (BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget!=-NO_TARGET) {
if (BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->friendly) {
if (BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget]->GetHP()>0) {

Loading…
Cancel
Save