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

[Trigger] Is this trigger optimised?

Status
Not open for further replies.
Level 3
Joined
Mar 10, 2018
Messages
32
I have a map with a 'Circle of Power' hero selection system. I have too many heroes there so I decided to avoid the flood of 'Hero enters circle A --> Spawn Hero A' triggers.
Is my version better or should I use the commonly known system?

Here's my trigger:
(sorry I wrote this by hand because my editor isn't in english and it doesn't copy here properly)

Event:
A unit is given an order (unit -> object)
Condition:
(UnitType of (Triggering Unit)) is Wisp
(Owner of (Target unit of issued Order)) is Neutral-Passive
((Target unit of issued Order) is Hero) is True
Action:
- Explode unit (Triggering unit)
- if (Owner of (Triggering unit)) is Player 0 (Red)
then
Set (Spawn_point) = position of gg_unit_hcas0001
else
Set (Spawn_point) = position of gg_unit_hcas0002
- Create 1 (Unit-Type of (Target unit of issued Order)) for (Owner of (Triggering unit)) at Spawn_point

I wonder if it has more leaks that the common system. My thought that the game has to check every single time you make a 'unit->object' order so that can create lags, right? I cannot turn this trigger off because players can get more heroes during the game (this map has only 2 players).

So how can I improve this and make as leakless as possible?
 
Level 9
Joined
Apr 23, 2011
Messages
527
Add
  • call removeLocation(udg_Spawn_ppoint)
at the end to remove the point leak.

As to optimizing it further;
Since there are only 2 other players on the map, you could make the spawnpoint variable into an array and set its position at map initialization. This way, you only need to set another variable for the player number of the (Owner of (Triggering unit)).
  • Set Spawn_point[1] = (Position of gg_unit_hcas0001)
  • Set Spawn_point[2] = (Position of gg_unit_hcas0002)
Maybe something like this?
  • Actions:
    • Set unit = (Triggering unit)
    • Set player = (Owner of unit)
    • Set PN = (Player number of player)
    • Set hero = (Unit-type of (Target unit of issued Order))
    • Unit - Explode unit
    • Unit - Create 1 hero for player at Spawn_point[PN] facing Default building facing degrees
 
Status
Not open for further replies.
Top