1
This commit is contained in:
parent
c68350eac4
commit
e45bb60ac1
@ -30,6 +30,124 @@ const int kReviveTimeAdd = 12;
|
|||||||
const int kSkinNum = 4;
|
const int kSkinNum = 4;
|
||||||
const int kREVIVE_BUFF_ID = 0;
|
const int kREVIVE_BUFF_ID = 0;
|
||||||
|
|
||||||
|
static void InternalShot(Human* hum, MetaData::Equip* bullet_meta, int skill_id, bool& shot_ok)
|
||||||
|
{
|
||||||
|
shot_ok = false;
|
||||||
|
#if 0
|
||||||
|
if (!curr_weapon->meta) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
float fly_distance = 5;
|
||||||
|
#endif
|
||||||
|
for (auto& tuple : bullet_meta->bullet_born_offset) {
|
||||||
|
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
||||||
|
bullet_born_offset.Rotate(hum->attack_dir.CalcAngle(a8::Vec2::UP));
|
||||||
|
a8::Vec2 bullet_born_pos = hum->GetPos() + bullet_born_offset;
|
||||||
|
if (hum->room->OverBorder(bullet_born_pos, 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hum->room->frame_event.AddShot(hum);
|
||||||
|
for (auto& tuple : bullet_meta->bullet_born_offset) {
|
||||||
|
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
||||||
|
bullet_born_offset.Rotate(hum->attack_dir.CalcAngle(a8::Vec2::UP));
|
||||||
|
a8::Vec2 bullet_born_pos = hum->GetPos() + bullet_born_offset;
|
||||||
|
a8::Vec2 bullet_dir = hum->attack_dir;
|
||||||
|
float bullet_angle = std::get<2>(tuple);
|
||||||
|
if (bullet_meta->i->bullet_angle() >= 0.10f) {
|
||||||
|
int angle = (int)bullet_meta->i->bullet_angle() * 1000;
|
||||||
|
#if 0
|
||||||
|
if (curr_weapon->GetUpgradeMeta()) {
|
||||||
|
angle -= curr_weapon->GetAttrValue(kHAT_BulletAngle) * 1000;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (angle > 0) {
|
||||||
|
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bullet_dir.Rotate(bullet_angle / 180.0f);
|
||||||
|
hum->room->frame_event.AddBullet(hum, bullet_born_pos, bullet_dir, fly_distance);
|
||||||
|
#if 0
|
||||||
|
hum->room->CreateBullet(hum, curr_weapon, bullet_born_pos, bullet_dir, fly_distance);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
--curr_weapon->ammo;
|
||||||
|
#endif
|
||||||
|
int slot_id = bullet_meta->i->_inventory_slot();
|
||||||
|
switch (slot_id) {
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
//手雷
|
||||||
|
if (hum->GetInventory(slot_id) > 0) {
|
||||||
|
hum->DecInventory(slot_id, 1);
|
||||||
|
#if 0
|
||||||
|
++curr_weapon->ammo;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#if 0
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
hum->AutoLoadingBullet();
|
||||||
|
}
|
||||||
|
hum->need_sync_active_player = true;
|
||||||
|
hum->SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
//烟雾弹
|
||||||
|
if (hum->GetInventory(slot_id) > 0) {
|
||||||
|
hum->DecInventory(slot_id, 1);
|
||||||
|
#if 0
|
||||||
|
++curr_weapon->ammo;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#if 0
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
hum->AutoLoadingBullet();
|
||||||
|
}
|
||||||
|
hum->need_sync_active_player = true;
|
||||||
|
hum->SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hum->last_shot_frameno_ = hum->room->GetFrameNo();
|
||||||
|
if (!hum->need_sync_active_player) {
|
||||||
|
hum->room->frame_event.AddBulletNumChg(hum);
|
||||||
|
}
|
||||||
|
shot_ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
Human::Human():MoveableEntity()
|
Human::Human():MoveableEntity()
|
||||||
{
|
{
|
||||||
default_weapon.weapon_idx = 0;
|
default_weapon.weapon_idx = 0;
|
||||||
@ -425,43 +543,6 @@ void Human::Shot(a8::Vec2& target_dir, bool& shot_ok)
|
|||||||
|
|
||||||
void Human::DirectShot(MetaData::Equip* bullet_meta, int skill_id, bool& shot_ok)
|
void Human::DirectShot(MetaData::Equip* bullet_meta, int skill_id, bool& shot_ok)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < bullet_meta->bullet_born_offset.size(); ++i) {
|
|
||||||
auto& tuple = bullet_meta->bullet_born_offset[i];
|
|
||||||
room->xtimer.AddDeadLineTimerAndAttach
|
|
||||||
(std::get<0>(tuple) / FRAME_RATE_MS,
|
|
||||||
a8::XParams()
|
|
||||||
.SetSender(this)
|
|
||||||
.SetParam1(bullet_meta)
|
|
||||||
.SetParam2(a8::MakeInt64(skill_id, i))
|
|
||||||
.SetParam3(a8::MakeInt64(attack_dir.x * TEN_W, attack_dir.y * TEN_W)),
|
|
||||||
[] (const a8::XParams& param)
|
|
||||||
{
|
|
||||||
Human* sender = (Human*)param.sender.GetUserData();
|
|
||||||
MetaData::Equip* bullet_meta = (MetaData::Equip*)param.param1.GetUserData();
|
|
||||||
if (sender) {
|
|
||||||
int skill_id = a8::Low32(param.param2.GetInt64());
|
|
||||||
int offset_idx = a8::High32(param.param2.GetInt64());
|
|
||||||
float attack_x = a8::Low32(param.param3.GetInt64()) / (float)TEN_W;
|
|
||||||
float attack_y = a8::High32(param.param3.GetInt64()) / (float)TEN_W;
|
|
||||||
a8::Vec2 old_attack_dir = sender->attack_dir;
|
|
||||||
if (bullet_meta->bullet_born_offset.size() <= 1){
|
|
||||||
sender->attack_dir = a8::Vec2(attack_x, attack_y);
|
|
||||||
sender->attack_dir.Normalize();
|
|
||||||
}
|
|
||||||
sender->InternalShot(bullet_meta,
|
|
||||||
skill_id,
|
|
||||||
offset_idx);
|
|
||||||
sender->attack_dir = old_attack_dir;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
&xtimer_attacher.timer_list_);
|
|
||||||
}
|
|
||||||
OnAttack();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Human::InternalShot(MetaData::Equip* bullet_meta, int skill_id, size_t offset_idx)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::TankShot(a8::Vec2& target_dir)
|
void Human::TankShot(a8::Vec2& target_dir)
|
||||||
|
@ -50,6 +50,7 @@ class Human : public MoveableEntity
|
|||||||
MetaData::Dress* skin_jlf_meta = nullptr;
|
MetaData::Dress* skin_jlf_meta = nullptr;
|
||||||
MetaData::Equip* skin_tank_meta = nullptr;
|
MetaData::Equip* skin_tank_meta = nullptr;
|
||||||
HumanAbility ability;
|
HumanAbility ability;
|
||||||
|
long long last_shot_frameno_ = 0;
|
||||||
|
|
||||||
a8::Vec2 move_dir;
|
a8::Vec2 move_dir;
|
||||||
a8::Vec2 attack_dir;
|
a8::Vec2 attack_dir;
|
||||||
@ -319,12 +320,10 @@ private:
|
|||||||
std::set<GridCell*>& dec_grids);
|
std::set<GridCell*>& dec_grids);
|
||||||
void RemoveFromScene();
|
void RemoveFromScene();
|
||||||
void ResetSkill();
|
void ResetSkill();
|
||||||
void InternalShot(MetaData::Equip* bullet_meta, int skill_id, size_t offset_idx);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int level_ = 0;
|
int level_ = 0;
|
||||||
int exp_ = 0;
|
int exp_ = 0;
|
||||||
long long last_shot_frameno_ = 0;
|
|
||||||
long long last_use_skill_frameno_ = 0;
|
long long last_use_skill_frameno_ = 0;
|
||||||
long long hide_frameno_ = 0;
|
long long hide_frameno_ = 0;
|
||||||
long long accelerate_frameno_ = 0;
|
long long accelerate_frameno_ = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user