Advertisement
MVGDaniel

Untitled

Apr 6th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. local Spell = { }
  2. Spell.LearnTime = 180
  3. Spell.Description = [[
  4. Slows down your opponent.
  5.  
  6. Casted on NPC will just
  7. stop it from attacking you
  8. due to Source
  9. engine limitations.
  10. ]]
  11. Spell.Category = HpwRewrite.CategoryNames.Fight
  12. Spell.FlyEffect = "hpw_stupefy_main"
  13. Spell.ImpactEffect = "hpw_stupefy_impact"
  14. Spell.ApplyDelay = 0.5
  15. Spell.AccuracyDecreaseVal = 0.3
  16.  
  17. Spell.ForceAnim = { ACT_VM_PRIMARYATTACK_5 }
  18. Spell.SpriteColor = Color(0, 255, 255)
  19. Spell.NodeOffset = Vector(-727, -393, 0)
  20. Spell.OnlyIfLearned = { "Colloshoo" }
  21.  
  22. if SERVER then
  23. util.AddNetworkString("hpwrewrite_impedimenta_handler")
  24. else
  25. net.Receive("hpwrewrite_impedimenta_handler", function()
  26. local startTime = CurTime()
  27. local endTime = CurTime() + 10
  28.  
  29. local val = 1
  30.  
  31. hook.Add("AdjustMouseSensitivity", "hpwrewrite_impedimenta_handler", function(def)
  32. if CurTime() > endTime then hook.Remove("AdjustMouseSensitivity", "hpwrewrite_impedimenta_handler") return 1 end
  33.  
  34. local a = endTime - CurTime()
  35.  
  36. if a > 7 then
  37. val = math.Approach(val, 0.1, FrameTime() * 0.5)
  38. elseif a < 3 then
  39. val = math.Approach(val, 1, FrameTime() * 0.5)
  40. end
  41.  
  42. return val
  43. end)
  44. end)
  45. end
  46.  
  47. function Spell:OnSpellSpawned(wand, spell)
  48. wand:PlayCastSound()
  49. end
  50.  
  51. function Spell:OnFire(wand)
  52. return true
  53. end
  54.  
  55. local undereff = { }
  56.  
  57. function Spell:OnCollide(spell, data)
  58. local ent = data.HitEntity
  59.  
  60. if IsValid(ent) and not undereff[ent] then
  61. local name = "hpwrewrite_impedimenta_handler" .. ent:EntIndex()
  62.  
  63. if ent:IsPlayer() then
  64. local oldM = ent:GetWalkSpeed()
  65. local oldR = ent:GetRunSpeed()
  66. local oldP = ent:GetJumpPower()
  67.  
  68. ent:SetWalkSpeed(oldM * 0.1)
  69. ent:SetRunSpeed(oldR * 0.1)
  70. ent:SetJumpPower(oldP * 0.1)
  71.  
  72. local wep = ent:GetActiveWeapon()
  73. if IsValid(wep) then
  74. wep:SetNextPrimaryFire(CurTime() + 7)
  75. wep:SetNextSecondaryFire(CurTime() + 7)
  76. end
  77.  
  78. net.Start("hpwrewrite_impedimenta_handler")
  79. net.Send(ent)
  80.  
  81. timer.Create(name, 10, 1, function()
  82. ent:SetWalkSpeed(oldM)
  83. ent:SetRunSpeed(oldR)
  84. ent:SetJumpPower(oldP)
  85.  
  86. undereff[ent] = nil
  87. end)
  88. elseif ent:IsNPC() then
  89. local endTime = CurTime() + 10
  90.  
  91. hook.Add("Think", name, function()
  92. if not IsValid(ent) or CurTime() > endTime then
  93. undereff[ent] = nil
  94. hook.Remove("Think", name)
  95. return
  96. end
  97.  
  98. ent:ClearSchedule()
  99. ent:ClearGoal()
  100. ent:ClearEnemyMemory()
  101. ent:ClearExpression()
  102. ent:StopMoving()
  103. end)
  104. end
  105.  
  106. undereff[ent] = true
  107. end
  108. end
  109.  
  110. HpwRewrite:AddSpell("Impedimenta", Spell)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement