Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ["Punch"] = {
- ["Name"] = "Punch",
- ["Icon"] = "rbxassetid://93874368032471",
- ["LayoutOrder"] = 1,
- ["KeybindType"] = "MainAbility",
- ["Cooldown"] = 1.25,--Cooldown
- ["Callback"] = function(self, isLocal)
- -- LOCAL SIDE: play animation
- if isLocal then
- if self.Animations and self.Animations.Punch then
- self.Animations.Punch:Play(0.025)
- end
- return
- end
- -- SERVER SIDE: do the hitbox
- if not game:GetService("RunService"):IsServer() then
- return
- end
- -- Prevent ability spam
- if self.AbilitiesDisabled then
- return
- end
- self.AbilitiesDisabled = true
- -- Create the actual hitbox
- local Hitboxes = require(game.ReplicatedStorage.Modules.Hitboxes)
- Hitboxes:CreateHitbox(self.Player, {
- Size = Vector3.new(4, 5, 4),
- CFrameOffset = CFrame.new(0, 0, -2),
- Damage = self.Config.PunchDamage or 12,
- Time = 0.25,
- Knockback = 0.3,
- HitMultiple = false,
- Connections = {
- Hit = function(victim)
- -- WHO WAS HIT
- local humVictim = victim:FindFirstChildOfClass("Humanoid")
- local humSelf = self.Rig and self.Rig:FindFirstChildOfClass("Humanoid")
- if humVictim and humSelf then
- -- === LIFE STEAL ===
- -- amount to steal from victim’s current health
- local lifestealPct = self.Config.PunchLifeStealPct or 0.25
- local lifestealAmt = humVictim.Health * lifestealPct
- humSelf.Health = math.min(humSelf.Health + lifestealAmt, humSelf.MaxHealth)
- -- === MAX HEALTH STEAL ===
- -- optionally steal a % of the victim’s max health
- local stealMaxPct = self.Config.PunchMaxStealPct or 0.10
- local maxStealAmt = humVictim.MaxHealth * stealMaxPct
- -- add max health to self
- humSelf.MaxHealth = humSelf.MaxHealth + maxStealAmt
- humSelf.Health = humSelf.Health + maxStealAmt
- -- remove the max health stolen from the victim
- humVictim.MaxHealth = math.max(humVictim.MaxHealth - maxStealAmt, 1)
- humVictim.Health = math.min(humVictim.Health, humVictim.MaxHealth)
- end
- end
- }
- })
- -- reset ability
- task.delay(self.Config.PunchCooldown or 1.25, function()
- self.AbilitiesDisabled = false
- end)
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment