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

Create Units via Coordinates

Status
Not open for further replies.
Level 7
Joined
Aug 15, 2012
Messages
318
Hello I have one last question for my rpg which I basically need in order to continue because from what I hear if I place every one of my monsters on the map eventually will screw it all up. I am not good at jass and I have learnt lua in the past but that was over a year ago. I just do not want to have to create hundreds of regions and then create the units and then remove locations. It would be nice to just create the units via coordinates and remove any possible leaks I dont know if it leaks but. I just heard that in jass you can create units this way and it is more efficient so if someone can give me a snippet for one monster I will +rep and continue. I also have read basically every jass tutorial on here and tbh didnt see anything about it took days off my map to do so.

JASS:
function Trig_Create_Unit_Test_Actions takes nothing returns nothing
    call CreateUnit( Player(12), 'nfov', -6593, 29102, 270)
endfunction

//===========================================================================
function InitTrig_Create_Unit_Test takes nothing returns nothing
    set gg_trg_Create_Unit_Test = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Create_Unit_Test, function Trig_Create_Unit_Test_Actions )
endfunction
The Start I have am I 100% wrong or what?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
That works if you have checked "Run on map initialization".

Leaks are ussually things that are never destroyed or removed.
Units will get removed eventually (unless you do some weird shit).

Another thing that could leak is when you assign that unit to a local unit variable and not null it.
All extentions of handle have to be nulled at some point or recycled.
Global variables are ussually recycled but local variables are impossible to recycle, because they are local.
So you have to null all variables except string, integer, real, boolean and maybe code but I have to check that... which I am too lazy for. Common.j should be able to tell you.
 
Level 7
Joined
Aug 15, 2012
Messages
318
NVM I have it working in game 100% so I just have to null agents without them being declared? Or did I miss them being declared sorry im new to jass
If I wanted to add a drop to this how would I go about it like add x to last created unit right after he was made or what?
Also I never learnt what the 270 does what does that number mean or refer to when I have it?
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,657
When you use local variables (which you dont in your example) then you have to null them if you have set them to something.
It is not completely necessary if the object they refer to will never be destroyed/removed but it is a good habit.

Btw, you cant refer to the last created unit in your example, so if you want to do additional functions with that unit, you would have to use some kind of variable.
 
Level 7
Joined
Aug 15, 2012
Messages
318
When you use local variables (which you dont in your example) then you have to null them if you have set them to something.
It is not completely necessary if the object they refer to will never be destroyed/removed but it is a good habit.

Btw, you cant refer to the last created unit in your example, so if you want to do additional functions with that unit, you would have to use some kind of variable.

Ok well thats fine how would I go about adding drops to the now created unit would I need to add items 1 by one with thier own drop rate or can it add item sets? (the configured drop files)
 
Level 7
Joined
Aug 15, 2012
Messages
318
If you create them at map initialization you might as well place them on the map as it is likely more efficient anyway.

If you are making an RPG you will want to consider a dynamic spawn system where only if players are in the area monsters spawn.

You see I was actually thinking of this last night watching my friend play destiny hahah I was really intrigued by the way they did that although. It would be a weird twist the main reason I wanted to do this coordinate idea is because I looked at cot rpg and it has 0 units on the map and all of the sudden when you enter its a lively verse.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Well, coordinates dont really change that.
You can create that with locations as well.
However, the only reason to use locations in WC3 is to be able to load the Z value (terrain height) of that X,Y coordinate.
In all other cases, you can simply use an x and y real variable to specify the location.
 
Status
Not open for further replies.
Top