remove weapon_lv

This commit is contained in:
aozhiwei 2022-09-09 09:35:22 +08:00
parent b2c6932689
commit 0d16f4157b
13 changed files with 64 additions and 36 deletions

View File

@ -84,7 +84,6 @@ void Android::GiveEquip()
Weapon& weapon = weapons[GUN_SLOT1];
weapon.weapon_idx = GUN_SLOT1;
weapon.weapon_id = weapon_meta->i->id();
weapon.weapon_lv = robot_meta->i->weapon_lv();
weapon.ammo = 0;
weapon.meta = weapon_meta;
weapon.Recalc();

View File

@ -189,6 +189,21 @@ public:
return crit_atk_ratio_;
}
int GetClipVolume()
{
return clip_volume_;
}
int GetFireRate()
{
return fire_rate_;
}
int GetReloadTime()
{
return reload_time_;
}
void Init()
{
if (weapon_dto) {
@ -205,6 +220,9 @@ private:
atk_ = weapon_meta->i->atk();
crit_atk_ = weapon_meta->i->critical();
crit_atk_ratio_ = weapon_meta->i->cri_damage();
clip_volume_ = weapon_meta->i->clip_volume();
fire_rate_ = weapon_meta->i->fire_rate();
reload_time_ = weapon_meta->i->reload_time();
}
void DtoInit()
@ -273,6 +291,9 @@ private:
float atk_ = 0.0f;
float crit_atk_ = 0.0f;
float crit_atk_ratio_ = 0.0f;
int clip_volume_ = 0;
int fire_rate_ = 0;
int reload_time_ = 0;
};
@ -663,3 +684,30 @@ float BattleDataContext::GetDodge(Bullet* bullet)
{
return hero_ability_->GetDodge();
}
int BattleDataContext::GetClipVolume(Creature* c, Weapon* weapon)
{
if (!weapon->meta) {
return 0;
}
auto p = GetWeaponByUniId(weapon->weapon_uniid);
return p ? p->GetClipVolume() : weapon->meta->i->clip_volume();
}
int BattleDataContext::GetFireRate(Creature* c, Weapon* weapon)
{
if (!weapon->meta) {
return 0;
}
auto p = GetWeaponByUniId(weapon->weapon_uniid);
return p ? p->GetFireRate() : weapon->meta->i->fire_rate();
}
int BattleDataContext::GetReloadTime(Creature* c, Weapon* weapon)
{
if (!weapon->meta) {
return 0;
}
auto p = GetWeaponByUniId(weapon->weapon_uniid);
return p ? p->GetReloadTime() : weapon->meta->i->reload_time();
}

View File

@ -24,6 +24,7 @@ class Creature;
class Bullet;
class Obstacle;
class Explosion;
class Weapon;
struct PlayerStats;
class HeroAbility;
class WeaponAbility;
@ -65,6 +66,9 @@ struct BattleDataContext
MetaData::Equip* weapon2_meta);
void Init(Creature* c);
void GetSkillList(std::vector<int>& skill_list);
int GetClipVolume(Creature* c, Weapon* weapon);
int GetFireRate(Creature* c, Weapon* weapon);
int GetReloadTime(Creature* c, Weapon* weapon);
private:
void Clear();

View File

@ -251,7 +251,6 @@ void Buff::ProcBecome()
hold_weapons_.push_back(*weapon);
weapon->weapon_id = weapon_meta->i->id();
weapon->weapon_lv = 1;
weapon->meta = weapon_meta;
weapon->Recalc();
weapon->ammo = weapon->GetClipVolume(owner);
@ -928,7 +927,6 @@ void Buff::ProcMachineGun()
hold_weapons_.push_back(*weapon);
weapon->weapon_id = weapon_meta->i->id();
weapon->weapon_lv = 1;
weapon->meta = weapon_meta;
weapon->Recalc();
weapon->ammo = weapon->GetClipVolume(owner);

View File

@ -41,7 +41,6 @@ void Car::Initialize()
Weapon& weapon = weapons[GUN_SLOT1];
weapon.weapon_idx = GUN_SLOT1;
weapon.weapon_id = weapon_meta->i->id();
weapon.weapon_lv = 1;
weapon.meta = weapon_meta;
weapon.Recalc();
weapon.ammo = weapon.GetClipVolume(this);

View File

