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

[Trigger] Mounting trigger doesn't work...

Status
Not open for further replies.
Level 4
Joined
Jan 28, 2013
Messages
94
Hey!
So I tried to make a mounting trigger where a Hero could use a ability to mount, either by clicking on the mount or use a ability. But for some reason it doesn't seem to work for me.

Here's the triggers:
  • Mount
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Mount (Dummy)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Casting unit)) Equal to Player 1 (Red)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Casting unit)) Equal to Elite Knight
            • Then - Actions
              • Set MountPlayer1Knight = (Casting unit)
              • Set LocTempKnightPlayer1 = (Position of MountPlayer1Knight)
              • Game Cache - Store MountPlayer1Knight as MountHero of Player1Knight in Hero1Red
              • Game Cache - Save Hero1Red
              • Unit - Remove (Casting unit) from the game
              • Unit - Create 1 Elite Knight (mounted) for Player 1 (Red) at LocTempKnightPlayer1 facing Default building facing degrees
              • Game - Display to (All players) the text: Debug - Knight Saved
            • Else - Actions
              • Game - Display to (All players) the text: Debug - Unit Type f...
        • Else - Actions
          • Game - Display to (All players) the text: Debug - Player or a...
This trigger runs as it should. I have changed it a few times over though. I used to have a Replace unit action instead of Remove in the first part but I changed that. I also had leak removers but they're also gone now.

  • Dismount
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Mount (Dummy)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Casting unit)) Equal to Player 1 (Red)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Casting unit)) Equal to Elite Knight (mounted)
            • Then - Actions
              • Set MountPlayer1Knight = (Casting unit)
              • Set LocTempKnightPlayer1 = (Position of MountPlayer1Knight)
              • Unit - Remove MountPlayer1Knight from the game
              • Game Cache - Restore MountHero of Player1Knight from Hero1Red for Player 1 (Red) at LocTempKnightPlayer1 facing 0.00
              • Game - Display to (All players) the text: Debug - Knight rest...
            • Else - Actions
              • Game - Display to (All players) the text: Debug - Unit Type f...
        • Else - Actions
          • Game - Display to (All players) the text: Debug - Player or a...
This is the trigger which doesn't work. It removes the Knight (mounted) but it doesn't restore the Knight.

Note. These triggers used to be in the same trigger but I separated them when I tried to check the errors.
---

  • Mounting 2
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Mount Aimed 2 (Dummy)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Casting unit)) Equal to Player 1 (Red)
          • (Unit-type of (Target unit of ability being cast)) Equal to Rental Horse
          • (Unit-type of (Casting unit)) Equal to Elite Knight
        • Then - Actions
          • Set MountPlayer1Knight = (Casting unit)
          • Set LocTempKnightPlayer1 = (Position of MountPlayer1Knight)
          • Unit - Remove (Casting unit) from the game
          • Unit - Create 1 Elite Knight (mounted) for Player 1 (Red) at LocTempKnightPlayer1 facing Default building facing degrees
          • Unit - Remove (Target unit of ability being cast) from the game
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Casting unit)) Equal to Player 1 (Red)
          • (Unit-type of (Target unit of ability being cast)) Equal to Elite Knight (mounted)
          • (Unit-type of (Casting unit)) Equal to Elite Knight (mounted)
        • Then - Actions
          • Set MountPlayer1Knight = (Casting unit)
          • Set LocTempKnightPlayer1 = (Position of MountPlayer1Knight)
          • Unit - Remove (Casting unit) from the game
          • Unit - Create 1 Elite Knight for Player 1 (Red) at LocTempKnightPlayer1 facing Default building facing degrees
          • Unit - Remove (Target unit of ability being cast) from the game
        • Else - Actions
This trigger doesn't work like it should. I can change into the Knight (mounted) but not back to the Knight. Mostly because the spell doesn't work even though I used Targets Allowed: Self. Also I'm not that pleased with it making a new unit. I would like to keep level, abilities and items with the hero.

The custom spells are built on:
Mount - Thunder Clap
Mount Aimed - Holy Light (couldn't target anyone...)
Mount Aimed 2 - Fire Ball (couldn't target self)

Units:
Knight - Paladin (model Captain)
Knight mounted - Paladin (model Knight)

Also, I would like this trigger to be MUI and work online. But I'm not sure how to do that...
 
Level 4
Joined
Jan 28, 2013
Messages
94
Hide the unit, don't remove it.

I'd use a hashtable over Game Cache.
So Instead of Remove Unit - Knight I should hide it? How about the mounted version? Should I hide that too?

But what if I mount a move far away and then dismount? How should I do then? Should I teleport the character somehow?

I don't know how to use Hashtables... I'm also using JNGP which doesn't support GUI hastables... which means I have to use JASS... which I don't get at all.

Thanks for the quick answer anyhow!

Edit. Well once the unit is hidden I can still access it via the hero tab. That's not good. Also when I gain the mounted version i got two heroes... one mounted and one not mounted.
Edit 2. I stand corrected. The unit is visible on the hero tab but inaccessible.
 
Level 11
Joined
Feb 23, 2009
Messages
577
Hiding units works great.

Hide / Change Ownership to neutral (to hide portrait) and add invulnerable ability just in case lol.

And yes I would do the same with both (mounted and unmounted).

Either that or use the Replace Unit instead, and set the new unit's stats/exp to the old's, it will keep all the items.
 
Level 4
Joined
Jan 28, 2013
Messages
94
Hiding units works great.

Hide / Change Ownership to neutral (to hide portrait) and add invulnerable ability just in case lol.

And yes I would do the same with both (mounted and unmounted).

Either that or use the Replace Unit instead, and set the new unit's stats/exp to the old's, it will keep all the items.

That's a great advice! I'll test it, thanks.
 
Status
Not open for further replies.
Top