Почему не работает скилл?

  • Автор темы Автор темы Qunian
  • Дата начала Дата начала

Qunian

Новичок
23 Фев 2019
3
0
Проект
Holy Wat
Решил я создать переключаемую способность, которая будет работать как пассивка бристлбека, только без иголок. Всё значит написал, переключение работает, модификатор накладывается, только урон не режется, один и тот же проходит. Не подскажите, что не так?
Код:
"defend"

    {

            "BaseClass"                     "ability_datadriven"

            "AbilityTextureName"            "defend"

            "MaxLevel"                         "1"

            "AbilityBehavior"                "DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_TOGGLE | DOTA_ABILITY_BEHAVIOR_IMMEDIATE"


                            "AbilitySpecial"

                            {

                                    "01"

                                    {

                                        "var_type"                        "FIELD_INTEGER"

                                        "side_damage_reduction"            "8 12 16 20"

                                    }

                                    "02"

                                    {

                                        "var_type"                        "FIELD_INTEGER"

                                        "back_damage_reduction"            "16 24 32 40"

                                    }

                                    "03"

                                    {

                                        "var_type"                        "FIELD_INTEGER"

                                        "side_angle"                    "110"

                                    }

                                    "04"

                                         "var_type"                        "FIELD_INTEGER"

                                        "back_angle"                     "70"    

                                    }

                            }

                   

         "OnToggleOn"

         {

                "ApplyModifier"

                {

                        "ModifierName"    "bristleback"

                        "Target"         "CASTER"

                }

         }

         "OnToggleOff"

         {

                "RemoveModifier"

                {

                        "ModifierName"    "bristleback"

                        "Target"

                        {

                                "Center"               "CASTER"

                                "Flags"             "DOTA_UNIT_TARGET_FLAG_DEAD"

                        }

                }

         }

       

         "Modifiers"

         {

                "bristleback"

                {

                        "Passive"            "1"

                        "IsHidden"            "0"

                        "IsDebuff"            "0"

       

                        "EffectAttachType"    "follow_origin"

                        "OnTakeDamage"

                        // "%attack_damage" is set to the damage value after mitigation

                        {

                            "RunScript"

                            {

                                    "ScriptFile"    "bristleback.lua"

                                    "Function"        "bristleback_takedamage"

                                    "Damage"        "%attack_damage"

                            }

                        }

                }

         }

    }

Lua:
function bristleback_takedamage(params)

    -- Create the threshold counter on the unit if it doesn't exist.

    if params.unit.quill_threshold_counter == nil then

        params.unit.quill_threshold_counter = 0.0

    end


    local ability = params.ability

    local back_reduction_percentage = ability:GetLevelSpecialValueFor("back_damage_reduction", ability:GetLevel() - 1) / 100

    local side_reduction_percentage = ability:GetLevelSpecialValueFor("side_damage_reduction", ability:GetLevel() - 1) / 100


    -- The y value of the angles vector contains the angle we actually want: where units are directionally facing in the world.

    local victim_angle = params.unit:GetAnglesAsVector().y

    local origin_difference = params.unit:GetAbsOrigin() - params.attacker:GetAbsOrigin()

    -- Get the radian of the origin difference between the attacker and Bristleback. We use this to figure out at what angle the attacker is at relative to Bristleback.

    local origin_difference_radian = math.atan2(origin_difference.y, origin_difference.x)

    -- Convert the radian to degrees.

    origin_difference_radian = origin_difference_radian * 180

    local attacker_angle = origin_difference_radian / math.pi

    -- See the opening block comment for why I do this. Basically it's to turn negative angles into positive ones and make the math simpler.

    attacker_angle = attacker_angle + 180.0

    -- Finally, get the angle at which Bristleback is facing the attacker.

    local result_angle = attacker_angle - victim_angle

    result_angle = math.abs(result_angle)


    -- Check for the side angle first. If the attack doesn't pass this check, we don't have to do back angle calculations.

    if result_angle >= (180 - (ability:GetSpecialValueFor("side_angle") / 2)) and result_angle <= (180 + (ability:GetSpecialValueFor("side_angle") / 2)) then

        -- Check for back angle. If this check doesn't pass, then do side angle "damage reduction".

        if result_angle >= (180 - (ability:GetSpecialValueFor("back_angle") / 2)) and result_angle <= (180 + (ability:GetSpecialValueFor("back_angle") / 2)) then

            -- Check if the reduced damage is lethal

            if((params.unit:GetHealth() - (params.Damage * (1 - back_reduction_percentage))) >= 1) then

                -- This is the actual "damage reduction".

                params.unit:SetHealth((params.Damage * back_reduction_percentage) + params.unit:GetHealth())

         

            end

        else

            -- Check if the reduced damage is lethal

            if((params.unit:GetHealth() - (params.Damage * (1 - side_reduction_percentage))) >= 1) then

                -- This is the actual "damage reduction".

                params.unit:SetHealth((params.Damage * side_reduction_percentage) + params.unit:GetHealth())

                -- Play the sound on Bristleback.

         

            end

        end

    end

end
 
Последнее редактирование:
А путь к луа то де? Нету пути и не будет работать!
Пример не юзай так
bristleback.lua
а так надо heroes/bristleback.lua
Все довжно работать!
Смотри, У меня в папке с Vscript нет подпапки с heroes,datadriven сразу берёт напрямую от туда(из папки с Vscripts), это в доте есть подпапки
 
Это наверное ошибка либо абилки Lua
Просто SpellLibrary обновляли 2 года назад а абилку 4 года назад, вдруг вольво этот способ убрали
 
Решил я создать переключаемую способность, которая будет работать как пассивка бристлбека, только без иголок. Всё значит написал, переключение работает, модификатор накладывается, только урон не режется, один и тот же проходит. Не подскажите, что не так?
Код:
"defend"

    {

            "BaseClass"                     "ability_datadriven"

            "AbilityTextureName"            "defend"

            "MaxLevel"                         "1"

            "AbilityBehavior"                "DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_TOGGLE | DOTA_ABILITY_BEHAVIOR_IMMEDIATE"


                            "AbilitySpecial"

                            {

                                    "01"

                                    {

                                        "var_type"                        "FIELD_INTEGER"

                                        "side_damage_reduction"            "8 12 16 20"

                                    }

                                    "02"

                                    {

                                        "var_type"                        "FIELD_INTEGER"

                                        "back_damage_reduction"            "16 24 32 40"

                                    }

                                    "03"

                                    {

                                        "var_type"                        "FIELD_INTEGER"

                                        "side_angle"                    "110"

                                    }

                                    "04"

                                         "var_type"                        "FIELD_INTEGER"

                                        "back_angle"                     "70"   

                                    }

                            }

                  

         "OnToggleOn"

         {

                "ApplyModifier"

                {

                        "ModifierName"    "bristleback"

                        "Target"         "CASTER"

                }

         }

         "OnToggleOff"

         {

                "RemoveModifier"

                {

                        "ModifierName"    "bristleback"

                        "Target"

                        {

                                "Center"               "CASTER"

                                "Flags"             "DOTA_UNIT_TARGET_FLAG_DEAD"

                        }

                }

         }

      

         "Modifiers"

         {

                "bristleback"

                {

                        "Passive"            "1"

                        "IsHidden"            "0"

                        "IsDebuff"            "0"

      

                        "EffectAttachType"    "follow_origin"

                        "OnTakeDamage"

                        // "%attack_damage" is set to the damage value after mitigation

                        {

                            "RunScript"

                            {

                                    "ScriptFile"    "bristleback.lua"

                                    "Function"        "bristleback_takedamage"

                                    "Damage"        "%attack_damage"

                            }

                        }

                }

         }

    }

