Помогите с говнокодом

Веджитто

Пользователь
3 Июн 2017
25
0
1
Проект
Dotomemium Phoenix
Реакции
0 0 0
#1
Хочу сделать абилку, чтобы давала стаки всех статов каждый раз, когда герой получает урон при хп <200. Не работает
Код:
"zenkai"
{
    // General
    //-------------------------------------------------------------------------------------------------------------
    "BaseClass"                "ability_datadriven"
    "AbilityBehavior"                "DOTA_ABILITY_BEHAVIOR_PASSIVE"
    "AbilityType"                    "DOTA_ABILITY_TYPE_ULTIMATE"
    "SpellImmunityType"                "SPELL_IMMUNITY_ENEMIES_NO"
    "FightRecapLevel"                "2"
    "AbilityTextureName"            "skeleton_king_reincarnation"
    
    // Time       
    //-------------------------------------------------------------------------------------------------------------
    "AbilityCooldown"                "260 160 60"

    // Cost
    //-------------------------------------------------------------------------------------------------------------
    "AbilityManaCost"                "160"

    // Stats
    //-------------------------------------------------------------------------------------------------------------
    "AbilityModifierSupportValue"    "0.2"    // Slow isn't the main function of this ability.

    "AbilitySpecial"
    {
        "01"
        {
            "var_type"                "FIELD_INTEGER"
            "reward_damage"        "2 3 5 8"
        }
        
    }

    "precache"
    {
        "soundfile"    "soundevents/game_sounds_heroes/game_sounds_skeletonking.vsndevts"
        "particle"    "particles/units/heroes/hero_skeletonking/wraith_king_reincarnate.vpcf"
        "particle"    "particles/units/heroes/hero_skeletonking/skeleton_king_death.vpcf"
        "particle"    "particles/units/heroes/hero_skeletonking/wraith_king_reincarnate_slow_debuff.vpcf"
    }

    "Modifiers"
    {
        "modifier_reincarnation"
        {
            "Passive"    "1"
            "IsHidden"    "1"

            "OnTakeDamage"
            {
                "RunScript"
                {
                    "ScriptFile"        "heroes/hero_skeleton_king/reincarnation.lua"
                    "Function"            "Reincarnation"
                    "RewardDamage"    "%reward_damage"
                }
            }
        }
        "modifier_duel_damage_datadriven"
        {
            "Attributes"        "MODIFIER_ATTRIBUTE_PERMANENT"

            "Properties"
            {
                "MODIFIER_PROPERTY_STATS_STRENGTH_BONUS"    "1"
                "MODIFIER_PROPERTY_STATS_AGILITY_BONUS"    "1"
                "MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"    "1"
            }
        }
        

        
    }
}
Код:
function Reincarnation( event )
    local caster = event.caster
    local casterHP = caster:GetHealth()
    local ability = keys.ability
    local modifier_duel = "modifier_duel_datadriven"
    if casterHP <= 200 then
     if not caster:HasModifier(modifier_duel_damage) then
            ability:ApplyDataDrivenModifier(caster, caster, modifier_duel_damage, {})
        end
        local duel_stacks = caster:GetModifierStackCount(modifier_duel_damage, ability) + keys.RewardDamage
        caster:SetModifierStackCount(modifier_duel_damage, ability, duel_stacks)
        caster:RemoveModifierByName(modifier_duel)
    end
end
 

Веджитто

Пользователь
3 Июн 2017
25
0
1
Проект
Dotomemium Phoenix
Реакции
0 0 0
#2
Пробовал делать так:
Код:
"z2"
{
    // General
    //-------------------------------------------------------------------------------------------------------------
    "BaseClass"                        "ability_datadriven"
    "AbilityBehavior"                "DOTA_ABILITY_BEHAVIOR_PASSIVE"
    "SpellImmunityType"                "SPELL_IMMUNITY_ENEMIES_YES"
    "AbilityTextureName"             "slark_essence_shift"

    // Special
    //-------------------------------------------------------------------------------------------------------------
    "AbilitySpecial"
    {
        "01"
        {
            "var_type"                "FIELD_INTEGER"
            "agi_gain"                "3"
        }
        "02"
        {
            "var_type"                "FIELD_INTEGER"
            "stat_loss"                "-"
        }
        "03"
        {
            "var_type"                "FIELD_FLOAT"
            "duration"                "9999999999"
        }
    }
    
    
    "Modifiers"
    {
        "modifier_slark_essence_shift_datadriven"  //This modifier is always on Slark and simply triggers a script when an autoattack lands on an enemy.
        {
            "Passive"   "1"
            "IsHidden"  "1"
            
            "OnTakeDamage"
            {
                "RunScript"
                {
                    "ScriptFile"                "heroes/hero_skeleton_king/z2.lua"
                    "Function"                     "modifier_slark_essence_shift_datadriven_on_attack_landed"
                    "StatLoss"                    "%stat_loss"
                }
            }
        }
        "modifier_slark_essence_shift_datadriven_buff_counter"  //A visible counter that will appear in Slark's modifier bar.
        {
            "Duration"            "%duration"
            "Passive"            "0"
            "IsHidden"            "0"
        }
        
        "modifier_slark_essence_shift_datadriven_buff"
        {
            "Duration"                "%duration"
            "Passive"                "0"
            "IsHidden"              "1"
            "Attributes"            "MODIFIER_ATTRIBUTE_MULTIPLE"
            
            "Properties"
            {
                "MODIFIER_PROPERTY_STATS_AGILITY_BONUS"        "%agi_gain"
                "MODIFIER_PROPERTY_STATS_STRENGTH_BONUS"        "%agi_gain"
                "MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"        "%agi_gain"
            }
            
            
        }
        
    }
}
Код:
Код:
function modifier_slark_essence_shift_datadriven_on_attack_landed(keys)
    
        local casterHP = keys.caster:GetHealth()
        --For Slark, update his visible counter modifier's stack count and duration, and raise his Agility.  The full amount of Agility is gained
        --even if the target does not have any more attributes to steal.
        if casterHP <= 200 then
        previous_stack_count = 0
        if keys.caster:HasModifier("modifier_slark_essence_shift_datadriven_buff_counter") then
            previous_stack_count = keys.caster:GetModifierStackCount("modifier_slark_essence_shift_datadriven_buff_counter", keys.caster)
            
            --We have to remove and replace the modifier so the duration will refresh (so it will show the duration of the latest Essence Shift).
            keys.caster:RemoveModifierByNameAndCaster("modifier_slark_essence_shift_datadriven_buff_counter", keys.caster)
        end
        keys.ability:ApplyDataDrivenModifier(keys.caster, keys.caster, "modifier_slark_essence_shift_datadriven_buff_counter", nil)
        keys.caster:SetModifierStackCount("modifier_slark_essence_shift_datadriven_buff_counter", keys.caster, previous_stack_count + 1)
        
        --Apply an Agility buff for Slark.
        keys.ability:ApplyDataDrivenModifier(keys.caster, keys.caster, "modifier_slark_essence_shift_datadriven_buff", nil)
        end
    end
