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

[Solved] Invisibility that breaks upon movement

Status
Not open for further replies.
Level 2
Joined
Feb 19, 2019
Messages
12
Hello there,

Just installed WC III (ROC & TFT) again after many years and decided to make a little custom game-mode.
I want to have a unit be able to become invisible at will and that the effects ends when the character attacks or moves.

Any help would be appreciated. Fair warning, I know absolutely nothing about triggers, so please bear with me if I'm a little slow.
 
Level 28
Joined
Feb 18, 2014
Messages
3,581
Invisibility dispels automatically when a unit is issued to attack so no need to trigger it. As for the movement, you'll need to use a movement detection system such as Is Unit Moving 2.1.0.0 or if you want a simple one then check this
Your trigger should look like this :
  • Remove Invisibility
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Point[2] = Point[1]
      • Set Point[1] = (Position of YourUnit)
      • Set WalkDistance = (Distance between Point[1] and Point[2])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WalkDistance Greater or Equal to 1.00
        • Then - Actions
          • Set IsMoving = TRUE
          • Unit - Remove Invisibility buff from YourUnit
        • Else - Actions
          • Set IsMoving = FALSE
      • Custom script: call RemoveLocation( udg_Point[2])
 
Level 5
Joined
May 12, 2014
Messages
133
Wouldn't you just use that one night elf ability? I think it was shadowmeld? Iirc there's an option to allow it at all times of the day.
 
Level 2
Joined
Feb 19, 2019
Messages
12
Invisibility dispels automatically when a unit is issued to attack so no need to trigger it. As for the movement, you'll need to use a movement detection system such as Is Unit Moving 2.1.0.0 or if you want a simple one then check this
Your trigger should look like this :
  • Remove Invisibility
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Point[2] = Point[1]
      • Set Point[1] = (Position of YourUnit)
      • Set WalkDistance = (Distance between Point[1] and Point[2])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WalkDistance Greater or Equal to 1.00
        • Then - Actions
          • Set IsMoving = TRUE
          • Unit - Remove Invisibility buff from YourUnit
        • Else - Actions
          • Set IsMoving = FALSE
      • Custom script: call RemoveLocation( udg_Point[2])

I know nothing about triggers so forgive me if this is a dumb question, but where do you find the 'Set Point' actions? I searched through the possible actions but couldn't find any?
 
Level 2
Joined
Feb 19, 2019
Messages
12
Wouldn't you just use that one night elf ability? I think it was shadowmeld? Iirc there's an option to allow it at all times of the day.

This was also my first idea.
But I've searched on various forums and couldn't find anything, and I simply don't know enough about triggers to set it up myself.
 
Level 28
Joined
Feb 18, 2014
Messages
3,581
I know nothing about triggers so forgive me if this is a dumb question, but where do you find the 'Set Point' actions? I searched through the possible actions but couldn't find any?
They are called "variables". You can learn more about them in this tutorial : Variables
This was also my first idea.
But I've searched on various forums and couldn't find anything, and I simply don't know enough about triggers to set it up myself.
Use Permanent Invisibility instead. It works on day time as well.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,898
Okay, I've read the tutorial. And I've figured out the set point part, but can't find anything relating to distance between two points. Again, sorry if I'm a bit slow.
Well, that's normal if you don't know about triggers.
Before you start to go deep in the hell of the triggers world without knowing anything, I really suggest you first: Either mess around with events and actions for you to check what they do, you obviously don't have to do this for every single one, but for the ones which you're not sure what their behavior is, some are really straight forward. Or create a separate map which you have a clear and easy purpose, like a map where there are 2 bases and you spawn troops to the opposite team and order them to attack, and you would have features like upgrading the towers, the troops, etc...you could also make when the towers are destroyed to give bounty and/or give a message which notifies who destroyed the tower. Then from a simple idea you can expand it and make it more complex.
The whole point here isn't to delay you to make your current map, but rather learn the basics of the triggers so you actually understand them and understand what you're doing. Just don't jump into hard maps yet. Warseeker gave you a good solution, although you think it is chinese at moment:D
I don't really recommend reading a bunch of tutorials for you unless you have some doubts or looking for something very peculiar and specific, the practice of triggering will make you fly through the learning curve, just don't try to get lost :)
 
Level 2
Joined
Feb 19, 2019
Messages
12
WalkDistance is a variable of type "Real". The value associated to it in this example is : Math - Distance Between Points

Okay, Almost done (I hope). lastly the two set IsMoving = TRUE/FALSE what are these used for, and how do I set them up.

Secondly, the last part "Custom script: call RemoveLocation( udg_Point[2])" what is this?

Edit: It seems to be working without these last three parts. Though, maybe there is something I've missed.

Well, that's normal if you don't know about triggers.
Before you start to go deep in the hell of the triggers world without knowing anything, I really suggest you first: Either mess around with events and actions for you to check what they do, you obviously don't have to do this for every single one, but for the ones which you're not sure what their behavior is, some are really straight forward. Or create a separate map which you have a clear and easy purpose, like a map where there are 2 bases and you spawn troops to the opposite team and order them to attack, and you would have features like upgrading the towers, the troops, etc...you could also make when the towers are destroyed to give bounty and/or give a message which notifies who destroyed the tower. Then from a simple idea you can expand it and make it more complex.
The whole point here isn't to delay you to make your current map, but rather learn the basics of the triggers so you actually understand them and understand what you're doing. Just don't jump into hard maps yet. Warseeker gave you a good solution, although you think it is chinese at moment:D
I don't really recommend reading a bunch of tutorials for you unless you have some doubts or looking for something very peculiar and specific, the practice of triggering will make you fly through the learning curve, just don't try to get lost :)

