Teleport trigger trouble.

Cookie!

Member
Reaction score
0
I'm making an RPG style map, where heroes can be teleported back to base. This is achieved by giving the base building a "Summon Hero" spell. The way it's supposed to work is this:

1) Player clicks on Summon Hero spell in base building.
2) Glowy SFX appears around hero, 5 second wait.
3) If hero hasn't been attacked in this five-second delay, teleport happens sucessfully.

If, at any point during the wait, the hero is attacked, the teleport is cancelled.


Here's my code:

TeleportingHeroes - UnitGroup
TeleportSFX - Array to store special effects for later deletion.
temp_Unit, temp_UnitGroup and temp_Point are exactly what they say.

Code:
Teleport
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Summon Hero 
    Actions
        Custom script:   local unit udg_temp_Unit
        Set temp_UnitGroup = (Units owned by (Owner of (Casting unit)) matching (((Matching unit) is A Hero) Equal to True))
        Set temp_Unit = (Random unit from temp_UnitGroup)
        Unit Group - Add temp_Unit to TeleportingHeroes
        Game - Display to (All players) the text: (String((Number of units in TeleportingHeroes)))
        Special Effect - Create a special effect attached to the origin of temp_Unit using Abilities\Spells\Human\MassTeleport\MassTeleportTo.mdl
        Set TeleportSFX[(Player number of (Owner of temp_Unit))] = (Last created special effect)
        Wait 5.00 game-time seconds
        Game - Display to (All players) the text: wait done
        Game - Display to (All players) the text: (String((Number of units in TeleportingHeroes)))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (temp_Unit is in TeleportingHeroes) Equal to True
            Then - Actions
                Unit Group - Remove temp_Unit from TeleportingHeroes
                Special Effect - Destroy TeleportSFX[(Player number of (Owner of temp_Unit))]
                Special Effect - Create a special effect attached to the origin of temp_Unit using Abilities\Spells\Human\MassTeleport\MassTeleportCaster.mdl
                Special Effect - Destroy (Last created special effect)
                Set temp_Point = (Position of (Triggering unit))
                Unit - Move temp_Unit instantly to temp_Point
            Else - Actions
                Do nothing
        Custom script:   call DestroyGroup(udg_temp_UnitGroup)
        Custom script:   call RemoveLocation(udg_temp_Point)
        Custom script:   set udg_temp_Unit = null

I also have another trigger which fires whenever a unit from the TeleportingHeroes unit group gets attacked, and removes said unit from the unit group.

The trigger works fine if I leave out the check to make sure the unit is still in the group, but when I enable the check, everything goes south. :banghead: The teleporting SFX stays on the unit indefinitely, and the teleport never happens.

The unit group has one unit in it, both before and after the wait. I've already made sure that the other trigger isn't firing accidentally.

Any thoughts?
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Could you upload the map containing the effect? I can't see a problem just from the text.
 

Cookie!

Member
Reaction score
0
Here's a map illustrating what I'm trying to say:
 

Attachments

  • Teleport trouble.w3x
    18.7 KB · Views: 244

jackall

You can change this now in User CP.
Reaction score
37
I see that you tried shadowing a global variable using a local one and afaik that is no longer possible. I deleted that line

Trigger:
  • Custom script: local unit udg_temp_Unit


and the triggers worked as intended.

View attachment Teleport trouble.w3x

Hmm... Nevermind about the shadowing, it seems to be working. Looks like there's just something wrong about that local unit variable.
 

Cookie!

Member
Reaction score
0
No longer possible? I'm afraid you lost me there.

I need the variable to be local, as several players could be teleporting at once. If that line is removed, the trigger loses MPI functionality, right?
 

afisakov

You can change this now in User CP.
Reaction score
37
Afraid I don't know too much about local variable, but another good way to make it MPI is to make temp_unit an array, and then set the number equal to player number.
so the the line would look like: set temp_unit[player number of owner of casting unit]=...
this makes it MPI without needing local variables, assumming each player has only 1 hero, which seems true if u can find that hero with "Random unit from temp_UnitGroup"

btw, I would move
Custom script: call DestroyGroup(udg_temp_UnitGroup)
to just above the wait, u r done with it by then and it prevents the risk that it gets overwritten by another player (during the wait) before it can be removed.

As for the special effect, it stays on because by the time u try to get rid of it, it is no longer "last created". You might have to make a special effect array, set it to last created special effect, and then remove the special effect later this way. Not sure, never actually tried doing this.
 

Cookie!

Member
Reaction score
0
After a bit of testing, I've come to the conclusion that jackall is right, it is the shadowing that is messing the trigger up. I implemented a check right after the wait to find out if temp_Unit is alive, and apparently, it wasn't. :nuts:

Anyhow, I designed something along the lines of what afisakov suggested, and I have something that works.

I've used a dummy unit to buff the teleporting hero with a "Teleporting" buff, and the trigger checks for this buff after the wait. The other trigger removes this buff if the unit gets attacked.

Trigger:
  • Teleport Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Hero
    • Actions
      • Set temp_UnitGroup = (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is A Hero) Equal to True))
      • Set Teleporting_Heroes[(Player number of (Owner of (Triggering unit)))] = (Random unit from temp_UnitGroup)
      • Custom script: call DestroyGroup(udg_temp_UnitGroup)
      • Set temp_Point = (Position of Teleporting_Heroes[(Player number of (Owner of (Triggering unit)))])
      • Unit - Create 1 Dummy Unit for (Owner of (Triggering unit)) at temp_Point facing Default building facing degrees
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Add Teleport Dummy to (Last created unit)
      • Unit - Order (Last created unit) to Orc Shaman - Bloodlust Teleporting_Heroes[(Player number of (Owner of (Triggering unit)))]
      • Custom script: call RemoveLocation(udg_temp_Point)
      • Wait 5.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Teleporting_Heroes[(Player number of (Owner of (Triggering unit)))] has buff Teleporting ) Equal to True
        • Then - Actions
          • Unit - Remove Teleporting buff from Teleporting_Heroes[(Player number of (Owner of (Triggering unit)))]
          • Special Effect - Create a special effect attached to the origin of Teleporting_Heroes[(Player number of (Owner of (Triggering unit)))] using Abilities\Spells\Human\MassTeleport\MassTeleportCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set temp_Point = (Position of (Triggering unit))
          • Unit - Move Teleporting_Heroes[(Player number of (Owner of (Triggering unit)))] instantly to temp_Point
          • Camera - Pan camera as necessary for (Owner of (Triggering unit)) to temp_Point over 1.00 seconds
          • Custom script: call RemoveLocation(udg_temp_Point)
        • Else - Actions


Note that the glowy SFX is now applied through the buff, so that's one less variable for me to trip over. :D

As for the special effect, it stays on because by the time u try to get rid of it, it is no longer "last created". You might have to make a special effect array, set it to last created special effect, and then remove the special effect later this way. Not sure, never actually tried doing this.

I was talking about the first effect, which I did store in an array. Despite this, it remained on the unit. (Because, for some reason, the unit was "dead")
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top