How to create a custom unit

Sim

Forum Administrator
Staff member
Reaction score
534
So you've read some tutorials on how to get started, the terrain editor was pretty straight-forward, everything is looking great... and yet, you are still left wondering, how do I create a custom unit?

Unfortunately, the Dota 2 Editor does not feature a user-friendly User Interface in order for us to modify the units. Also, the number of unit models available for editing is quite low, due to the nature of Dota 2 and its restricted number of units compared to Warcraft 3 and Starcraft 2, and their numerous, unique campaign units.

That being said, you can still create custom units, but it's done slightly outside of the editor.

If you followed this simple tutorial, which everyone should have by now, you should be in possession of your map, and its addon. With it, are several folders. You will need to find your addon's root directory. First locate your steam directory, and then navigate to:

Steam/SteamApps/common/dota 2 beta/dota_ugc/game/dota_addons/YOUR_ADDON_NAME/

This is your root directory, where YOUR_ADDON_NAME is, well, the name of your addon. Let's name our addon Zergling Madness, for fun. So, under Zergling_madness there should be a list of folders.

addon_directory.jpg

Within these folders are the custom content of your addon, or map. Units are located under scripts/npc/npc_units_custom.txt

Opening this file into your favorite text editor will bring up the dreaded Dota 2 Unit Editor! This is what it should look like:

DefaultCustomUnits.jpg

If you're wondering about the color, follow this link under "What you need".

Editing units is thus a data-driven process, where you list properties for the unit, and define its characteristics. Most of the challenge comes through finding the names of the characteristics you want, and to find proper paths for the various models/particles you want the unit to have.

Custom Unit Example

We're going to create a custom unit named "Guardian of Fire". Let's say we want it to have a fire feel and a small fire ability. Our guardian will be stationed next to an objective and should protect it, so it will be neutral unit.

Here is the code you should paste inside your npc_units_custom.txt file:

JASS:
//=================================================================================
    // Creature: Guardian of Fire
    //=================================================================================
    "npc_dota_creature_guardian_fire"
    {
        // General
        //----------------------------------------------------------------
        "Model"                        "models/items/warlock/golem/doom_of_ithogoaki/doom_of_ithogoaki.vmdl"    // Model.
        "BaseClass"                    "npc_dota_creature"
        "SoundSet"                    "Creep_Bad_Range"
        "GameSoundsFile"            "soundevents/game_sounds_creeps.vsndevts"
        "Level"                        "4"
        "ModelScale"                 "1.0"
        "CanBeDominated"            "0"

        // Abilities
        //----------------------------------------------------------------
        "Ability1"                    "forged_spirit_melting_strike"            // Ability 1
        "Ability2"                    ""            // Ability 2
        "Ability3"                    ""            // Ability 3
        "Ability4"                    ""            // Ability 4

        // Armor
        //----------------------------------------------------------------
        "ArmorPhysical"                "5"            // Physical protection.
        "MagicalResistance"            "25"        // Percentage

        // Attack
        //----------------------------------------------------------------
        "AttackCapabilities"        "DOTA_UNIT_CAP_RANGED_ATTACK"
        "AttackDamageMin"            "55"        // Damage range min.
        "AttackDamageMax"            "100"        // Damage range max.
        "AttackRate"                "1.5"        // Speed of attack.
        "AttackAnimationPoint"        "0.4"        // Normalized time in animation cycle to attack.
        "AttackAcquisitionRange"    "800"        // Range within a target can be acquired.
        "AttackRange"                "600"        // Range within a target can be attacked.
        "ProjectileModel"            "particles/units/heroes/hero_invoker/invoker_forged_spirit_projectile.vpcf" // Particle system model for projectile.
        "ProjectileSpeed"            "1100"        // Speed of projectile.       

        // Bounds
        //----------------------------------------------------------------
        "BoundsHullName"            "DOTA_HULL_SIZE_HERO"            // Hull type used for navigation/locomotion.
        "RingRadius"                "80"
        "HealthBarOffset"            "200"

        // Bounty
        //----------------------------------------------------------------
        "BountyXP"                    "500"        // Experience earn.
        "BountyGoldMin"                "150"        // Gold earned min.
        "BountyGoldMax"                "300"        // Gold earned max.       

        // Status
        //----------------------------------------------------------------
        "StatusHealth"                "2500"        // Base health.
        "StatusHealthRegen"            "3"        // Health regeneration rate.
        "StatusMana"                "200"            // Base mana.
        "StatusManaRegen"            "30.0"        // Mana regeneration rate.     
   
        // Vision
        //----------------------------------------------------------------
        "VisionDaytimeRange"        "1800"        // Range of vision during day light.
        "VisionNighttimeRange"        "800"        // Range of vision at night time.

        // Team
        //----------------------------------------------------------------
        "TeamName"                    "DOTA_TEAM_NEUTRALS"                        // Team name.
        "CombatClassAttack"            "DOTA_COMBAT_CLASS_ATTACK_BASIC"
        "CombatClassDefend"            "DOTA_COMBAT_CLASS_DEFEND_BASIC"
        "UnitRelationshipClass"        "DOTA_NPC_UNIT_RELATIONSHIP_TYPE_DEFAULT"

        // Inventory
        //----------------------------------------------------------------
        "HasInventory"                "0"

        // Movement
        //----------------------------------------------------------------
        "MovementCapabilities"        "DOTA_UNIT_CAP_MOVE_GROUND"
        "MovementSpeed"                "300"        // Speed.

        // Creature Data
        //----------------------------------------------------------------
        "Creature"
        {
            "CanRespawn"                "1"
            "DefaultState"                "Invade"
            "States"
            {
                "Invade"
                {
                    "Name"                "Invade"
                    "Aggression"        "100.0"
                    "Avoidance"            "0.0"
                    "Support"            "0.0"
                }
            }
        }
    }

