Created
December 20, 2016 21:11
-
-
Save Solonarv/fa95a1f60c1c61b28f0fd180308a11d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flicker_rapid_strike = class({}) | |
LinkLuaModifier("modifier_rapid_strike", "heroes/hero_flicker/modifier_rapid_strike.lua", LUA_MODIFIER_MOTION_NONE) | |
function flicker_rapid_strike:OnSpellStart() | |
local target = self:GetCursorTarget() | |
self:GetCaster().rapid_strike_target = target | |
self:GetCaster():AddNewModifier(self:GetCaster(), self, "modifier_rapid_strike", {}) | |
end | |
function flicker_rapid_strike:GetBaseAttackTime() | |
return self:GetSpecialValueFor("base_attack_time") | |
end | |
function flicker_rapid_strike:GetAttackCount() | |
return self:GetSpecialValueFor("attack_count") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"flicker_rapid_strike" | |
{ | |
"BaseClass" "ability_lua" | |
"ScriptFile" "heroes/hero_flicker/flicker_rapid_strike.lua" | |
"AbilityTextureName" "ember_spirit_sleight_of_fist" | |
"MaxLevel" "4" | |
"AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_UNIT_TARGET" | |
"AbilityUnitTargetTeam" "DOTA_UNIT_TARGET_TEAM_ENEMY" | |
"AbilityUnitTargetType" "DOTA_UNIT_TARGET_HERO | DOTA_UNIT_TARGET_BASIC" | |
"AbilityUnitTargetFlags" "DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES" | |
"AbilityCooldown" "15 13 11 9" | |
"AbilityManaCost" "120" | |
"AbilityCastRange" "325" | |
"AbilityCastPoint" "0.4" | |
"AbilityCastAnimation" "ACT_DOTA_CAST_ABILITY_2" | |
"AbilitySpecial" | |
{ | |
"01" | |
{ | |
"var_type" "FIELD_INTEGER" | |
"attack_count" "2 2 3 4" | |
} | |
"02" | |
{ | |
"var_type" "FIELD_FLOAT" | |
"base_attack_time" "1.0 0.8 0.8 0.6" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modifier_rapid_strike = class({}) | |
function modifier_rapid_strike:DeclareFunctions() | |
local funcs = { | |
MODIFIER_EVENT_ON_ATTACK_LANDED, | |
MODIFIER_PROPERTY_BASE_ATTACK_TIME_CONSTANT | |
} | |
return funcs | |
end | |
function modifier_rapid_strike:GetModifierBaseAttackTimeConstant() | |
return self:GetAbility():GetBaseAttackTime() | |
end | |
function modifier_rapid_strike:CheckState() | |
local state = { | |
[MODIFIER_STATE_INVULNERABLE] = true, | |
[MODIFIER_STATE_NO_HEALTH_BAR] = true, | |
[MODIFIER_STATE_NO_UNIT_COLLISION] = true, | |
[MODIFIER_STATE_SILENCED] = true, | |
[MODIFIER_STATE_ROOTED] = true | |
} | |
return state | |
end | |
function modifier_rapid_strike:OnCreated(kv) | |
self.target = self:GetParent().rapid_strike_target | |
self.attacks = 0 | |
self.old_loc = self:GetParent():GetAbsOrigin() | |
self:Teleport("OnCreated") | |
self:GetParent():MoveToTargetToAttack(self.target) | |
--self:StartIntervalThink(1 / self:GetParent():GetAttacksPerSecond()) | |
end | |
function modifier_rapid_strike:OnAttackLanded(kv) | |
self.attacks = self.attacks + 1 | |
if self.attacks < self:GetAbility():GetAttackCount() then | |
self:Teleport("OnAttackLanded") | |
else | |
self:GetParent():RemoveModifierByNameAndCaster("modifier_rapid_strike", self:GetCaster()) | |
end | |
if self.attacks < self:GetAbility():GetAttackCount() - 1 then | |
self:StartIntervalThink(1 / self:GetParent():GetAttacksPerSecond()) | |
end | |
return false | |
end | |
function modifier_rapid_strike:Teleport(from) | |
print("Teleport called by "..tostring(from)) | |
if IsServer() then | |
local parent = self:GetParent() | |
local a_loc = parent:GetOrigin() | |
local t_loc = self.target:GetOrigin() | |
local attack_range = parent:GetAttackRange() | |
local new_dir = (t_loc - a_loc):Normalized() | |
local new_dir = RotatePosition(new_dir, QAngle(0, RandomFloat(-15, 15), 0), Vector(0, 0, 0)) | |
local new_pos = t_loc + new_dir * attack_range * 0.8 | |
print(GameRules:GetGameTime().." :: teleporting to "..tostring(new_pos).." near "..tostring(t_loc)) | |
FindClearSpaceForUnit(self:GetParent(), new_pos, false) | |
end | |
end | |
function modifier_rapid_strike:OnDestroy() | |
local caster = self:GetParent() | |
if IsServer() then | |
FindClearSpaceForUnit(caster, self.old_loc, false) | |
end | |
caster:Stop() | |
caster.rapid_strike_target = nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment