This commit is contained in:
aozhiwei 2023-03-02 17:58:38 +08:00
parent 3b4108804f
commit 4f64659756
8 changed files with 147 additions and 43 deletions

View File

@ -2139,20 +2139,44 @@ void Human::ProcReloadAction()
void Human::ProcUseItemAction()
{
#if 1
const mt::Equip* item_meta = mt::Equip::GetById(action_item_id);
#else
const mt::Equip* item_meta = mt::Equip::GetByIdBySlotId(action_item_id);
#endif
if (!item_meta) {
return;
}
if (GetInventory(item_meta->_inventory_slot()) <= 0) {
return;
}
switch (action_item_id) {
switch (item_meta->_inventory_slot()) {
case IS_HEALTHKIT:
{
+stats.use_medicine_times;
AddHp(item_meta->heal() * (1 + GetAbility()->GetAttrRate(kHAT_DrugEfficacy)));
switch (std::get<0>(item_meta->_heal)) {
case 1:
{
#if 1
AddHp(std::get<1>(item_meta->_heal));
#else
AddHp(std::<>item_meta->heal() * (1 + GetAbility()->GetAttrRate(kHAT_DrugEfficacy)));
#endif
}
break;
case 2:
{
AddHp(std::get<1>(item_meta->_heal) * GetMaxHP());
}
break;
default:
{
}
break;
}
DecInventory(item_meta->_inventory_slot(), 1);
GetTrigger()->UseItemAction(action_item_id);
GetTrigger()->UseItemAction(item_meta->_inventory_slot());
}
break;
case IS_PAIN_KILLER:
@ -2161,7 +2185,7 @@ void Human::ProcUseItemAction()
if (!pain_killer_timer.expired()) {
int passed_time = (room->GetFrameNo() - pain_killer_frameno) * FRAME_RATE_MS;
int left_time = std::max(0, pain_killer_lastingtime * 1000 - passed_time);
int anodyne_max_time = mt::Param::GetIntParam("anodyne_max_time");
int anodyne_max_time = item_meta->time();
left_time = std::min(left_time, anodyne_max_time * 1000);
pain_killer_lastingtime += std::min(item_meta->time() * 1000,
anodyne_max_time * 1000 - left_time) / 1000;
@ -2169,14 +2193,28 @@ void Human::ProcUseItemAction()
pain_killer_frameno = room->GetFrameNo();
pain_killer_lastingtime = item_meta->time();
if (pain_killer_lastingtime > 0) {
auto heal = item_meta->heal();
pain_killer_timer = room->xtimer.SetIntervalWpEx
(
SERVER_FRAME_RATE,
[this, heal] (int event, const a8::Args* args)
[this, item_meta] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
AddHp(heal);
switch (std::get<0>(item_meta->_heal)) {
case 1:
{
AddHp(std::get<1>(item_meta->_heal));
}
break;
case 2:
{
AddHp(std::get<1>(item_meta->_heal) * GetMaxHP());
}
break;
default:
{
}
break;
}
if (room->GetFrameNo() - pain_killer_frameno >
pain_killer_lastingtime * SERVER_FRAME_RATE) {
room->xtimer.Delete(pain_killer_timer);
@ -2185,45 +2223,60 @@ void Human::ProcUseItemAction()
},
&xtimer_attacher);
}
AddHp(item_meta->heal());
switch (std::get<0>(item_meta->_heal)) {
case 1:
{
AddHp(std::get<1>(item_meta->_heal));
}
break;
case 2:
{
AddHp(std::get<1>(item_meta->_heal) * GetMaxHP());
}
break;
default:
{
}
break;
}
}
DecInventory(item_meta->_inventory_slot(), 1);
MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
GetTrigger()->UseItemAction(action_item_id);
GetTrigger()->UseItemAction(item_meta->_inventory_slot());
}
break;
case IS_SHEN_BAO:
{
+stats.use_medicine_times;
if (!shen_bao_timer.expired()) {
a8::Args args({item_meta->time()});
room->xtimer.FireEvent(shen_bao_timer, kShenBaoAddTimeTimerEvent, &args);
} else {
int exec_time = 0;
int total_time = item_meta->time();
int heal = item_meta->heal();
shen_bao_timer = room->xtimer.SetIntervalWpEx
(
SERVER_FRAME_RATE,
[this, exec_time, total_time, heal] (int event, const a8::Args* args) mutable
{
if (a8::TIMER_EXEC_EVENT == event) {
exec_time += 1;
if (exec_time >= total_time || dead) {
room->xtimer.DeleteCurrentTimer();
} else {
AddHp(heal);
}
} else if (kShenBaoAddTimeTimerEvent == event) {
total_time += args->Get<int>(0);
}
},
&xtimer_attacher);
AddHp(heal);
if (!dead && downed) {
downed = false;
if (!downed_timer.expired()) {
room->xtimer.Delete(downed_timer);
}
if (GetBuffById(kDownBuffId)) {
RemoveBuffById(kDownBuffId);
}
SyncAroundPlayers(__FILE__, __LINE__, __func__);
switch (std::get<0>(item_meta->_heal)) {
case 1:
{
AddHp(std::get<1>(item_meta->_heal));
}
break;
case 2:
{
AddHp(std::get<1>(item_meta->_heal) * GetMaxHP());
}
break;
default:
{
}
break;
}
}
DecInventory(item_meta->_inventory_slot(), 1);
MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
GetTrigger()->UseItemAction(action_item_id);
GetTrigger()->UseItemAction(item_meta->_inventory_slot());
}
break;
default:

View File

@ -174,6 +174,15 @@ namespace mt
_hit_buff_list.push_back(a8::XValue(str));
}
}
{
_heal = std::make_tuple<int, float>(0, 0.0f);
std::vector<std::string> strings;
a8::Split(hit_buff(), strings, ':');
if (strings.size() > 1) {
_heal = std::make_tuple<int, float>(a8::XValue(strings[0]).GetInt(),
a8::XValue(strings[1]).GetDouble());
}
}
}
void Equip::Init2()

View File

@ -29,6 +29,7 @@ namespace mt
int _car_deactive_buff_id = 0;
long long _special_damage_type = 0;
int _group_id = 0;
std::tuple<int, float> _heal;
void Init1();
void Init2();

View File

@ -26,7 +26,7 @@ namespace mtb
int bullet_speed() const { return bullet_speed_; };
int range() const { return range_; };
int use_time() const { return use_time_; };
int heal() const { return heal_; };
const std::string heal() const { return heal_; };
int time() const { return time_; };
const std::string volume() const { return volume_; };
int bullet_rad() const { return bullet_rad_; };
@ -160,7 +160,7 @@ namespace mtb
int bullet_speed_ = 0;
int range_ = 0;
int use_time_ = 0;
int heal_ = 0;
std::string heal_;
int time_ = 0;
std::string volume_;
int bullet_rad_ = 0;

View File

@ -239,7 +239,7 @@ namespace mtb
meta_class->SetSimpleField(13, "bullet_speed", a8::reflect::ET_INT32, my_offsetof2(Equip, bullet_speed_));
meta_class->SetSimpleField(14, "range", a8::reflect::ET_INT32, my_offsetof2(Equip, range_));
meta_class->SetSimpleField(15, "use_time", a8::reflect::ET_INT32, my_offsetof2(Equip, use_time_));
meta_class->SetSimpleField(16, "heal", a8::reflect::ET_INT32, my_offsetof2(Equip, heal_));
meta_class->SetSimpleField(16, "heal", a8::reflect::ET_STRING, my_offsetof2(Equip, heal_));
meta_class->SetSimpleField(17, "time", a8::reflect::ET_INT32, my_offsetof2(Equip, time_));
meta_class->SetSimpleField(18, "volume", a8::reflect::ET_STRING, my_offsetof2(Equip, volume_));
meta_class->SetSimpleField(19, "bullet_rad", a8::reflect::ET_INT32, my_offsetof2(Equip, bullet_rad_));

View File

@ -981,14 +981,45 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
int action_param = 0;
switch (action_item_id) {
case IS_HEALTHKIT:
case IS_SHEN_BAO:
{
action_param = item_meta->heal();
switch (std::get<0>(item_meta->_heal)) {
case 1:
{
action_param = std::get<1>(item_meta->_heal);
}
break;
case 2:
{
action_param = std::get<1>(item_meta->_heal) * GetMaxHP();
}
break;
default:
{
}
break;
}
}
break;
case IS_PAIN_KILLER:
case IS_SHEN_BAO:
{
action_param = item_meta->heal() * item_meta->time();
switch (std::get<0>(item_meta->_heal)) {
case 1:
{
action_param = std::get<1>(item_meta->_heal) * item_meta->time();
}
break;
case 2:
{
action_param = std::get<1>(item_meta->_heal) * GetMaxHP()
* item_meta->time();
}
break;
default:
{
}
break;
}
}
break;
default:

View File

@ -445,14 +445,17 @@ void Player::UpdateUseItemIdx()
1.5);
break;
}
#if 0
GetTrigger()->UseItemAction(use_item_idx);
#endif
use_time *= 1 - GetAbility()->GetAttrRate(kHAT_DrugTime);
use_time -= GetAbility()->GetAttrAbs(kHAT_DrugTime);
use_time = std::max(1, use_time);
StartAction(
AT_UseItem,
use_time,
use_item_idx,
//use_item_idx,
item_meta->id(),
0
);
}
@ -1040,6 +1043,13 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg)
room->SetInfiniteBulletMode();
} else if (cmd == "watchwar") {
AsyncRequestWatchWar(false);
} else if (cmd == "killself") {
float dmg_out = 0;
float dmg = GetMaxHP() + 10;
DecHP(dmg, VP_Gas, TEXT("battle_server_killer_gas", "毒圈"), VW_Gas,
VP_Gas,
TEXT("battle_server_killer_gas", "毒圈"),
dmg_out);
} else if (cmd == "shuaguai" && cmds.size() >= 3) {
int hero_id = a8::XValue(cmds[1]);
int hero_num = a8::XValue(cmds[2]);

View File

@ -156,7 +156,7 @@ message Equip
optional int32 bullet_speed = 13; //
optional int32 range = 14; //
optional int32 use_time = 15; //使
optional int32 heal = 16; //
optional string heal = 16; //
optional int32 time = 17; //
optional string volume = 19; //
optional int32 bullet_rad = 20; //