1
This commit is contained in:
parent
9d3ee41f77
commit
731417119f
@ -20,6 +20,7 @@ class Ability;
|
||||
class Bullet : public MoveableEntity
|
||||
{
|
||||
public:
|
||||
std::string weapon_uniid;
|
||||
int gun_lv = 0;
|
||||
MetaData::Equip* gun_meta = nullptr;
|
||||
MetaData::EquipUpgrade* gun_upgrade_meta = nullptr;
|
||||
@ -42,6 +43,8 @@ class Bullet : public MoveableEntity
|
||||
float GetExplosionRange();
|
||||
bool IsCurrWeapon();
|
||||
bool IsPreBattleBullet();
|
||||
/*void CalcDmg(Entity* entity, float& finaly_dmg,
|
||||
);*/
|
||||
|
||||
protected:
|
||||
Bullet();
|
||||
|
@ -16,6 +16,7 @@
|
||||
struct BulletInfo
|
||||
{
|
||||
CreatureWeakPtr c;
|
||||
long long weapon_uniid = 0;
|
||||
MetaData::Equip* weapon_meta = nullptr;
|
||||
MetaData::EquipUpgrade* weapon_upgrade_meta = nullptr;
|
||||
MetaData::Equip* bullet_meta = nullptr;
|
||||
@ -74,7 +75,8 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
||||
bullet_info.bullet_born_pos,
|
||||
bullet_info.bullet_dir,
|
||||
bullet_info.fly_distance,
|
||||
bullet_info.is_tank_skin);
|
||||
bullet_info.is_tank_skin,
|
||||
bullet_info.weapon_uniid);
|
||||
#ifdef DEBUG
|
||||
if (bullet_info.c.Get()->IsPlayer()) {
|
||||
bullet_info.c.Get()->SendDebugMsg(a8::Format("CreateBullet id:%d",
|
||||
@ -125,7 +127,8 @@ void InternalShot(Creature* c,
|
||||
int weapon_lv,
|
||||
int skill_id,
|
||||
float fly_distance,
|
||||
bool is_tank_skin)
|
||||
bool is_tank_skin,
|
||||
long long weapon_uniid)
|
||||
{
|
||||
if (weapon_meta->i->_inventory_slot() == IS_TRAP ||
|
||||
weapon_meta->i->_inventory_slot() == IS_MINE) {
|
||||
@ -204,6 +207,7 @@ void InternalShot(Creature* c,
|
||||
{
|
||||
BulletInfo bullet_info;
|
||||
bullet_info.c = c->GetWeakPtrRef();
|
||||
bullet_info.weapon_uniid = weapon_uniid;
|
||||
bullet_info.weapon_meta = weapon_meta;
|
||||
bullet_info.weapon_upgrade_meta = weapon_upgrade_meta;
|
||||
bullet_info.bullet_meta = bullet_meta;
|
||||
@ -1029,7 +1033,8 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
|
||||
1,
|
||||
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
|
||||
target_distance,
|
||||
false);
|
||||
false,
|
||||
0);
|
||||
SetAttackDir(old_attack_dir);
|
||||
}
|
||||
}
|
||||
@ -1051,7 +1056,8 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
|
||||
1,
|
||||
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
|
||||
target_distance,
|
||||
false);
|
||||
false,
|
||||
0);
|
||||
SetAttackDir(old_attack_dir);
|
||||
}
|
||||
}
|
||||
@ -1702,7 +1708,8 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
|
||||
GetCurrWeapon()->weapon_lv,
|
||||
0,
|
||||
fly_distance,
|
||||
false);
|
||||
false,
|
||||
GetCurrWeapon()->weapon_uniid);
|
||||
} else if (power_idx < GetCurrWeapon()->meta->power_charge.size()) {
|
||||
MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip
|
||||
(std::get<1>(GetCurrWeapon()->meta->power_charge[power_idx]));
|
||||
@ -1727,7 +1734,8 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
|
||||
GetCurrWeapon()->weapon_lv,
|
||||
0,
|
||||
fly_distance,
|
||||
false);
|
||||
false,
|
||||
0);
|
||||
} else {
|
||||
A8_ABORT();
|
||||
}
|
||||
@ -3036,9 +3044,6 @@ float Creature::GetAttrAbs(int attr_id)
|
||||
if (GetAbility()){
|
||||
val += GetAbility()->GetAttrAbs(attr_id);
|
||||
}
|
||||
if (GetBattleContext()) {
|
||||
val += GetBattleContext()->GetAttrAbs(attr_id);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -3048,9 +3053,6 @@ float Creature::GetAttrRate(int attr_id)
|
||||
if (GetAbility()){
|
||||
val += GetAbility()->GetAttrRate(attr_id);
|
||||
}
|
||||
if (GetBattleContext()) {
|
||||
val += GetBattleContext()->GetAttrRate(attr_id);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -3061,13 +3063,9 @@ void Creature::RecalcDtoAttr()
|
||||
}
|
||||
if (GetCurrWeapon()) {
|
||||
if (GetBattleContext()) {
|
||||
GetBattleContext()->CalcAttr(AsHuman()->hero_uniid,
|
||||
GetCurrWeapon()->weapon_uniid);
|
||||
}
|
||||
} else {
|
||||
if (GetBattleContext()) {
|
||||
GetBattleContext()->CalcAttr(AsHuman()->hero_uniid,
|
||||
"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -347,4 +347,5 @@ void InternalShot(Creature* sender,
|
||||
int weapon_lv,
|
||||
int skill_id,
|
||||
float fly_distance,
|
||||
bool is_tank_skin);
|
||||
bool is_tank_skin,
|
||||
long long weapon_uniid);
|
||||
|
@ -250,3 +250,23 @@ EntityWeakPtr& Entity::GetEntityWeakPtrRef()
|
||||
}
|
||||
return entity_weak_ptr_;
|
||||
}
|
||||
|
||||
float Entity::GetBaseAtk()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Entity::GetBaseDef()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Entity::GetTotalAtk()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Entity::GetTotalDef()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -80,6 +80,10 @@ class Entity
|
||||
EntityWeakPtr& GetEntityWeakPtrRef();
|
||||
bool IsClientCached(Human* hum);
|
||||
bool CanClientCache(Human* hum);
|
||||
virtual float GetBaseAtk();
|
||||
virtual float GetBaseDef();
|
||||
virtual float GetTotalAtk();
|
||||
virtual float GetTotalDef();
|
||||
|
||||
protected:
|
||||
void AddClientCache(Human* hum);
|
||||
|
@ -623,7 +623,8 @@ void Human::CarShot(const a8::Vec2& target_dir)
|
||||
second_weapon.weapon_lv,
|
||||
0,
|
||||
5,
|
||||
false);
|
||||
false,
|
||||
0);
|
||||
|
||||
--second_weapon.ammo;
|
||||
last_shot_frameno_ = room->GetFrameNo();
|
||||
@ -1867,8 +1868,8 @@ void Human::GenBattleReportData(a8::MutableXObject* params)
|
||||
} else {
|
||||
params->SetVal("alive_time", dead_frameno * 1000.0f / SERVER_FRAME_RATE);
|
||||
}
|
||||
params->SetVal("weapon_uuid1", spec_weapons.size() > 0 ? spec_weapons[0].weapon_uniid : "");
|
||||
params->SetVal("weapon_uuid2", spec_weapons.size() > 1 ? spec_weapons[1].weapon_uniid : "");
|
||||
params->SetVal("weapon_uuid1", spec_weapons.size() > 0 ? spec_weapons[0].weapon_uniid : 0);
|
||||
params->SetVal("weapon_uuid2", spec_weapons.size() > 1 ? spec_weapons[1].weapon_uniid : 0);
|
||||
params->SetVal("ranked", rank);
|
||||
params->SetVal("kills", stats.kills);
|
||||
params->SetVal("damage_out", stats.damage_amount_out);
|
||||
@ -3287,8 +3288,12 @@ void Human::OnBulletHit(Bullet* bullet)
|
||||
float def = 0;
|
||||
float finaly_dmg = 0;
|
||||
{
|
||||
float base_atk = bullet->gun_meta->i->atk();
|
||||
float total_atk = bullet->GetAtk() + GetAttrAbs(kHAT_Atk);
|
||||
float base_atk = 0;
|
||||
float atk_rate = (total_atk - base_atk) / base_atk;
|
||||
float base_def = 0;
|
||||
float def_rate = (0)/base_def;
|
||||
finaly_dmg = total_atk * (1 + atk_rate) * (1 - def_rate);
|
||||
}
|
||||
#else
|
||||
float dmg = bullet->GetAtk();
|
||||
|
@ -95,7 +95,7 @@ Player* PlayerMgr::CreatePlayerByCMJoin(Player* hum,
|
||||
if (equip_meta && equip_meta->i->equip_type() == EQUIP_TYPE_WEAPON) {
|
||||
hum->weapon_configs[weapon.weapon_id()] = weapon_lv;
|
||||
Weapon& spec_weapon = a8::FastAppend(hum->spec_weapons);
|
||||
spec_weapon.weapon_uniid = weapon.weapon_uniid();
|
||||
spec_weapon.weapon_uniid = a8::XValue(weapon.weapon_uniid());
|
||||
//spec_weapon.weapon_id = weapon.weapon_id();
|
||||
spec_weapon.weapon_id = item_meta->i->relationship();
|
||||
spec_weapon.weapon_lv = weapon_lv;
|
||||
|
@ -590,7 +590,8 @@ int Room::CreateBullet(Creature* sender,
|
||||
a8::Vec2 pos,
|
||||
a8::Vec2 dir,
|
||||
float fly_distance,
|
||||
bool is_tank_skin)
|
||||
bool is_tank_skin,
|
||||
long long weapon_uniid)
|
||||
{
|
||||
int bullet_uniid = 0;
|
||||
if (grid_service->CanAdd(pos.x, pos.y)) {
|
||||
@ -600,6 +601,7 @@ int Room::CreateBullet(Creature* sender,
|
||||
bullet->passenger.Attach(passenger);
|
||||
}
|
||||
bullet->room = this;
|
||||
bullet->weapon_uniid = weapon_uniid;
|
||||
bullet->gun_meta = weapon_meta;
|
||||
bullet->gun_upgrade_meta = weapon_upgrade_meta;
|
||||
bullet->meta = bullet_meta;
|
||||
|
@ -159,7 +159,8 @@ public:
|
||||
a8::Vec2 pos,
|
||||
a8::Vec2 dir,
|
||||
float fly_distance,
|
||||
bool is_tank_skin = false);
|
||||
bool is_tank_skin,
|
||||
long long weapon_uniid);
|
||||
Car* CreateCar(Human* driver,
|
||||
int car_uniid,
|
||||
MetaData::Equip* meta,
|
||||
|
@ -1,10 +1,30 @@
|
||||
#include "precompile.h"
|
||||
#include "metamgr.h"
|
||||
|
||||
float* GetAttrAbsPtr(std::array<float, kHAT_End>& attr, int attr_id)
|
||||
{
|
||||
if (!IsValidHumanAttr(attr_id)) {
|
||||
return nullptr;
|
||||
}
|
||||
return &attr[attr_id];
|
||||
}
|
||||
|
||||
float* GetAttrRatePtr(std::array<float, kHAT_End>& attr, int attr_id)
|
||||
{
|
||||
if (!IsValidHumanAttr(attr_id)) {
|
||||
return nullptr;
|
||||
}
|
||||
return &attr[attr_id];
|
||||
}
|
||||
|
||||
void BattleDataContext::Clear()
|
||||
{
|
||||
attr_abs_ = {};
|
||||
attr_rate_ = {};
|
||||
hero_attr_abs_ = {};
|
||||
hero_attr_rate_ = {};
|
||||
weapon1_attr_abs_ = {};
|
||||
weapon1_attr_rate_ = {};
|
||||
weapon2_attr_abs_ = {};
|
||||
weapon2_attr_rate_ = {};
|
||||
}
|
||||
|
||||
void BattleDataContext::ParseResult(a8::XObject& obj)
|
||||
@ -15,33 +35,82 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
|
||||
errmsg = obj.Get("errmsg").GetString();
|
||||
if (obj.HasKey("hero_dto") && obj.At("hero_dto")->IsObject()) {
|
||||
hero_dto = obj.At("hero_dto");
|
||||
hero_uniid = hero_dto->Get("hero_uniid", "").GetString();
|
||||
if (hero_dto->HasKey("attr") && hero_dto->IsArray()) {
|
||||
ApplyAttr(hero_attr_abs_,
|
||||
hero_attr_rate_,
|
||||
hero_dto->At("attr"));
|
||||
}
|
||||
}
|
||||
if (obj.HasKey("weapon_dto1") && obj.At("weapon_dto1")->IsObject()) {
|
||||
weapon_dto1 = obj.At("weapon_dto1");
|
||||
weapon_uniid1 = weapon_dto1->Get("gun_uniid", 0);
|
||||
if (weapon_dto1->HasKey("attr") && weapon_dto1->IsArray()) {
|
||||
ApplyAttr(weapon1_attr_abs_,
|
||||
weapon1_attr_rate_,
|
||||
weapon_dto1->At("attr"));
|
||||
}
|
||||
}
|
||||
if (obj.HasKey("weapon_dto2") && obj.At("weapon_dto2")->IsObject()) {
|
||||
weapon_dto2 = obj.At("weapon_dto2");
|
||||
weapon_uniid2 = weapon_dto2->Get("gun_uniid", 0);
|
||||
if (weapon_dto2->HasKey("attr") && weapon_dto2->IsArray()) {
|
||||
ApplyAttr(weapon2_attr_abs_,
|
||||
weapon2_attr_rate_,
|
||||
weapon_dto2->At("attr"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float BattleDataContext::GetAttrAbs(int attr_id)
|
||||
float BattleDataContext::GetHeroAttrAbs(int attr_id)
|
||||
{
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
return attr_abs_[attr_id];
|
||||
return hero_attr_abs_[attr_id];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float BattleDataContext::GetAttrRate(int attr_id)
|
||||
float BattleDataContext::GetHeroAttrRate(int attr_id)
|
||||
{
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
return attr_rate_[attr_id]/ 100.0f;
|
||||
return hero_attr_rate_[attr_id]/ 100.0f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float BattleDataContext::GetWeaponAttrAbs(long long weapon_uniid, int attr_id)
|
||||
{
|
||||
if (!weapon_uniid) {
|
||||
return 0;
|
||||
}
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
if (weapon_uniid == weapon_uniid1) {
|
||||
return weapon1_attr_abs_[attr_id];
|
||||
} else if (weapon_uniid == weapon_uniid2) {
|
||||
return weapon2_attr_abs_[attr_id];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float BattleDataContext::GetWeaponAttrRate(long long weapon_uniid, int attr_id)
|
||||
{
|
||||
if (!weapon_uniid) {
|
||||
return 0;
|
||||
}
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
if (weapon_uniid == weapon_uniid1) {
|
||||
return weapon1_attr_rate_[attr_id];
|
||||
} else if (weapon_uniid == weapon_uniid2) {
|
||||
return weapon2_attr_rate_[attr_id];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void BattleDataContext::CalcAttr(const std::string& hero_uniid,
|
||||
const std::string& curr_weapon_uniid)
|
||||
long long curr_weapon_uniid)
|
||||
{
|
||||
Clear();
|
||||
if (!hero_uniid.empty() &&
|
||||
@ -50,20 +119,20 @@ void BattleDataContext::CalcAttr(const std::string& hero_uniid,
|
||||
hero_dto->Get("hero_uniid", "").GetString() == hero_uniid
|
||||
) {
|
||||
if (hero_dto->HasKey("attr")) {
|
||||
ApplyAttr(hero_dto->At("attr"));
|
||||
//ApplyAttr(hero_dto->At("attr"));
|
||||
}
|
||||
}
|
||||
if (!curr_weapon_uniid.empty()) {
|
||||
if (!curr_weapon_uniid) {
|
||||
std::shared_ptr<a8::XObject> curr_weapon_dto;
|
||||
if (weapon_dto1 &&
|
||||
weapon_dto1->IsObject() &&
|
||||
weapon_dto1->Get("gun_uniid").GetString() == curr_weapon_uniid) {
|
||||
weapon_dto1->Get("gun_uniid").GetInt64() == curr_weapon_uniid) {
|
||||
curr_weapon_dto = weapon_dto1;
|
||||
}
|
||||
if (!curr_weapon_dto &&
|
||||
weapon_dto1 &&
|
||||
weapon_dto1->IsObject() &&
|
||||
weapon_dto1->Get("gun_uniid").GetString() == curr_weapon_uniid) {
|
||||
weapon_dto1->Get("gun_uniid").GetInt64() == curr_weapon_uniid) {
|
||||
curr_weapon_dto = weapon_dto1;
|
||||
}
|
||||
if (curr_weapon_dto) {
|
||||
@ -73,23 +142,26 @@ void BattleDataContext::CalcAttr(const std::string& hero_uniid,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void BattleDataContext::ApplyAttr(std::shared_ptr<a8::XObject> attr)
|
||||
void BattleDataContext::ApplyAttr(std::array<float, kHAT_End>& attr_abs,
|
||||
std::array<float, kHAT_End>& attr_rate,
|
||||
std::shared_ptr<a8::XObject> obj)
|
||||
{
|
||||
if (attr->IsArray()) {
|
||||
for (int i = 0; i < attr->Size(); ++i) {
|
||||
std::shared_ptr<a8::XObject> obj = attr->At(i);
|
||||
if (obj->IsArray()) {
|
||||
for (int i = 0; i < obj->Size(); ++i) {
|
||||
std::shared_ptr<a8::XObject> obj = obj->At(i);
|
||||
if (obj->IsObject()) {
|
||||
int attr_id = obj->Get("attr_id", 0);
|
||||
int type = obj->Get("type", 0);
|
||||
int val = obj->Get("val", 0);
|
||||
if (type == 1) {
|
||||
float* p = GetAttrAbsPtr(attr_id);
|
||||
float* p = GetAttrAbsPtr(attr_abs, attr_id);
|
||||
if (p) {
|
||||
*p = val;
|
||||
}
|
||||
} else if (type == 2) {
|
||||
float* p = GetAttrRatePtr(attr_id);
|
||||
float* p = GetAttrRatePtr(attr_rate, attr_id);
|
||||
if (p) {
|
||||
*p = val;
|
||||
}
|
||||
@ -98,19 +170,3 @@ void BattleDataContext::ApplyAttr(std::shared_ptr<a8::XObject> attr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float* BattleDataContext::GetAttrAbsPtr(int attr_id)
|
||||
{
|
||||
if (!IsValidHumanAttr(attr_id)) {
|
||||
return nullptr;
|
||||
}
|
||||
return &attr_abs_[attr_id];
|
||||
}
|
||||
|
||||
float* BattleDataContext::GetAttrRatePtr(int attr_id)
|
||||
{
|
||||
if (!IsValidHumanAttr(attr_id)) {
|
||||
return nullptr;
|
||||
}
|
||||
return &attr_rate_[attr_id];
|
||||
}
|
||||
|
@ -33,20 +33,31 @@ struct BattleDataContext
|
||||
std::shared_ptr<a8::XObject> weapon_dto1;
|
||||
std::shared_ptr<a8::XObject> weapon_dto2;
|
||||
|
||||
float GetAttrAbs(int attr_id);
|
||||
float GetAttrRate(int attr_id);
|
||||
float GetHeroAttrAbs(int attr_id);
|
||||
float GetHeroAttrRate(int attr_id);
|
||||
|
||||
float GetWeaponAttrAbs(long long weapon_uniid, int attr_id);
|
||||
float GetWeaponAttrRate(long long weapon_uniid, int attr_id);
|
||||
|
||||
void ParseResult(a8::XObject& obj);
|
||||
void CalcAttr(const std::string& hero_uniid,
|
||||
const std::string& curr_weapon_uniid);
|
||||
|
||||
private:
|
||||
void Clear();
|
||||
void ApplyAttr(std::shared_ptr<a8::XObject> attr);
|
||||
float* GetAttrAbsPtr(int attr_id);
|
||||
float* GetAttrRatePtr(int attr_id);
|
||||
void ApplyAttr(std::array<float, kHAT_End>& attr_abs,
|
||||
std::array<float, kHAT_End>& attr_rate,
|
||||
std::shared_ptr<a8::XObject> obj);
|
||||
|
||||
private:
|
||||
std::array<float, kHAT_End> attr_abs_ = {};
|
||||
std::array<float, kHAT_End> attr_rate_ = {};
|
||||
std::string hero_uniid;
|
||||
long long weapon_uniid1 = 0;
|
||||
long long weapon_uniid2 = 0;
|
||||
|
||||
std::array<float, kHAT_End> hero_attr_abs_ = {};
|
||||
std::array<float, kHAT_End> hero_attr_rate_ = {};
|
||||
|
||||
std::array<float, kHAT_End> weapon1_attr_abs_ = {};
|
||||
std::array<float, kHAT_End> weapon1_attr_rate_ = {};
|
||||
|
||||
std::array<float, kHAT_End> weapon2_attr_abs_ = {};
|
||||
std::array<float, kHAT_End> weapon2_attr_rate_ = {};
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
void Weapon::Clear()
|
||||
{
|
||||
weapon_uniid = "";
|
||||
weapon_uniid = 0;
|
||||
weapon_id = 0;
|
||||
weapon_lv = 0;
|
||||
ammo = 0;
|
||||
@ -17,7 +17,7 @@ void Weapon::Clear()
|
||||
|
||||
void Weapon::ToPB(cs::MFWeapon* pb_obj)
|
||||
{
|
||||
pb_obj->set_weapon_uniid(weapon_uniid);
|
||||
pb_obj->set_weapon_uniid(a8::XValue(weapon_uniid).GetString());
|
||||
pb_obj->set_weapon_id(weapon_id);
|
||||
pb_obj->set_weapon_lv(weapon_lv);
|
||||
pb_obj->set_ammo(ammo);
|
||||
|
@ -14,7 +14,7 @@ namespace MetaData
|
||||
|
||||
struct Weapon
|
||||
{
|
||||
std::string weapon_uniid;
|
||||
long long weapon_uniid = 0;
|
||||
int weapon_idx = 0;
|
||||
int weapon_id = 0;
|
||||
int weapon_lv = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user