Lua:
function bristleback_takedamage(params)

    -- Create the threshold counter on the unit if it doesn't exist.

    if params.unit.quill_threshold_counter == nil then

        params.unit.quill_threshold_counter = 0.0

    end


    local ability = params.ability

    local back_reduction_percentage = ability:GetLevelSpecialValueFor("back_damage_reduction", ability:GetLevel() - 1) / 100

    local side_reduction_percentage = ability:GetLevelSpecialValueFor("side_damage_reduction", ability:GetLevel() - 1) / 100


    -- The y value of the angles vector contains the angle we actually want: where units are directionally facing in the world.

    local victim_angle = params.unit:GetAnglesAsVector().y

    local origin_difference = params.unit:GetAbsOrigin() - params.attacker:GetAbsOrigin()

    -- Get the radian of the origin difference between the attacker and Bristleback. We use this to figure out at what angle the attacker is at relative to Bristleback.

    local origin_difference_radian = math.atan2(origin_difference.y, origin_difference.x)

    -- Convert the radian to degrees.

    origin_difference_radian = origin_difference_radian * 180

    local attacker_angle = origin_difference_radian / math.pi

    -- See the opening block comment for why I do this. Basically it's to turn negative angles into positive ones and make the math simpler.

    attacker_angle = attacker_angle + 180.0

    -- Finally, get the angle at which Bristleback is facing the attacker.

    local result_angle = attacker_angle - victim_angle

    result_angle = math.abs(result_angle)


    -- Check for the side angle first. If the attack doesn't pass this check, we don't have to do back angle calculations.

    if result_angle >= (180 - (ability:GetSpecialValueFor("side_angle") / 2)) and result_angle <= (180 + (ability:GetSpecialValueFor("side_angle") / 2)) then

        -- Check for back angle. If this check doesn't pass, then do side angle "damage reduction".

        if result_angle >= (180 - (ability:GetSpecialValueFor("back_angle") / 2)) and result_angle <= (180 + (ability:GetSpecialValueFor("back_angle") / 2)) then

            -- Check if the reduced damage is lethal

            if((params.unit:GetHealth() - (params.Damage * (1 - back_reduction_percentage))) >= 1) then

                -- This is the actual "damage reduction".

                params.unit:SetHealth((params.Damage * back_reduction_percentage) + params.unit:GetHealth())

        

            end

        else

            -- Check if the reduced damage is lethal

            if((params.unit:GetHealth() - (params.Damage * (1 - side_reduction_percentage))) >= 1) then

                -- This is the actual "damage reduction".

                params.unit:SetHealth((params.Damage * side_reduction_percentage) + params.unit:GetHealth())

                -- Play the sound on Bristleback.

        

            end

        end

    end

end
Советую юзать holdout абилку, это обычная абилка которая в доте копируешь код только вместо ID ты пишешь BaseClass и название абилки
Например для тебя чисто
C++:
    "abilka"
    {
        "BaseClass"                        "bristleback_bristleback"
        "AbilityBehavior"                "DOTA_ABILITY_BEHAVIOR_PASSIVE"
        "AbilitySound"                    "Hero_Bristleback.Bristleback"
        "AbilitySpecial"
        {
            "01"
            {
                "var_type"                        "FIELD_INTEGER"
                "side_damage_reduction"            "8 12 16 20"
            }
            "02"
            {
                "var_type"                        "FIELD_INTEGER"
                "back_damage_reduction"            "16 24 32 40"
            }
            "03"
            {
                "var_type"                        "FIELD_INTEGER"
                "side_angle"                    "110"
            }
            "04"
            {
                "var_type"                        "FIELD_INTEGER"
                "back_angle"                    "70"
            }
            "05"
            {
                "var_type"                        "FIELD_INTEGER"
                "quill_release_threshold"                "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
            }
        }
        "AbilityCastAnimation"        "ACT_DOTA_CAST_ABILITY_3"
    }
Но всегда лучше datadriven но я не могу ничего посоветовать кроме этого, ведь никогда не сталкивался с этой абилкой в datadriven
 
