add buff
This commit is contained in:
parent
d5cf643107
commit
ca61fb7f7e
0
server/gameserver/buff.cc
Normal file
0
server/gameserver/buff.cc
Normal file
23
server/gameserver/buff.h
Normal file
23
server/gameserver/buff.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
struct Player;
|
||||
struct Equip;
|
||||
struct Dress;
|
||||
struct Skill;
|
||||
struct Tank;
|
||||
struct Buff;
|
||||
}
|
||||
|
||||
class Human;
|
||||
class Buff
|
||||
{
|
||||
public:
|
||||
Human* owner = nullptr;
|
||||
MetaData::Buff* meta = nullptr;
|
||||
MetaData::Skill* skill_meta = nullptr;
|
||||
a8::XTimerAttacher xtimer_attacher;
|
||||
long long add_frameno = 0;
|
||||
|
||||
};
|
@ -639,181 +639,6 @@ bool Human::HasNoDownedTeammate()
|
||||
|
||||
void Human::DoSkill()
|
||||
{
|
||||
#if 0
|
||||
if (skill_meta && skill_meta->i->condition() == SC_Active) {
|
||||
int passed_time = (room->frame_no - last_use_skill_frameno_) * FRAME_RATE_MS;
|
||||
int skill_left_time = std::max(0, skill_meta->last_time * 1000 - passed_time);
|
||||
if (skill_left_time <= 0 || last_use_skill_frameno_ == 0) {
|
||||
skill_xtimer_attacher_.ClearTimerList();
|
||||
switch (skill_meta->i->type()) {
|
||||
case ST_Hide:
|
||||
{
|
||||
hide_frameno_ = room->frame_no;
|
||||
a8::SetBitFlag(status, HS_Hide);
|
||||
room->xtimer.AddDeadLineTimerAndAttach(skill_meta->last_time * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
},
|
||||
&skill_xtimer_attacher_.timer_list_,
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
a8::UnSetBitFlag(hum->status, HS_Hide);
|
||||
hum->need_sync_active_player = true;
|
||||
hum->BroadcastFullState();
|
||||
}
|
||||
);
|
||||
need_sync_active_player = true;
|
||||
BroadcastFullState();
|
||||
}
|
||||
break;
|
||||
case ST_SummonHero:
|
||||
{
|
||||
SummonHero();
|
||||
}
|
||||
break;
|
||||
case ST_Accelerate:
|
||||
{
|
||||
accelerate_frameno_ = room->frame_no;
|
||||
a8::SetBitFlag(status, HS_Accelerate);
|
||||
buff.speed += skill_meta->value1;
|
||||
room->xtimer.AddDeadLineTimerAndAttach(skill_meta->last_time * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
},
|
||||
&skill_xtimer_attacher_.timer_list_,
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
a8::UnSetBitFlag(hum->status, HS_Accelerate);
|
||||
hum->buff.speed = 0.0f;
|
||||
hum->need_sync_active_player = true;
|
||||
hum->BroadcastFullState();
|
||||
}
|
||||
);
|
||||
need_sync_active_player = true;
|
||||
BroadcastFullState();
|
||||
}
|
||||
break;
|
||||
case ST_DamageAdd:
|
||||
{
|
||||
damageadd_frameno_ = room->frame_no;
|
||||
a8::SetBitFlag(status, HS_DamageAdd);
|
||||
room->xtimer.AddDeadLineTimerAndAttach(skill_meta->last_time * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
},
|
||||
&skill_xtimer_attacher_.timer_list_,
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
a8::UnSetBitFlag(hum->status, HS_DamageAdd);
|
||||
hum->need_sync_active_player = true;
|
||||
hum->BroadcastFullState();
|
||||
}
|
||||
);
|
||||
need_sync_active_player = true;
|
||||
BroadcastFullState();
|
||||
}
|
||||
break;
|
||||
case ST_DefAdd:
|
||||
{
|
||||
defadd_frameno_ = room->frame_no;
|
||||
a8::SetBitFlag(status, HS_DefAdd);
|
||||
room->xtimer.AddDeadLineTimerAndAttach(skill_meta->last_time * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
},
|
||||
&skill_xtimer_attacher_.timer_list_,
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
a8::UnSetBitFlag(hum->status, HS_DefAdd);
|
||||
hum->need_sync_active_player = true;
|
||||
hum->BroadcastFullState();
|
||||
}
|
||||
);
|
||||
need_sync_active_player = true;
|
||||
BroadcastFullState();
|
||||
}
|
||||
break;
|
||||
case ST_RecoverHP:
|
||||
{
|
||||
recover_hp_frameno_ = room->frame_no;
|
||||
a8::SetBitFlag(status, HS_RecoverHP);
|
||||
room->xtimer.AddRepeatTimerAndAttach(SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(this)
|
||||
.SetParam1(skill_meta->i->value1()),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
if (a8::HasBitFlag(hum->status, HS_RecoverHP)) {
|
||||
hum->RecoverHp(param.param1);
|
||||
hum->need_sync_active_player = true;
|
||||
}
|
||||
},
|
||||
&skill_xtimer_attacher_.timer_list_
|
||||
);
|
||||
room->xtimer.AddDeadLineTimerAndAttach(skill_meta->last_time * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
},
|
||||
&skill_xtimer_attacher_.timer_list_,
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
a8::UnSetBitFlag(hum->status, HS_RecoverHP);
|
||||
hum->need_sync_active_player = true;
|
||||
hum->BroadcastFullState();
|
||||
}
|
||||
);
|
||||
need_sync_active_player = true;
|
||||
BroadcastFullState();
|
||||
}
|
||||
break;
|
||||
case ST_ReflectDamage:
|
||||
{
|
||||
reflect_damage_frameno_ = room->frame_no;
|
||||
a8::SetBitFlag(status, HS_ReflectDamage);
|
||||
room->xtimer.AddDeadLineTimerAndAttach(skill_meta->last_time * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
},
|
||||
&skill_xtimer_attacher_.timer_list_,
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
a8::UnSetBitFlag(hum->status, HS_ReflectDamage);
|
||||
hum->need_sync_active_player = true;
|
||||
hum->BroadcastFullState();
|
||||
}
|
||||
);
|
||||
need_sync_active_player = true;
|
||||
BroadcastFullState();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
last_use_skill_frameno_ = room->frame_no;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Human::FindLocation()
|
||||
@ -1537,105 +1362,6 @@ void Human::ClearFrameData()
|
||||
}
|
||||
}
|
||||
|
||||
void Human::GenBattleReportData(a8::MutableXObject* params)
|
||||
{
|
||||
int rank = 0;
|
||||
{
|
||||
std::vector<Human*> human_list;
|
||||
room->TouchHumanList(a8::XParams(),
|
||||
[&human_list] (Human* hum, a8::XParams& param) -> bool
|
||||
{
|
||||
human_list.push_back(hum);
|
||||
return true;
|
||||
});
|
||||
std::sort(human_list.begin(), human_list.end(),
|
||||
[] (Human* a, Human* b )
|
||||
{
|
||||
if (a->dead_frameno == b->dead_frameno) {
|
||||
return a->entity_uniid < b->entity_uniid;
|
||||
} else {
|
||||
return a->dead_frameno == 0 ||
|
||||
(b->dead_frameno != 0 && a->dead_frameno > b->dead_frameno);
|
||||
}
|
||||
});
|
||||
rank = human_list.size();
|
||||
for (size_t i = 0; i < human_list.size(); ++i) {
|
||||
if (human_list[i] == this) {
|
||||
rank = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
params->SetVal("account_id", account_id);
|
||||
params->SetVal("map_id", room->map_meta->i->map_id());
|
||||
params->SetVal("map_name", room->map_meta->i->map_name());
|
||||
params->SetVal("map_tpl_name", room->map_tpl_name);
|
||||
params->SetVal("game_time", time(nullptr));
|
||||
params->SetVal("hurt", stats.damage_amount_in);
|
||||
params->SetVal("rank", rank);
|
||||
params->SetVal("kills", stats.kills);
|
||||
params->SetVal("harm", stats.damage_amount_out);
|
||||
params->SetVal("add_HP", stats.heal_amount);
|
||||
if (!dead) {
|
||||
params->SetVal("alive_time", room->frame_no * 1000.0f / SERVER_FRAME_RATE);
|
||||
} else {
|
||||
params->SetVal("alive_time", dead_frameno * 1000.0f / SERVER_FRAME_RATE);
|
||||
}
|
||||
params->SetVal("team_status", team_members && team_members->size() > 1 ? 1 : 0);
|
||||
params->SetVal("room_uuid", room->room_uuid);
|
||||
|
||||
int snipe_kill = 0;
|
||||
int rifle_kill = 0;
|
||||
int pistol_kill = 0;
|
||||
int submachine_kill = 0;
|
||||
for (Human* hum : kill_humans) {
|
||||
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(hum->lethal_weapon);
|
||||
if (equip_meta) {
|
||||
switch (equip_meta->i->equip_subtype()) {
|
||||
case 7:
|
||||
{
|
||||
//狙击枪
|
||||
++snipe_kill;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
//步枪
|
||||
++rifle_kill;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
//手枪
|
||||
++pistol_kill;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
//冲锋枪
|
||||
++submachine_kill;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
params->SetVal("snipe_kill", snipe_kill);
|
||||
params->SetVal("rifle_kill", rifle_kill);
|
||||
params->SetVal("pistol_kill", pistol_kill);
|
||||
params->SetVal("submachine_kill", submachine_kill);
|
||||
|
||||
params->SetVal("rescue_member", stats.rescue_member);
|
||||
{
|
||||
float rank_param = MetaMgr::Instance()->GetRankRewardParam(rank);
|
||||
float kill_param = MetaMgr::Instance()->GetKillRewardParam(stats.kills);
|
||||
int coin_num = (rank_param * MetaMgr::Instance()->rank_param) +
|
||||
(kill_param * MetaMgr::Instance()->kill_param);
|
||||
stats.gold = coin_num;
|
||||
params->SetVal("coin_num", coin_num);
|
||||
}
|
||||
params->SetVal("score", 0);
|
||||
}
|
||||
|
||||
void Human::DeadDrop()
|
||||
{
|
||||
for (auto& weapon : weapons) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "entity.h"
|
||||
#include "cs_proto.pb.h"
|
||||
#include "GGListener.h"
|
||||
#include "buff.h"
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
@ -232,6 +233,7 @@ protected:
|
||||
private:
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
long long last_sync_gas_frameno = 0;
|
||||
std::list<Buff> buff_list_;
|
||||
|
||||
bool already_report_battle_ = false;
|
||||
bool sent_game_end_ = false;
|
||||
|
@ -357,6 +357,10 @@ namespace MetaData
|
||||
{
|
||||
}
|
||||
|
||||
void Buff::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void Dress::Init()
|
||||
{
|
||||
for (size_t j = 0; j < i->max_lv(); ++j) {
|
||||
|
@ -128,6 +128,13 @@ namespace MetaData
|
||||
void Init();
|
||||
};
|
||||
|
||||
struct Buff
|
||||
{
|
||||
const metatable::Buff* i = nullptr;
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
struct Dress
|
||||
{
|
||||
const metatable::Dress* i = nullptr;
|
||||
|
@ -172,6 +172,12 @@ message Tank
|
||||
optional int32 bullet_id = 2;
|
||||
optional int32 max_lv = 3;
|
||||
}
|
||||
|
||||
message Buff
|
||||
{
|
||||
optional int32 buff_id = 1;
|
||||
}
|
||||
|
||||
//end
|
||||
|
||||
message DoorObjJson
|
||||
|
Loading…
x
Reference in New Issue
Block a user