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

Detection of Unloading? Please Help me!

Status
Not open for further replies.
Level 31
Joined
Apr 17, 2009
Messages
3,571
Hey Guys,

I'm working on a Jungle Survivor map.
I have made a tent, you can construct with an item in your inventory.
The tent has the ability of the Orc house, so units can enter the tent.

Now I wanted the units to have increased life points regeneration when they enter the tent, so I made a trigger, with which I add the "Ring of Regeneration - Ability", when they get loaded in the tent.


  • Healing Inside Tent Activate
    • Ereignisse
      • Einheit - A unit Wird in einen Transporter geladen.
    • Bedingungen
    • Aktionen
      • Set HealingInsideTent_Unit = (Triggering unit)
      • Einheit - Add Healing (Inside the Tent) to (Triggering unit)


All works fine, but then I tried to make a trigger, that removes the ability when they leave the tent (left click on the icon of the unit in the tent).
But I couldn't find any actions that can detect if a unit leaves the tent (or gets unloaded).

I already tried "A unit enters Playable Map Area", but it doesn't work.
I also tried this:

  • Healing Inside Tent Deactivate
    • Ereignisse
      • Einheit - A unit Erhält einen Befehl ohne Ziel
    • Bedingungen
      • (Issued order) Gleich (Order(unload))
    • Aktionen
      • Einheit - Remove Healing (Inside the Tent) from HealingInsideTent_Unit


Without succes.

Please help me!
+2 rep for every useful help and credits for the one who solves my problem.
 
Level 2
Joined
Feb 8, 2010
Messages
17
Do you HAVE to right click the tent to enter it, or does it have a load ability like the zepplin?

I was thinking something in the lines of:

(Not infront of WE)
--------------------------------------------
Action
-Unit enters tent/ Right click tent
Condition
-
Action
-Set <Unit_in_tent> = True
--------------------------------------------

Then use region detection for when unit exits.

Event
-Unit Enters <Region>
Condition
-Unit_in_tent = True
Action
-Set Unit_in_tent = false
-Remove "Ring of Regeneration - Ability"
----------------------------------------------

I would personally try something along thos lines. Not sure if it works tho.


Regards,
Orbit
 
Ok, I made some quick triggers to check if a unit unloads or loads. It is simple, and in GUI so that it'll be easier to use. =P
  • UnitLoaded
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
    • Actions
      • Unit Group - Add (Triggering unit) to TransportGroup
      • Game - Display to (All players) the text: ((Name of (Triggering unit)) + was loaded!)
  • UnitLeaves
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TransportGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is being transported) Equal to False
            • Then - Actions
              • Unit Group - Remove (Picked unit) from TransportGroup
              • Game - Display to (All players) the text: ((Name of (Picked unit)) + was unloaded!)
            • Else - Actions
The Game - Display things were just there for debugging. I can make a JASS version later if you want. Anyway, all it requires is a group called "TransportGroup".

Good luck. =) Worked for me, even for the orc burrow. =P

EDIT: Here is a JASS version, relatively the same. But you can probably import your functions more easily into the gui one. This isn't a system, this is just kind of a template btw. In the periodic trigger, you can put your actions in the "then" part.
JASS:
function LAct takes nothing returns nothing
    call GroupAddUnit(udg_TransportGroup,GetTriggerUnit())
    call DisplayTextToPlayer(Player(0),0,0,GetUnitName(GetTriggerUnit())+" was loaded!")
endfunction
function InitTrig_UnitLoaded takes nothing returns nothing
    local trigger Loaded = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(Loaded,EVENT_PLAYER_UNIT_LOADED)
    call TriggerAddAction(Loaded,function LAct)
    set Loaded = null
endfunction
JASS:
function UnLCall takes nothing returns nothing
    if not IsUnitLoaded(GetEnumUnit()) then
        call GroupRemoveUnit(udg_TransportGroup,GetEnumUnit())
        call DisplayTextToPlayer(Player(0),0,0,GetUnitName(GetEnumUnit())+" was unloaded!")
    endif
endfunction
function UnLAct takes nothing returns nothing
    call ForGroup(udg_TransportGroup,function UnLCall)
endfunction
function InitTrig_UnitLeaves takes nothing returns nothing
    local trigger Unload = CreateTrigger()
    call TriggerRegisterTimerEvent(Unload,0.03,true)
    call TriggerAddAction(Unload,function UnLAct)
    set Unload = null
endfunction
 
Level 31
Joined
Apr 17, 2009
Messages
3,571
Okay, I made it a little bit different:

  • Unit Loaded
    • Events
      • Unit - A unit is loaded into a transport.
    • Conditions
    • Actions
      • Set InsideTent_Unit = (Triggering unit)
      • Unit - Add Healing (Inside the Tent) to InsideTent_Unit
and

  • Unit Unloaded
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
      • (InsideTent_Unit is being transported) Equal to False
    • Actions
      • Unit - Remove Healing (Inside the Tent) from InsideTent_Unit
      • Set InsideTent_Unit = No Unit
Somehow I've got a feeling that this little system isn't MUI.
Is it? How can I make it MUI?
 
Last edited:
It isn't MUI if you use a unit var because it can be overwritten if someone else goes into a transport.

If you need to, you can set the unit var to picked unit. =D
  • UnitLoaded
  • Events
    • Unit - A unit Is loaded into a transport
  • Conditions
  • Actions
    • Unit Group - Add (Triggering unit) to TransportGroup
    • Unit - Add Healing (Inside the Tent) to (Triggering Unit)
  • UnitLeaves
  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
    • Unit Group - Pick every unit in TransportGroup and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked unit) is being transported) Equal to False
          • Then - Actions
            • Unit Group - Remove (Picked unit) from TransportGroup
            • Unit - Remove Healing (Inside the Tent) from (Picked Unit)
          • Else - Actions
That should work. The reason for the unit group is so that you can reference to that unit without losing MUI.
 
Status
Not open for further replies.
Top