Решил я создать переключаемую способность, которая будет работать как пассивка бристлбека, только без иголок. Всё значит написал, переключение работает, модификатор накладывается, только урон не режется, один и тот же проходит. Не подскажите, что не так?
Код:
"defend"

    {

            "BaseClass"                     "ability_datadriven"

            "AbilityTextureName"            "defend"

            "MaxLevel"                         "1"

            "AbilityBehavior"                "DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_TOGGLE | DOTA_ABILITY_BEHAVIOR_IMMEDIATE"


                            "AbilitySpecial"

                            {

                                    "01"

                                    {

                                        "var_type"                        "FIELD_INTEGER"

                                        "side_damage_reduction"            "8 12 16 20"

                                    }

                                    "02"

                                    {

                                        "var_type"                        "FIELD_INTEGER"

                                        "back_damage_reduction"            "16 24 32 40"

                                    }

                                    "03"

                                    {

                                        "var_type"                        "FIELD_INTEGER"

                                        "side_angle"                    "110"

                                    }

                                    "04"

                                         "var_type"                        "FIELD_INTEGER"

                                        "back_angle"                     "70" 

                                    }

                            }

                

         "OnToggleOn"

         {

                "ApplyModifier"

                {

                        "ModifierName"    "bristleback"

                        "Target"         "CASTER"

                }

         }

         "OnToggleOff"

         {

                "RemoveModifier"

                {

                        "ModifierName"    "bristleback"

                        "Target"

                        {

                                "Center"               "CASTER"

                                "Flags"             "DOTA_UNIT_TARGET_FLAG_DEAD"

                        }

                }

         }

    

         "Modifiers"

         {

                "bristleback"

                {

                        "Passive"            "1"

                        "IsHidden"            "0"

                        "IsDebuff"            "0"

    

                        "EffectAttachType"    "follow_origin"

                        "OnTakeDamage"

                        // "%attack_damage" is set to the damage value after mitigation

                        {

                            "RunScript"

                            {

                                    "ScriptFile"    "bristleback.lua"

                                    "Function"        "bristleback_takedamage"

                                    "Damage"        "%attack_damage"

                            }

                        }

                }

         }

    }

Lua:
function bristleback_takedamage(params)

    -- Create the threshold counter on the unit if it doesn't exist.

    if params.unit.quill_threshold_counter == nil then

        params.unit.quill_threshold_counter = 0.0

    end


    local ability = params.ability

    local back_reduction_percentage = ability:GetLevelSpecialValueFor("back_damage_reduction", ability:GetLevel() - 1) / 100

    local side_reduction_percentage = ability:GetLevelSpecialValueFor("side_damage_reduction", ability:GetLevel() - 1) / 100


    -- The y value of the angles vector contains the angle we actually want: where units are directionally facing in the world.

    local victim_angle = params.unit:GetAnglesAsVector().y

    local origin_difference = params.unit:GetAbsOrigin() - params.attacker:GetAbsOrigin()

    -- Get the radian of the origin difference between the attacker and Bristleback. We use this to figure out at what angle the attacker is at relative to Bristleback.

    local origin_difference_radian = math.atan2(origin_difference.y, origin_difference.x)

    -- Convert the radian to degrees.

    origin_difference_radian = origin_difference_radian * 180

    local attacker_angle = origin_difference_radian / math.pi

    -- See the opening block comment for why I do this. Basically it's to turn negative angles into positive ones and make the math simpler.

    attacker_angle = attacker_angle + 180.0

    -- Finally, get the angle at which Bristleback is facing the attacker.

    local result_angle = attacker_angle - victim_angle

    result_angle = math.abs(result_angle)


    -- Check for the side angle first. If the attack doesn't pass this check, we don't have to do back angle calculations.

    if result_angle >= (180 - (ability:GetSpecialValueFor("side_angle") / 2)) and result_angle <= (180 + (ability:GetSpecialValueFor("side_angle") / 2)) then

        -- Check for back angle. If this check doesn't pass, then do side angle "damage reduction".

        if result_angle >= (180 - (ability:GetSpecialValueFor("back_angle") / 2)) and result_angle <= (180 + (ability:GetSpecialValueFor("back_angle") / 2)) then

            -- Check if the reduced damage is lethal

            if((params.unit:GetHealth() - (params.Damage * (1 - back_reduction_percentage))) >= 1) then

                -- This is the actual "damage reduction".

                params.unit:SetHealth((params.Damage * back_reduction_percentage) + params.unit:GetHealth())

      

            end

        else

            -- Check if the reduced damage is lethal

            if((params.unit:GetHealth() - (params.Damage * (1 - side_reduction_percentage))) >= 1) then

                -- This is the actual "damage reduction".

                params.unit:SetHealth((params.Damage * side_reduction_percentage) + params.unit:GetHealth())

                -- Play the sound on Bristleback.

      

            end

        end

    end

