generated from sigonasr2/CPlusPlusProjectTemplate
Internal inventory system setup
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
e96e5248e8
commit
874e5f6fb4
Binary file not shown.
76
main.cpp
76
main.cpp
@ -308,18 +308,19 @@ enum class BattleMoveName{
|
|||||||
PKFIRE_O,
|
PKFIRE_O,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ItemName{
|
||||||
|
COOKIE,
|
||||||
|
EGG,
|
||||||
|
PIZZA,
|
||||||
|
CRACKED_BAT,
|
||||||
|
LIGHT_JACKET,
|
||||||
|
KEY_TO_THE_PALACE,
|
||||||
|
};
|
||||||
|
|
||||||
using convert_t = std::codecvt_utf8<wchar_t>;
|
using convert_t = std::codecvt_utf8<wchar_t>;
|
||||||
std::wstring_convert<convert_t, wchar_t> strconverter;
|
std::wstring_convert<convert_t, wchar_t> strconverter;
|
||||||
|
std::string to_string(std::wstring wstr){return strconverter.to_bytes(wstr);}
|
||||||
std::string to_string(std::wstring wstr)
|
std::wstring to_wstring(std::string str){return strconverter.from_bytes(str);}
|
||||||
{
|
|
||||||
return strconverter.to_bytes(wstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring to_wstring(std::string str)
|
|
||||||
{
|
|
||||||
return strconverter.from_bytes(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Battle{
|
namespace Battle{
|
||||||
class Move{
|
class Move{
|
||||||
@ -348,6 +349,35 @@ namespace Battle{
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace EquipSlot{
|
||||||
|
enum Equip{
|
||||||
|
WEAPON,
|
||||||
|
ARMOR,
|
||||||
|
ACCESSORY,
|
||||||
|
NONE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ItemStatsStruct{
|
||||||
|
int hpRecovery=0;
|
||||||
|
int ppRecovery=0;
|
||||||
|
int attack=0;
|
||||||
|
int defense=0;
|
||||||
|
EquipSlot::Equip equip=EquipSlot::NONE; //Whether or not this is equipment.
|
||||||
|
bool important=false; //If an item's important it can't be discarded.
|
||||||
|
bool consumable=false; //Whether or not this item is consumed when used.
|
||||||
|
};
|
||||||
|
|
||||||
|
class Item{
|
||||||
|
public:
|
||||||
|
std::string name;
|
||||||
|
std::string description;
|
||||||
|
Battle::Move*battlemove=nullptr;
|
||||||
|
ItemStatsStruct stats;
|
||||||
|
Item(std::string name,std::string desc,ItemStatsStruct stats={0,0,0,0,EquipSlot::NONE,false,false},Battle::Move*battlemove=nullptr)
|
||||||
|
:name(name),description(desc),stats(stats),battlemove(battlemove){}
|
||||||
|
};
|
||||||
|
|
||||||
class Entity{
|
class Entity{
|
||||||
private:
|
private:
|
||||||
int HP=0;
|
int HP=0;
|
||||||
@ -369,13 +399,15 @@ class Entity{
|
|||||||
int selectedTarget = 0;
|
int selectedTarget = 0;
|
||||||
Battle::Move*selectedMove = nullptr; //The index of the selected move.
|
Battle::Move*selectedMove = nullptr; //The index of the selected move.
|
||||||
int channelTimeRemaining = 0; //The amount of channel time left until move can be performed.
|
int channelTimeRemaining = 0; //The amount of channel time left until move can be performed.
|
||||||
vd2d channelPos = {0,0}; //Where are channel is happening.
|
vd2d channelPos = {0,0}; //Where our channel is happening.
|
||||||
|
std::vector<Item*> inventory; //Used mostly for enemy spoils.
|
||||||
|
std::array<Item*,3> equipment; //Equipment this character is using.
|
||||||
//Used for initializing players.
|
//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,int damageReduction=0,bool smart=false,bool dumb=false)
|
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,damageReduction,smart,dumb){}
|
: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.
|
//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,int damageReduction=0,bool smart=false,bool dumb=false)
|
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),moveSet(moveSet),damageReduction(damageReduction),smart(smart),dumb(dumb){
|
: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++) {
|
for (int i=0;i<4;i++) {
|
||||||
this->resistances[i]=resistances[i];
|
this->resistances[i]=resistances[i];
|
||||||
}
|
}
|
||||||
@ -527,6 +559,7 @@ public:
|
|||||||
bool ANYKEYPRESSED=false;
|
bool ANYKEYPRESSED=false;
|
||||||
bool ACTIONKEYPRESSED=false;
|
bool ACTIONKEYPRESSED=false;
|
||||||
std::vector<std::vector<Battle::Move*>> BATTLE_MOVELIST_DISPLAY;
|
std::vector<std::vector<Battle::Move*>> BATTLE_MOVELIST_DISPLAY;
|
||||||
|
std::vector<Item*> PARTY_INVENTORY;
|
||||||
std::map<int,int> ADDITIONAL_FONT_VALS = {
|
std::map<int,int> ADDITIONAL_FONT_VALS = {
|
||||||
{α,0},{β,1},{γ,2},{Ω,3},{Σ,4},
|
{α,0},{β,1},{γ,2},{Ω,3},{Σ,4},
|
||||||
};
|
};
|
||||||
@ -549,6 +582,7 @@ public:
|
|||||||
std::vector<Particle*> PARTICLES;
|
std::vector<Particle*> PARTICLES;
|
||||||
std::vector<DamageNumber*> DAMAGE_NUMBERS;
|
std::vector<DamageNumber*> DAMAGE_NUMBERS;
|
||||||
std::map<std::pair<int,int>,vd2d> MOVEMENT_GRID;
|
std::map<std::pair<int,int>,vd2d> MOVEMENT_GRID;
|
||||||
|
std::map<ItemName,Item*>ITEMLIST;
|
||||||
vi2d SELECTED_MOVE_SQUARE;
|
vi2d SELECTED_MOVE_SQUARE;
|
||||||
|
|
||||||
Effect*CURRENT_EFFECT=nullptr;
|
Effect*CURRENT_EFFECT=nullptr;
|
||||||
@ -570,6 +604,7 @@ public:
|
|||||||
EnableLayer(layer::COLLISION,false);
|
EnableLayer(layer::COLLISION,false);
|
||||||
|
|
||||||
SetupMoveList();
|
SetupMoveList();
|
||||||
|
SetupItemList();
|
||||||
SetupPartyMemberStats();
|
SetupPartyMemberStats();
|
||||||
SetupAnimations();
|
SetupAnimations();
|
||||||
SetupObjectInfo();
|
SetupObjectInfo();
|
||||||
@ -2219,6 +2254,15 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
|||||||
MOVELIST[BattleMoveName::PKFIRE_O]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",OMEGA,360,100,ㅍ 32,7,0,false,{0,0,20,0});
|
MOVELIST[BattleMoveName::PKFIRE_O]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",OMEGA,360,100,ㅍ 32,7,0,false,{0,0,20,0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupItemList() { //hpRecovery,ppRecovery,attack,dmgReduction,equip,important,consumable
|
||||||
|
ITEMLIST[ItemName::COOKIE]=new Item("Cookie","A delightful little treat. Restores 40 HP.",{hpRecovery:40,consumable:true});
|
||||||
|
ITEMLIST[ItemName::EGG]=new Item("Egg","Did it come before or after the chicken? Restores 60 HP.",{hpRecovery:60,consumable:true});
|
||||||
|
ITEMLIST[ItemName::PIZZA]=new Item("Pizza","A scrumptious meal filled with lots of cheese. Restores 200 HP.",{hpRecovery:200,consumable:true});
|
||||||
|
ITEMLIST[ItemName::CRACKED_BAT]=new Item("Cracked Bat","Has some dents in it, but you can probably still dents things with it yourself.",{attack:4,equip:EquipSlot::WEAPON});
|
||||||
|
ITEMLIST[ItemName::LIGHT_JACKET]=new Item("Light Jacket","Fits just fine.",{defense:2,equip:EquipSlot::ARMOR});
|
||||||
|
ITEMLIST[ItemName::KEY_TO_THE_PALACE]=new Item("Key to the Palace","Lets you access a Palace.",{important:true});
|
||||||
|
}
|
||||||
|
|
||||||
void SetupAnimations() {
|
void SetupAnimations() {
|
||||||
CreateSprite("terrainmap.png");
|
CreateSprite("terrainmap.png");
|
||||||
CreateSprite("additionalFont.png");
|
CreateSprite("additionalFont.png");
|
||||||
@ -2726,7 +2770,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
|||||||
for (int i=0;i<ENCOUNTER_LIST[id]->objs.size();i++) {
|
for (int i=0;i<ENCOUNTER_LIST[id]->objs.size();i++) {
|
||||||
Entity*ent=ENCOUNTER_LIST[id]->objs[i];
|
Entity*ent=ENCOUNTER_LIST[id]->objs[i];
|
||||||
Object*newObj=new Object(ent->obj->id,ent->obj->name,ent->obj->GetPos(),ent->obj->spr,ent->obj->GetScale(),ent->obj->color,ent->obj->animationSpd,ent->obj->temp);
|
Object*newObj=new Object(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->PP,ent->maxPP,ent->baseAtk,ent->resistances,ent->speed,ent->moveSet,ent->damageReduction,ent->smart,ent->dumb));
|
ents.push_back(new Entity(newObj,ent->GetHP(),ent->maxHP,ent->PP,ent->maxPP,ent->baseAtk,ent->resistances,ent->speed,ent->moveSet,ent->inventory,ent->equipment,ent->damageReduction,ent->smart,ent->dumb));
|
||||||
}
|
}
|
||||||
Encounter*data=new Encounter(id,pos,ENCOUNTER_LIST[id]->playerPos,ents,chance);
|
Encounter*data=new Encounter(id,pos,ENCOUNTER_LIST[id]->playerPos,ents,chance);
|
||||||
data->chance=chance;
|
data->chance=chance;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user