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

[Solved] How to Detect Units Unloaded with GUI?

Status
Not open for further replies.
Level 2
Joined
Oct 2, 2019
Messages
11
So I want to be able to use GUI to stage an Event that detects when a unit is unloaded from a transport. There is no unload event in world editor's GUI that would make this problem easy to solve. Even if you try to make it an order event, the order string for unload doesn't work either. I have looked at multiple threads that talk about this problem, and I haven't found any sort of solution I can use. Most of these threads direct people to Bribe's GUI Events [GUI Unit Event v2.5.2.0], however I don't know Jass and I need to be able to modify some things in order to make it work for my map, so I wouldn't be able to feasibly use this. One example for why my map needs this function is that there is a transporter that gains movement when it is transporting a threshold of units, but of coarse loses the bonus when it unloads them. I also need to be able to detect the units being unloaded, as they need to be moved in a certain arrangement upon being unloaded (units don't move around traditionally and are instead sort of arranged along a 2d grid). As I said before, I have tried making this into an order event, but the order detection for the unload string doesn't seem to work. I also tried using a unit enters region event, however this doesn't work either since units being unloaded don't trigger the region entrance event for some reason unknown to me. I thought about using a periodic trigger to detect when units have been unloaded as suggested by some in other threads, but this might become messy for my map since there could be multiple players using multiple types of transporters at any given time, so I didn't want to have to resort to this if there is a more elegant solution around. Any help is appreciated.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
I'm not sure if Bribe's system is better but here's something I threw together that should be pretty user friendly. Note that you don't need to know how to use Jass in order to use Bribe's system. It uses custom events that are done in GUI so all you really need to figure out is which variables to use like what "UnitEvent becomes equal to 1.00" means. That should be fairly easy as I'm sure the Variable names are self-explanatory and Bribe has added information explaining it all.

Anyway, here's how my map works:
Using a Unit Indexer I keep track of a few variables, notably these 3:
IsLoaded (Boolean) = Whether or not a unit is loaded inside of a transport.
LoadedParent (Unit) = The Transport that is currently transporting a unit.
LoadCount (Integer) = How many units are loaded inside of a Transport.

This system works on a basic principle: When a unit is unloaded from a Transport it automatically issues a "stop" order. Because of this we can use the "stop" order to detect when a unit has exited from a Transport (Orc Burrow, Goblin Zeppelin, etc...). Using this system, if a unit is ordered to "stop" and our variable IsLoaded = True, then we know that the unit has just exited out of a Transport. We can then set IsLoaded = False for the unit and add additional actions like the Speed Buff you mentioned. I use this same concept to keep track of LoadCount (how many units are in the Transport).
This trigger detects when a unit is loaded into a transport. I store the variables LoadCount to the Transport and I store LoadedParent and IsLoaded to the Transporting Unit. You can add on any extra actions that you might want. For example, you could apply your Speed Buff to the Transport unit if LoadCount[CV1] is >= some number.
  • Load
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
    • Actions
      • -------- Increase the number of units loaded into the transport by 1 --------
      • Set CV1 = (Custom value of (Transporting unit))
      • Set LoadCount[CV1] = (LoadCount[CV1] + 1)
      • -------- - --------
      • -------- Set the transport as the "parent" of the loaded unit --------
      • Set CV2 = (Custom value of (Triggering unit))
      • Set LoadedParent[CV2] = (Transporting unit)
      • Set IsLoaded[CV2] = True
This trigger detects when a unit is unloaded from a transport. Triggering unit = the unloading unit. LoadedParent[CV1] = the transport. You could add your own variables here to make it more clear and easier to understand like "Set UnloadedUnit = Triggering Unit" and "Set Transport = LoadedParent[CV1]". Then do whatever else you want. For example, referring to your Speed Buff again, you could check if LoadCount[CV2] is <= some number and if so remove the Speed buff from LoadedParent[CV1].
  • Unload
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(stop))
      • IsLoaded[(Custom value of (Triggering unit))] Equal to True
    • Actions
      • -------- Since our unloaded unit issued a "stop" order and IsLoaded was True, we know that it just exited a transport --------
      • Set CV1 = (Custom value of (Triggering unit))
      • Set IsLoaded[CV1] = False
      • -------- - --------
      • -------- Find our unloaded unit's parent (the transport that was carrying it) and reduce the transport's Load Count by 1 --------
      • Set CV2 = (Custom value of LoadedParent[CV1])
      • Set LoadCount[CV2] = (LoadCount[CV2] - 1)
      • Game - Display to (All players) for 5.00 seconds the text: Unload from Transpo...

EDIT: Added v.2. The triggers will look slightly different than what I posted above but they're practically the same.
 

Attachments

  • Load and Unload v.2.w3x
    24.3 KB · Views: 55
Last edited:
Status
Not open for further replies.
Top