• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

[General] Handle on pre-placed objects

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

How do we find the handle on a pre-placed object?

e.g. I put a footman on the map. I want to now manipulate that footman. What is its unit reference value? I tried clicking on it and looking in the object manager but it doesn't telling me the raw value.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
If you select your footman in editor you can see his name at bottom, which unit is selected.

For example, Selected: Footman 0013

Then in trigger you have to write: gg_unit_hfoo_0013

gg_unit_ is always for preplaced units + hfoo (footman) + number of unit (depends how many units have been created before in editor)

Thank you, this makes sense!
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
I followed the suggestions, including invoking the variable, but I still get a bunch of errors.

JASS:
library City initializer init

globals
    constant real CITY_CENTER_X = -12826.9
    constant real CITY_CENTER_Y = 12474.9
    destructable CITY_GATE = gg_dest_DTg5_0008
endglobals

private function init takes nothing returns nothing
    call KillDestructable(CITY_GATE)
    call SetDestructableAnimation(CITY_GATE, "death alternate")
endfunction
endlibrary

It claims that gg_dest_DTg5_0008 is multiply defined and then it claims that it doesn't exist!

How on earth can I simply open a preplaced gate...

If I change it to a scope, the errors go away but the gate still doesn't open...
 
You can't assign a global to it in the global block (or at least, it doesn't make much sense to do so). In the generated map script, the globals are moved into the globals block, so you'll end up with something like this:
JASS:
globals
    constant real CITY_CENTER_X = -12826.9
    constant real CITY_CENTER_Y = 12474.9
    destructable CITY_GATE = gg_dest_DTg5_0008
    // ... some other globals
    destructable gg_dest_DTg5_0008 = null
endglobals

Note that the JASS parser reads the script from up to down, and it hasn't encountered gg_dest_DTg5_0008 yet (it is declared later). So it'll immediately throw an error. When you change it to a scope, it might order it after the gg_dest_DTg5_0008, but keep in mind that the variable either points to null or is uninitialized, so assigning CITY_GATE to it will just make CITY_GATE point to null (or it might stop the thread, if the variable is uninitialized).

The generated globals are set in a separate function, which is called on initialization. As such, you should assign CITY_GATE to it on initialization (or after a 0 second timer, whichever works):
JASS:
library City initializer init

globals
    constant real CITY_CENTER_X = -12826.9
    constant real CITY_CENTER_Y = 12474.9
    destructable CITY_GATE
endglobals

private function init takes nothing returns nothing
    set CITY_GATE = gg_dest_DTg5_0008
    call KillDestructable(CITY_GATE)
    call SetDestructableAnimation(CITY_GATE, "death alternate")
endfunction
endlibrary

Or you can simply use gg_dest_DTg5_0008, but it makes the code look kinda ugly so just stick with CITY_GATE (or assign a local to the gg global).
 
Status
Not open for further replies.
Top