解决了狐狸大招冷却和消耗的问题

This commit is contained in:
2025-10-18 17:30:58 +08:00
parent e0d7329905
commit ddde270ad5
11 changed files with 65 additions and 31 deletions

View File

@ -9,6 +9,7 @@ InvalidTagCharacters="\"\',"
NumBitsForContainerSize=6
NetIndexFirstBitSegment=16
+GameplayTagList=(Tag="Ability.Block.UltimatePlaying",DevComment="大招正在释放中")
+GameplayTagList=(Tag="Ability.Flags.Cooldown",DevComment="技能冷却")
+GameplayTagList=(Tag="Ability.Flags.Recast",DevComment="可以再次释放技能的标记")
+GameplayTagList=(Tag="Ability.Role.AttributeConsume",DevComment="角色属性损耗debuff")
+GameplayTagList=(Tag="Ability.Role.EatFood",DevComment="干饭")

Binary file not shown.

Binary file not shown.

View File

@ -11,12 +11,18 @@ function FoxUltimate:ctor()
self.ultimate_phase = 1 -- 大招阶段
self.active_recast_handle = nil
self.active_accelerate_handle = nil
self.tag_add_or_remove_delegate = nil
end
function FoxUltimate:K2_ActivateAbilityFromEvent(EventData)
print("FoxUltimate:K2_ActivateAbilityFromEvent", self.ultimate_phase)
if not self:K2_CommitAbilityCost(false) then
return self:K2_EndAbility()
end
local owner = self:GetOwningActorFromActorInfo()
self.movement = owner.MovementComponent
self.animation = owner.SpineAnimationComponent
@ -25,8 +31,17 @@ function FoxUltimate:K2_ActivateAbilityFromEvent(EventData)
local asc = self.asc
if self.tag_add_or_remove_delegate == nil then
self.tag_add_or_remove_delegate = slua.createDelegate(function(tag, is_add)
if is_add == 0 and not self.bIsActive then
self.ultimate_phase = 1
self:K2_CommitAbilityCooldown(false, false)
end
end)
owner:BindGameplayTagAddOrRemove(self.recast_tag, self.tag_add_or_remove_delegate)
end
if self.ultimate_phase == 1 or asc:HasMatchingGameplayTag(self.recast_tag) then
print("triggered")
self:TriggerUltimate(asc)
else
self:K2_EndAbility()
@ -134,7 +149,19 @@ end
function FoxUltimate:OnAnimationComplete(entry)
self.ultimate_phase = self.ultimate_phase + 1
local new_phase = self.ultimate_phase + 1
if new_phase > 3 then
self.ultimate_phase = 1
else
self.ultimate_phase = new_phase
end
print("FoxUltimate:OnAnimationComplete", self.ultimate_phase)
if not self.asc:HasMatchingGameplayTag(self.recast_tag) then
self.ultimate_phase = 1
self:K2_CommitAbilityCooldown(false, false)
end
entry.AnimationComplete:Clear()
entry.AnimationEvent:Clear()
self:K2_EndAbility()

View File

@ -1,27 +1,9 @@
#include "LuaCppBinding.h"
#include "AbilitySystemComponent.h"
#include "GameplayTagContainer.h"
using slua::lua_State, slua::LuaObject, slua::LuaStruct;
using namespace slua;
#pragma optimize( "", off )
bool HasMatchingGameplayTag(const UAbilitySystemComponent& Asc, const FName& TagName)
{
// return Asc.HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(TagName));
return true;
}
extern void RegisterAbilitySystemComponentExtension() {
REG_EXTENSION_METHOD_LAMBDA(UAbilitySystemComponent, "AHasMatchingGameplayTag", false,
[](UAbilitySystemComponent* ASC, const FName& Tag) -> bool {
return true;
}
);
}
#pragma optimize( "", on)

View File

@ -77,3 +77,18 @@ void ABusyPawnBase::InitPawnAbilities(const FBusyPawnBaseConfig& Config)const
}
}
void ABusyPawnBase::BindGameplayTagAddOrRemove(const FGameplayTag& Tag, FGameplayTagAddOrRemoveDelegate Delegate)const
{
AbilitySystemComponent->RegisterGameplayTagEvent(Tag, EGameplayTagEventType::NewOrRemoved).AddLambda(
[Delegate](const FGameplayTag GameplayTag, const int32 Value)
{
Delegate.ExecuteIfBound(GameplayTag, Value);
}
);
}
void ABusyPawnBase::InitCollision()
{
}

View File

@ -32,18 +32,18 @@ void ABusyPlayerRole::InitPawnAttributes(const struct FBusyPawnBaseConfig& Confi
Super::InitPawnAttributes(Config);
UBusyPlayerRoleAttributeSet* RoleAttributes = Cast<UBusyPlayerRoleAttributeSet>(Attributes);
if (RoleAttributes && Config.StaticStruct() == FBusyRoleBaseConfig::StaticStruct())
// if (RoleAttributes && Config.StaticStruct() == FBusyRoleBaseConfig::StaticStruct())
{
const FBusyRoleBaseConfig* RoleConfig = static_cast<const FBusyRoleBaseConfig*>(&Config);
RoleAttributes->InitHunger(RoleConfig->Hunger);
RoleAttributes->InitMaxHunger(RoleConfig->Hunger);
RoleAttributes->InitHungerConsume(RoleConfig->HungerConsume);
}
else
{
UE_LOG(LogBusyPawn, Warning, TEXT("ABusyPlayerRole::InitPawnAttributes Failed, RoleAttribute: %p, ConfigName: %s"),
RoleAttributes, *Config.StaticStruct()->GetFName().ToString()
);
}
// else
// {
// UE_LOG(LogBusyPawn, Warning, TEXT("ABusyPlayerRole::InitPawnAttributes Failed, RoleAttribute: %p, ConfigName: %s"),
// RoleAttributes, *Config.StaticStruct()->GetFName().ToString()
// );
// }
}

View File

@ -4,15 +4,17 @@
#include "Level/Actor/Components/BusyAbilitySystemComponent.h"
#include "BusyPawnBase.generated.h"
class USphereComponent;
struct FBusyPawnBaseConfig;
class USphereComponent;
class USpineBoneFollowerComponent;
class USpineSkeletonRendererComponent;
class USpineSkeletonAnimationComponent;
class UBusyPawnMovementComponent;
DECLARE_DYNAMIC_DELEGATE_TwoParams(FGameplayTagAddOrRemoveDelegate, const FGameplayTag&, Tag, const int32, Value);
#define MY_ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
@ -67,6 +69,13 @@ public:
virtual void InitPawnAttributes(const FBusyPawnBaseConfig& Config);
virtual void InitPawnAbilities(const FBusyPawnBaseConfig& Config) const;
public:
UFUNCTION(BlueprintCallable)
void BindGameplayTagAddOrRemove(const FGameplayTag& Tag, FGameplayTagAddOrRemoveDelegate Delegate)const;
protected:
void InitCollision();
protected:
UPROPERTY(EditDefaultsOnly)