1
This commit is contained in:
commit
c267859f55
@ -1169,10 +1169,18 @@ void Creature::Initialize()
|
|||||||
}
|
}
|
||||||
if (IsHuman()) {
|
if (IsHuman()) {
|
||||||
a8::XTimerWp nature_recover_hp_timer;
|
a8::XTimerWp nature_recover_hp_timer;
|
||||||
|
auto battling_state = std::make_shared<bool>(true);
|
||||||
|
GetTrigger()->AddListener
|
||||||
|
(
|
||||||
|
kBattleStartEvent,
|
||||||
|
[battling_state] (const a8::Args& args)
|
||||||
|
{
|
||||||
|
*battling_state = true;
|
||||||
|
});
|
||||||
nature_recover_hp_idle_timer = room->xtimer.SetIntervalWpEx
|
nature_recover_hp_idle_timer = room->xtimer.SetIntervalWpEx
|
||||||
(
|
(
|
||||||
SERVER_FRAME_RATE * mt::Param::s().nature_recover_hp_idletime,
|
SERVER_FRAME_RATE * mt::Param::s().nature_recover_hp_idletime,
|
||||||
[this, nature_recover_hp_timer] (int event, const a8::Args* args) mutable
|
[this, nature_recover_hp_timer, battling_state] (int event, const a8::Args* args) mutable
|
||||||
{
|
{
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
if (nature_recover_hp_timer.expired() && !HasBuffEffect(kBET_Dive)) {
|
if (nature_recover_hp_timer.expired() && !HasBuffEffect(kBET_Dive)) {
|
||||||
@ -1193,7 +1201,10 @@ void Creature::Initialize()
|
|||||||
},
|
},
|
||||||
&xtimer_attacher);
|
&xtimer_attacher);
|
||||||
}
|
}
|
||||||
|
if (*battling_state) {
|
||||||
|
*battling_state = false;
|
||||||
GetTrigger()->LeaveBattleMode();
|
GetTrigger()->LeaveBattleMode();
|
||||||
|
}
|
||||||
} else if (kRemoveNatureRecoverTimerEvent == event) {
|
} else if (kRemoveNatureRecoverTimerEvent == event) {
|
||||||
room->xtimer.ModifyTime
|
room->xtimer.ModifyTime
|
||||||
(nature_recover_hp_idle_timer,
|
(nature_recover_hp_idle_timer,
|
||||||
@ -1201,6 +1212,7 @@ void Creature::Initialize()
|
|||||||
if (!nature_recover_hp_timer.expired()) {
|
if (!nature_recover_hp_timer.expired()) {
|
||||||
room->xtimer.Delete(nature_recover_hp_timer);
|
room->xtimer.Delete(nature_recover_hp_timer);
|
||||||
}
|
}
|
||||||
|
*battling_state = true;
|
||||||
GetTrigger()->EnterBattleMode();
|
GetTrigger()->EnterBattleMode();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2504,6 +2516,7 @@ void Creature::OnBattleStart(Room* room)
|
|||||||
TryAddBuffAndSetTime(this, kInvincibleBuffId, FRAME_RATE_MS * 2);
|
TryAddBuffAndSetTime(this, kInvincibleBuffId, FRAME_RATE_MS * 2);
|
||||||
}
|
}
|
||||||
battle_start_time_ = f8::App::Instance()->GetNowTime();
|
battle_start_time_ = f8::App::Instance()->GetNowTime();
|
||||||
|
GetTrigger()->OnBattleStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Creature::CanFollow(Creature* follower)
|
bool Creature::CanFollow(Creature* follower)
|
||||||
|
@ -127,6 +127,11 @@ namespace mt
|
|||||||
s_.speed_rf = GetIntParam("SpeedRF", 5.0f);
|
s_.speed_rf = GetIntParam("SpeedRF", 5.0f);
|
||||||
s_.speed_rate_max = GetIntParam("SpeedRateMax", 0.2f);
|
s_.speed_rate_max = GetIntParam("SpeedRateMax", 0.2f);
|
||||||
|
|
||||||
|
s_.battle_hint_interval = GetIntParam("battle_hint_interval", s_.battle_hint_interval);
|
||||||
|
s_.battle_hint_duration = GetIntParam("battle_hint_duration", s_.battle_hint_duration);
|
||||||
|
s_.battle_hint_view_range = GetIntParam("battle_hint_view_range", s_.battle_hint_view_range);
|
||||||
|
s_.battle_hint_broadcast_range = GetIntParam("battle_hint_broadcast_range", s_.battle_hint_broadcast_range + 800);
|
||||||
|
|
||||||
#ifdef MYDEBUG
|
#ifdef MYDEBUG
|
||||||
s_.match_team_time = 6;
|
s_.match_team_time = 6;
|
||||||
s_.match_robot_time = 5;
|
s_.match_robot_time = 5;
|
||||||
|
@ -172,7 +172,7 @@ namespace mt
|
|||||||
int battle_hint_interval = 10;
|
int battle_hint_interval = 10;
|
||||||
int battle_hint_duration = 10;
|
int battle_hint_duration = 10;
|
||||||
int battle_hint_view_range = 512;
|
int battle_hint_view_range = 512;
|
||||||
int battle_hint_broadcast_range = 800;
|
int battle_hint_broadcast_range = 1600;
|
||||||
|
|
||||||
std::vector<float> block_effect_range;
|
std::vector<float> block_effect_range;
|
||||||
std::vector<float> crit_effect_range;
|
std::vector<float> crit_effect_range;
|
||||||
|
@ -2185,7 +2185,8 @@ void Human::SendViewerUiMemberUpdate(std::vector<int> member_ids)
|
|||||||
|
|
||||||
void Human::BroadcastBattleHint()
|
void Human::BroadcastBattleHint()
|
||||||
{
|
{
|
||||||
if (room->GetFrameNo() - last_battle_hint_frameno_ >= mt::Param::s().battle_hint_interval) {
|
if (room->GetFrameNo() - last_battle_hint_frameno_ >=
|
||||||
|
mt::Param::s().battle_hint_interval * SERVER_FRAME_RATE) {
|
||||||
if (last_battle_hint_uniid_ > 0) {
|
if (last_battle_hint_uniid_ > 0) {
|
||||||
if (room->GetFrameNo() - last_battle_hint_frameno_ <
|
if (room->GetFrameNo() - last_battle_hint_frameno_ <
|
||||||
mt::Param::s().battle_hint_duration * SERVER_FRAME_RATE + 8) {
|
mt::Param::s().battle_hint_duration * SERVER_FRAME_RATE + 8) {
|
||||||
@ -2196,6 +2197,8 @@ void Human::BroadcastBattleHint()
|
|||||||
last_battle_hint_uniid_ = 0;
|
last_battle_hint_uniid_ = 0;
|
||||||
}
|
}
|
||||||
last_battle_hint_frameno_ = room->GetFrameNo();
|
last_battle_hint_frameno_ = room->GetFrameNo();
|
||||||
|
#ifdef MYDEBUG
|
||||||
|
#endif
|
||||||
std::shared_ptr<cs::SMAddBattleHint> notify_msg;
|
std::shared_ptr<cs::SMAddBattleHint> notify_msg;
|
||||||
room->TraversePlayerList
|
room->TraversePlayerList
|
||||||
(
|
(
|
||||||
|
@ -738,3 +738,8 @@ void Trigger::BulletDmgEnd(Creature* target)
|
|||||||
{
|
{
|
||||||
DispatchEvent(kBulletDmgEndEvent, {target});
|
DispatchEvent(kBulletDmgEndEvent, {target});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Trigger::OnBattleStart()
|
||||||
|
{
|
||||||
|
DispatchEvent(kBattleStartEvent, {});
|
||||||
|
}
|
||||||
|
@ -39,6 +39,7 @@ enum EventId_e
|
|||||||
kBulletDmgStartEvent,
|
kBulletDmgStartEvent,
|
||||||
kBulletDmgEndEvent,
|
kBulletDmgEndEvent,
|
||||||
kCrazeModeEvent,
|
kCrazeModeEvent,
|
||||||
|
kBattleStartEvent
|
||||||
};
|
};
|
||||||
|
|
||||||
class Weapon;
|
class Weapon;
|
||||||
@ -94,6 +95,7 @@ public:
|
|||||||
void BeAttack(int attacker_id);
|
void BeAttack(int attacker_id);
|
||||||
void BulletDmgStart(Creature* target);
|
void BulletDmgStart(Creature* target);
|
||||||
void BulletDmgEnd(Creature* target);
|
void BulletDmgEnd(Creature* target);
|
||||||
|
void OnBattleStart();
|
||||||
|
|
||||||
std::weak_ptr<EventHandler> AddListener(int event_id, a8::CommonCbProc cb);
|
std::weak_ptr<EventHandler> AddListener(int event_id, a8::CommonCbProc cb);
|
||||||
void RemoveEventHandler(std::weak_ptr<EventHandler> handler_ptr);
|
void RemoveEventHandler(std::weak_ptr<EventHandler> handler_ptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user