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

Question about: Unit - Move unit and face angle (instantly)

Status
Not open for further replies.
Level 8
Joined
Nov 27, 2011
Messages
29
Hello all,

Currently I'm working on map to create a chess game.
I got a nice idea for the movement. I use the [Unit - Move unit and face angle (instantly)] trigger command and move a unit (which are the chess pieces) 256 points to move 1 space up, see also the image below.

upload_2018-9-16_18-17-33.png


I've got this working in all 4 directions. The movement is just a dummy ability, which does nothing by itself. The trigger positions it 1 space further.

I give these 4 movement abilities to the units and to make sure they cannot move by them self, I made them buildings (with a pathing map of the blacksmith) and set their moment speed to 0. I tested with another unit, but it cannot walk through the chess piece. I added part of the object editor below.

upload_2018-9-16_18-23-40.png


The only thing that is not working is when I click the movement button and it moves to a space where another chess piece (also a building) is standing, then 2 chess pieces are on the same space.

For those of you who did not fully understand the problem, I added the map. If you open it, you can see how the movement system works.
 

Attachments

  • Chess game - movement.w3x
    42 KB · Views: 46
Level 21
Joined
Aug 29, 2012
Messages
865
I reworked the code a bit, find it attached.

What I did is a simple integer check that looks at the number of units on the selected location in a small radius, and trigger an error message if someone's there.

As a side note, you may want to store your points into variables and delete them at the end of your trigger to avoid memory leaks.
 

Attachments

  • Chess game - Edit.w3x
    43.4 KB · Views: 47
Level 8
Joined
Nov 27, 2011
Messages
29
With your help I got a lot further with the map. I'm quite happy with the movement system now. There is only one thing that I do not seem to solve.

When a unit is killed, the trigger still thinks that there is a unit on that space, which means that another unit cannot enter the space.

I think it can be fixed if the temporary region (which is created during the movement) is set to 0, but I don't know how to call the temporary region.

Also, another question about the trigger you added:

How do I remove the region that is created when a unit moves? I found a way to clear Temp_Regions, but those are variables and this one seems different. I could be wrong here, so don't hesitate to correct me.

upload_2018-9-17_21-5-26.png
 

Attachments

  • Chess game v1.2.w3x
    51.3 KB · Views: 36
Level 21
Joined
Aug 29, 2012
Messages
865
Wow sorry I'm an idiot, that's definitely an oversight, find the new version attached.

I corrected it and tested, dead units shouldn't count now. I just added a condition that checks if the unit is alive or not, voilà.

Also, I added a point variable in order to clear the location leak. I don't know about the region one, but at least this one won't bother you now.

And that looks a lot like the WoW Karazhan encounter :thumbs_up:
 

Attachments

  • Chess game Edit.w3x
    52.6 KB · Views: 36
Level 39
Joined
Feb 27, 2007
Messages
5,067
  • Don't use "begins casting", use "starts the effect". The first one fires before mana cost and cooldown (in this case not important) and can be spammed by pressing the hotkey and then immediately pressing Stop, repeatedly. Use Begins... when you want to catch a spell cast before it goes off.
  • All of the triggers in your "Region" folder are pointless/useless because your units can't move on their own and when you do move them with a trigger its in increments of 256, which is exactly the length of 2 tiles. They will never not be moved to the middle of the region anyway.
  • If you want your units to be able to turn to face the things they are attacking, you can use this tutorial: Tower Turning Tutorial
  • Because your units are structures, when one is damaged you will start to hear the 'burning' sound effect. You can remove this by not making them buildings (will remove the pathing map you have set, but that doesn't matter if the units can't move themselves anyway) or by doing this: Remove Burning sound from buildings?
  • There's a "Display timed message to <player>" rather than "to <force>" option. Use that. Dynamically created forces leak as well.
Now for the movement bit. Don't use a temporary region like that. A group in range check will work just fine because that mostly covers the same area, and since units are moved only to the middle of the square anyway it will never miss anything. You also can do "Point with offset" rather than "point with polar offset". I would do this:
  • Actions
    • Set Point1 = Position of (Triggering Unit)
    • Set Point2 = Point1 offset by (0.00, 256.00) //this one goes up; need to change it for each direction but it's an (x,y) offset
    • Custom script: set bj_wantDestroyGroup = true
    • Set SpaceCount = Number of units in (Units within 128.00 of Point2 matching ((Matching Unit) is alive equal to true))
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • SpaceCount greater than 0
      • Then - Actions
        • Game - Display to (Owner of (Triggering unit)) for 5.00 seconds the text: You cannot move thi...
      • Else - Actions
        • Unit - Move (Triggering Unit) to Point2
    • Custom script: call RemoveLocation(udg_Point1)
    • Custom script: call RemoveLocation(udg_Point2)
 
Level 8
Joined
Nov 27, 2011
Messages
29
Maybe one of you could help me again with something. It might be the toughest question from my side thus far.

The white chess pieces are now working great. There are no issues left as far as I know (maybe they will return in a later stage).

The black chess pieces are not moving, because they can only move via abilities (move up, down, left & right).

I was wondering if any of you might know if there's a way that the computer will move his pieces. Especially when the unit itself or a neighbor unit is attacked by a range unit.
 

Attachments

  • Chess game.w3x
    52.7 KB · Views: 33
Level 39
Joined
Feb 27, 2007
Messages
5,067
I forgot to mention that you can also technically move your pieces out of the play area, since there's no check for that. I would put one big region that covers the whole board and then change the if-block
  • If (All conditions are true) then do (Then actions) else do (Else actions)
    • If - Conditions
      • SpaceCount equal to 0
      • (Point2 is in PlayRegion <gen>) equal to true
    • Then - Actions
      • Unit - Move (Triggering Unit) to Point2
    • Else - Actions
      • Game - Display to (Owner of (Triggering unit)) for 5.00 seconds the text: You cannot move thi...
Unfortunately, your only (real) option is to trigger the AI yourself. You could do this by ordering the units to use spells to move via triggers or building your own AI script with the AI editor, though the latter would be weird since it's designed to make Melee AIs. If you actually put a computer controller into that slot you can get it to automatically use a select few spells when certain conditions are met, but this likely isn't enough variety to build out a set of commands to move the units. Any custom spell will inherit the cast behavior of the spell it's based on, so you can change all of the art/effects/whatever still.
 
Status
Not open for further replies.
Top