完成shot改造
This commit is contained in:
parent
eb7c60e2ce
commit
9578fe6f06
@ -30,31 +30,16 @@ 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)
|
void InternalShot(Human* hum,
|
||||||
|
MetaData::Equip* weapon_meta,
|
||||||
|
MetaData::EquipUpgrade* weapon_upgrade_meta,
|
||||||
|
MetaData::Equip* bullet_meta,
|
||||||
|
int weapon_lv,
|
||||||
|
int skill_id,
|
||||||
|
float fly_distance,
|
||||||
|
bool is_tank_skin)
|
||||||
{
|
{
|
||||||
shot_ok = false;
|
for (auto& tuple : weapon_meta->bullet_born_offset) {
|
||||||
|
|
||||||
if (!bullet_meta) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
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));
|
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));
|
bullet_born_offset.Rotate(hum->attack_dir.CalcAngle(a8::Vec2::UP));
|
||||||
a8::Vec2 bullet_born_pos = hum->GetPos() + bullet_born_offset;
|
a8::Vec2 bullet_born_pos = hum->GetPos() + bullet_born_offset;
|
||||||
@ -63,14 +48,14 @@ static void InternalShot(Human* hum, MetaData::Equip* bullet_meta, int skill_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hum->room->frame_event.AddShot(hum);
|
hum->room->frame_event.AddShot(hum);
|
||||||
for (auto& tuple : bullet_meta->bullet_born_offset) {
|
for (auto& tuple : weapon_meta->bullet_born_offset) {
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
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));
|
bullet_born_offset.Rotate(hum->attack_dir.CalcAngle(a8::Vec2::UP));
|
||||||
a8::Vec2 bullet_born_pos = hum->GetPos() + bullet_born_offset;
|
a8::Vec2 bullet_born_pos = hum->GetPos() + bullet_born_offset;
|
||||||
a8::Vec2 bullet_dir = hum->attack_dir;
|
a8::Vec2 bullet_dir = hum->attack_dir;
|
||||||
float bullet_angle = std::get<2>(tuple);
|
float bullet_angle = std::get<2>(tuple);
|
||||||
if (bullet_meta->i->bullet_angle() >= 0.10f) {
|
if (weapon_meta->i->bullet_angle() >= 0.10f) {
|
||||||
int angle = (int)bullet_meta->i->bullet_angle() * 1000;
|
int angle = (int)weapon_meta->i->bullet_angle() * 1000;
|
||||||
#if 0
|
#if 0
|
||||||
if (curr_weapon->GetUpgradeMeta()) {
|
if (curr_weapon->GetUpgradeMeta()) {
|
||||||
angle -= curr_weapon->GetAttrValue(kHAT_BulletAngle) * 1000;
|
angle -= curr_weapon->GetAttrValue(kHAT_BulletAngle) * 1000;
|
||||||
@ -81,72 +66,22 @@ static void InternalShot(Human* hum, MetaData::Equip* bullet_meta, int skill_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bullet_dir.Rotate(bullet_angle / 180.0f);
|
bullet_dir.Rotate(bullet_angle / 180.0f);
|
||||||
|
if (hum->GetCar().car_id != 0) {
|
||||||
|
bullet_born_pos.x += MetaMgr::Instance()->horse_shoot_x;
|
||||||
|
bullet_born_pos.y += MetaMgr::Instance()->horse_shoot_y;
|
||||||
|
}
|
||||||
hum->room->frame_event.AddBullet(hum, bullet_born_pos, bullet_dir, fly_distance);
|
hum->room->frame_event.AddBullet(hum, bullet_born_pos, bullet_dir, fly_distance);
|
||||||
#if 0
|
if (hum->room->BattleStarted()) {
|
||||||
hum->room->CreateBullet(hum, curr_weapon, bullet_born_pos, bullet_dir, fly_distance);
|
hum->room->CreateBullet(hum,
|
||||||
#endif
|
weapon_meta,
|
||||||
}
|
weapon_upgrade_meta,
|
||||||
#if 0
|
bullet_meta,
|
||||||
--curr_weapon->ammo;
|
bullet_born_pos,
|
||||||
#endif
|
bullet_dir,
|
||||||
int slot_id = bullet_meta->i->_inventory_slot();
|
fly_distance,
|
||||||
switch (slot_id) {
|
is_tank_skin);
|
||||||
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()
|
||||||
@ -458,43 +393,15 @@ void Human::Shot(a8::Vec2& target_dir, bool& shot_ok)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
InternalShot(this,
|
||||||
float fly_distance = 5;
|
curr_weapon->meta,
|
||||||
#endif
|
curr_weapon->GetUpgradeMeta(),
|
||||||
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
curr_weapon->bullet_meta,
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
curr_weapon->weapon_lv,
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
0,
|
||||||
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
|
5,
|
||||||
if (room->OverBorder(bullet_born_pos, 0)) {
|
false);
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
room->frame_event.AddShot(this);
|
|
||||||
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
|
||||||
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
|
|
||||||
a8::Vec2 bullet_dir = attack_dir;
|
|
||||||
float bullet_angle = std::get<2>(tuple);
|
|
||||||
if (curr_weapon->meta->i->bullet_angle() >= 0.10f) {
|
|
||||||
int angle = (int)curr_weapon->meta->i->bullet_angle() * 1000;
|
|
||||||
if (curr_weapon->GetUpgradeMeta()) {
|
|
||||||
angle -= curr_weapon->GetAttrValue(kHAT_BulletAngle) * 1000;
|
|
||||||
}
|
|
||||||
if (angle > 0) {
|
|
||||||
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bullet_dir.Rotate(bullet_angle / 180.0f);
|
|
||||||
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
|
|
||||||
room->CreateBullet(this,
|
|
||||||
curr_weapon->meta,
|
|
||||||
curr_weapon->GetUpgradeMeta(),
|
|
||||||
curr_weapon->bullet_meta,
|
|
||||||
bullet_born_pos,
|
|
||||||
bullet_dir,
|
|
||||||
fly_distance);
|
|
||||||
}
|
|
||||||
--curr_weapon->ammo;
|
--curr_weapon->ammo;
|
||||||
int slot_id = curr_weapon->meta->i->_inventory_slot();
|
int slot_id = curr_weapon->meta->i->_inventory_slot();
|
||||||
switch (slot_id) {
|
switch (slot_id) {
|
||||||
@ -560,43 +467,16 @@ void Human::TankShot(a8::Vec2& target_dir)
|
|||||||
if (tank_weapon.ammo <= 0) {
|
if (tank_weapon.ammo <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto& tuple : tank_weapon.meta->bullet_born_offset) {
|
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
InternalShot(this,
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
tank_weapon.meta,
|
||||||
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
|
tank_weapon.GetUpgradeMeta(),
|
||||||
if (room->OverBorder(bullet_born_pos, 0)) {
|
tank_weapon.bullet_meta,
|
||||||
return;
|
tank_weapon.weapon_lv,
|
||||||
}
|
0,
|
||||||
}
|
5,
|
||||||
room->frame_event.AddShot(this);
|
true);
|
||||||
for (auto& tuple : tank_weapon.meta->bullet_born_offset) {
|
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
|
||||||
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
|
|
||||||
a8::Vec2 bullet_dir = attack_dir;
|
|
||||||
float bullet_angle = std::get<2>(tuple);
|
|
||||||
if (tank_weapon.meta->i->bullet_angle() >= 0.01f) {
|
|
||||||
int angle = (int)tank_weapon.meta->i->bullet_angle() * 1000;
|
|
||||||
if (tank_weapon.GetUpgradeMeta()) {
|
|
||||||
angle -= tank_weapon.GetAttrValue(kHAT_BulletAngle) * 1000;
|
|
||||||
}
|
|
||||||
if (angle > 0) {
|
|
||||||
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bullet_dir.Rotate(bullet_angle / 180.0f);
|
|
||||||
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
|
|
||||||
if (room->BattleStarted()) {
|
|
||||||
room->CreateBullet(this,
|
|
||||||
tank_weapon.meta,
|
|
||||||
tank_weapon.GetUpgradeMeta(),
|
|
||||||
tank_weapon.bullet_meta,
|
|
||||||
bullet_born_pos,
|
|
||||||
bullet_dir,
|
|
||||||
fly_distance,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--tank_weapon.ammo;
|
--tank_weapon.ammo;
|
||||||
last_shot_frameno_ = room->GetFrameNo();
|
last_shot_frameno_ = room->GetFrameNo();
|
||||||
room->frame_event.AddTankBulletNumChg(this);
|
room->frame_event.AddTankBulletNumChg(this);
|
||||||
|
@ -286,6 +286,7 @@ class Human : public MoveableEntity
|
|||||||
void ChangeToRace(RaceType_e race, int level);
|
void ChangeToRace(RaceType_e race, int level);
|
||||||
void ChangeToRaceAndNotify(RaceType_e race, int level);
|
void ChangeToRaceAndNotify(RaceType_e race, int level);
|
||||||
void WinExp(Human* sender, int exp);
|
void WinExp(Human* sender, int exp);
|
||||||
|
HumanCar& GetCar() { return car_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _InternalUpdateMove(float speed);
|
void _InternalUpdateMove(float speed);
|
||||||
@ -404,3 +405,12 @@ private:
|
|||||||
friend class FrameMaker;
|
friend class FrameMaker;
|
||||||
friend class FrameEvent;
|
friend class FrameEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void InternalShot(Human* hum,
|
||||||
|
MetaData::Equip* weapon_meta,
|
||||||
|
MetaData::EquipUpgrade* weapon_upgrade_meta,
|
||||||
|
MetaData::Equip* bullet_meta,
|
||||||
|
int weapon_lv,
|
||||||
|
int skill_id,
|
||||||
|
float fly_distance,
|
||||||
|
bool is_tank_skin);
|
||||||
|
@ -344,57 +344,16 @@ void Player::Shot()
|
|||||||
action_type == AT_Relive) {
|
action_type == AT_Relive) {
|
||||||
CancelAction();
|
CancelAction();
|
||||||
}
|
}
|
||||||
#if 1
|
|
||||||
if (true) {
|
InternalShot(this,
|
||||||
#else
|
curr_weapon->meta,
|
||||||
if (room->gas_data.gas_mode != GasInactive &&
|
curr_weapon->GetUpgradeMeta(),
|
||||||
!a8::HasBitFlag(status, HS_Fly) &&
|
curr_weapon->bullet_meta,
|
||||||
!a8::HasBitFlag(status, HS_Jump)
|
curr_weapon->weapon_lv,
|
||||||
) {
|
0,
|
||||||
#endif
|
fly_distance,
|
||||||
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
false);
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
|
||||||
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
|
|
||||||
if (room->OverBorder(bullet_born_pos, 0)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
room->frame_event.AddShot(this);
|
|
||||||
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
|
||||||
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
|
|
||||||
a8::Vec2 bullet_dir = attack_dir;
|
|
||||||
float bullet_angle = std::get<2>(tuple);
|
|
||||||
if (curr_weapon->meta->i->bullet_angle() >= 0.01f) {
|
|
||||||
int angle = (int)curr_weapon->meta->i->bullet_angle() * 1000;
|
|
||||||
if (curr_weapon->GetUpgradeMeta()) {
|
|
||||||
angle -= curr_weapon->GetAttrValue(kHAT_BulletAngle) * 1000;
|
|
||||||
}
|
|
||||||
if (angle > 0) {
|
|
||||||
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bullet_dir.Rotate(bullet_angle / 180.0f);
|
|
||||||
if (car_.car_id != 0) {
|
|
||||||
bullet_born_pos.x += MetaMgr::Instance()->horse_shoot_x;
|
|
||||||
bullet_born_pos.y += MetaMgr::Instance()->horse_shoot_y;
|
|
||||||
}
|
|
||||||
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
|
|
||||||
if (room->BattleStarted()) {
|
|
||||||
room->CreateBullet(this,
|
|
||||||
curr_weapon->meta,
|
|
||||||
curr_weapon->GetUpgradeMeta(),
|
|
||||||
curr_weapon->bullet_meta,
|
|
||||||
bullet_born_pos,
|
|
||||||
bullet_dir,
|
|
||||||
fly_distance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (curr_weapon->weapon_idx != 0) {
|
if (curr_weapon->weapon_idx != 0) {
|
||||||
--curr_weapon->ammo;
|
--curr_weapon->ammo;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user