• 🏆 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!

Get attachement point's Z value

Status
Not open for further replies.
Level 3
Joined
Jun 15, 2021
Messages
30
Is there a way to get Z value of unit's chest, for example? I'm doing some lightning-based skills and I know how to do it with preset Z values, but I couldn't find if you can get Z value of a unit's attachement :(

Btw, changing lightning color seems not to be working in Reforged?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
Closest thing you can do is get a unit's projectile launch/impact-Z / flying height using blizzard functions. That being said, if your map doesn't have too many units you could define these values yourself.

Basically something like this:
  • Set Variable ChestZ[footman id] = 60.00
  • Set Variable ChestZ[knight id] = 90.00
  • Set Variable ChestZ[mountain giant id] = 150.00
Well, actually you'd want to save it in a Hashtable since the unit id is too long to fit into an [Index]:
  • Events:
  • Map Initialization
  • Actions:
  • Hashtable - Create a Hashtable
  • Set Variable AttachmentZHashtable = Last created Hashtable
  • // setup your Units and their respective Z-heights
  • Set Variable Unit[1] = Footman
  • Set Variable Unit[2] = Knight
  • Set Variable Unit[3] = Mountain Giant
  • Set Variable Z[1] = 60.00
  • Set Variable Z[2] = 90.00
  • Set Variable Z[3] = 150.00
  • Set Variable ChestZIndex = 0 // you could store different attachment points with these (ex: OverheadZIndex = 1, HeadZIndex = 2, etc)
  • // then loop over all of these Units and add them to the Hashtable
  • For each integer Loop from 1 to 3 do...
  • Custom script: set udg_Id = GetUnitTypeId(udg_Unit[udg_Loop])
  • Hashtable - Save Z[Loop] as Id of ChestZIndex in AttachmentZHashtable
Id and Loop are Integer variables that you'd need to create yourself.

Then whenever you want to get a unit's Chest Z-height you simply Load their Unit-Type Id from the Hashtable referencing the Chest Index:
  • Set Variable LoadUnit = Triggering unit
  • Custom script: set udg_Id = GetUnitTypeId(udg_LoadUnit)
  • Set Variable ZHeight = Load Id of ChestZIndex from AttachmentZHashtable
  • // ZHeight will be equal to the unit's ChestZ value

Last time I tried using Lightning in Reforged I couldn't get it to work at all. Search around Hive because other people have made posts about it.
 
Last edited:
Level 3
Joined
Jun 15, 2021
Messages
30
Closest thing you can do is get a unit's projectile launch/impact-Z / flying height using blizzard functions. That being said, if your map doesn't have too many units you could define these values yourself.

Basically something like this:
  • Set Variable ChestZ[footman id] = 60.00
  • Set Variable ChestZ[knight id] = 90.00
  • Set Variable ChestZ[mountain giant id] = 150.00
Well, actually you'd want to save it in a Hashtable since the unit id is too long to fit into an [Index]:
  • Events:
  • Map Initialization
  • Actions:
  • Hashtable - Create a Hashtable
  • Set Variable AttachmentZHashtable = Last created Hashtable
  • // setup your Units and their respective Z-heights
  • Set Variable Unit[1] = Footman
  • Set Variable Unit[2] = Knight
  • Set Variable Unit[3] = Mountain Giant
  • Set Variable Z[1] = 60.00
  • Set Variable Z[2] = 90.00
  • Set Variable Z[3] = 150.00
  • Set Variable ChestZIndex = 0 // you could store different attachment points with these (ex: OverheadZIndex = 1, HeadZIndex = 2, etc)
  • // then loop over all of these Units and add them to the Hashtable
  • For each integer Loop from 1 to 3 do...
  • Custom script: set udg_Id = GetUnitTypeId(udg_Unit[udg_Loop])
  • Hashtable - Save Z[Loop] as Id of ChestZIndex in AttachmentZHashtable
Id and Loop are Integer variables that you'd need to create yourself.

Then whenever you want to get a unit's Chest Z-height you simply Load their Unit-Type Id from the Hashtable referencing the Chest Index:
  • Set Variable LoadUnit = Triggering unit
  • Custom script: set udg_Id = GetUnitTypeId(udg_LoadUnit)
  • Set Variable ZHeight = Load Id of ChestZIndex from AttachmentZHashtable
  • // ZHeight will be equal to the unit's ChestZ value

Last time I tried using Lightning in Reforged I couldn't get it to work at all. Search around Hive because other people have made posts about it.
Thank you for answer. Lightning through custom scripts works fine at most, but it's buggy sometimes (as for me, it just doesn't appear for some reason in ~20-25% cases). Gotta try your method tomorrow!
 
Status
Not open for further replies.
Top