talent & fashion
This commit is contained in:
parent
1ad105df3c
commit
094c6b58a0
3
.gitignore
vendored
3
.gitignore
vendored
@ -21,4 +21,5 @@ __pycache__
|
||||
.user
|
||||
game.py
|
||||
*.cxx
|
||||
compile_commands.json
|
||||
compile_commands.json
|
||||
.vscode/settings.json
|
||||
|
@ -136,12 +136,8 @@ void Human::Initialize()
|
||||
RecalcSelfCollider();
|
||||
volume_ = meta->volume;
|
||||
observers_.insert(this);
|
||||
ability.hp = meta->i->health();
|
||||
for (auto& weapon : spec_weapons) {
|
||||
if (weapon.meta) {
|
||||
ability.hp += weapon.meta ? weapon.GetAttrValue(kHAT_MaxHp) : 0;
|
||||
}
|
||||
}
|
||||
RecalcMaxHp();
|
||||
ability.hp = ability.max_hp;
|
||||
}
|
||||
|
||||
float Human::GetSpeed()
|
||||
@ -1570,7 +1566,9 @@ void Human::RecalcBaseAttr()
|
||||
if (helmet_meta) {
|
||||
ability.def += helmet_meta->i->def();
|
||||
}
|
||||
ability.max_hp = std::max(ability.hp, ability.max_hp);
|
||||
RecalcSkinAttr();
|
||||
RecalcTalentAttr();
|
||||
RecalcMaxHp();
|
||||
}
|
||||
|
||||
int Human::GetInventory(int slot_id)
|
||||
@ -1611,7 +1609,7 @@ void Human::RecoverHp(int inc_hp)
|
||||
{
|
||||
if (!dead) {
|
||||
ability.hp += inc_hp;
|
||||
ability.hp = std::max(GetHP(), GetMaxHP());
|
||||
ability.hp = std::min(GetHP(), GetMaxHP());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2090,15 +2088,69 @@ bool Human::IsEnemy(Human* hum)
|
||||
}
|
||||
}
|
||||
|
||||
void Human::RecalTalentAttr()
|
||||
void Human::RecalcTalentAttr()
|
||||
{
|
||||
talent_attr_abs_ = {};
|
||||
if (curr_weapon == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 1;i <= maxtalent; i++)
|
||||
{
|
||||
auto talent = MetaMgr::Instance()->GetTalent(i);
|
||||
std::string label(curr_weapon->meta->i.equip_label());
|
||||
if (talent->GetEquipLabel() == a8::XValue(label).GetInt()) {
|
||||
talent_attr_abs_[kHAT_Atk] += talent->GetAtkPlus();
|
||||
talent_attr_abs_[kHAT_MaxHp] += talent->GetHpPlus();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Human::RecalSkinAttr()
|
||||
void Human::RecalcSkinAttr()
|
||||
{
|
||||
std::map<int, int> skinmap = {};
|
||||
int fashionid = 0;
|
||||
for(int i = 0;i < 6;i++)
|
||||
{
|
||||
skinmap[skins[i].skin_id] = skins[i].skin_id;
|
||||
if (i == 1) {
|
||||
fashionid = skins[i].skin_id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
skin_attr_abs_ = {};
|
||||
auto fashion = MetaMgr::Instance()->GetFashion(fashionid);
|
||||
if (fashion != nullptr && fashion->CheckFashion(skinmap)){
|
||||
fashion->GetAttr(skin_attr_abs_);
|
||||
}
|
||||
|
||||
for(auto& item:skinmap)
|
||||
{
|
||||
auto skinattr = MetaMgr::Instance()->GetSkinAttr(item.first);
|
||||
if (skinattr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int i = kHAT_Begin; i < kHAT_End; i++)
|
||||
{
|
||||
skin_attr_abs_[i] += (*skinattr)[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Human::RecalcMaxHp()
|
||||
{
|
||||
ability.max_hp = meta->i->health();
|
||||
for (auto& weapon : spec_weapons) {
|
||||
if (weapon.meta) {
|
||||
ability.max_hp += weapon.meta ? weapon.GetAttrValue(kHAT_MaxHp) : 0;
|
||||
}
|
||||
}
|
||||
ability.max_hp += talent_attr_abs_[kHAT_MaxHp];
|
||||
ability.max_hp += skin_attr_abs_[kHAT_MaxHp];
|
||||
}
|
||||
|
||||
void Human::_InternalUpdateMove(float speed)
|
||||
{
|
||||
@ -3320,6 +3372,10 @@ float Human::GetAttrAbs(int attr_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
attr_abs_val += talent_attr_abs_[attr_id];
|
||||
attr_abs_val += skin_attr_abs_[attr_id];
|
||||
}
|
||||
return attr_abs_val;
|
||||
}
|
||||
|
||||
@ -4024,14 +4080,10 @@ void Human::OnMetaChange()
|
||||
curr_weapon = &weapons[0];
|
||||
}
|
||||
}
|
||||
ability.hp = meta->i->health();
|
||||
for (auto& weapon : spec_weapons) {
|
||||
if (weapon.meta) {
|
||||
ability.hp += weapon.meta ? weapon.GetAttrValue(kHAT_MaxHp) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
room->frame_event.AddHpChg(this);
|
||||
RecalcBaseAttr();
|
||||
ability.hp = ability.max_hp;
|
||||
skill_meta_ = MetaMgr::Instance()->GetSkill(meta->i->active_skill());
|
||||
ResetSkill();
|
||||
MetaData::Skill* passive_skill_meta = MetaMgr::Instance()->GetSkill(meta->i->passive_skill());
|
||||
|
@ -297,8 +297,8 @@ class Human : public MoveableEntity
|
||||
void DeadDrop();
|
||||
bool IsEnemy(Human* hum);
|
||||
|
||||
void RecalTalentAttr();
|
||||
void RecalSkinAttr();
|
||||
void RecalcTalentAttr();
|
||||
void RecalcSkinAttr();
|
||||
|
||||
protected:
|
||||
void _InternalUpdateMove(float speed);
|
||||
@ -312,6 +312,8 @@ protected:
|
||||
void AutoChgWeapon();
|
||||
void CancelRevive();
|
||||
|
||||
void RecalcMaxHp();
|
||||
|
||||
private:
|
||||
void ClearFrameData();
|
||||
void GenBattleReportData(a8::MutableXObject* params);
|
||||
|
@ -580,4 +580,81 @@ namespace MetaData
|
||||
);
|
||||
}
|
||||
|
||||
void Talent::Init()
|
||||
{
|
||||
talentid = a8::XValue(i->talent_id()).GetInt();
|
||||
if (!i->equip_label().empty()) {
|
||||
equiplabel = a8::XValue(i->equip_label()).GetInt();
|
||||
hpplus = a8::XValue(i->hp_upgrade()).GetInt();
|
||||
} else {
|
||||
equiplabel = a8::XValue(i->equip_label2()).GetInt();
|
||||
atkplus = a8::XValue(i->atk_upgrade()).GetInt();
|
||||
}
|
||||
}
|
||||
|
||||
int Talent::GetId()
|
||||
{
|
||||
return talentid;
|
||||
}
|
||||
|
||||
int Talent::GetEquipLabel()
|
||||
{
|
||||
return equiplabel;
|
||||
}
|
||||
|
||||
int Talent::GetHpPlus()
|
||||
{
|
||||
return hpplus;
|
||||
}
|
||||
|
||||
int Talent::GetAtkPlus()
|
||||
{
|
||||
return atkplus;
|
||||
}
|
||||
|
||||
void Fashion::Init()
|
||||
{
|
||||
fashionid = i->id();
|
||||
std::vector<std::string> strings;
|
||||
a8::Split(i->spera_attr(), strings, ';');
|
||||
for(auto& item: strings)
|
||||
{
|
||||
std::vector<std::string> itemstrs;
|
||||
a8::Split(item, itemstrs, ':');
|
||||
if (itemstrs.size() < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int key = a8::XValue(itemstrs[0]).GetInt();
|
||||
int value = a8::XValue(itemstrs[1]).GetInt();
|
||||
attr_abs[key] = value;
|
||||
}
|
||||
|
||||
strings.clear();
|
||||
a8::Split(i->item_id(), strings, '|');
|
||||
for(auto& item: strings)
|
||||
{
|
||||
fashion_details.push_back(a8::XValue(item).GetInt());
|
||||
}
|
||||
}
|
||||
|
||||
bool Fashion::CheckFashion(const std::map<int, int> &skins)
|
||||
{
|
||||
for(auto& item: fashion_details)
|
||||
{
|
||||
if (skins.find(item) == skins.end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Fashion::GetAttr(std::array<float, kHAT_End> &attarr)
|
||||
{
|
||||
for(int i = kHAT_Begin; i < kHAT_End; i++)
|
||||
{
|
||||
attarr[i] = attr_abs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,4 +234,32 @@ namespace MetaData
|
||||
|
||||
};
|
||||
|
||||
struct Talent
|
||||
{
|
||||
const metatable::Talent* i = nullptr;
|
||||
void Init();
|
||||
int GetId();
|
||||
int GetEquipLabel();
|
||||
int GetHpPlus();
|
||||
int GetAtkPlus();
|
||||
|
||||
private:
|
||||
int talentid = 0;
|
||||
int equiplabel = 0;
|
||||
int hpplus = 0;
|
||||
int atkplus = 0;
|
||||
};
|
||||
|
||||
struct Fashion
|
||||
{
|
||||
const metatable::Fashion* i = nullptr;
|
||||
void Init();
|
||||
bool CheckFashion(const std::map<int, int> &skins);
|
||||
void GetAttr(std::array<float, kHAT_End> &attarr);
|
||||
|
||||
private:
|
||||
int fashionid = 0;
|
||||
std::array<float, kHAT_End> attr_abs = {};
|
||||
std::vector<int> fashion_details = {};
|
||||
};
|
||||
}
|
||||
|
@ -63,6 +63,11 @@ public:
|
||||
std::list<metatable::AI> ai_meta_list;
|
||||
std::list<MetaData::AI> ai_list;
|
||||
|
||||
std::list<metatable::Talent> talent_meta_list;
|
||||
std::list<MetaData::Talent> talent_list;
|
||||
std::list<metatable::Fashion> fashion_meta_list;
|
||||
std::list<MetaData::Fashion> fashion_list;
|
||||
|
||||
std::map<std::string, MetaData::Parameter*> parameter_hash;
|
||||
std::map<int, MetaData::Map*> gamemap_hash;
|
||||
std::map<int, MetaData::AirDrop*> airdrop_hash;
|
||||
@ -90,6 +95,9 @@ public:
|
||||
std::map<int, MetaData::Robot*> robot_hash;
|
||||
std::map<int, std::vector<MetaData::AirLine*>> airline_hash;
|
||||
std::map<int, MetaData::AI*> ai_hash;
|
||||
std::map<int, MetaData::Talent*> talent_hash;
|
||||
std::map<int, MetaData::Fashion*> fashion_hash;
|
||||
std::map<int, std::array<float, kHAT_End>> skinatt_hash;
|
||||
|
||||
void Load()
|
||||
{
|
||||
@ -138,6 +146,8 @@ public:
|
||||
f8::ReadCsvMetaFile(res_path + "equipUpgrade@equipUpgrade.csv", equipupgrade_meta_list);
|
||||
f8::ReadCsvMetaFile(res_path + "robot@robot.csv", robot_meta_list);
|
||||
f8::ReadCsvMetaFile(res_path + "ai@ai.csv", ai_meta_list);
|
||||
f8::ReadCsvMetaFile(res_path + "talent@talent.csv", talent_meta_list);
|
||||
f8::ReadCsvMetaFile(res_path + "fashion@fashion.csv", fashion_meta_list);
|
||||
BindToMetaData();
|
||||
#if 1
|
||||
{
|
||||
@ -489,6 +499,16 @@ private:
|
||||
if (meta._inventory_slot() > -1) {
|
||||
equip_slot_hash[meta._inventory_slot()] = &item;
|
||||
}
|
||||
|
||||
if (meta->equip_type() == 10) {
|
||||
if (!meta->atk().empty()) {
|
||||
skinatt_hash[item.i->id()][kHAT_Atk] = a8::XValue(meta->atk()).GetInt();
|
||||
}
|
||||
|
||||
if (!meta->max_hp().empty()) {
|
||||
skinatt_hash[item.i->id()][kHAT_MaxHp] = a8::XValue(meta->max_hp()).GetInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& meta : player_meta_list) {
|
||||
@ -616,6 +636,20 @@ private:
|
||||
item.Init();
|
||||
ai_hash[a8::MakeInt64(meta.ai_level(), meta.ai_mode())] = &item;
|
||||
}
|
||||
|
||||
for (auto& meta : talent_meta_list) {
|
||||
MetaData::Talent& item = a8::FastAppend(talent_list);
|
||||
item.i = &meta;
|
||||
item.Init();
|
||||
talent_hash[meta.talent_id()] = &item;
|
||||
}
|
||||
|
||||
for (auto& meta : fashion_meta_list) {
|
||||
MetaData::Fashion& item = a8::FastAppend(fashion_list);
|
||||
item.i = &meta;
|
||||
item.Init();
|
||||
fashion_hash[meta.id()] = &item;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
@ -848,3 +882,21 @@ MetaData::AI* MetaMgr::GetAI(int ai_level, int ai_mode)
|
||||
auto itr = loader_->ai_hash.find(a8::MakeInt64(ai_level, ai_mode));
|
||||
return itr != loader_->ai_hash.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
MetaData::Talent* MetaMgr::GetTalent(int talentid)
|
||||
{
|
||||
auto itr = loader_->talent_hash.find(talentid);
|
||||
return itr != loader_->talent_hash.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
MetaData::Fashion* MetaMgr::GetFashion(int fashionid)
|
||||
{
|
||||
auto itr = loader_->fashion_hash.find(fashionid);
|
||||
return itr != loader_->fashion_hash.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
std::array<float, kHAT_End>* MetaMgr::GetSkinAttr(int skinid)
|
||||
{
|
||||
auto itr = loader_->skinatt_hash.find(skinid);
|
||||
return itr != loader_->skinatt_hash.end() ? &(itr->second) : nullptr;
|
||||
}
|
||||
|
@ -49,6 +49,10 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
MetaData::Robot* RandRobot(std::set<int>& refreshed_robot_set);
|
||||
MetaData::AI* GetAI(int ai_level, int ai_mode);
|
||||
|
||||
MetaData::Talent* GetTalent(int talentid);
|
||||
MetaData::Fashion* GetFashion(int fashionid);
|
||||
std::array<float, kHAT_End>* GetSkinAttr(int skinid);
|
||||
|
||||
int gas_inactive_time = 10;
|
||||
int newbie_gas_inactive_time = 5;
|
||||
int midbrid_gas_inactive_time = 15;
|
||||
|
@ -582,6 +582,7 @@ void Player::LootInteraction(Loot* entity)
|
||||
a8::SetBitFlag(status, HS_AlreadyEquip);
|
||||
ProcNewBieLogic();
|
||||
}
|
||||
RecalcBaseAttr();
|
||||
}
|
||||
break;
|
||||
case EQUIP_TYPE_OLDSKIN:
|
||||
@ -592,6 +593,7 @@ void Player::LootInteraction(Loot* entity)
|
||||
case EQUIP_TYPE_SKIN:
|
||||
{
|
||||
ProcLootSkin(entity, item_meta);
|
||||
RecalcBaseAttr();
|
||||
}
|
||||
break;
|
||||
case EQUIP_TYPE_CAR:
|
||||
@ -885,6 +887,7 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google:
|
||||
add_num = curr_weapon->GetClipVolume();
|
||||
curr_weapon->ammo = add_num;
|
||||
}
|
||||
RecalcBaseAttr();
|
||||
}
|
||||
for (auto& spec_weapon : spec_weapons) {
|
||||
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(spec_weapon.weapon_id);
|
||||
|
@ -117,8 +117,8 @@ Player* PlayerMgr::CreatePlayerByCMJoin(Player* hum,
|
||||
hum->SetSkinInfo(msg.baseskin());
|
||||
#endif
|
||||
hum->maxtalent = msg.talent();
|
||||
hum->RecalTalentAttr();
|
||||
hum->RecalSkinAttr();
|
||||
hum->RecalcTalentAttr();
|
||||
hum->RecalcSkinAttr();
|
||||
|
||||
socket_hash_[socket] = hum;
|
||||
return hum;
|
||||
|
Loading…
x
Reference in New Issue
Block a user