1
This commit is contained in:
parent
17426c8a6b
commit
169e3607f0
@ -22,13 +22,6 @@ Android::~Android()
|
||||
void Android::Initialize()
|
||||
{
|
||||
health = meta->i->health();
|
||||
helmet = DEF_HELMET_ID;
|
||||
chest = DEF_CHEST_ID;
|
||||
#if 0
|
||||
weapon = DEF_WEAPON_ID;
|
||||
#endif
|
||||
helmet_meta = MetaMgr::Instance()->GetEquip(helmet);
|
||||
chest_meta = MetaMgr::Instance()->GetEquip(chest);
|
||||
RecalcSelfCollider();
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,6 @@ const float TEN_W = 10000 * 10;
|
||||
|
||||
const int SYS_RESET_TIME = 2*60; //每日两点重置
|
||||
|
||||
const int DEF_HELMET_ID = 12404;
|
||||
const int DEF_CHEST_ID = 12401;
|
||||
const int DEF_WEAPON_ID = 12103;
|
||||
|
||||
const int GAS_INACTIVE_TIME = 200;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "room.h"
|
||||
#include "bullet.h"
|
||||
#include "collider.h"
|
||||
#include "loot.h"
|
||||
|
||||
Human::Human()
|
||||
{
|
||||
@ -73,7 +74,7 @@ void Human::FillMFObjectFull(cs::MFObjectFull* full_data)
|
||||
p->set_anim_seq(anim_seq);
|
||||
p->set_action_type(action_type);
|
||||
p->set_skin(skin);
|
||||
|
||||
p->set_backpack(backpack);
|
||||
p->set_helmet(helmet);
|
||||
p->set_chest(chest);
|
||||
curr_weapon->ToPB(p->mutable_weapon());
|
||||
@ -249,3 +250,34 @@ void Human::UpdatePoisoning()
|
||||
this->new_objects.insert(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Human::DropItem(int item_id)
|
||||
{
|
||||
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(item_id);
|
||||
if (equip_meta) {
|
||||
Loot* entity = new Loot();
|
||||
entity->room = room;
|
||||
entity->meta = equip_meta;
|
||||
entity->entity_uniid = room->AllocUniid();
|
||||
{
|
||||
Vector2D dir = Vector2D::UP;
|
||||
dir.Rotate(a8::RandAngle());
|
||||
entity->pos = pos + dir * (25 + rand() % 50);
|
||||
}
|
||||
entity->item_id = equip_meta->i->id();
|
||||
entity->count = 1;
|
||||
entity->Initialize();
|
||||
room->uniid_hash_[entity->entity_uniid] = entity;
|
||||
for (auto& pair : room->human_hash_) {
|
||||
pair.second->new_objects.insert(entity);
|
||||
pair.second->part_objects.insert(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Human::SyncAroundPlayers()
|
||||
{
|
||||
for (auto& pair : room->human_hash_) {
|
||||
pair.second->new_objects.insert(this);
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class Human : public Entity
|
||||
int anim_seq = 0;
|
||||
int action_type = 0;
|
||||
int skin = 0;
|
||||
int backpack = 0;
|
||||
int helmet = 0;
|
||||
int chest = 0;
|
||||
int energy_shield = 0;
|
||||
@ -73,6 +74,8 @@ class Human : public Entity
|
||||
void FindPath();
|
||||
float GetRadius();
|
||||
void UpdatePoisoning();
|
||||
void DropItem(int item_id);
|
||||
void SyncAroundPlayers();
|
||||
|
||||
private:
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
|
@ -45,17 +45,13 @@ Player::~Player()
|
||||
void Player::Initialize()
|
||||
{
|
||||
health = meta->i->health();
|
||||
helmet = DEF_HELMET_ID;
|
||||
chest = DEF_CHEST_ID;
|
||||
#if 1
|
||||
#if 0
|
||||
weapons[GUN_SLOT1].weapon_idx = GUN_SLOT1;
|
||||
weapons[GUN_SLOT1].weapon_id = DEF_WEAPON_ID;
|
||||
weapons[GUN_SLOT1].weapon_lv = 1;
|
||||
weapons[GUN_SLOT1].meta = MetaMgr::Instance()->GetEquip(DEF_WEAPON_ID);;
|
||||
curr_weapon = &weapons[GUN_SLOT1];
|
||||
#endif
|
||||
helmet_meta = MetaMgr::Instance()->GetEquip(helmet);
|
||||
chest_meta = MetaMgr::Instance()->GetEquip(chest);
|
||||
RecalcSelfCollider();
|
||||
}
|
||||
|
||||
@ -211,6 +207,7 @@ void Player::Shot()
|
||||
}
|
||||
}
|
||||
need_sync_active_player = true;
|
||||
SyncAroundPlayers();
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
@ -229,6 +226,7 @@ void Player::Shot()
|
||||
}
|
||||
}
|
||||
need_sync_active_player = true;
|
||||
SyncAroundPlayers();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -368,8 +366,51 @@ void Player::LootInteraction(Loot* entity)
|
||||
curr_scope_idx = item_meta->i->_inventory_slot() - 12;
|
||||
}
|
||||
}
|
||||
need_sync_active_player = true;
|
||||
} else {
|
||||
switch (item_meta->i->equip_type()) {
|
||||
case 7:
|
||||
{
|
||||
//背包
|
||||
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()) {
|
||||
return;
|
||||
}
|
||||
DropItem(old_item_meta->i->id());
|
||||
}
|
||||
backpack = item_meta->i->id();
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
//防具
|
||||
if (item_meta->i->equip_subtype() == 1) {
|
||||
//盔甲
|
||||
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(chest);
|
||||
if (old_item_meta) {
|
||||
if (old_item_meta->i->equip_lv() <= item_meta->i->equip_lv()) {
|
||||
return;
|
||||
}
|
||||
DropItem(old_item_meta->i->id());
|
||||
}
|
||||
chest = item_meta->i->id();
|
||||
} else if (item_meta->i->equip_subtype() == 2) {
|
||||
//头盔
|
||||
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(helmet);
|
||||
if (old_item_meta) {
|
||||
if (old_item_meta->i->equip_lv() <= item_meta->i->equip_lv()) {
|
||||
return;
|
||||
}
|
||||
DropItem(old_item_meta->i->id());
|
||||
}
|
||||
helmet = item_meta->i->id();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
need_sync_active_player = true;
|
||||
SyncAroundPlayers();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -567,6 +608,10 @@ void Player::_CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg)
|
||||
void Player::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
||||
{
|
||||
player_data->set_has_action(false);
|
||||
player_data->set_skin(skin);
|
||||
player_data->set_backpack(backpack);
|
||||
player_data->set_helmet(helmet);
|
||||
player_data->set_chest(chest);
|
||||
player_data->set_cur_weapon_idx(curr_weapon->weapon_idx);
|
||||
player_data->set_cur_scope(curr_scope_idx);
|
||||
for (auto& weapon : weapons) {
|
||||
|
@ -355,6 +355,11 @@ message MFActivePlayerData
|
||||
optional int32 action_item_id = 5;
|
||||
optional int32 action_target_id = 6;
|
||||
|
||||
optional int32 skin = 30; //皮肤id
|
||||
optional int32 backpack = 31; //背包
|
||||
optional int32 helmet = 32; //头盔
|
||||
optional int32 chest = 33; //防弹衣
|
||||
|
||||
optional int32 cur_scope = 10; //当前视野倍数 1 2 4 8 15
|
||||
/*
|
||||
0: 9mm
|
||||
|
Loading…
x
Reference in New Issue
Block a user