Compare commits

...

45 Commits

Author SHA1 Message Date
06cd095e37 adjust 2025-05-04 11:53:25 +08:00
62816aeb7b adjust 2025-05-04 11:37:24 +08:00
315c7d57e4 add log 2025-05-04 11:16:34 +08:00
cae20c8783 fix 2025-04-23 15:48:24 +08:00
088b45189a fix talent 2025-04-20 23:09:00 +08:00
a89bf30f56 fix 2025-04-20 23:02:43 +08:00
cffcc9fe50 fix 2025-04-20 22:57:19 +08:00
6c8b349eb8 fix 2025-04-20 22:53:50 +08:00
094c6b58a0 talent & fashion 2025-04-20 22:41:36 +08:00
1ad105df3c talent & skin attr 2025-04-18 18:40:25 +08:00
ad47190220 adjust 2025-04-12 02:25:48 +08:00
9141ac81f9 adjust 2025-04-11 19:40:56 +08:00
bb5bb8bdb9 http->https 2025-01-02 19:28:32 +08:00
aozhiwei
983277ae4a 修复prepare_items 2021-01-28 16:43:07 +08:00
aozhiwei
85b9e474f3 1 2021-01-06 16:58:12 +08:00
aozhiwei
4e7ddfa237 添加连续加载子弹功能 2021-01-06 16:50:12 +08:00
aozhiwei
dfac21df80 1 2021-01-06 16:46:35 +08:00
aozhiwei
6a40f89ea4 添加战利品 2020-12-04 19:28:31 +08:00
aozhiwei
30551d587c 修复点射问题 2020-11-30 13:45:19 +08:00
aozhiwei
db16743f9a 添加公会信息 2020-11-19 16:48:30 +08:00
aozhiwei
ff0b198474 1 2020-11-18 19:28:05 +08:00
aozhiwei
aa84b1bf39 添加battleReportUrl自定义功能 2020-11-18 19:23:13 +08:00
aozhiwei
4ebeb286e9 修复切换坐骑子弹没更新问题 2020-10-21 10:31:15 +08:00
aozhiwei
f24e49355b 1 2020-09-02 19:46:13 +08:00
aozhiwei
881044b0b6 1 2020-09-02 19:11:02 +08:00
aozhiwei
13b65e9658 1 2020-09-02 14:02:18 +08:00
aozhiwei
24998d2f0d 1 2020-09-01 17:25:09 +08:00
aozhiwei
a1be31c98b 添加组队校验 2020-08-31 15:12:31 +08:00
aozhiwei
5012b4117d 1 2020-08-31 13:23:50 +08:00
aozhiwei
a067330169 1 2020-08-31 13:09:03 +08:00
aozhiwei
0b5b069153 1 2020-08-26 15:05:26 +08:00
aozhiwei
1f8ed08d76 1 2020-08-25 14:31:41 +08:00
aozhiwei
e27ca14710 1 2020-08-25 14:25:06 +08:00
aozhiwei
8d64947cec 1 2020-08-25 14:23:24 +08:00
aozhiwei
a1e6db3f91 修改配置文件读取路径 2020-08-25 14:03:58 +08:00
aozhiwei
8aa1eb88e7 1 2020-08-21 18:03:07 +08:00
aozhiwei
72bfc3bd73 1 2020-08-21 16:57:48 +08:00
aozhiwei
9a5d7b7ae2 1 2020-08-21 16:57:35 +08:00
aozhiwei
cde2d860c0 1 2020-08-21 15:43:09 +08:00
aozhiwei
cdf4acffd0 修复武器属性问题 2020-08-21 11:15:03 +08:00
aozhiwei
47e2112319 上报接口添加渠道判断 2020-08-20 16:59:34 +08:00
aozhiwei
41787f8d59 1 2020-08-20 15:47:54 +08:00
aozhiwei
d40e904b0a 头条版伪装无限使用 2020-08-20 15:45:31 +08:00
aozhiwei
4546e3ec20 头条不掉落时装 2020-08-20 13:22:10 +08:00
aozhiwei
2fab34b404 1 2020-08-19 20:12:18 +08:00
21 changed files with 747 additions and 40 deletions

3
.gitignore vendored
View File

@ -21,4 +21,5 @@ __pycache__
.user .user
game.py game.py
*.cxx *.cxx
compile_commands.json compile_commands.json
.vscode/settings.json

16
server/bin/restart.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
source /etc/profile
source /root/.bash_profile
pid=$(ps -ef|grep "gameserver2004 -n $2 -i $1"|grep -v grep|awk '{print $2}')
echo $pid
if [[ $pid != "" ]]
then
echo $pid|xargs kill -9
else
echo "pid 为空"
fi
nohup ./gameserver2004 -n $2 -i $1 >> gameserver2004$2_$1.out &

View File

@ -138,7 +138,8 @@ enum BuffEffectType_e
kBET_CliEffect1 = 19, //僵尸被动光环减速(客户端表现用) kBET_CliEffect1 = 19, //僵尸被动光环减速(客户端表现用)
kBET_CliEffect2 = 20, //僵尸被动光环毒物(客户端表现用) kBET_CliEffect2 = 20, //僵尸被动光环毒物(客户端表现用)
kBET_CliEffect3 = 21, //僵尸被动光环地震(客户端表现用) kBET_CliEffect3 = 21, //僵尸被动光环地震(客户端表现用)
kBET_CliEffect4 = 22, //被拖拽(客户端表现用) kBET_CliEffect4 = 22, //被拖拽(客户端表现用)
kBET_HunLuan = 23, //混乱,在烟雾弹中不自动瞄准
kBET_End kBET_End
}; };
@ -226,6 +227,7 @@ enum EquipType_e
EQUIP_TYPE_CAR = 9, EQUIP_TYPE_CAR = 9,
EQUIP_TYPE_SKIN = 10, EQUIP_TYPE_SKIN = 10,
EQUIP_TYPE_CAMOUFLAGE = 11, EQUIP_TYPE_CAMOUFLAGE = 11,
EQUIP_TYPE_SPOILS = 12,
EQUIP_TYPE_End EQUIP_TYPE_End
}; };
@ -324,7 +326,8 @@ enum ColliderTag_e
enum GameChannel_e enum GameChannel_e
{ {
kWxChannelId = 6001 kWxChannelId = 6001,
kTouTiaoChannelId = 6006
}; };
const char* const PROJ_NAME_FMT = "game%d_gameserver"; const char* const PROJ_NAME_FMT = "game%d_gameserver";

View File

@ -97,6 +97,8 @@ void HandlerMgr::RegisterNetMsgHandlers()
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMAdStart); RegisterNetMsgHandler(&ggmsghandler, &Player::_CMAdStart);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMAdCancel); RegisterNetMsgHandler(&ggmsghandler, &Player::_CMAdCancel);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMAdEnd); RegisterNetMsgHandler(&ggmsghandler, &Player::_CMAdEnd);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMGetBoxInfo);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMOpenBox);
} }
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle, void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,

View File

@ -23,6 +23,7 @@
#include "buff.h" #include "buff.h"
#include "roomobstacle.h" #include "roomobstacle.h"
#include "aicomponent.h" #include "aicomponent.h"
#include "jsondatamgr.h"
#include "framework/cpp/utils.h" #include "framework/cpp/utils.h"
#include "framework/cpp/httpclientpool.h" #include "framework/cpp/httpclientpool.h"
@ -135,12 +136,8 @@ void Human::Initialize()
RecalcSelfCollider(); RecalcSelfCollider();
volume_ = meta->volume; volume_ = meta->volume;
observers_.insert(this); observers_.insert(this);
ability.hp = meta->i->health(); RecalcMaxHp();
for (auto& weapon : spec_weapons) { ability.hp = ability.max_hp;
if (weapon.meta) {
ability.hp += weapon.meta ? weapon.GetAttrValue(kHAT_MaxHp) : 0;
}
}
} }
float Human::GetSpeed() float Human::GetSpeed()
@ -221,6 +218,9 @@ void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data
p->set_max_energy_shield(max_energy_shield); p->set_max_energy_shield(max_energy_shield);
} }
#endif #endif
if (guild_id != 0) {
p->set_guild_id(guild_id);
}
p->set_vip(vip); p->set_vip(vip);
p->set_sdmg(sdmg); p->set_sdmg(sdmg);
p->set_kill_count(stats.kills); p->set_kill_count(stats.kills);
@ -305,6 +305,9 @@ void Human::FillMFPlayerStats(cs::MFPlayerStats* stats_pb)
} }
stats_pb->set_account_id(account_id); stats_pb->set_account_id(account_id);
if (guild_id != 0) {
stats_pb->set_guild_id(guild_id);
}
for (auto& pair : stats.items) { for (auto& pair : stats.items) {
auto p = stats_pb->add_items(); auto p = stats_pb->add_items();
@ -377,6 +380,9 @@ void Human::FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over)
team_data->set_user_value1(user_value1); team_data->set_user_value1(user_value1);
team_data->set_user_value2(user_value2); team_data->set_user_value2(user_value2);
team_data->set_user_value3(user_value3); team_data->set_user_value3(user_value3);
if (guild_id != 0) {
team_data->set_guild_id(guild_id);
}
} }
} }
} }
@ -952,8 +958,17 @@ void Human::FillSMGameOver(cs::SMGameOver& msg)
} }
} }
} }
cs::MFPlayerStats* p = msg.add_player_stats(); {
FillMFPlayerStats(p); cs::MFPlayerStats* p = msg.add_player_stats();
FillMFPlayerStats(p);
}
{
for (auto& pair : spoils_items) {
auto p = msg.add_spoils_items();
p->add_values(pair.first);
p->add_values(pair.second);
}
}
} }
void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
@ -1551,7 +1566,9 @@ void Human::RecalcBaseAttr()
if (helmet_meta) { if (helmet_meta) {
ability.def += helmet_meta->i->def(); 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) int Human::GetInventory(int slot_id)
@ -1592,7 +1609,7 @@ void Human::RecoverHp(int inc_hp)
{ {
if (!dead) { if (!dead) {
ability.hp += inc_hp; ability.hp += inc_hp;
ability.hp = std::max(GetHP(), GetMaxHP()); ability.hp = std::min(GetHP(), GetMaxHP());
} }
} }
@ -2071,6 +2088,69 @@ bool Human::IsEnemy(Human* hum)
} }
} }
void Human::RecalcTalentAttr()
{
talent_attr_abs_ = {};
if (curr_weapon == nullptr)
{
return;
}
for(int i = 1;i <= maxtalent; i++)
{
auto talent = MetaMgr::Instance()->GetTalent(i);
if (talent->GetEquipLabel() == curr_weapon->meta->i->equip_label()) {
talent_attr_abs_[kHAT_Atk] += talent->GetAtkPlus();
talent_attr_abs_[kHAT_MaxHp] += talent->GetHpPlus();
}
}
}
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) void Human::_InternalUpdateMove(float speed)
{ {
float nx = move_dir.x * speed; float nx = move_dir.x * speed;
@ -2436,6 +2516,20 @@ void Human::GenZbModeBattleReportData(a8::MutableXObject* params)
void Human::DeadDrop() void Human::DeadDrop()
{ {
auto SkinCanDrop =
[this] (Skin* skin) -> bool
{
#ifdef DEBUG
return false;
#else
if (JsonDataMgr::Instance()->channel == kTouTiaoChannelId) {
return false;
} else {
return skin->skin_id != 0;
}
#endif
};
if (GetRace() == kHumanRace && !HasBuffEffect(kBET_Terminator)) { if (GetRace() == kHumanRace && !HasBuffEffect(kBET_Terminator)) {
for (auto& weapon : weapons) { for (auto& weapon : weapons) {
if (weapon.weapon_id != 0 && weapon.weapon_id != default_weapon.weapon_id) { if (weapon.weapon_id != 0 && weapon.weapon_id != default_weapon.weapon_id) {
@ -2449,7 +2543,7 @@ void Human::DeadDrop()
} }
{ {
Skin* old_skin = GetSkinByIdx(kSkinSlot_HAT); Skin* old_skin = GetSkinByIdx(kSkinSlot_HAT);
if (old_skin && old_skin->skin_id != 0) { if (old_skin && old_skin->skin_id != 0 && SkinCanDrop(old_skin)) {
a8::Vec2 dir = a8::Vec2::UP; a8::Vec2 dir = a8::Vec2::UP;
dir.Rotate(a8::RandAngle()); dir.Rotate(a8::RandAngle());
room->CreateLoot(old_skin->skin_id, GetPos() + dir * (40 + rand() % 50), 1, 1); room->CreateLoot(old_skin->skin_id, GetPos() + dir * (40 + rand() % 50), 1, 1);
@ -2458,7 +2552,7 @@ void Human::DeadDrop()
} }
{ {
Skin* old_skin = GetSkinByIdx(kSkinSlot_CLOTH); Skin* old_skin = GetSkinByIdx(kSkinSlot_CLOTH);
if (old_skin && old_skin->skin_id != 0) { if (old_skin && old_skin->skin_id != 0 && SkinCanDrop(old_skin)) {
a8::Vec2 dir = a8::Vec2::UP; a8::Vec2 dir = a8::Vec2::UP;
dir.Rotate(a8::RandAngle()); dir.Rotate(a8::RandAngle());
room->CreateLoot(old_skin->skin_id, GetPos() + dir * (40 + rand() % 50), 1, 1); room->CreateLoot(old_skin->skin_id, GetPos() + dir * (40 + rand() % 50), 1, 1);
@ -2514,11 +2608,33 @@ void Human::SendBattleReport()
if (App::Instance()->HasFlag(3)) { if (App::Instance()->HasFlag(3)) {
url = "http://192.168.100.41/webapp/index.php?c=Role&a=battleReport"; url = "http://192.168.100.41/webapp/index.php?c=Role&a=battleReport";
} else { } else {
url = "https://game2004api-test.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; if (JsonDataMgr::Instance()->channel != 0) {
url = a8::Format("https://game2004api-test.kingsome.cn/%d/webapp/index.php?c=Role&a=battleReport",
{
JsonDataMgr::Instance()->channel
});
} else {
url = "https://game2004api-test.kingsome.cn/webapp/index.php?c=Role&a=battleReport";
}
} }
} else { } else {
url = "http://game2004api.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; if (JsonDataMgr::Instance()->channel != 0) {
if (kTouTiaoChannelId == JsonDataMgr::Instance()->channel) {
url = a8::Format("https://game2004api-al.kingsome.cn/%d/webapp/index.php?c=Role&a=battleReport",
{
JsonDataMgr::Instance()->channel
});
} else {
url = a8::Format("https://game2004api.kingsome.cn/%d/webapp/index.php?c=Role&a=battleReport",
{
JsonDataMgr::Instance()->channel
});
}
} else {
url = "https://game2004api.kingsome.cn/webapp/index.php?c=Role&a=battleReport";
}
} }
JsonDataMgr::Instance()->GetBattleReportUrl(url);
std::string data; std::string data;
params->ToUrlEncodeStr(data); params->ToUrlEncodeStr(data);
f8::HttpClientPool::Instance()->HttpGet( f8::HttpClientPool::Instance()->HttpGet(
@ -2603,6 +2719,7 @@ void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta)
if (car_.meta->i->buffid()) { if (car_.meta->i->buffid()) {
RemoveBuffById(car_.meta->i->buffid()); RemoveBuffById(car_.meta->i->buffid());
} }
car_weapon = Weapon();
} }
car_.car_uniid = entity->GetEntityUniId(); car_.car_uniid = entity->GetEntityUniId();
car_.car_id = item_meta->i->id(); car_.car_id = item_meta->i->id();
@ -2623,6 +2740,16 @@ void Human::ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta)
AddItem(item_meta->i->id(), 1); AddItem(item_meta->i->id(), 1);
} }
void Human::ProcSpoils(Loot* entity, MetaData::Equip* item_meta)
{
if (spoils_items.find(item_meta->i->id()) !=
spoils_items.end()) {
spoils_items[item_meta->i->id()] += entity->count;
} else {
spoils_items[item_meta->i->id()] = entity->count;
}
}
void Human::FindLocationWithTarget(Entity* target) void Human::FindLocationWithTarget(Entity* target)
{ {
a8::Vec2 old_pos = GetPos(); a8::Vec2 old_pos = GetPos();
@ -3244,6 +3371,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; return attr_abs_val;
} }
@ -3948,14 +4079,10 @@ void Human::OnMetaChange()
curr_weapon = &weapons[0]; 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); room->frame_event.AddHpChg(this);
RecalcBaseAttr(); RecalcBaseAttr();
ability.hp = ability.max_hp;
skill_meta_ = MetaMgr::Instance()->GetSkill(meta->i->active_skill()); skill_meta_ = MetaMgr::Instance()->GetSkill(meta->i->active_skill());
ResetSkill(); ResetSkill();
MetaData::Skill* passive_skill_meta = MetaMgr::Instance()->GetSkill(meta->i->passive_skill()); MetaData::Skill* passive_skill_meta = MetaMgr::Instance()->GetSkill(meta->i->passive_skill());
@ -4036,13 +4163,34 @@ void Human::ProcReloadAction()
if (GetInventory(bullet_meta->i->_inventory_slot()) <= if (GetInventory(bullet_meta->i->_inventory_slot()) <=
p_weapon->GetClipVolume() - ammo) { p_weapon->GetClipVolume() - ammo) {
add_num = GetInventory(bullet_meta->i->_inventory_slot()); add_num = GetInventory(bullet_meta->i->_inventory_slot());
if (p_weapon->meta->i->reloadtype() == 1) {
add_num = 1;
}
DecInventory(bullet_meta->i->_inventory_slot(), add_num); DecInventory(bullet_meta->i->_inventory_slot(), add_num);
} else { } else {
add_num = p_weapon->GetClipVolume() - ammo; add_num = p_weapon->GetClipVolume() - ammo;
if (p_weapon->meta->i->reloadtype() == 1) {
add_num = 1;
}
DecInventory(bullet_meta->i->_inventory_slot(), add_num); DecInventory(bullet_meta->i->_inventory_slot(), add_num);
} }
p_weapon->ammo += add_num; p_weapon->ammo += add_num;
need_sync_active_player = true;; need_sync_active_player = true;
if (p_weapon->meta->i->reloadtype() == 1) {
room->xtimer.AddDeadLineTimerAndAttach
(1,
a8::XParams()
.SetSender(this)
.SetParam1(p_weapon->weapon_idx)
.SetParam2(p_weapon->weapon_id),
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->NextReload(param.param2, param.param1);
},
&xtimer_attacher.timer_list_
);
}
} }
} }
} }
@ -4050,3 +4198,19 @@ void Human::ProcReloadAction()
} }
} }
void Human::NextReload(int prev_weapon_id, int prev_weapon_idx)
{
if (action_type != AT_None) {
return;
}
Weapon* p_weapon = curr_weapon;
if (car_weapon.meta) {
p_weapon = &car_weapon;
}
if (p_weapon &&
p_weapon->weapon_id == prev_weapon_id &&
p_weapon->weapon_idx == prev_weapon_idx) {
AutoLoadingBullet(true);
}
}

View File

@ -44,6 +44,7 @@ class Human : public MoveableEntity
bool auto_fill = false; bool auto_fill = false;
int today_enter_times = 0; int today_enter_times = 0;
int account_registertime = 0; int account_registertime = 0;
int channel = 0;
MetaData::Player* meta = nullptr; MetaData::Player* meta = nullptr;
MetaData::Equip* helmet_meta = nullptr; MetaData::Equip* helmet_meta = nullptr;
MetaData::Equip* chest_meta = nullptr; MetaData::Equip* chest_meta = nullptr;
@ -61,6 +62,7 @@ class Human : public MoveableEntity
long long user_value1 = 0; long long user_value1 = 0;
long long user_value2 = 0; long long user_value2 = 0;
long long user_value3 = 0; long long user_value3 = 0;
long long guild_id = 0;
long long last_cmmove_frameno = 0; long long last_cmmove_frameno = 0;
bool downed = false; bool downed = false;
bool disconnected = false; bool disconnected = false;
@ -132,6 +134,7 @@ class Human : public MoveableEntity
Weapon grow_weapon; Weapon grow_weapon;
std::map<int, int> weapon_configs; std::map<int, int> weapon_configs;
std::map<int, int> skin_configs; std::map<int, int> skin_configs;
std::map<int, int> spoils_items;
bool use_skill = false; bool use_skill = false;
size_t curr_skill_phase = 0; size_t curr_skill_phase = 0;
@ -149,6 +152,8 @@ class Human : public MoveableEntity
int kill_times = 0; int kill_times = 0;
int rank = 0; int rank = 0;
int maxtalent = 0;
std::function<void(Human*)> on_grid_chg; std::function<void(Human*)> on_grid_chg;
Human(); Human();
@ -292,17 +297,23 @@ class Human : public MoveableEntity
void DeadDrop(); void DeadDrop();
bool IsEnemy(Human* hum); bool IsEnemy(Human* hum);
void RecalcTalentAttr();
void RecalcSkinAttr();
protected: protected:
void _InternalUpdateMove(float speed); void _InternalUpdateMove(float speed);
void ProcLootSkin(Loot* entity, MetaData::Equip* item_meta); void ProcLootSkin(Loot* entity, MetaData::Equip* item_meta);
void ProcLootCar(Loot* entity, MetaData::Equip* item_meta); void ProcLootCar(Loot* entity, MetaData::Equip* item_meta);
void ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta); void ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta);
void ProcSpoils(Loot* entity, MetaData::Equip* item_meta);
void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list); void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
Buff* GetBuffById(int buff_id); Buff* GetBuffById(int buff_id);
void ProcSkillPhase(MetaData::SkillPhase* phase); void ProcSkillPhase(MetaData::SkillPhase* phase);
void AutoChgWeapon(); void AutoChgWeapon();
void CancelRevive(); void CancelRevive();
void RecalcMaxHp();
private: private:
void ClearFrameData(); void ClearFrameData();
void GenBattleReportData(a8::MutableXObject* params); void GenBattleReportData(a8::MutableXObject* params);
@ -333,6 +344,7 @@ private:
void OnMetaChange(); void OnMetaChange();
void OnChgToTerminator(); void OnChgToTerminator();
void ProcReloadAction(); void ProcReloadAction();
void NextReload(int prev_weapon_id, int prev_weapon_idx);
protected: protected:
int level_ = 0; int level_ = 0;
@ -393,6 +405,8 @@ private:
std::array<float, kHAT_End> buff_attr_abs_ = {}; std::array<float, kHAT_End> buff_attr_abs_ = {};
std::array<float, kHAT_End> buff_attr_rate_ = {}; std::array<float, kHAT_End> buff_attr_rate_ = {};
std::array<float, kHAT_End> talent_attr_abs_ = {};
std::array<float, kHAT_End> skin_attr_abs_ = {};
std::array<ObjectSyncFlags, FIXED_OBJECT_MAXID> fixed_object_sync_flags_ = {}; std::array<ObjectSyncFlags, FIXED_OBJECT_MAXID> fixed_object_sync_flags_ = {};