Thanks for the advice. I made a couple of really trash TD maps back in the day (mid 2000's i think), but I've forgotten everything I'd learned about triggers, since then. Might not be a bad idea to just start from scratch, and figure it all out again :)
 
Last edited by a moderator:
Level 28
Joined
Feb 18, 2014
Messages
3,581
Okay, Almost done (I hope). lastly the two set IsMoving = TRUE/FALSE what are these used for, and how do I set them up.

Secondly, the last part "Custom script: call RemoveLocation( udg_Point[2])" what is this?

Edit: It seems to be working without these last three parts. Though, maybe there is something I've missed.
They are just boolean, they don't do anything in this case, as for the RemoveLocation this latter is used to remove leaks in your triggers.
 
Last edited:
Level 2
Joined
Feb 19, 2019
Messages
12
They are just boolean, they don't do anything in this case, as for the RemoveLocation this latter is used to remove leaks in your triggers.

Leaks?
Also, would it be possible to change it from a specific unit to a unit type? So if any, say, Footman used invisibility movement would cancel the effect? If not, what about all units?
Also, thanks a lot for the help, I really appreciate it.
 
Level 39
Joined
Feb 27, 2007
Messages
5,038
Memory leaks cause your map to consume additional memory and lag over time:
Memory Leaks
Things That Leak

Much harder to make it work for any footman because each footman's current position would need to be stored in a point variable. Hashtables can be used for this purpose but I would not recommend adding that complexity here. Instead I would suggest you use the resource Warseeker linked in their first post: Is Unit Moving 2.1.0.0
 
Level 2
Joined
Feb 19, 2019
Messages
12
Memory leaks cause your map to consume additional memory and lag over time:
Memory Leaks
Things That Leak

Much harder to make it work for any footman because each footman's current position would need to be stored in a point variable. Hashtables can be used for this purpose but I would not recommend adding that complexity here. Instead I would suggest you use the resource Warseeker linked in their first post: Is Unit Moving 2.1.0.0

I don't think Memory leaks will become an issue if the map only takes circa 8-12 minutes to complete.

Is there not a way of telling the trigger only to store the position of a unit if the unit has used invisibility / is invisible?
 
Level 5
Joined
May 12, 2014
Messages
133
Shadowmeld is an object editor only thing. You dont need triggers to modify it. He asked for invisibility on command that breaks when moving/attacking. Just scroll through the OE and see if there is an option to allow during the day as well as night.

I'm not opposed to learning everything there is to triggers. But this seems like a very easy problem to solve. I can't confirm for myself that the day/night/both option does exist though.

EDIT: Can confirm the day/night option does NOT exist! A quick search on google works wonders lol.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,038
I don't think Memory leaks will become an issue if the map only takes circa 8-12 minutes to complete.
You're welcome to think anything you want, but length of map is not the metric that matters here. How much and how often you are leaking objects is much more important, aka leaks per second or leaks per trigger-firing. If you choose not to fix your leaks you may find your map suffers greatly or it might not matter, but if it does matter than you're gonna hate yourself for having to go back through your triggers and fix them all.
Is there not a way of telling the trigger only to store the position of a unit if the unit has used invisibility / is invisible?
Yes you can check if the unit has the invisibility buff and only track units once they gain the buff, but that still leaves you with N units you are tracking at any given time. It can be done with a dynamically indexed array: Visualize: Dynamic Indexing
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,898
You're welcome to think anything you want, but length of map is not the metric that matters here. How much and how often you are leaking objects is much more important, aka leaks per second or leaks per trigger-firing. If you choose not to fix your leaks you may find your map suffers greatly or it might not matter, but if it does matter than you're gonna hate yourself for having to go back through your triggers and fix them all.
Pyrogasm, while you're absolutely correct, the OP already mentioned he knew nothing about triggers, so telling him to remove leaks is ridiculous and not even a priority at the moment. It is the equivalent of starting to code in a new language which you have no idea how it works and you're already trying to do something advanced. He still needs to gain basic knowledge about triggers instead of putting a lot of info which isn't understandable at first.
 
Level 39
Joined
Feb 27, 2007
Messages
5,038
They specifically asked about a RemoveLocation and then inquired about memory leaks. I provided additional information and fact, and even explained how it doesn’t need to be done if they are willing to suffer the consequences of that choice.

Being aware of something makes it much easier to address later. Especially since the two main methods to address leaks are 1-2 line additions that a mapmaker can learn to do by rote and then just keep inserting those bits in triggers they make.
 
Level 2
Joined
Feb 19, 2019
Messages
12
You're welcome to think anything you want, but length of map is not the metric that matters here. How much and how often you are leaking objects is much more important, aka leaks per second or leaks per trigger-firing. If you choose not to fix your leaks you may find your map suffers greatly or it might not matter, but if it does matter than you're gonna hate yourself for having to go back through your triggers and fix them all.

Yes you can check if the unit has the invisibility buff and only track units once they gain the buff, but that still leaves you with N units you are tracking at any given time. It can be done with a dynamically indexed array: Visualize: Dynamic Indexing

I've tried to make something that I thought would work, but It doesn't work :( I've no clue as to why it doesn't. Any Assistance would be greatly appreciated.
Image of the trigger bellow (don't know how to post triggers, sorry), camouflage is just the sorceresses invisibility renamed.
CAMO-TRIGGER

EDIT: I've found a solution! It might not be pretty and i could probably be optimized a lot, but at least it works!
For anybody interested here it is CAMO-TRIGGER-V3
 
Last edited:
Status
Not open for further replies.
Top