Skip to content

Commit

Permalink
Implement feature: Super Hammer - Combo - Fling victims (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Toney authored Dec 31, 2024
1 parent fe8c554 commit 86934cc
Showing 1 changed file with 89 additions and 47 deletions.
136 changes: 89 additions & 47 deletions src/ServerStorage/Classes/Items/SuperHammerServerItem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function SuperHammerServerItem.new(): ServerItem
local comboBreakingTask: thread?;
local staminaRecoverySuppressionEffect: Effect?;
local animationTrack: AnimationTrack;
local stunLockObjects: {AlignOrientation | AlignPosition} = {};
local stunnedContestants: {[ServerContestant]: {AlignOrientation | AlignPosition}} = {};

local function activate(self: ServerItem, action: Action): ()

Expand Down Expand Up @@ -286,6 +286,38 @@ function SuperHammerServerItem.new(): ServerItem

if comboCount >= 10 then

-- Fling the victims.
for contestant, alignmentObjects in pairs(stunnedContestants) do

if contestant ~= _contestant then

for _, alignmentObject in alignmentObjects do

alignmentObject:Destroy();

end;

local humanoidRootPart = if contestant.character then contestant.character:FindFirstChild("HumanoidRootPart") else nil;
local rootAttachment = if humanoidRootPart then humanoidRootPart:FindFirstChild("RootAttachment") else nil;
if humanoidRootPart and humanoidRootPart:IsA("BasePart") and rootAttachment and rootAttachment:IsA("Attachment") then

local linearVelocity = Instance.new("LinearVelocity");
linearVelocity.Attachment0 = rootAttachment;
linearVelocity.Parent = humanoidRootPart;
linearVelocity.VectorVelocity = (humanoidRootPart.Position - _meshPart.Position).Unit * 500;
linearVelocity.MaxForce = math.huge;
task.delay(1, function()

linearVelocity:Destroy();

end);

end;

end;

end;

task.wait(0.5);
self:breakdown();

Expand Down Expand Up @@ -314,72 +346,79 @@ function SuperHammerServerItem.new(): ServerItem
local possibleEnemyCharacter = possibleEnemyContestant.character;
if possibleEnemyContestant ~= _contestant and possibleEnemyCharacter and basePart:IsDescendantOf(possibleEnemyCharacter) and not table.find(immuneContestants, possibleEnemyContestant) then

onEnemyHit:Fire();

-- Remove a swipe.
if style == "Combo" then

-- Freeze the user and the victim.
local function stunLockCharacter(character: Model)
if comboCount < 10 then

local humanoid = character:FindFirstChild("Humanoid");
if humanoid and humanoid:IsA("Humanoid") then
-- Freeze the user and the victim.
local function stunLockContestant(contestant: ServerContestant)

humanoid.AutoRotate = false;
if not contestant.character then

end;
return;

local humanoidRootPart = character:FindFirstChild("HumanoidRootPart");
if not humanoidRootPart or not humanoidRootPart:IsA("BasePart") then
end;

return;
local humanoid = contestant.character:FindFirstChild("Humanoid");
if humanoid and humanoid:IsA("Humanoid") then

end;
humanoid.AutoRotate = false;

local attachment = humanoidRootPart:FindFirstChild("RootAttachment");
if not attachment or not attachment:IsA("Attachment") then

return;
end;

end;
local humanoidRootPart = contestant.character:FindFirstChild("HumanoidRootPart");
if not humanoidRootPart or not humanoidRootPart:IsA("BasePart") then

if not humanoidRootPart:FindFirstChild("SuperHammerStunLockOrientation") then
return;

local alignOrientation = Instance.new("AlignOrientation");
alignOrientation.Name = "SuperHammerStunLockOrientation";
alignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment;
alignOrientation.CFrame = humanoidRootPart.CFrame;
alignOrientation.MaxTorque = math.huge;
alignOrientation.Attachment0 = attachment;
alignOrientation.Parent = humanoidRootPart;
table.insert(stunLockObjects, alignOrientation);
end;

end;
local attachment = humanoidRootPart:FindFirstChild("RootAttachment");
if not attachment or not attachment:IsA("Attachment") then

return;

if not humanoidRootPart:FindFirstChild("SuperHammerStunLockPosition") then
end;

local alignPosition = Instance.new("AlignPosition");
alignPosition.Name = "SuperHammerStunLockPosition";
alignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment;
alignPosition.Position = humanoidRootPart.Position;
alignPosition.MaxForce = math.huge;
alignPosition.Attachment0 = attachment;
alignPosition.Parent = humanoidRootPart;
table.insert(stunLockObjects, alignPosition);
stunnedContestants[contestant] = stunnedContestants[contestant] or {};
if not humanoidRootPart:FindFirstChild("SuperHammerStunLockOrientation") then

end;
local alignOrientation = Instance.new("AlignOrientation");
alignOrientation.Name = "SuperHammerStunLockOrientation";
alignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment;
alignOrientation.CFrame = humanoidRootPart.CFrame;
alignOrientation.MaxTorque = math.huge;
alignOrientation.Attachment0 = attachment;
alignOrientation.Parent = humanoidRootPart;
table.insert(stunnedContestants[contestant], alignOrientation);

end;
end;

if _contestant.character then

stunLockCharacter(_contestant.character);
if not humanoidRootPart:FindFirstChild("SuperHammerStunLockPosition") then

end
local alignPosition = Instance.new("AlignPosition");
alignPosition.Name = "SuperHammerStunLockPosition";
alignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment;
alignPosition.Position = humanoidRootPart.Position;
alignPosition.MaxForce = math.huge;
alignPosition.Attachment0 = attachment;
alignPosition.Parent = humanoidRootPart;
table.insert(stunnedContestants[contestant], alignPosition);

stunLockCharacter(possibleEnemyCharacter);
end;

end;

stunLockContestant(_contestant);
stunLockContestant(possibleEnemyContestant);

end;

end;

onEnemyHit:Fire();

-- Add immunity.
table.insert(immuneContestants, possibleEnemyContestant);
Expand Down Expand Up @@ -550,17 +589,20 @@ function SuperHammerServerItem.new(): ServerItem

end;

for _, object in stunLockObjects do
for contestant, objects in pairs(stunnedContestants) do

local character = if object.Parent then object.Parent.Parent else nil;
local humanoid = if character then character:FindFirstChild("Humanoid") else nil;
local humanoid = if contestant.character then contestant.character:FindFirstChild("Humanoid") else nil;
if humanoid and humanoid:IsA("Humanoid") then

humanoid.AutoRotate = true;

end;

object:Destroy();
for _, object in objects do

object:Destroy();

end;

end;

Expand Down

0 comments on commit 86934cc

Please sign in to comment.