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

[vJASS] Making a unit unselectable, with no pathing, yet targetable.

Status
Not open for further replies.
Hello guys.

I am making a custom missile system, where the missiles are targetable for some units (think starcrafts point defence guns). To set the missile dummys orientation, i use SetUnitLookAt in combination with SetUnitPosition (the latter required for it to work), which means the dummies must ignore pathing. They must also be unselectable.

I know that adding locust to the unit and then morphing it into itself makes it unselectable but targetable, however, it will be pathable, which screws up the movement. I also heard that immediately removing the morph ability afterwards makes it unpathable, but that only gives the effect of regular locust for me. I can also note that SetUnitPathing does not work after adding locust in this case, for some reason.

Any ideas?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I don't know why you what effect hover has but NONE also removes collision.

Anyway for the unselectable.
I suppose that you use a dummy unit and add a special effect over that unit. (maybe 2 or 3)
In that case, you can just de-select the unit when it gets selected.

  • Deselect wrong units.
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - Player 3 (Teal) Selects a unit
      • Player - Player 4 (Purple) Selects a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Selection - Remove (Triggering unit) from selection for (Triggering player)
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Make the unit neutral?
I bet that you somewhere save who "made" the missile and you can use that as a reference for the player, you can also save the player ofcourse.

If you make it neutral, you can select the missile so you can display its info but you cannot control it. Making it targetable is no problem because it is still a normal unit.
 
Well, the thing is,the dummy must belong to the player owning it so that enemy anti-ballistic turrets can auto-target it. Also, like you said, making it neutral does not make it unselectable, and this particular dummy has a very large bounds radius (which is also neccesary for the SetUnitLookAt method of setting orientation), so it is quite easy to select. What i am looking for is a solution to how i can disable the pathing after applying/morphing away locust.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
So you still want to use flying?
Hmm...
Well I think that there is collision that is bound to the model.
At least if I remove a unit's model it has no collision any more.
Maybe you attach collision to a unit's model and you just have to remove that from your dummy model.

I know of one way to completely remove a unit's collision but then it is a building.
I don't know what happens when you set a building's position but I cannot test that atm.
I think that there is a good chance that it will be placed on exacly that location instead of using the pathing grid.
If the pathing map is set to an empty file or a no-collision file, it has completely removed collision.

For selection... I do not know how you can do that.
 
Maker suggested me to use Movement Type - None as the movement type for dummies and set it's base as 1(for SetUnitX/Y, 0 makes SetUnitX/Y useless), then use this script:
JASS:
if UnitAddAbility(someUnit, 'Amrf') and UnitRemoveAbility(someUnit, 'Amrf') then
endif

To adjust it's height.

But I guess the real problem is you use SetUnitPosition. SetUnitPosition recognizes pathing such as cliffs. Use SetUnitX/Y
 
I can't use SetUnitX/Y. The reason for this is the way SetUnitLookAt works.

Basically, there is a trick that allows you to set the orientation of a dummy to any angle. This is to lock its body part facing to itself, with an offset corresponding to the vector you want it to point towards. This is how it looks:
JASS:
call SetUnitLookAt(u, "Bone_Chest", u, xdir * 1000, ydir * 1000, zdir * 1000)
There are, however, two things required for this to work - the unit must be moved using SetUnitPosition afterwards, and the bounds radius of the model must encircle the map center. Credits to this discovery goes to N-a-z-g-u-l. Moving the unit using SetUnitX/Y does not update the orientation of the missile.

I will try with setting movement type to none though and see how that goes, though from experience i know that units with no movement speed cannot use SetUnitPosition.

EDIT: Perhaps this is a bit far-fetched, but maybe it is possible to first set its position using GetUnitPosition, and then afterwards set it again using SetUnitX/Y? Sure, it will be slower, but it might work. Still looking for better answers though.
 
These are the methods i have tried (roughly):

JASS:
//METHOD 1
set u = CreateUnit('Hfoo', Player(owner), x, y, 0) //Create the unit as a footman, as you cannot morph a unit into itself
call UnitAddAbility(u, 'Aloc') //Add locust
call UnitAddAbility(u, 'mrph') //Morph into a dummy
call UnitAddAbility(u, 'Amrf') //Add and remove crow form
call UnitRemoveAbility(u, 'Amrf')
call SetUnitPathing(u, false) //Remove pathing

Result: the unit becomes unselectable, but still pathable. Somehow SetUnitPathing has no effect.

JASS:
//METHOD 2
set u = CreateUnit('dumm', Player(owner), x, y, 0) //Create the unit as a dummy.
call UnitAddAbility(u, 'Aloc') //Add locust
call ShowUnit(u, false) //Hide unit before removing locust
call UnitRemoveAbility(u, 'Aloc') //Remove locust
call ShowUnit(u, true)
call UnitAddAbility(u, 'Amrf') //Add and remove crow form
call UnitRemoveAbility(u, 'Amrf')
call SetUnitPathing(u, false) //Remove pathing

Result: the opposite of what i want - the unit becomes selectable, but unpathable and untargetable.

I also tried method 1 except with removing the morph ability after i add it - i have heard this removes pathing again, but it actually just has the effect of regular locust.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
So you only need the pathing now?

As mentioned before, you could use NONE or fly as movement type
The system that I use sometimes has foot as movement type and disables the collision in the triggers.
It also uses the crow form hack to make it fly.
It also uses "Move (unit) instantly to (point), facing (real) degrees"

I forgot where I got it from or who made it so I cannot give you the link.
(He also used his own or a standard dummy model.)
 
Like i said before, i need the unit to be:
  • Unselectable
  • Targetable
  • Ignoring pathing

I tried using "none" as pathing type - it improves the situation slightly, but the unit still jitters in a way it doesn't do when only locust is used. If you read my code you see that i am already using crow form and the jass equivalent of moving a unit instantly. I also try to disable the collision using triggers (SetUnitPathing), but for some reason, it doesn't work.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
"SetUnitPathing()" is not very usefull as it does not do all the work.
On the other hand, it does something at least.

To know what it does requires a bit of knowledge of how pathing is done in WC3.
When a unit (any object) is moved to a location (movement included) it will check that place if this object can stand there without collision problems.
When you use "SetUnitPathing()" to turn its collsion off, you remove that check.
However, when a different unit wants to come near that "no-collision-object", it will still see its pathing.
So that "no-collision-object" can walk through other objects but not the other way around.
It also does not change anything to pathing of cliffs and stuff.

That is as far as I know.

Like i said before, i need the unit to be:
  • Unselectable
  • Targetable
  • Ignoring pathing
The reason i do so is because it makes the unit targetable yet unselectable.
So you only need the pathing now.
 
Status
Not open for further replies.
Top