1
This commit is contained in:
parent
931008868f
commit
f627a1754b
@ -172,45 +172,57 @@ void Bullet::ProcBomb()
|
||||
}
|
||||
});
|
||||
|
||||
bool block = false;
|
||||
if (objects.empty()) {
|
||||
float bullet_range = gun_meta->i->range();
|
||||
if (gun_upgrade_meta && gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange) > 0) {
|
||||
bullet_range += gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange);
|
||||
}
|
||||
float distance = (GetPos() - born_pos).Norm();
|
||||
if (distance >= bullet_range) {
|
||||
#if 0
|
||||
sender->SummonObstacle(0, GetPos());
|
||||
#endif
|
||||
if (distance >= fly_distance) {
|
||||
block = true;
|
||||
}
|
||||
} else {
|
||||
switch (meta->i->_inventory_slot()) {
|
||||
case 4:
|
||||
{
|
||||
//榴弹炮
|
||||
a8::Vec2 bomb_pos = GetPos();
|
||||
room->frame_event.AddExplosionEx(sender, meta->i->id(), bomb_pos,
|
||||
gun_meta->i->explosion_effect());
|
||||
OnHit(objects);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
//手雷
|
||||
a8::Vec2 bomb_pos = GetPos();
|
||||
room->frame_event.AddExplosion(this, meta->i->id(), bomb_pos);
|
||||
OnHit(objects);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
{
|
||||
//烟雾弹
|
||||
a8::Vec2 bomb_pos = GetPos();
|
||||
room->frame_event.AddSmoke(this, meta->i->id(), bomb_pos);
|
||||
ProcSmokeBomb();
|
||||
}
|
||||
break;
|
||||
}
|
||||
float delay_time = 0;
|
||||
if (!block) {
|
||||
delay_time = gun_meta->i->missiles_time();
|
||||
}
|
||||
switch (meta->i->_inventory_slot()) {
|
||||
case IS_RPG:
|
||||
{
|
||||
//榴弹炮
|
||||
a8::Vec2 bomb_pos = GetPos();
|
||||
room->frame_event.AddExplosionEx(sender, meta->i->id(), bomb_pos,
|
||||
gun_meta->i->explosion_effect());
|
||||
OnHit(objects);
|
||||
}
|
||||
break;
|
||||
case IS_FRAG:
|
||||
{
|
||||
//手雷
|
||||
ProcFragBomb(delay_time);
|
||||
}
|
||||
break;
|
||||
case IS_SMOKE:
|
||||
{
|
||||
//烟雾弹
|
||||
a8::Vec2 bomb_pos = GetPos();
|
||||
room->frame_event.AddSmoke(this, meta->i->id(), bomb_pos);
|
||||
ProcSmokeBomb();
|
||||
}
|
||||
break;
|
||||
case IS_POSION_GAS_BOMB:
|
||||
{
|
||||
//毒气弹
|
||||
a8::Vec2 bomb_pos = GetPos();
|
||||
room->frame_event.AddSmoke(this, meta->i->id(), bomb_pos);
|
||||
ProcPosionGasBomb(delay_time);
|
||||
}
|
||||
break;
|
||||
case IS_MOLOTOR_COCKTAIL:
|
||||
{
|
||||
//燃烧瓶
|
||||
a8::Vec2 bomb_pos = GetPos();
|
||||
room->frame_event.AddSmoke(this, meta->i->id(), bomb_pos);
|
||||
ProcMolotorCocktailBomb(delay_time);
|
||||
}
|
||||
break;
|
||||
}
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
@ -255,13 +267,12 @@ void Bullet::ProcSmokeBomb()
|
||||
|
||||
bool Bullet::IsBomb()
|
||||
{
|
||||
#if 0
|
||||
((metatable::Equip*)meta->i)->set__inventory_slot(6);
|
||||
#endif
|
||||
return
|
||||
meta->i->_inventory_slot() == 4 ||
|
||||
meta->i->_inventory_slot() == 5 ||
|
||||
meta->i->_inventory_slot() == 6;
|
||||
meta->i->_inventory_slot() == IS_RPG ||
|
||||
meta->i->_inventory_slot() == IS_FRAG ||
|
||||
meta->i->_inventory_slot() == IS_SMOKE ||
|
||||
meta->i->_inventory_slot() == IS_POSION_GAS_BOMB ||
|
||||
meta->i->_inventory_slot() == IS_MOLOTOR_COCKTAIL;
|
||||
}
|
||||
|
||||
void Bullet::MapServiceUpdate()
|
||||
@ -319,7 +330,7 @@ void Bullet::Check(float distance)
|
||||
bullet_range += gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange);
|
||||
}
|
||||
if (!objects.empty() || distance > bullet_range ||
|
||||
(IsBomb() && meta->i->_inventory_slot() != 4 && distance >= fly_distance)
|
||||
(IsBomb() && distance >= fly_distance)
|
||||
) {
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
@ -332,3 +343,22 @@ void Bullet::Check(float distance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bullet::ProcFragBomb(float delay_time)
|
||||
{
|
||||
a8::Vec2 bomb_pos = GetPos();
|
||||
room->frame_event.AddExplosion(this, meta->i->id(), bomb_pos);
|
||||
#if 0
|
||||
OnHit(objects);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Bullet::ProcPosionGasBomb(float delay_time)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Bullet::ProcMolotorCocktailBomb(float delay_time)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ protected:
|
||||
void OnHit(std::set<Entity*>& objects);
|
||||
void ProcBomb();
|
||||
void ProcSmokeBomb();
|
||||
void ProcFragBomb(float delay_time);
|
||||
void ProcPosionGasBomb(float delay_time);
|
||||
void ProcMolotorCocktailBomb(float delay_time);
|
||||
bool IsBomb();
|
||||
inline void MapServiceUpdate();
|
||||
float GetAtk();
|
||||
|
@ -89,6 +89,8 @@ enum InventorySlot_e
|
||||
IS_SMOKE = 6,
|
||||
IS_HEALTHKIT = 7, //医疗包
|
||||
IS_PAIN_KILLER = 8, //止痛药
|
||||
IS_POSION_GAS_BOMB = 9,
|
||||
IS_MOLOTOR_COCKTAIL = 10,
|
||||
|
||||
IS_1XSCOPE = 12,
|
||||
IS_2XSCOPE = 13,
|
||||
|
41
server/gameserver/frag_mitask.cc
Normal file
41
server/gameserver/frag_mitask.cc
Normal file
@ -0,0 +1,41 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "frag_mitask.h"
|
||||
#include "room.h"
|
||||
#include "player.h"
|
||||
#include "metadata.h"
|
||||
|
||||
void FragMiTask::Check()
|
||||
{
|
||||
{
|
||||
std::list<Player*> deleted_hums;
|
||||
for (auto& hum : player_set) {
|
||||
if (bomb_pos.Distance(hum->GetPos()) > gun_meta->i->bullet_rad() + hum->meta->i->radius()) {
|
||||
hum->RemoveBuffByEffectId(kBET_HunLuan);
|
||||
deleted_hums.push_back(hum);
|
||||
}
|
||||
}
|
||||
for (auto& hum : deleted_hums) {
|
||||
player_set.erase(hum);
|
||||
}
|
||||
}
|
||||
room->TouchPlayerList
|
||||
(a8::XParams(),
|
||||
[this] (Player* hum, a8::XParams&) -> bool
|
||||
{
|
||||
if (bomb_pos.Distance(hum->GetPos()) < gun_meta->i->bullet_rad() + hum->meta->i->radius()) {
|
||||
if (!hum->HasBuffEffect(kBET_HunLuan)) {
|
||||
hum->AddBuff(nullptr, buff_meta, 1, nullptr);
|
||||
player_set.insert(hum);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void FragMiTask::Done()
|
||||
{
|
||||
for (auto& hum : player_set) {
|
||||
hum->RemoveBuffByEffectId(kBET_HunLuan);
|
||||
}
|
||||
}
|
24
server/gameserver/frag_mitask.h
Normal file
24
server/gameserver/frag_mitask.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "microtask.h"
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
struct Buff;
|
||||
struct Equip;
|
||||
}
|
||||
|
||||
class Room;
|
||||
class Player;
|
||||
class FragMiTask : public MicroTask
|
||||
{
|
||||
public:
|
||||
Room* room = nullptr;
|
||||
a8::Vec2 bomb_pos;
|
||||
std::set<Player*> player_set;
|
||||
MetaData::Buff* buff_meta = nullptr;
|
||||
MetaData::Equip* gun_meta = nullptr;
|
||||
|
||||
void Check();
|
||||
void Done();
|
||||
};
|
41
server/gameserver/molotor_cocktail_mitask.cc
Normal file
41
server/gameserver/molotor_cocktail_mitask.cc
Normal file
@ -0,0 +1,41 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "molotor_cocktail_mitask.h"
|
||||
#include "room.h"
|
||||
#include "player.h"
|
||||
#include "metadata.h"
|
||||
|
||||
void MolotorCocktailMiTask::Check()
|
||||
{
|
||||
{
|
||||
std::list<Player*> deleted_hums;
|
||||
for (auto& hum : player_set) {
|
||||
if (bomb_pos.Distance(hum->GetPos()) > gun_meta->i->bullet_rad() + hum->meta->i->radius()) {
|
||||
hum->RemoveBuffByEffectId(kBET_HunLuan);
|
||||
deleted_hums.push_back(hum);
|
||||
}
|
||||
}
|
||||
for (auto& hum : deleted_hums) {
|
||||
player_set.erase(hum);
|
||||
}
|
||||
}
|
||||
room->TouchPlayerList
|
||||
(a8::XParams(),
|
||||
[this] (Player* hum, a8::XParams&) -> bool
|
||||
{
|
||||
if (bomb_pos.Distance(hum->GetPos()) < gun_meta->i->bullet_rad() + hum->meta->i->radius()) {
|
||||
if (!hum->HasBuffEffect(kBET_HunLuan)) {
|
||||
hum->AddBuff(nullptr, buff_meta, 1, nullptr);
|
||||
player_set.insert(hum);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void MolotorCocktailMiTask::Done()
|
||||
{
|
||||
for (auto& hum : player_set) {
|
||||
hum->RemoveBuffByEffectId(kBET_HunLuan);
|
||||
}
|
||||
}
|
24
server/gameserver/molotor_cocktail_mitask.h
Normal file
24
server/gameserver/molotor_cocktail_mitask.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "microtask.h"
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
struct Buff;
|
||||
struct Equip;
|
||||
}
|
||||
|
||||
class Room;
|
||||
class Player;
|
||||
class MolotorCocktailMiTask : public MicroTask
|
||||
{
|
||||
public:
|
||||
Room* room = nullptr;
|
||||
a8::Vec2 bomb_pos;
|
||||
std::set<Player*> player_set;
|
||||
MetaData::Buff* buff_meta = nullptr;
|
||||
MetaData::Equip* gun_meta = nullptr;
|
||||
|
||||
void Check();
|
||||
void Done();
|
||||
};
|
41
server/gameserver/posiongas_mitask.cc
Normal file
41
server/gameserver/posiongas_mitask.cc
Normal file
@ -0,0 +1,41 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "posiongas_mitask.h"
|
||||
#include "room.h"
|
||||
#include "player.h"
|
||||
#include "metadata.h"
|
||||
|
||||
void PosionGasMiTask::Check()
|
||||
{
|
||||
{
|
||||
std::list<Player*> deleted_hums;
|
||||
for (auto& hum : player_set) {
|
||||
if (bomb_pos.Distance(hum->GetPos()) > gun_meta->i->bullet_rad() + hum->meta->i->radius()) {
|
||||
hum->RemoveBuffByEffectId(kBET_HunLuan);
|
||||
deleted_hums.push_back(hum);
|
||||
}
|
||||
}
|
||||
for (auto& hum : deleted_hums) {
|
||||
player_set.erase(hum);
|
||||
}
|
||||
}
|
||||
room->TouchPlayerList
|
||||
(a8::XParams(),
|
||||
[this] (Player* hum, a8::XParams&) -> bool
|
||||
{
|
||||
if (bomb_pos.Distance(hum->GetPos()) < gun_meta->i->bullet_rad() + hum->meta->i->radius()) {
|
||||
if (!hum->HasBuffEffect(kBET_HunLuan)) {
|
||||
hum->AddBuff(nullptr, buff_meta, 1, nullptr);
|
||||
player_set.insert(hum);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void PosionGasMiTask::Done()
|
||||
{
|
||||
for (auto& hum : player_set) {
|
||||
hum->RemoveBuffByEffectId(kBET_HunLuan);
|
||||
}
|
||||
}
|
24
server/gameserver/posiongas_mitask.h
Normal file
24
server/gameserver/posiongas_mitask.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "microtask.h"
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
struct Buff;
|
||||
struct Equip;
|
||||
}
|
||||
|
||||
class Room;
|
||||
class Player;
|
||||
class PosionGasMiTask : public MicroTask
|
||||
{
|
||||
public:
|
||||
Room* room = nullptr;
|
||||
a8::Vec2 bomb_pos;
|
||||
std::set<Player*> player_set;
|
||||
MetaData::Buff* buff_meta = nullptr;
|
||||
MetaData::Equip* gun_meta = nullptr;
|
||||
|
||||
void Check();
|
||||
void Done();
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user