Let's explain the important lines, shall we, and what we can do with them?

First of all, "npc_dota_creature_guardian_fire" is the in-editor name of your unit. It's the reference to it. Make it an obvious name.

"Model" is the model of the unit. Here, I chose a special warlock golem model. What's really important about this line is that you need to have the full path. One way to find it is to open the asset browser, which is always opened with the editor, and type in at the top "golem". You will see a list of models and particles. Click on the model ending with "doom_of_ithogoaki". It should show up, animated, to the right. In the bottom right corner of the screen, there should be a line named "Asset relative path". That's where you find your model's path. Select it, copy it, and paste it in your code. There you go!

"BaseClass" is what the unit actually is. npc_dota_hero is, well, a hero. Among other choices are npc_dota_tower, a building which can attack. npc_dota_building, a building which can't attack, and many more. Our choice here is npc_dota_creature, a unit which isn't a hero. There are lots of different kinds of base classes.

The next lines are pretty straightforward, until the abilities. A non-hero unit can have hero abilities, but they will always be maxed out in levels. So, a 4-levels ability will always be level 4 on a non-hero unit. You can also give units normal abilities, which is what we did here. Be careful to give the unit the correct name of the ability.

"AttackCapabilities" 3 choices here.
  • DOTA_UNIT_CAP_MELEE_ATTACK
  • DOTA_UNIT_CAP_RANGED_ATTACK
  • DOTA_UNIT_CAP_NO_ATTACK
"AttackRate" can be as low as 0.01 for a very, very fast attack. The rest of the options are balance details, set whatever you want. Testing is the key here.

"ProjectileModel" this is like the model above. You find it in the asset browser, and it is very important to put the correct path of the particle, or else nothing will show up (which is annoying). See "Model" above for more information.

Hull size isn't very important, it's aesthetic, what matters is that the health bar can be offset compared to the unit's model size. Generally useless.

Give it the bounty you want, health you want, these are balance matters.

"TeamName" There are 4 teams in dota currently:
  • DOTA_TEAM_BADGUYS
  • DOTA_TEAM_GOODGUYS
  • DOTA_TEAM_NEUTRALS
  • DOTA_TEAM_NOTEAM
"CombatClass" refers to the attack and defense property of the unit. Heroes have the best attack and defense, while others have more reduction to their outgoing damage. Test it for whatever purpose you may have for your unit.

The deal at the end is the tricky part. The "States". Units will cast their spells, or not, depending on those states. This unit, for example, will always cast its most aggressive spell, due to its 100% aggression stance. You can toy with those settings and see what does what, but I'm not entirely sure still if those are based on % of HP or pure probabilities. Anyhow, higher "Support" value tends to cast defensive spells, while higher "Aggression" value means more offensive spells.
 
Last edited:
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top