Monster Drop Data reading from configuration implemented.
This commit is contained in:
parent
b61f9ddf96
commit
a29df8b954
@ -177,9 +177,6 @@
|
||||
<ClInclude Include="GameState.h">
|
||||
<Filter>Header Files\Game States</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Item.h">
|
||||
<Filter>Configurations</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MenuItemButton.h">
|
||||
<Filter>Header Files\Interface</Filter>
|
||||
</ClInclude>
|
||||
@ -258,6 +255,9 @@
|
||||
<ClInclude Include="PopupMenuLabel.h">
|
||||
<Filter>Header Files\Interface</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Item.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Player.cpp">
|
||||
|
||||
@ -40,6 +40,8 @@ SUCH DAMAGE.
|
||||
#include "DamageNumber.h"
|
||||
#include "DEFINES.h"
|
||||
#include "Attributable.h"
|
||||
#include "Item.h"
|
||||
#include "safemap.h"
|
||||
|
||||
INCLUDE_ITEM_DATA
|
||||
|
||||
@ -61,7 +63,7 @@ struct MonsterDropData{
|
||||
int minQty=1;
|
||||
int maxQty=1;
|
||||
MonsterDropData(std::string itemName,float dropChance,int minQty=1,int maxQty=1)
|
||||
:item(ITEM_DATA.at(itemName)),dropChance(dropChance),minQty(minQty),maxQty(maxQty){}
|
||||
:item(&ITEM_DATA.at(itemName)),dropChance(dropChance),minQty(minQty),maxQty(maxQty){}
|
||||
};
|
||||
|
||||
struct MonsterData{
|
||||
@ -78,9 +80,10 @@ struct MonsterData{
|
||||
std::string jumpAnimation="WARRIOR_IDLE_S";
|
||||
std::string shootAnimation="WARRIOR_IDLE_S";
|
||||
std::string deathAnimation="WARRIOR_IDLE_S";
|
||||
std::vector<MonsterDropData> dropData;
|
||||
public:
|
||||
MonsterData();
|
||||
MonsterData(int id,std::string name,int hp,int atk,std::vector<std::string>animations,float moveSpd=1.0f,float size=1.0f,int strategy=0,int collisionDmg=0);
|
||||
MonsterData(int id,std::string name,int hp,int atk,std::vector<std::string>animations,std::vector<MonsterDropData>drops,float moveSpd=1.0f,float size=1.0f,int strategy=0,int collisionDmg=0);
|
||||
int GetHealth();
|
||||
int GetAttack();
|
||||
float GetMoveSpdMult();
|
||||
@ -95,6 +98,7 @@ struct MonsterData{
|
||||
std::vector<std::string>GetAnimations(){
|
||||
return animations;
|
||||
}
|
||||
const std::vector<MonsterDropData>&GetDropData();
|
||||
std::string GetDisplayName();
|
||||
static void InitializeMonsterData();
|
||||
static std::map<int,Renderable*>imgs;
|
||||
|
||||
@ -37,18 +37,20 @@ SUCH DAMAGE.
|
||||
#include "config.h"
|
||||
#include "DEFINES.h"
|
||||
#include "safemap.h"
|
||||
#include "Item.h"
|
||||
|
||||
INCLUDE_DATA
|
||||
INCLUDE_STRATEGY_DATA
|
||||
INCLUDE_ANIMATION_DATA
|
||||
INCLUDE_ITEM_DATA
|
||||
|
||||
std::map<int,MonsterData>MONSTER_DATA;
|
||||
safemap<std::string,MonsterData*>MONSTER_NAME_DATA;
|
||||
|
||||
MonsterData::MonsterData()
|
||||
:atk(0),collisionDmg(0),hp(0),id(0),moveSpd(0),size(0),strategy(0){}
|
||||
MonsterData::MonsterData(int id,std::string name,int hp,int atk,std::vector<std::string>animations,float moveSpd,float size,int strategy,int collisionDmg):
|
||||
id(id),name(name),hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),collisionDmg(collisionDmg){}
|
||||
MonsterData::MonsterData(int id,std::string name,int hp,int atk,std::vector<std::string>animations,std::vector<MonsterDropData>drops,float moveSpd,float size,int strategy,int collisionDmg):
|
||||
id(id),name(name),hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),dropData(drops),collisionDmg(collisionDmg){}
|
||||
|
||||
void MonsterData::InitializeMonsterData(){
|
||||
int id=0;
|
||||
@ -119,12 +121,26 @@ void MonsterData::InitializeMonsterData(){
|
||||
animationCounter++;
|
||||
}
|
||||
|
||||
std::vector<MonsterDropData>drops;
|
||||
|
||||
//Add drop items to monster data from the config.
|
||||
int dropDataCounter=0;
|
||||
while(DATA["Monsters"][std::to_string(id)].HasProperty("DROP["+std::to_string(dropDataCounter)+"]")){
|
||||
datafile drop=DATA["Monsters"][std::to_string(id)]["DROP["+std::to_string(dropDataCounter)+"]"];
|
||||
if(!ITEM_DATA.count(drop.GetString(0))){
|
||||
ERR("Could not add drop "<<drop.GetString(0)<<" to "<<MonsterName<<"'s drop table! Item does not exist!");
|
||||
}
|
||||
drops.push_back(MonsterDropData{drop.GetString(0),float(drop.GetReal(1)),drop.GetInt(2),drop.GetInt(3)});
|
||||
dropDataCounter++;
|
||||
}
|
||||
|
||||
MonsterData monster(
|
||||
id,
|
||||
MonsterName,
|
||||
DATA["Monsters"][std::to_string(id)]["Health"].GetInt(),
|
||||
DATA["Monsters"][std::to_string(id)]["Attack"].GetInt(),
|
||||
animations,
|
||||
drops,
|
||||
DATA["Monsters"][std::to_string(id)]["MoveSpd"].GetReal()/100,
|
||||
DATA["Monsters"][std::to_string(id)]["Size"].GetReal()/100,
|
||||
STRATEGY_DATA[DATA["Monsters"][std::to_string(id)]["Strategy"].GetString()],
|
||||
@ -176,3 +192,6 @@ std::string MonsterData::GetShootAnimation(){
|
||||
std::string MonsterData::GetDeathAnimation(){
|
||||
return animations[DEATH];
|
||||
}
|
||||
const std::vector<MonsterDropData>&MonsterData::GetDropData(){
|
||||
return dropData;
|
||||
}
|
||||
@ -35,7 +35,7 @@ SUCH DAMAGE.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 2992
|
||||
#define VERSION_BUILD 2998
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user