• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Special effect of a unit's model

Status
Not open for further replies.
Level 5
Joined
Jul 15, 2012
Messages
101
Hello hiveworkshoparians,

how may I create a special effect as a unit's self model?

  • Special Effect - Create a special effect at (Position of (Last created unit)) using units\creeps\OgreOneHeadedArmored\OgreOneHeadedArmored.mdl
like this, except that I wouldn't need to specify the exact name of the model, just a particular unit and it uses it's own model.

something close to this:

  • Special Effect - Create a special effect at (Position of (Last created unit)) using (Model of (Last created unit))
 
Level 39
Joined
Feb 27, 2007
Messages
4,992
You could create another copy of the unit itself, give it locust, and pause it. That would effectively be a model of the unit that nobody could interact with. The only other option would be to read the string field from the unit itself, but model is not one of the string fields GUI allows you to read so I'm not sure it's even implemented. If it works it would be something like this:

  • -------- Create a unit variable "ModelUnit" and string variable "ModelPath" --------
  • Set ModelUnit = (Triggering Unit)
  • Custom script: set udg_ModelPath = BlzGetUnitStringField(udg_ModelUnit, ConvertUnitStringField('umdl'))
  • -------- now use ModelPath here --------
 
Level 5
Joined
Jul 15, 2012
Messages
101
Thank you for clear instructions. I believe that creating another unit would interfere with unit groups.. Also, it appears that ModelPath is empty.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,511
You could do something like this using a Unit Indexer. Check out the link in my Signature to download a Unit Indexer if you don't already use one.
  • Setup Models
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Variable Model[1] = units\human\Footman\Footman
      • Set Variable UnitType[1] = Footman
      • -------- - --------
      • Set Variable Model[2] = units\human\Rifleman\Rifleman
      • Set Variable UnitType[2] = Rifleman
      • -------- - --------
      • Set Variable TotalUnitTypes = 2
SaveModel is a String (Array) that is used with the Unit Indexer to save the model to the unit.
  • Set Unit's Model
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Set Variable UDex = (Custom value of (Triggering unit))
      • For each (Integer A) from 1 to TotalUnitTypes, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to UnitType[(Integer A)]
            • Then - Actions
              • Set Variable SaveModel[UDex] = Model[(Integer A)]
            • Else - Actions
  • Create Model Example
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set Variable UDex = (Custom value of (Triggering unit))
      • Special Effect - Create a special effect at (Position of (Triggering unit)) using Model[UDex]
A bit of work and maybe some performance issues if you have A LOT of units or spawn units often (Looping through each of their unit types) but it would certainly work.

If you use Lua (and I think Jass too) you can simplify this by using the unit's id as the Array.
Lua:
function CreateModelTable()
    Model = {}
    Spellbreaker = 1211117616
    Model[Spellbreaker] = "units\\human\\BloodElfSpellThief\\BloodElfSpellThief"
end

function ExampleSfx()
    --Just pretend that this function runs when a unit casts an ability like I did in the GUI example
    local u = GetTriggerUnit()
    local id = GetUnitTypeId(u)
    AddSpecialEffect(Model[id], 0, 0)
end
 
Last edited:
Status
Not open for further replies.
Top