Advertisement
warpdragon

Untitled

Mar 18th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. --[[Author: YOLOSPAGHETTI
  2. Date: February 17, 2016
  3. Creates the eidelons]]
  4. function CreateEidelons(keys)
  5. local caster = keys.caster
  6. local target = keys.target
  7. local ability = keys.ability
  8. local target_origin = target:GetAbsOrigin()
  9. local direction = target:GetForwardVector()
  10. local duration = ability:GetLevelSpecialValueFor("duration_tooltip", ability:GetLevel())
  11. local count = ability:GetLevelSpecialValueFor("spawn_count", ability:GetLevel())
  12. local xp_radius = ability:GetLevelSpecialValueFor("xp_radius", ability:GetLevel())
  13. local bounty = target:GetGoldBounty()
  14. local xp = target:GetDeathXP()
  15. local units = FindUnitsInRadius(caster:GetTeamNumber(), target_origin, nil, xp_radius, DOTA_UNIT_TARGET_TEAM_FRIENDLY, DOTA_UNIT_TARGET_HERO, 0, 0, false)
  16. local shared_xp = xp/table.getn(units)
  17. local eidelon_level = ability:GetLevel()
  18.  
  19. -- Determines which unit to spawn
  20. local unit_name
  21. if eidelon_level == 1 then
  22. unit_name = "npc_dota_lesser_eidolon"
  23. elseif eidelon_level == 2 then
  24. unit_name = "npc_dota_eidolon"
  25. elseif eidelon_level == 3 then
  26. unit_name = "npc_dota_greater_eidolon"
  27. elseif eidelon_level == 4 then
  28. unit_name = "npc_dota_dire_eidolon"
  29. end
  30.  
  31. if eidelon_level >= 1 and eidelon_level <= 4 then
  32. -- Takes note of the caster for when the eidelons split
  33. ability.caster = caster
  34. -- Kills the target unit
  35. target:ForceKill(true)
  36. -- Gives the caster the gold bounty
  37. caster:SetGold(caster:GetGold() + bounty, false)
  38. -- Splits the experience among heroes in range
  39. for i,unit in ipairs(units) do
  40. unit:AddExperience(shared_xp, 0, false, false)
  41. end
  42. -- Creates the eidelons on the target and facing the same direction
  43. for i=0,count-1 do
  44. local eidelon = CreateUnitByName(unit_name, target_origin, true, caster, nil, caster:GetTeam())
  45. eidelon:SetForwardVector(direction)
  46. eidelon:SetControllableByPlayer(caster:GetPlayerID(), true)
  47. eidelon:SetOwner(caster)
  48.  
  49. -- Adds the green duration circle, and kills the eidelon after the duration ends
  50. eidelon:AddNewModifier(eidelon, nil, "modifier_kill", {duration = duration})
  51. -- Phases the eidelon for a short period so there is no unit collision
  52. eidelon:AddNewModifier(eidelon, nil, "modifier_phased", {duration = 0.03})
  53. -- Applies the modifier to count each eidelon's attacks
  54. ability:ApplyDataDrivenModifier( eidelon, eidelon, "modifier_check_attacks", {} )
  55. -- Takes note of the game time, so we know the duration for the split eidelons
  56. eidelon.time = GameRules:GetGameTime()
  57. end
  58. end
  59. end
  60.  
  61. --[[Author: YOLOSPAGHETTI
  62. Date: February 17, 2016
  63. Splits the eidelons if they hit the attack count]]
  64. function CheckAttacks(keys)
  65. local caster = keys.caster -- The eidelon
  66. local target = keys.target -- The target it is attacking
  67. local ability = keys.ability
  68. local attack_count = ability:GetLevelSpecialValueFor("split_attack_count", ability:GetLevel())
  69. local duration = ability:GetLevelSpecialValueFor("duration_tooltip", ability:GetLevel())
  70. local time_left = duration - (GameRules:GetGameTime() - caster.time)
  71.  
  72. -- Counts the number of attacks for each eidelon
  73. if target:GetTeam() ~= caster:GetTeam() and target:IsBuilding() == false then
  74. if caster.attacks == nil then
  75. caster.attacks = 1
  76. else
  77. caster.attacks = caster.attacks + 1
  78. end
  79. end
  80.  
  81. -- If the number of attacks is greater than the necessary count, we split the eidelon (create a new one)
  82. if caster.attacks >= attack_count then
  83. local eidelon = CreateUnitByName(caster:GetUnitName(), caster:GetAbsOrigin(), true, ability.caster, ability.caster, ability.caster:GetTeam())
  84. eidelon:SetForwardVector(caster:GetForwardVector())
  85. eidelon:SetControllableByPlayer(ability.caster:GetPlayerID(), true)
  86. eidelon:SetOwner(ability.caster)
  87.  
  88. --Adds the green duration circle, and kill the eidelon after the duration ends
  89. eidelon:AddNewModifier(eidelon, nil, "modifier_kill", {duration = time_left})
  90. -- Phases the eidelon for a short period so there is no unit collision
  91. eidelon:AddNewModifier(eidelon, nil, "modifier_phased", {duration = 0.03})
  92. -- Remove the modifier to check attacks
  93. caster:RemoveModifierByName("modifier_check_attacks")
  94. -- Heal the original eidelon to full
  95. caster:Heal(caster:GetMaxHealth(), caster)
  96. end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement