Applying modifier to units

edited January 2017 in Questions

Well, I have a custom ability: sorry for bad formatting

My custom cvar command calls ToggleAbility method.

Toggling ability ON/OFF.

So ability applies to my hero only. Does ApplyDataDrivenModifier(caster, unit, modifier, nil) method seem like incorrect, or there i need more behaviors and targettypes for ability?

Comments

  • Posts: 96

    I'm not sure if I understand it correctly. Are you trying to make an "aura" type of ability? Currently from what I understand in your code is that you're applying "modifier_debuff_datadriven" to only to caster.

    If you're trying to make aura type of ability, try following this example https://github.com/Pizzalol/SpellLibrary/blob/53ed8d5ebcf3e3c9e158d05d787515aec71d7de3/game/scripts/npc/abilities/skeleton_king_vampiric_aura_datadriven.txt

  • edited January 2017 Posts: 273

    @Splinter If I understood correctly what you want your toggle ability should at least contain these behaviors:

    "AbilityBehavior"   "DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_TOGGLE"
    

    Your lua code makes my skin crawl. I will try to help you fix it:

    1) You are not usins your custom function ToggleAbility(value, myhero) anywhere. Do you even need it?

    2) your local targets = event.target_entities is always nil because you had no targeting behaviors. With DOTA_ABILITY_BEHAVIOR_NO_TARGET it will still be nil, so I really don't know what your ability is supposed to do.

    3) you don't need semi-colons ( ; ). They are not needed in this programming language. Semi-colons in Lua are generally only required when writing multiple statements on a line.

    4) if you are applying the modifier only to the caster, you don't need lua anyway but if you want to do it via lua: you just do this

    if not caster:HasModifier(sight_modifier) then 
       ability:ApplyDataDrivenModifier(caster, caster, sight_modifier, nil);
    end
    

    So the main problem for us here is trying to understand what you want for your ability to do. If you explain us what you want maybe we can help more.

  • @Darkonius, hi. You're right. I 've bound ToggleAbility() to my custom command (with 1/0 values). Ability has to give vision (MODIFIER_PROPERTY_PROVIDES_FOW_POSITION). Totally the same as Original Thirst (Bloodseeker), but w/o movespeedbuff and full hp cap to get vision. Here is a script for Thirst, but vision is given by AddFOWViewer() method. So I wanna make smthng similar, but with toggle behavior, binding toggling to custom command and using PROVIDES_FOW_POSITION property.

  • @Splinter you are pidor Kappa

  • edited January 2017 Posts: 273

    @Splinter You don't need lua for that:

    "your_ability"
    {
       "BaseClass"              "ability_datadriven"
       "AbilityTextureName" "your_texture"
       "AbilityBehavior"        "DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_TOGGLE"
       "AbilityUnitTargetTeam"  "DOTA_UNIT_TARGET_TEAM_ENEMY"
       "AbilityUnitTargetType"      "DOTA_UNIT_TARGET_HERO"
       "SpellImmunityType"      "SPELL_IMMUNITY_ENEMIES_YES"
       "SpellDispellableType"       "SPELL_DISPELLABLE_NO"
    
       "precache"
       {
        "particle"          "particles/units/heroes/hero_myhero/my_particle.vpcf"
       }
    
       "OnToggleOn"
       {
          "ActOnTargets"
          {
           "Target"
           {
            "Center"    "CASTER"
            "Radius"    "GLOBAL"
            "Teams"     "DOTA_UNIT_TARGET_TEAM_ENEMY"
            "Types"     "DOTA_UNIT_TARGET_HERO"
            "Flags" "DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES"
           }
    
           "Action"    
           {
            "ApplyModifier"
            {
               "ModifierName"   "modifier_custom_reveal_debuff"
               "Target"         "TARGET"
            }
           }
          }
       }
    
       "OnToggleOff"
       {
          "ActOnTargets"
          {
             "Target"
             {
                "Center"    "CASTER"
                "Radius"    "GLOBAL"
                "Teams"     "DOTA_UNIT_TARGET_TEAM_ENEMY"
                "Types"     "DOTA_UNIT_TARGET_HERO"
                "Flags" "DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES | DOTA_UNIT_TARGET_FLAG_INVULNERABLE | DOTA_UNIT_TARGET_FLAG_DEAD"
             }
    
             "Action"    
             {
                "RemoveModifier"
                {
                   "ModifierName"   "modifier_custom_reveal_debuff"
                   "Target"         "TARGET"
                }
             }
          }
       }
    
       "Modifiers"
       {                
        "modifier_custom_reveal_debuff"
        {
           "IsHidden"   "1"     // Is the debuff icon not visible on enemies (on the hud)?
           "IsDebuff"   "1"
           "IsPurgable" "0"
    
           "EffectName"         "particles/units/heroes/hero_myhero/particle.vpcf"
           "EffectAttachType"   "follow_origin"
    
           "Properties"
           {
              "MODIFIER_PROPERTY_PROVIDES_FOW_POSITION"     "1"
              "MODIFIER_PROPERTY_FORCE_DRAW_MINIMAP"        "1" // I don't know if this property does anything
           }
    
           // If you don't want true sight over the hero remove stuff below this line
           "Priority"          "MODIFIER_PRIORITY_ULTRA"
    
           "States"
           {
              "MODIFIER_STATE_INVISIBLE"    "MODIFIER_STATE_VALUE_DISABLED"
           }
           //
        }
       }        
    }
    
  • edited January 2017 Posts: 273

    Actually my code is not good (ActOnTargets is applying only in the moment of toggling which is not what you want). It needs an aura. OnToggleOn should apply the aura source to the caster. Aura source is a modifier with parameters:

    "Aura" "modifier_custom_reveal_debuff"
    "Aura_Radius"    "GLOBAL"
    "Aura_Teams"     "DOTA_UNIT_TARGET_TEAM_ENEMY"
    "Aura_Types"     "DOTA_UNIT_TARGET_HERO"
    "Aura_Flags" "DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES | DOTA_UNIT_TARGET_FLAG_INVULNERABLE | DOTA_UNIT_TARGET_FLAG_OUT_OF_WORLD"
    

    OnToggleOff should remove the aura source modifier from the caster.