中级玩家
 
- 贡献度
- 0
- 金元
- 1691
- 积分
- 169
- 精华
- 0
- 注册时间
- 2021-2-26
|
-- Configuration --------------------------
local HPRegenerateValue = 5
local MPRegenerateValue = 5
local ActiveTurnBigorSmallMod = 1
local BigScale = 2.0
local SmallScale = 0.5
local BigAttackIncrease = 100
local SmallDefenceIncrease = 100
local MPCostForBig = 10
local MPCostforSmall = 10
-------------------------------------------
local SimpleCmdShared = require("scShared")
function FVector(x, y, z)
return { X = x, Y = y, Z = z }
end
function FRotator(x, y, z)
return { X = x, Y = y, Z = z }
end
SimpleCmdShared.GetMoveMent = "BGUCharacterMovementComponent"
SimpleCmdShared.GetSpringArm = "BUS_SpringArmComponent"
SimpleCmdShared.GetFollowCam = "UCameraComponent"
local wukong = nil
local wukongcontroller = nil
RegisterHook("/Script/Engine.PlayerController:ClientRestart", function(self, NewPawn)
wukong = NewPawn:get()
wukongcontroller = self:get()
SimpleCmdShared.LogValue(wukong:GetFullName())
end)
local obj = nil
function getobj()
if obj == nil then
obj = StaticFindObject("/Script/b1-Managed.Default__BGUFunctionLibraryCS")
end
return obj
end
function getwukong()
if wukong == nil then
return FindFirstOf("Unit_Player_Wukong_C")
end
return wukong
end
function IsNilOrInvalid(obj)
return obj == nil or not obj:IsValid()
end
-- 数值修正
local atkBase_Current = 0
local defBase_Current = 0
local condition = 0
local changetype = 0
local powerCD = 0
function valueModifier()
local wukong = getwukong()
local obj = getobj()
if IsNilOrInvalid(wukong) or IsNilOrInvalid(obj) then
return
end
local atkBase = obj:GetAttrValue(wukong, 103)
local defBase = obj:GetAttrValue(wukong, 104)
if defBase < 0 or atkBase < 0 then
return
end
if changetype == 1 then
if condition ~= 1 then
local Setvalue = defBase_Current - SmallDefenceIncrease
if Setvalue >= 0 and condition > 1 then
obj:BGUSetAttrValue(wukong, 104, Setvalue)
defBase_Current = 0
end
atkBase_Current = atkBase + BigAttackIncrease
obj:BGUSetAttrValue(wukong, 103, atkBase_Current)
condition = 1
end
elseif changetype == 2 then
local Setvalue = atkBase_Current - BigAttackIncrease
if condition ~= 2 then
if Setvalue >= 0 and condition == 1 then
obj:BGUSetAttrValue(wukong, 103, Setvalue)
atkBase_Current = 0
end
defBase_Current = defBase + SmallDefenceIncrease
obj:BGUSetAttrValue(wukong, 104, defBase_Current)
condition = 2
end
elseif changetype == 0 then
if condition ~= 0 then
if condition == 1 then
local Setvalue = atkBase_Current - BigAttackIncrease
if Setvalue >= 0 then
obj:BGUSetAttrValue(wukong, 103, Setvalue)
end
atkBase_Current = 0
elseif condition > 1 then
local Setvalue = defBase_Current - SmallDefenceIncrease
if Setvalue >= 0 then
obj:BGUSetAttrValue(wukong, 104, Setvalue)
end
defBase_Current = 0
end
condition = 0
end
end
end
function powerCoolDown()
powerCD = 0
end
-- 放大
RegisterKeyBind(Key.OEM_PLUS, function()
if powerCD ~= 1 and ActiveTurnBigorSmallMod ~= 0 then
local newScale = FVector(BigScale,BigScale,BigScale)
changetype = 1
wukong:SetActorScale3D(newScale)
if condition ~= 1 then
local wukong = getwukong()
local obj = getobj()
if not IsNilOrInvalid(wukong) and not IsNilOrInvalid(obj) then
local currentMP = obj:GetAttrValue(wukong, 152)
if currentMP > MPCostForBig then
local Setvalue = currentMP - MPCostForBig
obj:BGUSetAttrValue(wukong, 152, Setvalue)
valueModifier()
powerCD = 1
ExecuteWithDelay(100, function()
powerCoolDown()
end)
end
end
end
local movement = FindAllOf(SimpleCmdShared.GetMoveMent)
for index, value in ipairs(movement) do
local fullName = value:GetFullName()
if string.find(fullName, "Unit_Player_Wukong_C") and string.find(fullName, "CharMoveComp") then
value["MaxStepHeight"] = 1000
end
end
end
end)
-- 缩小
RegisterKeyBind(Key.OEM_MINUS, function()
if powerCD ~= 1 and ActiveTurnBigorSmallMod ~= 0 then
local newScale = FVector(SmallScale,SmallScale,SmallScale)
changetype = 2
wukong:SetActorScale3D(newScale)
if condition ~= 2 then
local wukong = getwukong()
local obj = getobj()
if not IsNilOrInvalid(wukong) and not IsNilOrInvalid(obj) then
local currentMP = obj:GetAttrValue(wukong, 152)
if currentMP > MPCostforSmall then
local Setvalue = currentMP - MPCostforSmall
obj:BGUSetAttrValue(wukong, 152, Setvalue)
valueModifier()
powerCD = 1
ExecuteWithDelay(100, function()
powerCoolDown()
end)
end
end
end
local movement = FindAllOf(SimpleCmdShared.GetMoveMent)
for index, value in ipairs(movement) do
local fullName = value:GetFullName()
if string.find(fullName, "Unit_Player_Wukong_C") and string.find(fullName, "CharMoveComp") then
value["MaxStepHeight"] = 1000
end
end
powerCD = 1
ExecuteWithDelay(100, function()
powerCoolDown()
end)
end
end)
-- 还原
RegisterKeyBind(8, function()
if powerCD ~= 1 and ActiveTurnBigorSmallMod ~= 0 then
local newScale = FVector(1,1,1)
changetype = 0
wukong:SetActorScale3D(newScale)
if condition ~= 0 then
valueModifier()
end
local movement = FindAllOf(SimpleCmdShared.GetMoveMent)
for index, value in ipairs(movement) do
local fullName = value:GetFullName()
if string.find(fullName, "Unit_Player_Wukong_C") and string.find(fullName, "CharMoveComp") then
value["MaxStepHeight"] = 1000
end
end
powerCD = 1
ExecuteWithDelay(100, function()
powerCoolDown()
end)
end
end)
-- 实时检查
local checkInterval = 1000
function CheckData()
local wukong = getwukong()
local obj = getobj()
if not IsNilOrInvalid(wukong) and not IsNilOrInvalid(obj) then
local currentMP = obj:GetAttrValue(wukong, 152)
local MaxMP = obj:GetAttrValue(wukong, 2)
if currentMP < MaxMP and currentMP >= 0 then
local DifferentMP = MaxMP - currentMP
if DifferentMP <= MPRegenerateValue then
obj:BGUSetAttrValue(wukong, 152, MaxMP)
else
local SetMP = currentMP + MPRegenerateValue
obj:BGUSetAttrValue(wukong, 152, SetMP)
end
end
local currentHP = obj:GetAttrValue(wukong, 151)
local MaxHP = obj:GetAttrValue(wukong, 1)
if currentHP < MaxHP and currentHP > 0 then
local DifferentMP = MaxHP - currentHP
if DifferentMP <= HPRegenerateValue then
obj:BGUSetAttrValue(wukong, 151, MaxHP)
else
local SetHP = currentHP + HPRegenerateValue
obj:BGUSetAttrValue(wukong, 151, SetHP)
end
end
local currentScale = wukong:GetActorScale3D()
local atkBase = obj:GetAttrValue(wukong, 103)
local defBase = obj:GetAttrValue(wukong, 104)
if currentScale.X == 1 and condition ~= 0 then
if condition == 1 and atkBase_Current == atkBase then
local newScale = FVector(BigScale,BigScale,BigScale)
wukong:SetActorScale3D(newScale)
local movement = FindAllOf(SimpleCmdShared.GetMoveMent)
for index, value in ipairs(movement) do
local fullName = value:GetFullName()
if string.find(fullName, "Unit_Player_Wukong_C") and string.find(fullName, "CharMoveComp") then
value["MaxStepHeight"] = 1000
end
end
elseif condition ==2 and defBase_Current == defBase then
local newScale = FVector(SmallScale,SmallScale,SmallScale)
wukong:SetActorScale3D(newScale)
local movement = FindAllOf(SimpleCmdShared.GetMoveMent)
for index, value in ipairs(movement) do
local fullName = value:GetFullName()
if string.find(fullName, "Unit_Player_Wukong_C") and string.find(fullName, "CharMoveComp") then
value["MaxStepHeight"] = 1000
end
end
elseif (condition == 1 and atkBase_Current ~= atkBase) or (condition ==2 and defBase_Current ~= defBase) then
condition = 0
end
elseif currentScale.X > 1 and condition == 1 and atkBase_Current ~= atkBase then
atkBase_Current = atkBase
elseif currentScale.X > 1 and condition == 2 and defBase_Current ~= defBase then
defBase_Current = defBas
end
ExecuteWithDelay(checkInterval, function()
CheckData()
end)
end
end
RegisterHook("/Script/Engine.PlayerController:ClientRestart", function(self, NewPawn)
wukong = NewPawn:get()
ExecuteWithDelay(checkInterval * 30, function()
CheckData()
end)
end)
|
|