Advertisement
Guest User

Untitled

a guest
Dec 5th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.28 KB | None | 0 0
  1.  
  2. function ghostship_mark_allies( caster, ability, target )
  3.     local allHeroes = HeroList:GetAllHeroes()
  4.     local delay = ability:GetLevelSpecialValueFor( "tooltip_delay", ability:GetLevel() - 1 )
  5.     local particleName = "particles/units/heroes/hero_kunkka/kunkka_ghostship_marker.vpcf"
  6.    
  7.     for k, v in pairs( allHeroes ) do
  8.         if v:GetPlayerID() and v:GetTeam() == caster:GetTeam() then
  9.             local fxIndex = ParticleManager:CreateParticleForPlayer( particleName, PATTACH_ABSORIGIN, v, PlayerResource:GetPlayer( v:GetPlayerID() ) )
  10.             ParticleManager:SetParticleControl( fxIndex, 0, target )
  11.            
  12.             EmitSoundOnClient( "Ability.pre.Torrent", PlayerResource:GetPlayer( v:GetPlayerID() ) )
  13.            
  14.             -- Destroy particle after delay
  15.             Timers:CreateTimer( delay, function()
  16.                     ParticleManager:DestroyParticle( fxIndex, false )
  17.                     return nil
  18.                 end
  19.             )
  20.         end
  21.     end
  22. end
  23.  
  24.  
  25. function ghostship_start_traverse( keys )
  26.     -- Variables
  27.     local caster = keys.caster
  28.     local ability = keys.ability
  29.     local casterPoint = caster:GetAbsOrigin()
  30.     local targetPoint = keys.target_points[1]
  31.     local spawnDistance = ability:GetLevelSpecialValueFor("ghostship_distance", ability:GetLevel() - 1 )
  32.     local projectileSpeed = ability:GetLevelSpecialValueFor("ghostship_speed", ability:GetLevel() - 1 )
  33.     local radius = ability:GetLevelSpecialValueFor("ghostship_width", ability:GetLevel() - 1 )
  34.     local stunDelay = ability:GetLevelSpecialValueFor("tooltip_delay", ability:GetLevel() - 1 )
  35.     local stunDuration = ability:GetLevelSpecialValueFor("stun_duration", ability:GetLevel() - 1 )
  36.     local damage = ability:GetAbilityDamage()
  37.     local damageType = ability:GetAbilityDamageType()
  38.     local targetBuffTeam = DOTA_UNIT_TARGET_TEAM_FRIENDLY
  39.     local targetImpactTeam = DOTA_UNIT_TARGET_TEAM_ENEMY
  40.     local targetType = DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC + DOTA_UNIT_TARGET_MECHANICAL
  41.     local targetFlag = DOTA_UNIT_TARGET_FLAG_NONE
  42.    
  43.     -- Get necessary vectors
  44.     local forwardVec = targetPoint - casterPoint
  45.         forwardVec = forwardVec:Normalized()
  46.     local backwardVec = casterPoint - targetPoint
  47.         backwardVec = backwardVec:Normalized()
  48.     local spawnPoint = casterPoint + ( spawnDistance * backwardVec )
  49.     local impactPoint = casterPoint + ( spawnDistance * forwardVec )
  50.     local velocityVec = Vector( forwardVec.x, forwardVec.y, 0 )
  51.  
  52.  
  53.     print()
  54.     print(spawnDistance)
  55.     print(projectileSpeed)
  56.    
  57.     -- Show visual effect
  58.     ghostship_mark_allies( caster, ability, impactPoint )
  59.    
  60.     -- Spawn projectiles
  61.     local projectileTable = {
  62.         Ability = ability,
  63.         EffectName = "particles/units/heroes/hero_kunkka/kunkka_ghost_ship.vpcf",
  64.         vSpawnOrigin = spawnPoint,
  65.         fDistance = spawnDistance * 2,
  66.         fStartRadius = radius,
  67.         fEndRadius = radius,
  68.         fExpireTime = GameRules:GetGameTime() + 5,
  69.         Source = caster,
  70.         bHasFrontalCone = false,
  71.         bReplaceExisting = false,
  72.         bProvidesVision = false,
  73.         iUnitTargetTeam = targetBuffTeam,
  74.         iUnitTargetType = targetType,
  75.         vVelocity = velocityVec * projectileSpeed
  76.     }
  77.     ProjectileManager:CreateLinearProjectile( projectileTable )
  78.    
  79.     -- Create timer for crashing
  80.     Timers:CreateTimer( stunDelay, function()
  81.             local units = FindUnitsInRadius(
  82.                 caster:GetTeamNumber(), impactPoint, caster, radius, targetImpactTeam,
  83.                 targetType, targetFlag, FIND_ANY_ORDER, false
  84.             )
  85.            
  86.             -- Fire sound event
  87.             local dummy = CreateUnitByName( "npc_dummy_unit", impactPoint, false, caster, caster, caster:GetTeamNumber() )
  88.             StartSoundEvent( "Ability.Ghostship.crash", dummy )
  89.             dummy:ForceKill( true )
  90.            
  91.             -- Stun and damage enemies
  92.             for k, v in pairs( units ) do
  93.                 if not v:IsMagicImmune() then
  94.                     local damageTable = {
  95.                         victim = v,
  96.                         attacker = caster,
  97.                         damage = damage,
  98.                         damage_type = damageType
  99.                     }
  100.                     ApplyDamage( damageTable )
  101.                 end
  102.                
  103.                 v:AddNewModifier( caster, nil, "modifier_stunned", { duration = stunDuration } )
  104.             end
  105.            
  106.             return nil  -- Delete timer
  107.         end
  108.     )
  109. end
  110.  
  111.  
  112. function ghostship_register_damage( keys )
  113.     local target = keys.unit
  114.     local damageTaken = keys.DamageTaken
  115.     if not target.ghostship_damage then
  116.         target.ghostship_damage = 0
  117.     end
  118.    
  119.     target.ghostship_damage = target.ghostship_damage + damageTaken
  120. end
  121.  
  122.  
  123. function ghostship_spread_damage( keys )
  124.     -- Init in case never take any damage
  125.     if not keys.target.ghostship_damage then
  126.         keys.target.ghostship_damage = 0
  127.     end
  128.  
  129.     -- Variables
  130.     local target = keys.target
  131.     local ability = keys.ability
  132.     local damageDuration = ability:GetLevelSpecialValueFor( "damage_duration", ability:GetLevel() - 1 )
  133.     local damageInterval = ability:GetLevelSpecialValueFor( "damage_interval", ability:GetLevel() - 1 )
  134.     local damageCurrentTime = 0.0
  135.     local damagePerInterval = target.ghostship_damage * ( damageInterval / damageDuration )
  136.     local minimumHealth = 1
  137.  
  138.     -- Overtime debuff
  139.     Timers:CreateTimer( damageInterval, function()
  140.             -- HP Removal
  141.             local targetHealth = target:GetHealth()
  142.             if targetHealth - damagePerInterval <= minimumHealth then
  143.                 target:SetHealth( minimumHealth )
  144.             else
  145.                 target:SetHealth( targetHealth - damagePerInterval )
  146.             end
  147.            
  148.             -- Update timer
  149.             damageCurrentTime = damageCurrentTime + damageInterval
  150.            
  151.             -- Check closing condition
  152.             if damageCurrentTime >= damageDuration then
  153.                 return nil
  154.             else
  155.                 return damageInterval
  156.             end
  157.         end
  158.     )
  159. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement