添加皮肤处理
This commit is contained in:
parent
c03bcd4da7
commit
ab22a18bb0
@ -184,7 +184,10 @@ enum EquipAttr_e
|
|||||||
|
|
||||||
enum EquipType_e
|
enum EquipType_e
|
||||||
{
|
{
|
||||||
|
EQUIP_TYPE_WEAPON = 1,
|
||||||
|
EQUIP_TYPE_OLDSKIN = 8,
|
||||||
EQUIP_TYPE_CAR = 9,
|
EQUIP_TYPE_CAR = 9,
|
||||||
|
EQUIP_TYPE_SKIN = 10,
|
||||||
EQUIP_TYPE_End
|
EQUIP_TYPE_End
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -232,6 +235,12 @@ enum MapObjectType_e
|
|||||||
kMOT_SpawnPoint = 2
|
kMOT_SpawnPoint = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum SkinSlot_e
|
||||||
|
{
|
||||||
|
kSkinSlot_CLOTH = 1,
|
||||||
|
kSkinSlot_HAT = 2,
|
||||||
|
};
|
||||||
|
|
||||||
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
||||||
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "framework/cpp/httpclientpool.h"
|
#include "framework/cpp/httpclientpool.h"
|
||||||
|
|
||||||
const int kReviveTimeAdd = 12;
|
const int kReviveTimeAdd = 12;
|
||||||
|
const int kSkinNum = 4;
|
||||||
|
|
||||||
Human::Human():Entity()
|
Human::Human():Entity()
|
||||||
{
|
{
|
||||||
@ -44,6 +45,11 @@ Human::Human():Entity()
|
|||||||
weapon.weapon_lv = 0;
|
weapon.weapon_lv = 0;
|
||||||
weapon.ammo = 0;
|
weapon.ammo = 0;
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < kSkinNum; ++i) {
|
||||||
|
Skin& skin = a8::FastAppend(skins);
|
||||||
|
skin.skin_id = 0;
|
||||||
|
skin.skin_lv = 1;
|
||||||
|
}
|
||||||
weapons[0] = default_weapon;
|
weapons[0] = default_weapon;
|
||||||
curr_weapon = &weapons[0];
|
curr_weapon = &weapons[0];
|
||||||
inventory_[IS_1XSCOPE] = 1;
|
inventory_[IS_1XSCOPE] = 1;
|
||||||
@ -86,7 +92,7 @@ float Human::GetSpeed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (aiming) {
|
} else if (aiming) {
|
||||||
return meta->i->aiming_speed();
|
return std::max(1, meta->i->aiming_speed());
|
||||||
}
|
}
|
||||||
float speed = meta->i->move_speed();
|
float speed = meta->i->move_speed();
|
||||||
speed = (speed + buff_attr_abs_[kHAT_Speed]) * (1 + buff_attr_rate_[kHAT_Speed]);
|
speed = (speed + buff_attr_abs_[kHAT_Speed]) * (1 + buff_attr_rate_[kHAT_Speed]);
|
||||||
@ -2173,7 +2179,7 @@ void Human::SendBattleReport()
|
|||||||
delete params;
|
delete params;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta)
|
void Human::ProcLootOldSkin(Loot* entity, MetaData::Equip* item_meta)
|
||||||
{
|
{
|
||||||
auto oil_sync_func =
|
auto oil_sync_func =
|
||||||
[] (const a8::XParams& param)
|
[] (const a8::XParams& param)
|
||||||
@ -2254,6 +2260,44 @@ void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta)
|
||||||
|
{
|
||||||
|
switch (item_meta->i->equip_subtype()) {
|
||||||
|
case 11:
|
||||||
|
{
|
||||||
|
//装饰
|
||||||
|
Skin* old_skin = GetSkinByIdx(kSkinSlot_HAT);
|
||||||
|
if (old_skin) {
|
||||||
|
a8::Vec2 dir = a8::Vec2::UP;
|
||||||
|
dir.Rotate(a8::RandAngle());
|
||||||
|
room->CreateLoot(old_skin->skin_id, GetPos() + dir * (40 + rand() % 50), 1, 1);
|
||||||
|
|
||||||
|
*old_skin = Skin();
|
||||||
|
old_skin->skin_id = item_meta->i->id();
|
||||||
|
old_skin->skin_lv = 1;
|
||||||
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
{
|
||||||
|
//衣服
|
||||||
|
Skin* old_skin = GetSkinByIdx(kSkinSlot_CLOTH);
|
||||||
|
if (old_skin) {
|
||||||
|
a8::Vec2 dir = a8::Vec2::UP;
|
||||||
|
dir.Rotate(a8::RandAngle());
|
||||||
|
room->CreateLoot(old_skin->skin_id, GetPos() + dir * (40 + rand() % 50), 1, 1);
|
||||||
|
|
||||||
|
*old_skin = Skin();
|
||||||
|
old_skin->skin_id = item_meta->i->id();
|
||||||
|
old_skin->skin_lv = 1;
|
||||||
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta)
|
void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta)
|
||||||
{
|
{
|
||||||
if (downed) {
|
if (downed) {
|
||||||
@ -2413,24 +2457,42 @@ void Human::FreeReviveTimer()
|
|||||||
void Human::RandSkin()
|
void Human::RandSkin()
|
||||||
{
|
{
|
||||||
std::vector<int> ids = {1, 2, 3, 4, 5, 6};
|
std::vector<int> ids = {1, 2, 3, 4, 5, 6};
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < kSkinNum; ++i) {
|
||||||
int rand_idx = rand() % ids.size();
|
int rand_idx = rand() % ids.size();
|
||||||
Skin& skin = a8::FastAppend(skins);
|
int skin_id = ids[rand_idx];
|
||||||
|
if (skin_id == 2) {
|
||||||
|
skin_id = 13001 + rand(6);
|
||||||
|
} else if (skin_id == 3) {
|
||||||
|
skin_id = 15001 + rand(6);
|
||||||
|
}
|
||||||
|
Skin& skin = skins[i];
|
||||||
skin.skin_id = ids[rand_idx];
|
skin.skin_id = ids[rand_idx];
|
||||||
skin.skin_lv = 1;
|
skin.skin_lv = 1;
|
||||||
ids.erase(ids.begin() + rand_idx);
|
ids.erase(ids.begin() + rand_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::AddSkin(int skin_id)
|
void Human::SetSkin(int idx, int skin_id)
|
||||||
{
|
{
|
||||||
if (skins.size() < 4) {
|
if (idx < kSkinNum) {
|
||||||
Skin& skin = a8::FastAppend(skins);
|
Skin& skin = skins[idx];
|
||||||
skin.skin_id = skin_id;
|
skin.skin_id = skin_id;
|
||||||
skin.skin_lv = 1;
|
skin.skin_lv = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Skin* Human::GetSkinByIdx(int idx)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
for (auto& skin : skins) {
|
||||||
|
if (i == idx) {
|
||||||
|
return &skin;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
MetaData::Skill* Human::CurrentSkillMeta()
|
MetaData::Skill* Human::CurrentSkillMeta()
|
||||||
{
|
{
|
||||||
return skill_meta_;
|
return skill_meta_;
|
||||||
|
@ -219,7 +219,8 @@ class Human : public Entity
|
|||||||
void FreeDownedTimer();
|
void FreeDownedTimer();
|
||||||
void FreeReviveTimer();
|
void FreeReviveTimer();
|
||||||
void RandSkin();
|
void RandSkin();
|
||||||
void AddSkin(int skin_id);
|
void SetSkin(int idx, int skin_id);
|
||||||
|
Skin* GetSkinByIdx(int idx);
|
||||||
MetaData::Skill* CurrentSkillMeta();
|
MetaData::Skill* CurrentSkillMeta();
|
||||||
int GetSkillLeftTime();
|
int GetSkillLeftTime();
|
||||||
int GetSkillCd();
|
int GetSkillCd();
|
||||||
@ -241,6 +242,7 @@ class Human : public Entity
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _UpdateMove(int speed);
|
void _UpdateMove(int speed);
|
||||||
|
void ProcLootOldSkin(Loot* entity, MetaData::Equip* item_meta);
|
||||||
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 ResetTankSkin();
|
void ResetTankSkin();
|
||||||
@ -311,7 +313,7 @@ private:
|
|||||||
bool sent_battlereport_ = false;
|
bool sent_battlereport_ = false;
|
||||||
bool sent_game_end_ = false;
|
bool sent_game_end_ = false;
|
||||||
|
|
||||||
std::list<Skin> skins;
|
std::vector<Skin> skins;
|
||||||
|
|
||||||
friend class FrameMaker;
|
friend class FrameMaker;
|
||||||
friend class FrameEvent;
|
friend class FrameEvent;
|
||||||
|
@ -513,7 +513,7 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (item_meta->i->equip_type()) {
|
switch (item_meta->i->equip_type()) {
|
||||||
case 1:
|
case EQUIP_TYPE_WEAPON:
|
||||||
{
|
{
|
||||||
//装备
|
//装备
|
||||||
if (item_meta->i->equip_subtype() == 1) {
|
if (item_meta->i->equip_subtype() == 1) {
|
||||||
@ -569,7 +569,12 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case EQUIP_TYPE_OLDSKIN:
|
||||||
|
{
|
||||||
|
ProcLootOldSkin(entity, item_meta);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EQUIP_TYPE_SKIN:
|
||||||
{
|
{
|
||||||
ProcLootSkin(entity, item_meta);
|
ProcLootSkin(entity, item_meta);
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,12 @@ Player* PlayerMgr::CreatePlayerByCMJoin(long ip_saddr, int socket, const cs::CMJ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 1
|
#if 1
|
||||||
for (int skin_id : msg.baseskin()) {
|
{
|
||||||
hum->AddSkin(skin_id);
|
int idx = 0;
|
||||||
|
for (int skin_id : msg.baseskin()) {
|
||||||
|
hum->SetSkin(idx, skin_id);
|
||||||
|
++idx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
hum->SetSkinInfo(msg.baseskin());
|
hum->SetSkinInfo(msg.baseskin());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user