1
This commit is contained in:
parent
49c8e679ee
commit
6e58b6b66a
@ -69,6 +69,15 @@ void InternalShot(Creature* c,
|
|||||||
Creature::Creature():MoveableEntity()
|
Creature::Creature():MoveableEntity()
|
||||||
{
|
{
|
||||||
weak_ptr_chunk_.Set(this);
|
weak_ptr_chunk_.Set(this);
|
||||||
|
inventory_[IS_1XSCOPE] = 1;
|
||||||
|
|
||||||
|
if (MetaMgr::Instance()->fighting_mode) {
|
||||||
|
inventory_[IS_9MM] = FIGHTING_MODE_BULLET_NUM;
|
||||||
|
inventory_[IS_556MM] = FIGHTING_MODE_BULLET_NUM;
|
||||||
|
inventory_[IS_762MM] = FIGHTING_MODE_BULLET_NUM;
|
||||||
|
inventory_[IS_12GAUGE] = FIGHTING_MODE_BULLET_NUM;
|
||||||
|
inventory_[IS_RPG] = FIGHTING_MODE_BULLET_NUM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Creature::~Creature()
|
Creature::~Creature()
|
||||||
@ -957,3 +966,141 @@ void Creature::UpdatePoisoning()
|
|||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok)
|
||||||
|
{
|
||||||
|
shot_ok = false;
|
||||||
|
if (!curr_weapon->meta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (downed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curr_weapon->weapon_idx != 0 &&
|
||||||
|
curr_weapon->ammo <= 0) {
|
||||||
|
AutoLoadingBullet();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE) <
|
||||||
|
curr_weapon->GetAttrValue(kHAT_FireRate)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InternalShot(this,
|
||||||
|
curr_weapon->meta,
|
||||||
|
curr_weapon->GetUpgradeMeta(),
|
||||||
|
curr_weapon->bullet_meta,
|
||||||
|
curr_weapon->weapon_lv,
|
||||||
|
0,
|
||||||
|
5,
|
||||||
|
false);
|
||||||
|
|
||||||
|
--curr_weapon->ammo;
|
||||||
|
int slot_id = curr_weapon->meta->i->_inventory_slot();
|
||||||
|
switch (slot_id) {
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
//手雷
|
||||||
|
if (GetInventory(slot_id) > 0) {
|
||||||
|
DecInventory(slot_id, 1);
|
||||||
|
++curr_weapon->ammo;
|
||||||
|
} else {
|
||||||
|
int weapon_idx = curr_weapon->weapon_idx;
|
||||||
|
*curr_weapon = Weapon();
|
||||||
|
curr_weapon->weapon_idx = weapon_idx;
|
||||||
|
if (weapons[SMOKE_SLOT].weapon_id != 0) {
|
||||||
|
curr_weapon = &weapons[SMOKE_SLOT];
|
||||||
|
} else {
|
||||||
|
curr_weapon = &weapons[0];
|
||||||
|
}
|
||||||
|
AutoLoadingBullet();
|
||||||
|
}
|
||||||
|
need_sync_active_player = true;
|
||||||
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
//烟雾弹
|
||||||
|
if (GetInventory(slot_id) > 0) {
|
||||||
|
DecInventory(slot_id, 1);
|
||||||
|
++curr_weapon->ammo;
|
||||||
|
} else {
|
||||||
|
int weapon_idx = curr_weapon->weapon_idx;
|
||||||
|
*curr_weapon = Weapon();
|
||||||
|
curr_weapon->weapon_idx = weapon_idx;
|
||||||
|
if (weapons[FRAG_SLOT].weapon_id != 0) {
|
||||||
|
curr_weapon = &weapons[FRAG_SLOT];
|
||||||
|
} else {
|
||||||
|
curr_weapon = &weapons[0];
|
||||||
|
}
|
||||||
|
AutoLoadingBullet();
|
||||||
|
}
|
||||||
|
need_sync_active_player = true;
|
||||||
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
last_shot_frameno_ = room->GetFrameNo();
|
||||||
|
if (!need_sync_active_player && IsPlayer()) {
|
||||||
|
room->frame_event.AddBulletNumChg((Human*)this);
|
||||||
|
}
|
||||||
|
shot_ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Creature::AutoLoadingBullet(bool manual)
|
||||||
|
{
|
||||||
|
Weapon* p_weapon = curr_weapon;
|
||||||
|
if (car_weapon.meta) {
|
||||||
|
p_weapon = &car_weapon;
|
||||||
|
}
|
||||||
|
if (p_weapon->weapon_idx != 0 &&
|
||||||
|
(p_weapon->ammo <= 0 ||
|
||||||
|
(manual && p_weapon->ammo < p_weapon->GetClipVolume()))
|
||||||
|
) {
|
||||||
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(p_weapon->meta->i->use_bullet());
|
||||||
|
if (bullet_meta &&
|
||||||
|
bullet_meta->i->_inventory_slot() >= 0 &&
|
||||||
|
bullet_meta->i->_inventory_slot() < (int)inventory_.size()
|
||||||
|
) {
|
||||||
|
if (GetInventory(bullet_meta->i->_inventory_slot()) > 0) {
|
||||||
|
if (on_loading_bullet) {
|
||||||
|
on_loading_bullet();
|
||||||
|
}
|
||||||
|
StartAction(AT_Reload,
|
||||||
|
p_weapon->GetAttrValue(kHAT_ReloadTime),
|
||||||
|
p_weapon->weapon_id,
|
||||||
|
p_weapon->weapon_idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Creature::GetInventory(int slot_id)
|
||||||
|
{
|
||||||
|
if (!IsValidSlotId(slot_id)) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return inventory_[slot_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
void Creature::AddInventory(int slot_id, int num)
|
||||||
|
{
|
||||||
|
assert(num > 0);
|
||||||
|
if (!IsValidSlotId(slot_id)) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
inventory_[slot_id] += num;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Creature::DecInventory(int slot_id, int num)
|
||||||
|
{
|
||||||
|
assert(num > 0);
|
||||||
|
if (!IsValidSlotId(slot_id)) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
inventory_[slot_id] -= num;
|
||||||
|
}
|
||||||
|
@ -19,7 +19,10 @@ class Creature : public MoveableEntity
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
std::vector<Weapon> weapons;
|
||||||
|
long long last_shot_frameno_ = 0;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
bool downed = false;
|
||||||
bool dead = false;
|
bool dead = false;
|
||||||
bool real_dead = false;
|
bool real_dead = false;
|
||||||
int team_id = 0;
|
int team_id = 0;
|
||||||
@ -35,6 +38,7 @@ class Creature : public MoveableEntity
|
|||||||
Weapon car_weapon;
|
Weapon car_weapon;
|
||||||
|
|
||||||
bool need_sync_active_player = false;
|
bool need_sync_active_player = false;
|
||||||
|
std::function<void ()> on_loading_bullet;
|
||||||
|
|
||||||
Creature();
|
Creature();
|
||||||
virtual ~Creature() override;
|
virtual ~Creature() override;
|
||||||
@ -100,6 +104,14 @@ class Creature : public MoveableEntity
|
|||||||
void TouchProperTargets(std::function<void (Creature*, bool&)> func);
|
void TouchProperTargets(std::function<void (Creature*, bool&)> func);
|
||||||
CreatureWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; };
|
CreatureWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; };
|
||||||
|
|
||||||
|
void Shot(a8::Vec2& target_dir, bool& shot_ok);
|
||||||
|
|
||||||
|
void AutoLoadingBullet(bool manual = false);
|
||||||
|
int GetInventory(int slot_id);
|
||||||
|
void AddInventory(int slot_id, int num);
|
||||||
|
void DecInventory(int slot_id, int num);
|
||||||
|
std::array<int, IS_END - 1>& GetInventoryData() { return inventory_; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
virtual void AddBuffPostProc(Creature* caster, Buff* buff);
|
virtual void AddBuffPostProc(Creature* caster, Buff* buff);
|
||||||
@ -141,7 +153,7 @@ private:
|
|||||||
a8::Vec2 skill_target_pos_;
|
a8::Vec2 skill_target_pos_;
|
||||||
std::map<int, Skill*> skill_hash_;
|
std::map<int, Skill*> skill_hash_;
|
||||||
std::map<int, Skill*> passive_skill_hash_;
|
std::map<int, Skill*> passive_skill_hash_;
|
||||||
|
std::array<int, IS_END - 1> inventory_ = {};
|
||||||
friend class Skill;
|
friend class Skill;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,9 +42,7 @@ void HeroAI::Update(int delta_time)
|
|||||||
hero->poisoning_time += delta_time;
|
hero->poisoning_time += delta_time;
|
||||||
}
|
}
|
||||||
if (hero->poisoning) {
|
if (hero->poisoning) {
|
||||||
#if 0
|
|
||||||
hero->UpdatePoisoning();
|
hero->UpdatePoisoning();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (hero->dead) {
|
if (hero->dead) {
|
||||||
return;
|
return;
|
||||||
@ -299,9 +297,7 @@ void HeroAI::ChangeToStateAI(HeroState_e to_state)
|
|||||||
hero->move_dir = a8::Vec2(1.0f, 0);
|
hero->move_dir = a8::Vec2(1.0f, 0);
|
||||||
hero->move_dir.Rotate(a8::RandAngle());
|
hero->move_dir.Rotate(a8::RandAngle());
|
||||||
hero->move_dir.Normalize();
|
hero->move_dir.Normalize();
|
||||||
#if 0
|
|
||||||
hero->attack_dir = hero->move_dir;
|
hero->attack_dir = hero->move_dir;
|
||||||
#endif
|
|
||||||
if (node_.param1 <= 1) {
|
if (node_.param1 <= 1) {
|
||||||
moving_ = false;
|
moving_ = false;
|
||||||
}
|
}
|
||||||
@ -313,9 +309,7 @@ void HeroAI::ChangeToStateAI(HeroState_e to_state)
|
|||||||
if (node_.target.Get()) {
|
if (node_.target.Get()) {
|
||||||
hero->move_dir = node_.target.Get()->GetPos() - hero->GetPos();
|
hero->move_dir = node_.target.Get()->GetPos() - hero->GetPos();
|
||||||
hero->move_dir.Normalize();
|
hero->move_dir.Normalize();
|
||||||
#if 0
|
|
||||||
hero->attack_dir = hero->move_dir;
|
hero->attack_dir = hero->move_dir;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -364,11 +358,9 @@ float HeroAI::GetAttackRange()
|
|||||||
{
|
{
|
||||||
float attack_range = 0;
|
float attack_range = 0;
|
||||||
Hero* myself = (Hero*)owner;
|
Hero* myself = (Hero*)owner;
|
||||||
#if 0
|
|
||||||
if (myself->curr_weapon && myself->curr_weapon->meta) {
|
if (myself->curr_weapon && myself->curr_weapon->meta) {
|
||||||
attack_range = myself->curr_weapon->meta->i->range();
|
attack_range = myself->curr_weapon->meta->i->range();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
attack_range = std::min(ai_meta->i->attack_range(), (int)attack_range);
|
attack_range = std::min(ai_meta->i->attack_range(), (int)attack_range);
|
||||||
return attack_range;
|
return attack_range;
|
||||||
}
|
}
|
||||||
@ -401,9 +393,7 @@ void HeroAI::DoShotAI()
|
|||||||
}
|
}
|
||||||
a8::Vec2 old_attack_dir = myself->attack_dir;
|
a8::Vec2 old_attack_dir = myself->attack_dir;
|
||||||
myself->attack_dir = shot_dir;
|
myself->attack_dir = shot_dir;
|
||||||
#if 0
|
|
||||||
myself->Shot(shot_dir, shot_ok);
|
myself->Shot(shot_dir, shot_ok);
|
||||||
#endif
|
|
||||||
myself->attack_dir = old_attack_dir;
|
myself->attack_dir = old_attack_dir;
|
||||||
if (shot_ok) {
|
if (shot_ok) {
|
||||||
if (node_.shot_times <= 0) {
|
if (node_.shot_times <= 0) {
|
||||||
@ -418,13 +408,9 @@ void HeroAI::DoShotAI()
|
|||||||
int HeroAI::GetAttackTimes()
|
int HeroAI::GetAttackTimes()
|
||||||
{
|
{
|
||||||
Hero* myself = (Hero*)owner;
|
Hero* myself = (Hero*)owner;
|
||||||
#if 0
|
|
||||||
if (myself->curr_weapon) {
|
if (myself->curr_weapon) {
|
||||||
return std::min(ai_meta->i->attack_times(), myself->curr_weapon->GetClipVolume());
|
return std::min(ai_meta->i->attack_times(), myself->curr_weapon->GetClipVolume());
|
||||||
} else {
|
} else {
|
||||||
return ai_meta->i->attack_times();
|
return ai_meta->i->attack_times();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,15 +58,6 @@ Human::Human():Creature()
|
|||||||
}
|
}
|
||||||
weapons[0] = default_weapon;
|
weapons[0] = default_weapon;
|
||||||
curr_weapon = &weapons[0];
|
curr_weapon = &weapons[0];
|
||||||
inventory_[IS_1XSCOPE] = 1;
|
|
||||||
|
|
||||||
if (MetaMgr::Instance()->fighting_mode) {
|
|
||||||
inventory_[IS_9MM] = FIGHTING_MODE_BULLET_NUM;
|
|
||||||
inventory_[IS_556MM] = FIGHTING_MODE_BULLET_NUM;
|
|
||||||
inventory_[IS_762MM] = FIGHTING_MODE_BULLET_NUM;
|
|
||||||
inventory_[IS_12GAUGE] = FIGHTING_MODE_BULLET_NUM;
|
|
||||||
inventory_[IS_RPG] = FIGHTING_MODE_BULLET_NUM;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Human::~Human()
|
Human::~Human()
|
||||||
@ -417,89 +408,6 @@ void Human::FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::Shot(a8::Vec2& target_dir, bool& shot_ok)
|
|
||||||
{
|
|
||||||
shot_ok = false;
|
|
||||||
if (!curr_weapon->meta) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (downed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curr_weapon->weapon_idx != 0 &&
|
|
||||||
curr_weapon->ammo <= 0) {
|
|
||||||
AutoLoadingBullet();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE) <
|
|
||||||
curr_weapon->GetAttrValue(kHAT_FireRate)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
InternalShot(this,
|
|
||||||
curr_weapon->meta,
|
|
||||||
curr_weapon->GetUpgradeMeta(),
|
|
||||||
curr_weapon->bullet_meta,
|
|
||||||
curr_weapon->weapon_lv,
|
|
||||||
0,
|
|
||||||
5,
|
|
||||||
false);
|
|
||||||
|
|
||||||
--curr_weapon->ammo;
|
|
||||||
int slot_id = curr_weapon->meta->i->_inventory_slot();
|
|
||||||
switch (slot_id) {
|
|
||||||
case 5:
|
|
||||||
{
|
|
||||||
//手雷
|
|
||||||
if (GetInventory(slot_id) > 0) {
|
|
||||||
DecInventory(slot_id, 1);
|
|
||||||
++curr_weapon->ammo;
|
|
||||||
} else {
|
|
||||||
int weapon_idx = curr_weapon->weapon_idx;
|
|
||||||
*curr_weapon = Weapon();
|
|
||||||
curr_weapon->weapon_idx = weapon_idx;
|
|
||||||
if (weapons[SMOKE_SLOT].weapon_id != 0) {
|
|
||||||
curr_weapon = &weapons[SMOKE_SLOT];
|
|
||||||
} else {
|
|
||||||
curr_weapon = &weapons[0];
|
|
||||||
}
|
|
||||||
AutoLoadingBullet();
|
|
||||||
}
|
|
||||||
need_sync_active_player = true;
|
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
{
|
|
||||||
//烟雾弹
|
|
||||||
if (GetInventory(slot_id) > 0) {
|
|
||||||
DecInventory(slot_id, 1);
|
|
||||||
++curr_weapon->ammo;
|
|
||||||
} else {
|
|
||||||
int weapon_idx = curr_weapon->weapon_idx;
|
|
||||||
*curr_weapon = Weapon();
|
|
||||||
curr_weapon->weapon_idx = weapon_idx;
|
|
||||||
if (weapons[FRAG_SLOT].weapon_id != 0) {
|
|
||||||
curr_weapon = &weapons[FRAG_SLOT];
|
|
||||||
} else {
|
|
||||||
curr_weapon = &weapons[0];
|
|
||||||
}
|
|
||||||
AutoLoadingBullet();
|
|
||||||
}
|
|
||||||
need_sync_active_player = true;
|
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
last_shot_frameno_ = room->GetFrameNo();
|
|
||||||
if (!need_sync_active_player) {
|
|
||||||
room->frame_event.AddBulletNumChg(this);
|
|
||||||
}
|
|
||||||
shot_ok = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Human::CarShot(a8::Vec2& target_dir)
|
void Human::CarShot(a8::Vec2& target_dir)
|
||||||
{
|
{
|
||||||
if (!car_weapon.meta) {
|
if (!car_weapon.meta) {
|
||||||
@ -741,35 +649,6 @@ float Human::GetMaxHP()
|
|||||||
return ability.max_hp;
|
return ability.max_hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::AutoLoadingBullet(bool manual)
|
|
||||||
{
|
|
||||||
Weapon* p_weapon = curr_weapon;
|
|
||||||
if (car_weapon.meta) {
|
|
||||||
p_weapon = &car_weapon;
|
|
||||||
}
|
|
||||||
if (p_weapon->weapon_idx != 0 &&
|
|
||||||
(p_weapon->ammo <= 0 ||
|
|
||||||
(manual && p_weapon->ammo < p_weapon->GetClipVolume()))
|
|
||||||
) {
|
|
||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(p_weapon->meta->i->use_bullet());
|
|
||||||
if (bullet_meta &&
|
|
||||||
bullet_meta->i->_inventory_slot() >= 0 &&
|
|
||||||
bullet_meta->i->_inventory_slot() < (int)inventory_.size()
|
|
||||||
) {
|
|
||||||
if (GetInventory(bullet_meta->i->_inventory_slot()) > 0) {
|
|
||||||
if (on_loading_bullet) {
|
|
||||||
on_loading_bullet();
|
|
||||||
}
|
|
||||||
StartAction(AT_Reload,
|
|
||||||
p_weapon->GetAttrValue(kHAT_ReloadTime),
|
|
||||||
p_weapon->weapon_id,
|
|
||||||
p_weapon->weapon_idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Human::FillSMGameOver(cs::SMGameOver& msg)
|
void Human::FillSMGameOver(cs::SMGameOver& msg)
|
||||||
{
|
{
|
||||||
if (stats.rank <= 0) {
|
if (stats.rank <= 0) {
|
||||||
@ -1411,7 +1290,7 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
|||||||
auto p = player_data->add_weapons();
|
auto p = player_data->add_weapons();
|
||||||
weapon.ToPB(p);
|
weapon.ToPB(p);
|
||||||
}
|
}
|
||||||
for (auto& num : inventory_) {
|
for (auto& num : GetInventoryData()) {
|
||||||
player_data->add_inventory(num);
|
player_data->add_inventory(num);
|
||||||
}
|
}
|
||||||
player_data->set_energy_shield(energy_shield);
|
player_data->set_energy_shield(energy_shield);
|
||||||
@ -1482,32 +1361,6 @@ void Human::RecalcBaseAttr()
|
|||||||
ability.max_hp = std::max(ability.hp, ability.max_hp);
|
ability.max_hp = std::max(ability.hp, ability.max_hp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Human::GetInventory(int slot_id)
|
|
||||||
{
|
|
||||||
if (!IsValidSlotId(slot_id)) {
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
return inventory_[slot_id];
|
|
||||||
}
|
|
||||||
|
|
||||||
void Human::AddInventory(int slot_id, int num)
|
|
||||||
{
|
|
||||||
assert(num > 0);
|
|
||||||
if (!IsValidSlotId(slot_id)) {
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
inventory_[slot_id] += num;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Human::DecInventory(int slot_id, int num)
|
|
||||||
{
|
|
||||||
assert(num > 0);
|
|
||||||
if (!IsValidSlotId(slot_id)) {
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
inventory_[slot_id] -= num;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Human::GetVolume(int slot_id)
|
int Human::GetVolume(int slot_id)
|
||||||
{
|
{
|
||||||
if (!IsValidSlotId(slot_id)) {
|
if (!IsValidSlotId(slot_id)) {
|
||||||
@ -2483,8 +2336,8 @@ void Human::DeadDrop()
|
|||||||
backpack = 0;
|
backpack = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t slot = 0; slot < inventory_.size(); ++slot) {
|
for (size_t slot = 0; slot < GetInventoryData().size(); ++slot) {
|
||||||
if (inventory_[slot] > 0) {
|
if (GetInventoryData()[slot] > 0) {
|
||||||
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquipBySlotId(slot);
|
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquipBySlotId(slot);
|
||||||
if (equip_meta) {
|
if (equip_meta) {
|
||||||
if (equip_meta->i->equip_type() == EQUIP_TYPE_BULLET) {
|
if (equip_meta->i->equip_type() == EQUIP_TYPE_BULLET) {
|
||||||
@ -2493,7 +2346,7 @@ void Human::DeadDrop()
|
|||||||
case IS_SMOKE:
|
case IS_SMOKE:
|
||||||
{
|
{
|
||||||
a8::Vec2 drop_pos = GetPos();
|
a8::Vec2 drop_pos = GetPos();
|
||||||
room->DropItem(drop_pos, equip_meta->i->id(), inventory_[slot], 1);
|
room->DropItem(drop_pos, equip_meta->i->id(), GetInventoryData()[slot], 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2501,7 +2354,7 @@ void Human::DeadDrop()
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a8::Vec2 drop_pos = GetPos();
|
a8::Vec2 drop_pos = GetPos();
|
||||||
room->DropItem(drop_pos, equip_meta->i->id(), inventory_[slot], 1);
|
room->DropItem(drop_pos, equip_meta->i->id(), GetInventoryData()[slot], 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,6 @@ class Human : public Creature
|
|||||||
MetaData::Equip* helmet_meta = nullptr;
|
MetaData::Equip* helmet_meta = nullptr;
|
||||||
MetaData::Equip* chest_meta = nullptr;
|
MetaData::Equip* chest_meta = nullptr;
|
||||||
MetaData::Dress* skin_jlf_meta = nullptr;
|
MetaData::Dress* skin_jlf_meta = nullptr;
|
||||||
long long last_shot_frameno_ = 0;
|
|
||||||
|
|
||||||
std::function<void ()> on_loading_bullet;
|
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string avatar_url;
|
std::string avatar_url;
|
||||||
@ -65,7 +62,6 @@ class Human : public Creature
|
|||||||
int sex = 0;
|
int sex = 0;
|
||||||
std::string user_data;
|
std::string user_data;
|
||||||
long long last_cmmove_frameno = 0;
|
long long last_cmmove_frameno = 0;
|
||||||
bool downed = false;
|
|
||||||
bool disconnected = false;
|
bool disconnected = false;
|
||||||
int anim_type = 0;
|
int anim_type = 0;
|
||||||
int anim_seq = 0;
|
int anim_seq = 0;
|
||||||
@ -91,7 +87,6 @@ class Human : public Creature
|
|||||||
long long real_dead_frameno = 0;
|
long long real_dead_frameno = 0;
|
||||||
|
|
||||||
Weapon default_weapon;
|
Weapon default_weapon;
|
||||||
std::vector<Weapon> weapons;
|
|
||||||
|
|
||||||
int curr_scope_idx = 0;
|
int curr_scope_idx = 0;
|
||||||
|
|
||||||
@ -148,7 +143,6 @@ class Human : public Creature
|
|||||||
void FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list);
|
void FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list);
|
||||||
long long GetRealDeadFrameNo(Room* room);
|
long long GetRealDeadFrameNo(Room* room);
|
||||||
void FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over);
|
void FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over);
|
||||||
void Shot(a8::Vec2& target_dir, bool& shot_ok);
|
|
||||||
void CarShot(a8::Vec2& target_dir);
|
void CarShot(a8::Vec2& target_dir);
|
||||||
virtual void RecalcSelfCollider() override;
|
virtual void RecalcSelfCollider() override;
|
||||||
bool IsCollisionInMapService();
|
bool IsCollisionInMapService();
|
||||||
@ -156,7 +150,6 @@ class Human : public Creature
|
|||||||
float GetRadius();
|
float GetRadius();
|
||||||
float GetHP();
|
float GetHP();
|
||||||
float GetMaxHP();
|
float GetMaxHP();
|
||||||
void AutoLoadingBullet(bool manual = false);
|
|
||||||
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
||||||
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override;
|
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override;
|
||||||
void AddToNewObjects(Entity* entity);
|
void AddToNewObjects(Entity* entity);
|
||||||
@ -185,9 +178,6 @@ class Human : public Creature
|
|||||||
void FillMFGasData(cs::MFGasData* gas_data);
|
void FillMFGasData(cs::MFGasData* gas_data);
|
||||||
void RecalcVolume();
|
void RecalcVolume();
|
||||||
void RecalcBaseAttr();
|
void RecalcBaseAttr();
|
||||||
int GetInventory(int slot_id);
|
|
||||||
void AddInventory(int slot_id, int num);
|
|
||||||
void DecInventory(int slot_id, int num);
|
|
||||||
int GetVolume(int slot_id);
|
int GetVolume(int slot_id);
|
||||||
void RecoverHp(int inc_hp);
|
void RecoverHp(int inc_hp);
|
||||||
void FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState>* states);
|
void FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState>* states);
|
||||||
@ -300,7 +290,6 @@ protected:
|
|||||||
bool leave_ = false;
|
bool leave_ = false;
|
||||||
long long leave_frameno_ = 0;
|
long long leave_frameno_ = 0;
|
||||||
|
|
||||||
std::array<int, IS_END - 1> inventory_ = {};
|
|
||||||
std::array<int, IS_END> volume_ = {};
|
std::array<int, IS_END> volume_ = {};
|
||||||
std::set<Entity*> new_objects;
|
std::set<Entity*> new_objects;
|
||||||
std::set<Entity*> part_objects;
|
std::set<Entity*> part_objects;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user