View File

@ -24,14 +24,28 @@ void JsonDataMgr::Init()
}); });
} }
} }
std::string gameserver_cluster_json_file; std::string gameserver_cluster_json_file;
std::string setting_json_file;
gameserver_cluster_json_file = a8::Format("%s/node%d/game%d.gameserver.cluster.json", gameserver_cluster_json_file = a8::Format("%s/node%d/game%d.gameserver.cluster.json",
{ {
work_path_, work_path_,
App::Instance()->node_id, App::Instance()->node_id,
GAME_ID GAME_ID
}); });
setting_json_file = a8::Format("%s/game%d.gameserver.setting.json",
{
work_path_,
GAME_ID
});
gameserver_cluster_json_.ReadFromFile(gameserver_cluster_json_file); gameserver_cluster_json_.ReadFromFile(gameserver_cluster_json_file);
setting_json_.ReadFromFile(setting_json_file);
if (setting_json_.GetType() == a8::XOT_OBJECT &&
setting_json_.HasKey("battle_report_url")) {
battle_report_url_ = setting_json_.Get("battle_report_url").GetString();
}
ip = GetConf()->At("ip")->AsXValue().GetString(); ip = GetConf()->At("ip")->AsXValue().GetString();
listen_port = GetConf()->At("listen_port")->AsXValue(); listen_port = GetConf()->At("listen_port")->AsXValue();
if (GetConf()->HasKey("channel")) { if (GetConf()->HasKey("channel")) {
@ -39,6 +53,11 @@ void JsonDataMgr::Init()
} }
server_info = a8::Format("%s:%d", {ip, listen_port}); server_info = a8::Format("%s:%d", {ip, listen_port});
Reload(); Reload();
a8::UdpLog::Instance()->Info("battle_report_url:%s",
{
battle_report_url_
});
} }
void JsonDataMgr::UnInit() void JsonDataMgr::UnInit()
@ -47,10 +66,13 @@ void JsonDataMgr::UnInit()
std::shared_ptr<a8::XObject> JsonDataMgr::GetConf() std::shared_ptr<a8::XObject> JsonDataMgr::GetConf()
{ {
if (App::Instance()->instance_id < 1 || App::Instance()->instance_id > gameserver_cluster_json_.Size()) { for (int i = 0; i < gameserver_cluster_json_.Size(); ++i) {
abort(); std::shared_ptr<a8::XObject> conf = gameserver_cluster_json_.At(i);
if (conf->At("instance_id")->AsXValue().GetInt() == App::Instance()->instance_id) {
return conf;
}
} }
return gameserver_cluster_json_[App::Instance()->instance_id - 1]; abort();
} }
std::shared_ptr<a8::XObject> JsonDataMgr::GetMasterServerClusterConf() std::shared_ptr<a8::XObject> JsonDataMgr::GetMasterServerClusterConf()
@ -69,3 +91,10 @@ void JsonDataMgr::Reload()
}); });
masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file); masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file);
} }
void JsonDataMgr::GetBattleReportUrl(std::string& url)
{
if (!battle_report_url_.empty()) {
url = battle_report_url_;
}
}

View File

@ -19,9 +19,14 @@ public:
std::string server_info; std::string server_info;
void Reload(); void Reload();
void GetBattleReportUrl(std::string& url);
private:
std::string battle_report_url_;
private: private:
std::string work_path_ = "../config"; std::string work_path_ = "../config";
a8::XObject setting_json_;
a8::XObject gameserver_cluster_json_; a8::XObject gameserver_cluster_json_;
a8::XObject masterserver_cluster_json_; a8::XObject masterserver_cluster_json_;
}; };

View File

@ -95,7 +95,7 @@ namespace MetaData
void EquipUpgrade::Init() void EquipUpgrade::Init()
{ {
const int MAX_LV = 20; const int MAX_LV = 64;
for (int j = 0; j < MAX_LV; ++j) { for (int j = 0; j < MAX_LV; ++j) {
std::array<float, kHAT_End>& attrs = a8::FastAppend(level_attrs); std::array<float, kHAT_End>& attrs = a8::FastAppend(level_attrs);
for (size_t k = 0; k < kHAT_End; ++k) { for (size_t k = 0; k < kHAT_End; ++k) {
@ -104,8 +104,8 @@ namespace MetaData
} }
{ {
std::vector<std::string> strings; std::vector<std::string> strings;
if (!i->spera_type().empty()) { if (!i->spera_attr().empty()) {
a8::Split(i->spera_type(), strings, '|'); a8::Split(i->spera_attr(), strings, '|');
} else { } else {
a8::Split(i->attr_type(), strings, '|'); a8::Split(i->attr_type(), strings, '|');
} }
@ -580,4 +580,81 @@ namespace MetaData
); );
} }
void Talent::Init()
{
talentid = i->talent_id();
if (i->equip_label() > 0) {
equiplabel = i->equip_label();
hpplus = i->hp_upgrade();
} else {
equiplabel = i->equip_label2();
atkplus = i->atk_upgrade();
}
}
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];
}
}
} }