@ -121,7 +121,6 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
void InternalShot(Creature* c,
MetaData::Equip* weapon_meta,
MetaData::Equip* bullet_meta,
int weapon_lv,
int skill_id,
float fly_distance,
bool is_tank_skin,
@ -211,7 +210,6 @@ void InternalShot(Creature* c,
bullet_info.bullet_dir = bullet_dir;
bullet_info.fly_distance = fly_distance;
bullet_info.is_tank_skin = is_tank_skin;
bullet_info.weapon_lv = weapon_lv;
bullet_info.delay_time = std::get<3>(tuple);
bullet_info.recoil_force = std::get<4>(tuple);
bullet_info.invincible_buff_uniid = invincible_buff_uniid;
@ -245,7 +243,6 @@ Creature::Creature():MoveableEntity()
auto& weapon = a8::FastAppend(weapons);
weapon.weapon_idx = i;
weapon.weapon_id = 0;
weapon.weapon_lv = 0;
weapon.ammo = 0;
}
@ -1055,7 +1052,6 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
this,
weapon_meta,
bullet_meta,
1,
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
target_distance,
false,
@ -1077,7 +1073,6 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
this,
weapon_meta,
bullet_meta,
1,
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
target_distance,
false,
@ -1177,7 +1172,6 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
if (spec_weapon_meta) {
second_weapon.weapon_idx = 100;
second_weapon.weapon_id = spec_weapon_meta->i->id();
second_weapon.weapon_lv = 1;
second_weapon.meta = spec_weapon_meta;
second_weapon.Recalc();
second_weapon.ammo = second_weapon.GetClipVolume(this);
@ -1801,7 +1795,6 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
InternalShot(this,
GetCurrWeapon()->meta,
GetCurrWeapon()->bullet_meta,
GetCurrWeapon()->weapon_lv,
0,
fly_distance,
false,
@ -1824,7 +1817,6 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
InternalShot(this,
weapon_meta,
bullet_meta,
GetCurrWeapon()->weapon_lv,
0,
fly_distance,
false,

View File

@ -347,7 +347,6 @@ private:
void InternalShot(Creature* sender,
MetaData::Equip* weapon_meta,
MetaData::Equip* bullet_meta,
int weapon_lv,
int skill_id,
float fly_distance,
bool is_tank_skin,

View File

@ -39,7 +39,6 @@ void Hero::Initialize()
Weapon& weapon = weapons[GUN_SLOT1];
weapon.weapon_idx = GUN_SLOT1;
weapon.weapon_id = weapon_meta->i->id();
weapon.weapon_lv = 1;
weapon.ammo = 10000;
weapon.meta = weapon_meta;
weapon.Recalc();

View File

@ -310,7 +310,6 @@ Human::Human():Creature()
{
default_weapon.weapon_idx = 0;
default_weapon.weapon_id = 30101;
default_weapon.weapon_lv = 1;
default_weapon.ammo = 1;
default_weapon.meta = MetaMgr::Instance()->GetEquip(default_weapon.weapon_id);
default_weapon.Recalc();
@ -777,7 +776,6 @@ void Human::CarShot(const a8::Vec2& target_dir)
InternalShot(this,
second_weapon.meta,
second_weapon.bullet_meta,
second_weapon.weapon_lv,
0,
5,
false,
@ -2210,7 +2208,7 @@ void Human::DeadDrop()
weapon.weapon_id != default_weapon.weapon_id
) {
a8::Vec2 drop_pos = GetPos();
room->DropItem(drop_pos, weapon.weapon_id, 1, weapon.weapon_lv);
room->DropItem(drop_pos, weapon.weapon_id, 1, 1);
if (weapon.ammo > 0 && weapon.bullet_meta && weapon.ammo < 200) {
if (IsPlayer() &&
weapon.bullet_meta &&
@ -3720,7 +3718,6 @@ void Human::ProcLootSpecItem(AddItemDTO& dto)
(dto.item_meta->i->_inventory_slot() - SPEC1_IS_BEGIN)
];
weapon->weapon_id = dto.item_id;
weapon->weapon_lv = 1;
weapon->ammo += dto.count;
weapon->meta = dto.item_meta;
weapon->Recalc();
@ -3749,7 +3746,6 @@ void Human::ProcLootSpecItem(AddItemDTO& dto)
(dto.item_meta->i->_inventory_slot() - SPEC2_IS_BEGIN)
];
weapon->weapon_id = dto.item_id;
weapon->weapon_lv = 1;
weapon->ammo += dto.count;
weapon->meta = dto.item_meta;
weapon->Recalc();
@ -3767,7 +3763,6 @@ void Human::ProcLootSpecItem(AddItemDTO& dto)
(dto.item_meta->i->_inventory_slot() - SPEC3_IS_BEGIN)
];
weapon->weapon_id = dto.item_id;
weapon->weapon_lv = 1;
weapon->ammo += dto.count;
weapon->meta = dto.item_meta;
weapon->Recalc();
@ -3839,7 +3834,6 @@ void Human::ProcLootWeapon(AddItemDTO& dto)
} else {
weapons[0].weapon_idx = 0;
weapons[0].weapon_id = dto.item_id;
weapons[0].weapon_lv = std::max(1, dto.item_level);
weapons[0].ammo = 0;
weapons[0].meta = dto.item_meta;
weapons[0].Recalc();
@ -3859,7 +3853,6 @@ void Human::ProcLootWeapon(AddItemDTO& dto)
return;
}
weapon->weapon_id = dto.item_id;
weapon->weapon_lv = std::max(1, dto.item_level);
weapon->ammo = 0;
weapon->meta = dto.item_meta;
weapon->Recalc();
@ -3988,7 +3981,6 @@ void Human::DropWeapon(int weapon_idx)
bool drop_ok = false;
Weapon* weapon = &weapons[weapon_idx];
int weapon_id = weapon->weapon_id;
int weapon_lv = weapon->weapon_lv;
int weapon_ammo = weapon->ammo;
MetaData::Equip* weapon_meta = weapon->meta;
if (weapon->weapon_id != 0) {
@ -4070,7 +4062,7 @@ void Human::DropWeapon(int weapon_idx)
{
a8::Vec2 dir = a8::Vec2::UP;
dir.Rotate(a8::RandAngle());
room->CreateLoot(weapon_id, GetPos() + dir * (40 + rand() % 50), 1, weapon_lv);
room->CreateLoot(weapon_id, GetPos() + dir * (40 + rand() % 50), 1, 1);
}
if (weapon_ammo > 0) {
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(weapon_meta->i->use_bullet());

View File

@ -78,7 +78,6 @@ void Player::Initialize()
weapon->weapon_uniid = spec_weapon.weapon_uniid;
weapon->weapon_idx = weapon_idx;
weapon->weapon_id = spec_weapon.weapon_id;
weapon->weapon_lv = spec_weapon.weapon_lv;
weapon->meta = item_meta;
weapon->Recalc();
weapon->ammo = weapon->GetClipVolume(this);

View File

@ -75,17 +75,14 @@ Player* PlayerMgr::CreatePlayerByCMJoin(Player* hum,
hum->user_data = msg.user_data();
for (auto& weapon : msg.weapons()) {
if (weapon.weapon_id() != 0) {
int weapon_lv = weapon.weapon_lv() > 0 ? weapon.weapon_lv() : 1;
MetaData::Item* item_meta = MetaMgr::Instance()->GetItem(weapon.weapon_id());
if (item_meta && item_meta->i->type() == 7) {
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(item_meta->i->relationship());
if (equip_meta && equip_meta->i->equip_type() == EQUIP_TYPE_WEAPON) {
hum->weapon_configs[weapon.weapon_id()] = weapon_lv;
//hum->weapon_configs[weapon.weapon_id()] = weapon_lv;
Weapon& spec_weapon = a8::FastAppend(hum->spec_weapons);
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;
spec_weapon.ammo = weapon.ammo();
spec_weapon.meta = equip_meta;
spec_weapon.Recalc();

View File

@ -3,12 +3,13 @@
#include "weapon.h"
#include "cs_proto.pb.h"
#include "metamgr.h"
#include "creature.h"
#include "battledatacontext.h"
void Weapon::Clear()
{
weapon_uniid = 0;
weapon_id = 0;
weapon_lv = 0;
ammo = 0;
meta = 0;
bullet_meta = nullptr;
@ -18,7 +19,7 @@ void Weapon::ToPB(Creature* c, cs::MFWeapon* pb_obj)
{
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_weapon_lv(1);
pb_obj->set_ammo(ammo);
pb_obj->set_volume(GetClipVolume(c));
}
@ -30,15 +31,15 @@ void Weapon::Recalc()
int Weapon::GetClipVolume(Creature* c)
{
return meta->i->clip_volume();
return c->GetBattleContext()->GetClipVolume(c, this);
}
int Weapon::GetFireRate(Creature* c)
{
return meta->i->fire_rate();
return c->GetBattleContext()->GetFireRate(c, this);
}
int Weapon::GetReloadTime(Creature* c)
{
return meta->i->reload_time();
return c->GetBattleContext()->GetReloadTime(c, this);
}

View File

@ -11,12 +11,13 @@ namespace MetaData
}
class Creature;
struct Weapon
class Weapon
{
public:
long long weapon_uniid = 0;
int weapon_idx = 0;
int weapon_id = 0;
int weapon_lv = 0;
int ammo = 0;
MetaData::Equip* meta = nullptr;
MetaData::Equip* bullet_meta = nullptr;