完成新手掉落刷机器人逻辑
This commit is contained in:
parent
adbf4a174a
commit
bc83b602b7
@ -112,7 +112,7 @@ void Bullet::OnHit(std::set<Entity*>& objects)
|
||||
obstacle->meta->i->damage() > 0.01f) {
|
||||
obstacle->Explosion(this);
|
||||
}
|
||||
room->ScatterDrop(obstacle->GetPos(), obstacle->meta->i->drop());
|
||||
player->DropItems(obstacle);
|
||||
}
|
||||
obstacle->BroadcastFullState(room);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "obstacle.h"
|
||||
#include "player.h"
|
||||
#include "buff.h"
|
||||
#include "roomobstacle.h"
|
||||
|
||||
#include "framework/cpp/utils.h"
|
||||
#include "framework/cpp/httpclientpool.h"
|
||||
@ -473,7 +474,7 @@ bool Human::IsCollisionInMapService()
|
||||
obstacle->Explosion(this);
|
||||
}
|
||||
#endif
|
||||
room->ScatterDrop(obstacle->GetPos(), obstacle->meta->i->drop());
|
||||
DropItems(obstacle);
|
||||
}
|
||||
obstacle->BroadcastFullState(room);
|
||||
} else {
|
||||
@ -2891,6 +2892,61 @@ float Human::GetBuffAttrRate(int attr_type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Human::IsPlayer()
|
||||
{
|
||||
return entity_subtype == EST_Player;
|
||||
}
|
||||
|
||||
bool Human::IsAndroid()
|
||||
{
|
||||
return entity_subtype == EST_Android;
|
||||
}
|
||||
|
||||
void Human::DropItems(Obstacle* obstacle)
|
||||
{
|
||||
bool is_treasure_box = false;
|
||||
if (obstacle->entity_subtype == EST_RoomObstacle) {
|
||||
is_treasure_box = ((RoomObstacle*)obstacle)->is_treasure_box;
|
||||
}
|
||||
int drop_id = obstacle->meta->i->drop();
|
||||
if (room->room_type == RT_NewBrid && IsPlayer()) {
|
||||
if (is_treasure_box) {
|
||||
if (box_drop_times_ < MetaMgr::Instance()->newbie_airdrop.size()) {
|
||||
drop_id = MetaMgr::Instance()->newbie_airdrop[box_drop_times_];
|
||||
}
|
||||
} else {
|
||||
if (normal_drop_times_ < MetaMgr::Instance()->newbie_drop.size()) {
|
||||
if (normal_drop_times_ == 0) {
|
||||
//刷一个机器人
|
||||
room->xtimer.AddDeadLineTimerAndAttach
|
||||
(0,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
hum->room->ShuaNewBieAndroid(hum);
|
||||
},
|
||||
&xtimer_attacher.timer_list_
|
||||
);
|
||||
room->ShuaNewBieAndroid(this);
|
||||
}
|
||||
drop_id = MetaMgr::Instance()->newbie_drop[normal_drop_times_];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (drop_id == 0) {
|
||||
drop_id = obstacle->meta->i->drop();
|
||||
}
|
||||
room->ScatterDrop(obstacle->GetPos(), drop_id);
|
||||
if (is_treasure_box) {
|
||||
++box_drop_times_;
|
||||
} else {
|
||||
++normal_drop_times_;
|
||||
}
|
||||
}
|
||||
|
||||
void Human::RecalcBuffAttr()
|
||||
{
|
||||
buff_attr_abs_ = {};
|
||||
|
@ -244,6 +244,9 @@ class Human : public MoveableEntity
|
||||
void DecItem(int item_id, int item_num);
|
||||
float GetBuffAttrAbs(int attr_id);
|
||||
float GetBuffAttrRate(int attr_id);
|
||||
bool IsPlayer();
|
||||
bool IsAndroid();
|
||||
void DropItems(Obstacle* obstacle);
|
||||
|
||||
protected:
|
||||
void _UpdateMove(int speed);
|
||||
@ -316,6 +319,8 @@ private:
|
||||
std::list<Buff> buff_list_;
|
||||
std::map<int, int> items_;
|
||||
std::set<int> battling_items_;
|
||||
size_t normal_drop_times_ = 0;
|
||||
size_t box_drop_times_ = 0;
|
||||
std::array<Buff*, kBET_End> buff_effect_ = {};
|
||||
|
||||
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
||||
|
@ -305,7 +305,7 @@ void Obstacle::Explosion(Bullet* bullet)
|
||||
obstacle->Die(room);
|
||||
}
|
||||
if (obstacle->IsDead(room)) {
|
||||
room->ScatterDrop(obstacle->GetPos(), obstacle->meta->i->drop());
|
||||
bullet->player->DropItems(obstacle);
|
||||
}
|
||||
obstacle->BroadcastFullState(room);
|
||||
}
|
||||
|
@ -1205,6 +1205,7 @@ void Room::AirDrop(int appear_time, int box_id)
|
||||
if (box_pos.y >= map_meta->i->map_height()) {
|
||||
box_pos.y = map_meta->i->map_height() - 1;
|
||||
}
|
||||
AdjustAirDropPos(thing_meta, box_pos);
|
||||
AabbCollider air_drop_aabb_box;
|
||||
{
|
||||
air_drop_aabb_box._min.x = 0 - thing_meta->i->width()/2.0f;
|
||||
@ -1228,22 +1229,43 @@ void Room::AirDrop(int appear_time, int box_id)
|
||||
return;
|
||||
}
|
||||
frame_event.AddAirDrop(appear_time, box_id, box_pos);
|
||||
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * appear_time / 1000.f,
|
||||
a8::XParams()
|
||||
.SetSender(this)
|
||||
.SetParam1(box_id)
|
||||
.SetParam2(box_pos.x)
|
||||
.SetParam3(box_pos.y),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Room* room = (Room*)param.sender.GetUserData();
|
||||
if (!room->game_over) {
|
||||
room->CreateObstacle(param.param1.GetInt(),
|
||||
param.param2.GetDouble(),
|
||||
param.param3.GetDouble());
|
||||
}
|
||||
},
|
||||
&xtimer_attacher_.timer_list_);
|
||||
xtimer.
|
||||
AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * appear_time / 1000.f,
|
||||
a8::XParams()
|
||||
.SetSender(this)
|
||||
.SetParam1(box_id)
|
||||
.SetParam2(box_pos.x)
|
||||
.SetParam3(box_pos.y),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Room* room = (Room*)param.sender.GetUserData();
|
||||
if (!room->game_over) {
|
||||
RoomObstacle* obstacle = room->
|
||||
CreateObstacle(param.param1.GetInt(),
|
||||
param.param2.GetDouble(),
|
||||
param.param3.GetDouble());
|
||||
obstacle->is_treasure_box = true;
|
||||
}
|
||||
},
|
||||
&xtimer_attacher_.timer_list_);
|
||||
++airdrop_times_;
|
||||
}
|
||||
}
|
||||
|
||||
void Room::AdjustAirDropPos(MetaData::MapThing* thing_meta, a8::Vec2& box_pos)
|
||||
{
|
||||
if (room_type == RT_NewBrid) {
|
||||
if (airdrop_times_ < MetaMgr::Instance()->newbie_airdrop.size()) {
|
||||
for (auto& pair : accountid_hash_) {
|
||||
if (pair.second) {
|
||||
Human* hum = pair.second;
|
||||
a8::Vec2 dir = a8::Vec2::UP;
|
||||
dir.Rotate(a8::RandAngle());
|
||||
box_pos = hum->GetPos() + dir * (80 + rand() % 50);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1695,3 +1717,25 @@ void Room::DisableHuman(Human* target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::ShuaNewBieAndroid(Human* target)
|
||||
{
|
||||
for (auto& pair : human_hash_) {
|
||||
if (pair.second->entity_subtype == EST_Android &&
|
||||
a8::HasBitFlag(pair.second->status, HS_Disable)) {
|
||||
Android* hum = (Android*)pair.second;
|
||||
a8::Vec2 pos = target->GetPos();
|
||||
pos.x -= MetaMgr::Instance()->newbie_first_robot_distance;
|
||||
if (grid_service->BroderOverFlow(pos.x, pos.y)) {
|
||||
a8::Vec2 pos = target->GetPos();
|
||||
pos.x += MetaMgr::Instance()->newbie_first_robot_distance;
|
||||
if (grid_service->BroderOverFlow(pos.x, pos.y)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
hum->SetPos(pos);
|
||||
EnableHuman(hum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ namespace MetaData
|
||||
struct Building;
|
||||
struct AirLine;
|
||||
struct MapTplThing;
|
||||
struct MapThing;
|
||||
}
|
||||
|
||||
namespace metatable
|
||||
@ -114,6 +115,7 @@ public:
|
||||
bool HaveMyTeam(const std::string& team_uuid);
|
||||
ObstacleData* GetPermanentObstacleData(int entity_uniid);
|
||||
long long GetGasInactiveTime();
|
||||
void ShuaNewBieAndroid(Human* target);
|
||||
|
||||
private:
|
||||
int AllocUniid();
|
||||
@ -130,6 +132,7 @@ private:
|
||||
void CombineTeam();
|
||||
void InitAirDrop();
|
||||
void AirDrop(int appear_time, int box_id);
|
||||
void AdjustAirDropPos(MetaData::MapThing* thing_meta, a8::Vec2& box_pos);
|
||||
void ShuaPlane();
|
||||
int NewTeam();
|
||||
RoomObstacle* CreateObstacle(int id, float x, float y);
|
||||
@ -157,6 +160,7 @@ private:
|
||||
int force_shua_android_times_ = 0;
|
||||
MetaData::AirLine* airline_ = nullptr;
|
||||
a8::XTimerAttacher xtimer_attacher_;
|
||||
size_t airdrop_times_ = 0;
|
||||
|
||||
int current_teamid_ = 0;
|
||||
int current_uniid_ = FIXED_OBJECT_MAXID;
|
||||
|
@ -7,6 +7,7 @@ class RoomObstacle : public Obstacle
|
||||
public:
|
||||
Room* room = nullptr;
|
||||
a8::XTimerAttacher xtimer_attacher;
|
||||
bool is_treasure_box = false;
|
||||
|
||||
RoomObstacle();
|
||||
virtual ~RoomObstacle() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user