View File

@ -110,6 +110,7 @@ namespace MetaData
const metatable::Drop* i = nullptr; const metatable::Drop* i = nullptr;
void Init(); void Init();
//0:item_id 1:item_num 2:weight
void RandItems(std::vector<std::tuple<int, int, int>>& drop_items); void RandItems(std::vector<std::tuple<int, int, int>>& drop_items);
private: private:
@ -233,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 = {};
};
} }

View File

@ -63,6 +63,11 @@ public:
std::list<metatable::AI> ai_meta_list; std::list<metatable::AI> ai_meta_list;
std::list<MetaData::AI> ai_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<std::string, MetaData::Parameter*> parameter_hash;
std::map<int, MetaData::Map*> gamemap_hash; std::map<int, MetaData::Map*> gamemap_hash;
std::map<int, MetaData::AirDrop*> airdrop_hash; std::map<int, MetaData::AirDrop*> airdrop_hash;
@ -90,23 +95,28 @@ public:
std::map<int, MetaData::Robot*> robot_hash; std::map<int, MetaData::Robot*> robot_hash;
std::map<int, std::vector<MetaData::AirLine*>> airline_hash; std::map<int, std::vector<MetaData::AirLine*>> airline_hash;
std::map<int, MetaData::AI*> ai_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() void Load()
{ {
if (!f8::IsOnlineEnv()) { if (!f8::IsOnlineEnv()) {
if (f8::IsTestEnv()) { if (f8::IsTestEnv()) {
res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.test/res/", res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.test/res%d/",
{ {
GAME_ID, GAME_ID,
App::Instance()->instance_id, App::Instance()->instance_id,
GAME_ID GAME_ID,
App::Instance()->instance_id
}); });
} else { } else {
res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.dev/res/", res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.dev/res%d/",
{ {
GAME_ID, GAME_ID,
App::Instance()->instance_id, App::Instance()->instance_id,
GAME_ID GAME_ID,
App::Instance()->instance_id
}); });
} }
} else { } else {
@ -136,6 +146,8 @@ public:
f8::ReadCsvMetaFile(res_path + "equipUpgrade@equipUpgrade.csv", equipupgrade_meta_list); f8::ReadCsvMetaFile(res_path + "equipUpgrade@equipUpgrade.csv", equipupgrade_meta_list);
f8::ReadCsvMetaFile(res_path + "robot@robot.csv", robot_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 + "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(); BindToMetaData();
#if 1 #if 1
{ {
@ -201,6 +213,10 @@ public:
MetaMgr::Instance()->zbmode_player_num) { MetaMgr::Instance()->zbmode_player_num) {
abort(); abort();
} }
{
METAMGR_READ(prebattle_box_id_chiji, 0);
METAMGR_READ(prebattle_box_id_zb, 0);
}
{ {
METAMGR_READ(newbie_first_robot_ammo, 3); METAMGR_READ(newbie_first_robot_ammo, 3);
METAMGR_READ(newbie_first_robot_appeartime, 8); METAMGR_READ(newbie_first_robot_appeartime, 8);
@ -483,6 +499,12 @@ private:
if (meta._inventory_slot() > -1) { if (meta._inventory_slot() > -1) {
equip_slot_hash[meta._inventory_slot()] = &item; equip_slot_hash[meta._inventory_slot()] = &item;
} }
if (meta.equip_type() == 10) {
skinatt_hash[item.i->id()][kHAT_Atk] = meta.atk();
skinatt_hash[item.i->id()][kHAT_MaxHp] = meta.max_hp();
}
} }
for (auto& meta : player_meta_list) { for (auto& meta : player_meta_list) {
@ -610,6 +632,20 @@ private:
item.Init(); item.Init();
ai_hash[a8::MakeInt64(meta.ai_level(), meta.ai_mode())] = &item; 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: private:
@ -842,3 +878,21 @@ MetaData::AI* MetaMgr::GetAI(int ai_level, int ai_mode)
auto itr = loader_->ai_hash.find(a8::MakeInt64(ai_level, ai_mode)); auto itr = loader_->ai_hash.find(a8::MakeInt64(ai_level, ai_mode));
return itr != loader_->ai_hash.end() ? itr->second : nullptr; 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;
}

View File

@ -49,6 +49,10 @@ class MetaMgr : public a8::Singleton<MetaMgr>
MetaData::Robot* RandRobot(std::set<int>& refreshed_robot_set); MetaData::Robot* RandRobot(std::set<int>& refreshed_robot_set);
MetaData::AI* GetAI(int ai_level, int ai_mode); 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 gas_inactive_time = 10;
int newbie_gas_inactive_time = 5; int newbie_gas_inactive_time = 5;
int midbrid_gas_inactive_time = 15; int midbrid_gas_inactive_time = 15;
@ -134,6 +138,9 @@ class MetaMgr : public a8::Singleton<MetaMgr>
MetaData::Player* android_meta = nullptr; MetaData::Player* android_meta = nullptr;
MetaData::Player* terminator_meta = nullptr; MetaData::Player* terminator_meta = nullptr;
int prebattle_box_id_chiji = 0;
int prebattle_box_id_zb = 0;
private: private:
MetaDataLoader* loader_ = nullptr; MetaDataLoader* loader_ = nullptr;

View File

@ -284,6 +284,14 @@ void Player::UpdateUseItemId()
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(use_item_id); MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(use_item_id);
if (item_meta && item_meta->i->equip_type() == EQUIP_TYPE_CAMOUFLAGE) { if (item_meta && item_meta->i->equip_type() == EQUIP_TYPE_CAMOUFLAGE) {
int item_num = GetItemNum(use_item_id); int item_num = GetItemNum(use_item_id);
if (JsonDataMgr::Instance()->channel == kTouTiaoChannelId) {
item_num = 1;
}
#ifdef DEBUG
if (channel == kTouTiaoChannelId) {
item_num = 1;
}
#endif
if (item_num > 0) { if (item_num > 0) {
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(item_meta->i->buffid()); MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(item_meta->i->buffid());
if (buff_meta && !GetBuffById(item_meta->i->buffid())) { if (buff_meta && !GetBuffById(item_meta->i->buffid())) {
@ -574,6 +582,7 @@ void Player::LootInteraction(Loot* entity)
a8::SetBitFlag(status, HS_AlreadyEquip); a8::SetBitFlag(status, HS_AlreadyEquip);
ProcNewBieLogic(); ProcNewBieLogic();
} }
RecalcBaseAttr();
} }
break; break;
case EQUIP_TYPE_OLDSKIN: case EQUIP_TYPE_OLDSKIN:
@ -584,6 +593,7 @@ void Player::LootInteraction(Loot* entity)
case EQUIP_TYPE_SKIN: case EQUIP_TYPE_SKIN:
{ {
ProcLootSkin(entity, item_meta); ProcLootSkin(entity, item_meta);
RecalcBaseAttr();
} }
break; break;
case EQUIP_TYPE_CAR: case EQUIP_TYPE_CAR:
@ -596,6 +606,11 @@ void Player::LootInteraction(Loot* entity)
ProcCamoutflage(entity, item_meta); ProcCamoutflage(entity, item_meta);
} }
break; break;
case EQUIP_TYPE_SPOILS:
{
ProcSpoils(entity, item_meta);
}
break;
default: default:
{ {
if (item_meta->i->_inventory_slot() >= 0 && if (item_meta->i->_inventory_slot() >= 0 &&
@ -872,6 +887,7 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google:
add_num = curr_weapon->GetClipVolume(); add_num = curr_weapon->GetClipVolume();
curr_weapon->ammo = add_num; curr_weapon->ammo = add_num;
} }
RecalcBaseAttr();
} }
for (auto& spec_weapon : spec_weapons) { for (auto& spec_weapon : spec_weapons) {
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(spec_weapon.weapon_id); MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(spec_weapon.weapon_id);
@ -972,8 +988,13 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
if (moving) { if (moving) {
moved_frames = 0; moved_frames = 0;
} }
shot_start = msg.shot_start(); //前一个状态是纯点射
shot_hold = msg.shot_hold(); if (shot_start && !shot_hold) {
} else {
shot_start = msg.shot_start();
shot_hold = msg.shot_hold();
}
fly_distance = std::min(200.0f, msg.fly_distance()); fly_distance = std::min(200.0f, msg.fly_distance());
if (!shot_hold) { if (!shot_hold) {
series_shot_frames = 0; series_shot_frames = 0;
@ -1293,6 +1314,81 @@ void Player::_CMAdEnd(f8::MsgHdr& hdr, const cs::CMAdEnd& msg)
InternalAdOk(); InternalAdOk();
} }
void Player::_CMGetBoxInfo(f8::MsgHdr& hdr, const cs::CMGetBoxInfo& msg)
{
cs::SMGetBoxInfo respmsg;
respmsg.set_box_id(msg.box_id());
std::vector<std::tuple<int, int, int>>* items = GetBox(msg.box_id());
if (items) {
for (auto& tuple : *items) {
auto p = respmsg.add_items();
p->add_values(std::get<0>(tuple));
p->add_values(std::get<1>(tuple));
}
}
SendNotifyMsg(respmsg);
}
void Player::_CMOpenBox(f8::MsgHdr& hdr, const cs::CMOpenBox& msg)
{
cs::SMOpenBox respmsg;
respmsg.set_box_id(msg.box_id());
respmsg.set_errcode(0);
if (msg.box_id() == 1) {
if (receved_box_hash_.find(msg.box_id()) == receved_box_hash_.end()) {
std::vector<std::tuple<int, int, int>>* items = GetBox(msg.box_id());
if (items) {
for (auto& tuple : *items) {
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(std::get<0>(tuple));
if (item_meta) {
auto p = respmsg.add_items();
p->add_values(std::get<0>(tuple));
p->add_values(std::get<1>(tuple));
if (item_meta->i->_inventory_slot() >= 0 &&
item_meta->i->_inventory_slot() < IS_END) {
if (GetInventory(item_meta->i->_inventory_slot()) <
GetVolume(item_meta->i->_inventory_slot())) {
int add_num = GetVolume(item_meta->i->_inventory_slot()) -
GetInventory(item_meta->i->_inventory_slot());
add_num = std::min(std::get<1>(tuple), add_num);
AddInventory(item_meta->i->_inventory_slot(), add_num);
}
} else {
switch (item_meta->i->equip_type()) {
case 7:
{
//背包
if (backpack == 0) {
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(backpack);
if (old_item_meta) {
if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) {
break;
}
room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1);
}
backpack = item_meta->i->id();
RecalcVolume();
}
}
break;
default:
break;
}
}
}
}
need_sync_active_player = true;
}
receved_box_hash_.insert(msg.box_id());
} else {
respmsg.set_errcode(1);
respmsg.set_errmsg("不能重复领取");
}
}
SendNotifyMsg(respmsg);
}
void Player::InternalAdCancel() void Player::InternalAdCancel()
{ {
if (GetBuffByEffectId(kBET_AdPlaying)) { if (GetBuffByEffectId(kBET_AdPlaying)) {
@ -1371,3 +1467,32 @@ void Player::ProcPreSettlementInfo(const std::string& pre_settlement_info)
rank = a8::XValue(tmp_strings[3]); rank = a8::XValue(tmp_strings[3]);
} }
} }
std::vector<std::tuple<int, int, int>>* Player::GetBox(int box_id)
{
if (box_id != 1) {
return nullptr;
}
{
auto itr = box_hash_.find(box_id);
if (itr != box_hash_.end()) {
return &itr->second;
}
}
int drop_id = 0;
if (room->GetRoomMode() == kZombieMode) {
drop_id = MetaMgr::Instance()->prebattle_box_id_zb;
} else {
drop_id = MetaMgr::Instance()->prebattle_box_id_chiji;
}
MetaData::Drop* drop_meta = MetaMgr::Instance()->GetDrop(drop_id);
if (drop_meta) {
std::vector<std::tuple<int, int, int>> drop_items;
drop_meta->RandItems(drop_items);
box_hash_[box_id] = drop_items;
}
{
auto itr = box_hash_.find(box_id);
return itr != box_hash_.end() ? &itr->second : nullptr;
}
}

View File

@ -101,6 +101,8 @@ class Player : public Human
void _CMAdStart(f8::MsgHdr& hdr, const cs::CMAdStart& msg); void _CMAdStart(f8::MsgHdr& hdr, const cs::CMAdStart& msg);
void _CMAdCancel(f8::MsgHdr& hdr, const cs::CMAdCancel& msg); void _CMAdCancel(f8::MsgHdr& hdr, const cs::CMAdCancel& msg);
void _CMAdEnd(f8::MsgHdr& hdr, const cs::CMAdEnd& msg); void _CMAdEnd(f8::MsgHdr& hdr, const cs::CMAdEnd& msg);
void _CMGetBoxInfo(f8::MsgHdr& hdr, const cs::CMGetBoxInfo& msg);
void _CMOpenBox(f8::MsgHdr& hdr, const cs::CMOpenBox& msg);
protected: protected:
Player(); Player();
@ -109,6 +111,11 @@ private:
void InternalAdCancel(); void InternalAdCancel();
void InternalAdOk(); void InternalAdOk();
void InternalUpdate(int delta_time); void InternalUpdate(int delta_time);
std::vector<std::tuple<int, int, int>>* GetBox(int box_id);
private:
std::map<int, std::vector<std::tuple<int, int, int>>> box_hash_;
std::set<int> receved_box_hash_;
friend class EntityFactory; friend class EntityFactory;
}; };

View File

@ -63,6 +63,7 @@ Player* PlayerMgr::CreatePlayerByCMJoin(Player* hum,
hum->today_enter_times = msg.today_enter_times(); hum->today_enter_times = msg.today_enter_times();
hum->create_tick = a8::XGetTickCount(); hum->create_tick = a8::XGetTickCount();
hum->account_registertime = f8::ExtractRegisterTimeFromSessionId(msg.session_id()); hum->account_registertime = f8::ExtractRegisterTimeFromSessionId(msg.session_id());
hum->channel = f8::ExtractChannelIdFromAccountId(msg.account_id());
hum->atk_add = msg.atk_add(); hum->atk_add = msg.atk_add();
hum->emoji1 = msg.emoji1(); hum->emoji1 = msg.emoji1();
hum->emoji2 = msg.emoji2(); hum->emoji2 = msg.emoji2();
@ -71,6 +72,7 @@ Player* PlayerMgr::CreatePlayerByCMJoin(Player* hum,
hum->user_value1 = msg.user_value1(); hum->user_value1 = msg.user_value1();
hum->user_value2 = msg.user_value2(); hum->user_value2 = msg.user_value2();
hum->user_value3 = msg.user_value3(); hum->user_value3 = msg.user_value3();
hum->guild_id = msg.guild_id();
#if 0 #if 0
if (hum->atk_add > 0.9999f) { if (hum->atk_add > 0.9999f) {
hum->atk_add = hum->atk_add / 100.0f; hum->atk_add = hum->atk_add / 100.0f;
@ -114,6 +116,10 @@ Player* PlayerMgr::CreatePlayerByCMJoin(Player* hum,
#else #else
hum->SetSkinInfo(msg.baseskin()); hum->SetSkinInfo(msg.baseskin());
#endif #endif
hum->maxtalent = msg.talent();
hum->RecalcTalentAttr();
hum->RecalcSkinAttr();
socket_hash_[socket] = hum; socket_hash_[socket] = hum;
return hum; return hum;
} }

View File

@ -2731,7 +2731,8 @@ void Room::AddPlayerPostProc(Player* hum)
{ {
Human* hum = (Human*)param.sender.GetUserData(); Human* hum = (Human*)param.sender.GetUserData();
std::string debugmsg = a8::Format("weapon_id:%d weapon_lv:%d atk:%f fire_rate:%f " std::string debugmsg = a8::Format("weapon_id:%d weapon_lv:%d atk:%f fire_rate:%f "
"volume:%d maxhp:%f curr_hp:%f", "volume:%d maxhp:%f hp:%f curr_hp:%f curr_max_hp:%f "
"base_reload_time:%f grow_reload_time:%f finaly_reload_time:%f",
{ {
hum->curr_weapon->weapon_id, hum->curr_weapon->weapon_id,
hum->curr_weapon->weapon_lv, hum->curr_weapon->weapon_lv,
@ -2739,7 +2740,14 @@ void Room::AddPlayerPostProc(Player* hum)
hum->curr_weapon->GetAttrValue(kHAT_FireRate), hum->curr_weapon->GetAttrValue(kHAT_FireRate),
hum->curr_weapon->GetAttrValue(kHAT_Volume), hum->curr_weapon->GetAttrValue(kHAT_Volume),
hum->curr_weapon->GetAttrValue(kHAT_MaxHp), hum->curr_weapon->GetAttrValue(kHAT_MaxHp),
hum->GetHP() hum->curr_weapon->GetAttrValue(kHAT_Hp),
hum->GetHP(),
hum->GetMaxHP(),
hum->curr_weapon->meta->i->reload_time(),
hum->curr_weapon->GetUpgradeMeta() ?
hum->curr_weapon->GetUpgradeMeta()->GetAttrValue
(hum->curr_weapon->weapon_lv, kHAT_ReloadTime) : 0,
hum->curr_weapon->GetAttrValue(kHAT_ReloadTime)
}); });
hum->SendDebugMsg(debugmsg); hum->SendDebugMsg(debugmsg);
}, },

View File

@ -162,9 +162,9 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
); );
hum->meta = MetaMgr::Instance()->human_meta; hum->meta = MetaMgr::Instance()->human_meta;
hum->room = room; hum->room = room;
room->AddPlayer(hum);
hum->ProcPrepareItems(msg.prepare_items()); hum->ProcPrepareItems(msg.prepare_items());
hum->ProcPrepareItems2(msg.prepare_items2()); hum->ProcPrepareItems2(msg.prepare_items2());
room->AddPlayer(hum);
PlayerMgr::Instance()->IncAccountNum(msg.account_id()); PlayerMgr::Instance()->IncAccountNum(msg.account_id());
if (JsonDataMgr::Instance()->channel != 0 && if (JsonDataMgr::Instance()->channel != 0 &&
JsonDataMgr::Instance()->channel != channel) { JsonDataMgr::Instance()->channel != channel) {
@ -175,6 +175,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
msg.account_id() msg.account_id()
}); });
} }
OnJoinRoomOk(msg, hum);
} }
void RoomMgr::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg) void RoomMgr::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
@ -544,3 +545,100 @@ bool RoomMgr::IsGM(const std::string& account_id)
{ {
return gm_hash_.find(account_id) != gm_hash_.end(); return gm_hash_.find(account_id) != gm_hash_.end();
} }
std::string RoomMgr::GenTeamHashData(const std::string& team_uuid, std::map<std::string, long long>* team_hash)
{
std::string data;
data += a8::Format("team_uuid:%s ", {team_uuid});
for (auto pair : *team_hash) {
data += a8::Format("%s->%d ", {pair.first, pair.second});
}
return data;
}
void RoomMgr::OnJoinRoomOk(const cs::CMJoin& msg, Player* hum)
{
a8::UdpLog::Instance()->Info
("join room ok: %s,%s,%d",
{
hum->account_id,
msg.team_uuid(),
hum->room->GetRoomUuid()
});
if (msg.team_members().size() <= 1) {
return;
}
std::map<std::string, long long>* team_hash = nullptr;
{
auto itr = team_room_hash_.find(msg.team_uuid());
if (itr == team_room_hash_.end()) {
team_room_hash_[msg.team_uuid()] = std::map<std::string, long long>();
itr = team_room_hash_.find(msg.team_uuid());
team_hash = &itr->second;
for (auto& team_member : msg.team_members()) {
team_hash->insert(std::make_pair(team_member.account_id(), 0));
}
a8::Timer::Instance()->AddDeadLineTimer
(1000 * 60,
a8::XParams()
.SetSender(msg.team_uuid()),
[] (const a8::XParams& params)
{
RoomMgr::Instance()->TeamRoomTimeOut(params.sender);
}
);
} else {
team_hash = &itr->second;
}
}
if (!team_hash) {
abort();
}
{
auto itr = team_hash->find(hum->account_id);
if (itr != team_hash->end()) {
itr->second = hum->room->GetRoomUuid();
} else {
a8::UdpLog::Instance()->Warning
("team_data:%s account_id:%s not exists",
{
GenTeamHashData(msg.team_uuid(), team_hash),
hum->account_id
});
}
}
}
void RoomMgr::TeamRoomTimeOut(const std::string& team_uuid)
{
std::map<std::string, long long>* team_hash = nullptr;
{
auto itr = team_room_hash_.find(team_uuid);
if (itr != team_room_hash_.end()) {
team_hash = &itr->second;
}
}
if (team_hash) {
bool ok = true;
for (auto pair : *team_hash) {
if (pair.second == 0) {
ok = false;
break;
}
}
if (!ok) {
a8::UdpLog::Instance()->Warning
("team match failed team_data:%s ",
{
GenTeamHashData(team_uuid, team_hash),
});
}
team_room_hash_.erase(team_uuid);
} else {
a8::UdpLog::Instance()->Warning
("team not found team_uuid:s",
{
team_uuid
});
}
}

View File

@ -53,6 +53,9 @@ class RoomMgr : public a8::Singleton<RoomMgr>
int creator_proto_version, int creator_proto_version,
int creator_channel); int creator_channel);
void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle); void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle);
std::string GenTeamHashData(const std::string& team_uuid, std::map<std::string, long long>* team_hash);
void OnJoinRoomOk(const cs::CMJoin& msg, Player* hum);
void TeamRoomTimeOut(const std::string& team_uuid);
private: private:
int current_room_idx_ = 0; int current_room_idx_ = 0;
@ -63,4 +66,5 @@ class RoomMgr : public a8::Singleton<RoomMgr>
std::map<long long, Room*> over_room_hash_; std::map<long long, Room*> over_room_hash_;
a8::TimerAttacher reportstate_timer_attacher_; a8::TimerAttacher reportstate_timer_attacher_;
std::map<std::string, int> gm_hash_; std::map<std::string, int> gm_hash_;
std::map<std::string, std::map<std::string, long long>> team_room_hash_;
}; };

View File

@ -18,6 +18,8 @@ enum CMMessageId_e
_CMAdStart = 212; _CMAdStart = 212;
_CMAdCancel = 213; _CMAdCancel = 213;
_CMAdEnd = 214; _CMAdEnd = 214;
_CMGetBoxInfo = 215;
_CMOpenBox = 216;
} }
enum SMMessageId_e enum SMMessageId_e
@ -28,6 +30,8 @@ enum SMMessageId_e
_SMWatchWar = 208; _SMWatchWar = 208;
_SMLeave = 209; _SMLeave = 209;
_SMGetBoxInfo = 216;
_SMOpenBox = 217;
_SMJoinedNotify = 103; _SMJoinedNotify = 103;
_SMMapInfo = 1002; _SMMapInfo = 1002;

View File

@ -187,6 +187,7 @@ message MFPlayerFull
optional int32 obj_uniid = 1; //id optional int32 obj_uniid = 1; //id
optional MFVec2 pos = 2; // optional MFVec2 pos = 2; //
optional MFVec2 dir = 3; // optional MFVec2 dir = 3; //
optional int64 guild_id = 4; //id
optional float max_health = 5; // optional float max_health = 5; //
optional float health = 6; // optional float health = 6; //
@ -527,6 +528,7 @@ message MFTeamData
optional int64 user_value1 = 31; //user_value1 optional int64 user_value1 = 31; //user_value1
optional int64 user_value2 = 32; //user_value2 optional int64 user_value2 = 32; //user_value2
optional int64 user_value3 = 33; //user_value3 optional int64 user_value3 = 33; //user_value3
optional int64 guild_id = 34; //id
} }
// //
@ -612,6 +614,7 @@ message MFPlayerStats
optional string killer_account_id = 42; //accountid() optional string killer_account_id = 42; //accountid()
optional string account_id = 21; //id optional string account_id = 21; //id
optional int64 guild_id = 22; //id
} }
// //
@ -732,9 +735,11 @@ message CMJoin
optional int64 user_value1 = 31; //user_value1 optional int64 user_value1 = 31; //user_value1
optional int64 user_value2 = 32; //user_value2 optional int64 user_value2 = 32; //user_value2
optional int64 user_value3 = 33; //user_value3 optional int64 user_value3 = 33; //user_value3
optional int64 guild_id = 34; //id
optional bool force_entry_newbie_room = 50; // optional bool force_entry_newbie_room = 50; //
repeated MFTeamMember team_members = 51; // repeated MFTeamMember team_members = 51; //
optional int32 room_mode = 52; //0: 1: optional int32 room_mode = 52; //0: 1:
optional int32 talent = 53; //max id
} }
//线 //线
@ -857,6 +862,18 @@ message CMAdEnd
optional int32 param = 1; //1: 2 optional int32 param = 1; //1: 2
} }
//
message CMGetBoxInfo
{
optional int32 box_id = 1; //1
}
//
message CMOpenBox
{
optional int32 box_id = 1; //1:
}
//endcmmsg //endcmmsg
//error_code == 0 , //error_code == 0 ,
@ -952,6 +969,7 @@ message SMGameOver
repeated MFPlayerStats player_stats = 6; // repeated MFPlayerStats player_stats = 6; //
optional string room_uuid = 7; //id optional string room_uuid = 7; //id
repeated MFTeamData team_data = 10; // repeated MFTeamData team_data = 10; //
repeated MFTuple spoils_items = 11; // 0: id 1:
} }
// //
@ -959,6 +977,22 @@ message SMLeave
{ {
} }
//
message SMGetBoxInfo
{
optional int32 box_id = 1; //1
repeated MFTuple items = 2; //values[0]:id values[1]:
}
//
message SMOpenBox
{
optional int32 box_id = 1; //1:
optional int32 errcode = 2; //
optional string errmsg = 3; //
repeated MFTuple items = 4; //values[0]:id values[1]:
}
//线 //线
message SMDisconnectNotify message SMDisconnectNotify
{ {

View File

@ -95,6 +95,8 @@ message Equip
optional int32 drop_id = 40; optional int32 drop_id = 40;
optional int32 explosion_effect = 42; optional int32 explosion_effect = 42;
optional string param1 = 43; optional string param1 = 43;
optional int32 reloadtype = 46;
optional int32 equip_label = 47;
optional string inventory_slot = 31; // optional string inventory_slot = 31; //
optional int32 _inventory_slot = 32; // optional int32 _inventory_slot = 32; //
@ -104,7 +106,7 @@ message EquipUpgrade
{ {
optional int32 id = 1; optional int32 id = 1;
optional string attr_type = 4; optional string attr_type = 4;
optional string spera_type = 5; optional string spera_attr = 5;
} }
message Player message Player
@ -337,4 +339,22 @@ message MapTplThingJson
optional float param3 = 11; optional float param3 = 11;
optional string object_type = 12; optional string object_type = 12;
optional int32 _object_type = 13; optional int32 _object_type = 13;
}
message Talent
{
optional int32 talent_id = 1;
optional string name = 2;
optional int32 hp_upgrade = 3;
optional int32 equip_label = 4;
optional int32 atk_upgrade = 5;
optional int32 equip_label2 = 6;
}
message Fashion
{
optional int32 id = 1;
optional string name = 2;
optional string item_id = 3;
optional string spera_attr = 4;
} }