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

[Trigger] How do I make this trigger more efficient?

Status
Not open for further replies.
Level 4
Joined
Nov 6, 2011
Messages
44
[Solved] How do I make this trigger more efficient?

  • British Isles
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Province[10] = Village 0010 <gen>
      • Set ProvincePoint[10] = ((Position of Province[10]) offset by (-50.00, -50.00))
      • Set ProvinceName[10] = London
The trigger is supposed to give a certain village an identity(variables for its position, name, and the variable for the unit itself).

The array is [10] taken from its name, "Village 0010", so that it will be easier to find it as I edit the map. That number will also serve as its ID(There is a separate variable for that called ProvinceID).

Now, I was thinking, how do I make the trigger more efficient so that I don't have to keep putting that ID number in the place where you enter the array number four times for each province(As you can see it says "10" four times in the trigger)? What can I do to reduce the number of times I have to enter it?
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Make it more efficient by using X/Y instead of position. X/Y are reals.

ProvinceX[10] = 1231
ProvinceY[10] = 3834

You can see X/Y in the World Editor when you move the mouse around, in the bot left corner.

after that, you just need to know how to handle X/Y (Which is the same Locations do, but these leak and are slower)


--------
To avoid putting the index over and over just set it to an integer variable

Set tempInteger = 10
Province[tempInteger] = Village0010
ProvinceX[tempInteger] = 1231
ProvinceY[tempInteger] = 3834
ProvinceName[tempInteger] = London
 
Level 4
Joined
Nov 6, 2011
Messages
44
U are leaking position of province and offset by
They both create a location



It isn't a dynamic location.

Make it more efficient by using X/Y instead of position. X/Y are reals.

ProvinceX[10] = 1231
ProvinceY[10] = 3834

You can see X/Y in the World Editor when you move the mouse around, in the bot left corner.

after that, you just need to know how to handle X/Y (Which is the same Locations do, but these leak and are slower)


--------
To avoid putting the index over and over just set it to an integer variable

Set tempInteger = 10
Province[tempInteger] = Village0010
ProvinceX[tempInteger] = 1231
ProvinceY[tempInteger] = 3834
ProvinceName[tempInteger] = London



I'll look into this, thanks.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Doesn't matter if it isn't a Dynamic Location. When you use "Position of" the game creates a Location (with an Id and everything else). If you don't clean it after using it, you take up some memory space that, even if they're only 20 or 30 leaks, they'll still takes memory you don't need to waste holding up unusefull data like this.
 
Level 4
Joined
Nov 6, 2011
Messages
44
Actually, you shouldn't bother with the leaks in this thread, I've had that fixed in another trigger, I guess I should've put that in the main post.
 
Status
Not open for further replies.
Top