end
Ошибка была в том что ты забыл открыть(или случайно удалил скобку) AbilitySpecial 4.
Ещё из-за "Passive" "1" был баг в результате которого даже выключенная способность давала сопротивление.
Вот исправленный DD код(луа код исправен):
Код:
"defend"
    {

        "BaseClass"                     "ability_datadriven"
        "AbilityTextureName"            "defend"
        "MaxLevel"                      "1"
        "AbilityBehavior"               "DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_TOGGLE | DOTA_ABILITY_BEHAVIOR_IMMEDIATE"

        "AbilitySpecial"
        {
            "01"
            {
                "var_type"                        "FIELD_INTEGER"
                "side_damage_reduction"            "20"
            }
            "02"
            {
                "var_type"                        "FIELD_INTEGER"
                "back_damage_reduction"            "100"
            }
            "03"
            {
                "var_type"                        "FIELD_INTEGER"
                "side_angle"                    "110"
            }
            "04"
            {//fixed
                "var_type"                        "FIELD_INTEGER"
                "back_angle"                     "70" 
            }
        }
                
        "OnToggleOn"
        {
            "ApplyModifier"
            {
                "ModifierName"    "bristleback"
                "Target"         "CASTER"
            }
        }

        "OnToggleOff"
        {
            "RemoveModifier"
            {
                "ModifierName"    "bristleback"

                "Target"
                {
                    "Center"               "CASTER"
                    "Flags"             "DOTA_UNIT_TARGET_FLAG_DEAD"
                }
            }
        }

        "Modifiers"
        {
            "bristleback"
            {
                "Passive"             "0"//fixed
                "IsHidden"            "0"
                "IsDebuff"            "0"
    
                "EffectAttachType"    "follow_origin"
                "OnTakeDamage"// "%attack_damage" is set to the damage value after mitigation
                {
                    "RunScript"
                    {
                        "ScriptFile"    "bristleback.lua"
                        "Function"      "bristleback_takedamage"
                        "Damage"        "%attack_damage"
                    }
                }
            }
        }
    }
P.S. Изменил значения для проверки.
 
Последнее редактирование:
Ошибка была в том что ты забыл открыть(или случайно удалил скобку) AbilitySpecial 4.
Ещё из-за "Passive" "1" был баг в результате которого даже выключенная способность давала сопротивление.
Вот исправленный DD код(луа код исправен):
Код:
"defend"
    {

        "BaseClass"                     "ability_datadriven"
        "AbilityTextureName"            "defend"
        "MaxLevel"                      "1"
        "AbilityBehavior"               "DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_TOGGLE | DOTA_ABILITY_BEHAVIOR_IMMEDIATE"

        "AbilitySpecial"
        {
            "01"
            {
                "var_type"                        "FIELD_INTEGER"
                "side_damage_reduction"            "20"
            }
            "02"
            {
                "var_type"                        "FIELD_INTEGER"
                "back_damage_reduction"            "100"
            }
            "03"
            {
                "var_type"                        "FIELD_INTEGER"
                "side_angle"                    "110"
            }
            "04"
            {//fixed
                "var_type"                        "FIELD_INTEGER"
                "back_angle"                     "70"
            }
        }
               
        "OnToggleOn"
        {
            "ApplyModifier"
            {
                "ModifierName"    "bristleback"
                "Target"         "CASTER"
            }
        }

        "OnToggleOff"
        {
            "RemoveModifier"
            {
                "ModifierName"    "bristleback"

                "Target"
                {
                    "Center"               "CASTER"
                    "Flags"             "DOTA_UNIT_TARGET_FLAG_DEAD"
                }
            }
        }

        "Modifiers"
        {
            "bristleback"
            {
                "Passive"             "0"//fixed
                "IsHidden"            "0"
                "IsDebuff"            "0"
   
                "EffectAttachType"    "follow_origin"
                "OnTakeDamage"// "%attack_damage" is set to the damage value after mitigation
                {
                    "RunScript"
                    {
                        "ScriptFile"    "bristleback.lua"
                        "Function"      "bristleback_takedamage"
                        "Damage"        "%attack_damage"
                    }
                }
            }
        }
    }
P.S. Изменил значения для проверки.
Ля какой ты внимательный, я даже сам 4 раза пересмотрел и неувидел это
 
Реклама: