This commit is contained in:
aozhiwei 2024-05-23 15:31:26 +08:00
parent 3a41ec1f53
commit bee91b360a
4 changed files with 92 additions and 1 deletions

View File

@ -273,6 +273,12 @@ void CallFuncBuff::Activate()
ShowExplosion(); ShowExplosion();
} }
break; break;
case BuffCallFunc_e::kAddArmorShield:
{
hold_param2_ = meta->GetBuffParam2(this);
AddArmorShield();
}
break;
default: default:
{ {
} }
@ -323,6 +329,14 @@ void CallFuncBuff::Deactivate()
} }
} }
break; break;
case BuffCallFunc_e::kAddArmorShield:
{
float dur_time = meta->GetBuffParam3(this);
if (dur_time > 0.00001f) {
owner->ClearArmorShield();
}
}
break;
default: default:
{ {
} }
@ -1860,3 +1874,50 @@ void CallFuncBuff::ShowExplosion()
explosion_effect, explosion_effect,
0); 0);
} }
void CallFuncBuff::AddArmorShield()
{
if (!owner->dead && !owner->downed) {
float dur_time = meta->GetBuffParam3(this);
if (dur_time < 0.00001f) {
dur_time = 99999999;
}
if (owner->armor_shield > 0) {
is_valid_ = false;
#if 0
owner->GetTrigger()->UpdateArmorShield(hold_param2_, dur_time);
#endif
} else {
owner->AddArmorShield(hold_param2_);
#if 0
event_handlers_.push_back(owner->GetTrigger()->AddListener
(
kUpdateArmorShieldEvent,
[this] (const a8::Args& args) mutable
{
int value = args.Get<int>(0);
int new_time = args.Get<int>(1);
owner->AddArmorShield(value);
}));
event_handlers_.push_back(owner->GetTrigger()->AddListener
(
kDestoryArmorShieldEvent,
[this] (const a8::Args& args) mutable
{
owner->RemoveBuffByUniId(buff_uniid);
}));
#endif
owner->room->xtimer.SetTimeoutWpEx
(
dur_time / FRAME_RATE_MS,
[owner = owner, buff_uniid = buff_uniid] (int event, const a8::Args* args) mutable
{
if (a8::TIMER_DELETE_EVENT == event) {
owner->ClearArmorShield();
owner->RemoveBuffByUniId(buff_uniid);
}
},
&owner->xtimer_attacher);
}
}
}

View File

@ -45,9 +45,9 @@ A8_DECLARE_CLASS_ENUM(BuffCallFunc_e, int,
kBuffEffectCondAdd = 45, kBuffEffectCondAdd = 45,
kRandAdd = 46, kRandAdd = 46,
kShowExplosion = 47, kShowExplosion = 47,
kAddArmorShield = 48,
); );
class CallFuncBuff : public Buff class CallFuncBuff : public Buff
{ {
public: public:
@ -90,6 +90,7 @@ class CallFuncBuff : public Buff
void BuffEffectCondAdd(); void BuffEffectCondAdd();
void RandAdd(); void RandAdd();
void ShowExplosion(); void ShowExplosion();
void AddArmorShield();
void InternalRangeHoldBuff(std::function<bool(glm::vec3&)> get_center_func); void InternalRangeHoldBuff(std::function<bool(glm::vec3&)> get_center_func);

View File

@ -3079,6 +3079,32 @@ void Creature::ClearEnergyShield()
false); false);
} }
void Creature::AddArmorShield(int value)
{
armor_shield = value;
max_armor_shield = value;
room->frame_event.AddPropChg
(
GetWeakPtrRef(),
kPropArmorShield,
armor_shield,
max_armor_shield,
true);
}
void Creature::ClearArmorShield()
{
armor_shield = 0;
max_armor_shield = 0;
room->frame_event.AddPropChg
(
GetWeakPtrRef(),
kPropArmorShield,
armor_shield,
max_armor_shield,
true);
}
std::weak_ptr<Effect> Creature::AddEffect(int effect_id) std::weak_ptr<Effect> Creature::AddEffect(int effect_id)
{ {
auto effect = std::make_shared<Effect>(); auto effect = std::make_shared<Effect>();

View File

@ -268,6 +268,9 @@ class Creature : public MoveableEntity
void AddEnergyShield(int value); void AddEnergyShield(int value);
void ClearEnergyShield(); void ClearEnergyShield();
void AddArmorShield(int value);
void ClearArmorShield();
void StartAction(ActionType_e action_type, void StartAction(ActionType_e action_type,
int action_duration, int action_duration,
int item_id, int item_id,