end
не помогает
 

vulkantsk

Друзья CG
21 Июн 2017
601
53
28
17
https://steamcommunity.com/profiles/76561198307890
www.dotabuff.com
Проект
Roshan defense
Реакции
58 0 5
#3
Хочу сделать абилку, чтобы давала стаки всех статов каждый раз, когда герой получает урон при хп <200. Не работает
Код:
"zenkai"
{
    // General
    //-------------------------------------------------------------------------------------------------------------
    "BaseClass"                "ability_datadriven"
    "AbilityBehavior"                "DOTA_ABILITY_BEHAVIOR_PASSIVE"
    "AbilityType"                    "DOTA_ABILITY_TYPE_ULTIMATE"
    "SpellImmunityType"                "SPELL_IMMUNITY_ENEMIES_NO"
    "FightRecapLevel"                "2"
    "AbilityTextureName"            "skeleton_king_reincarnation"
 
    // Time    
    //-------------------------------------------------------------------------------------------------------------
    "AbilityCooldown"                "260 160 60"

    // Cost
    //-------------------------------------------------------------------------------------------------------------
    "AbilityManaCost"                "160"

    // Stats
    //-------------------------------------------------------------------------------------------------------------
    "AbilityModifierSupportValue"    "0.2"    // Slow isn't the main function of this ability.

    "AbilitySpecial"
    {
        "01"
        {
            "var_type"                "FIELD_INTEGER"
            "reward_damage"        "2 3 5 8"
        }
     
    }

    "precache"
    {
        "soundfile"    "soundevents/game_sounds_heroes/game_sounds_skeletonking.vsndevts"
        "particle"    "particles/units/heroes/hero_skeletonking/wraith_king_reincarnate.vpcf"
        "particle"    "particles/units/heroes/hero_skeletonking/skeleton_king_death.vpcf"
        "particle"    "particles/units/heroes/hero_skeletonking/wraith_king_reincarnate_slow_debuff.vpcf"
    }

    "Modifiers"
    {
        "modifier_reincarnation"
        {
            "Passive"    "1"
            "IsHidden"    "1"

            "OnTakeDamage"
            {
                "RunScript"
                {
                    "ScriptFile"        "heroes/hero_skeleton_king/reincarnation.lua"
                    "Function"            "Reincarnation"
                    "RewardDamage"    "%reward_damage"
                }
            }
        }
        "modifier_duel_damage_datadriven"
        {
            "Attributes"        "MODIFIER_ATTRIBUTE_PERMANENT"

            "Properties"
            {
                "MODIFIER_PROPERTY_STATS_STRENGTH_BONUS"    "1"
                "MODIFIER_PROPERTY_STATS_AGILITY_BONUS"    "1"
                "MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"    "1"
            }
        }
     

     
    }
}
Код:
function Reincarnation( event )
    local caster = event.caster
    local casterHP = caster:GetHealth()
    local ability = keys.ability
    local modifier_duel = "modifier_duel_datadriven"
    if casterHP <= 200 then
     if not caster:HasModifier(modifier_duel_damage) then
            ability:ApplyDataDrivenModifier(caster, caster, modifier_duel_damage, {})
        end
        local duel_stacks = caster:GetModifierStackCount(modifier_duel_damage, ability) + keys.RewardDamage
        caster:SetModifierStackCount(modifier_duel_damage, ability, duel_stacks)
        caster:RemoveModifierByName(modifier_duel)
    end
end
1) название модифиаера в кв "modifier_duel_damage_datadriven" ,а у тебя в коде "modifier_duel_datadriven" - не совпадает
2) переменная local modifier_duel , а проверяешь по modifier_duel_damage
3) ты навешиваешь модифаер caster:SetModifierStackCount(modifier_duel_damage, ability, duel_stacks)
и тут же удаляешь модифаер с юнита caster:RemoveModifierByName(modifier_duel)
 
Реклама: