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

[JASS] Chess Moving System

Status
Not open for further replies.
Level 28
Joined
Aug 7, 2011
Messages
1,638
Ok... I've got a problem with the condition, the trigger is kinda simple. I've made the play board of the chess game to be with units, Square - White, Square - Black. Making the unit move to a square is easy, just click on it, but how to make it not move on squares which have other units in 90 range around them? Here's the trigger:
  • Events: A unit is issued an order targeting an object (The white or black square)
  • Conditions: (All units (Units within 90 of (Position of (Target unit of issued order)) matching ((Owner of Matching unit)) Equal to Player 1 Red are in (Rect centered at (Position of (Target unit of issued order)) with size (90, 90))
  • Actions: Unit - Set (Ordered unit) movement speed to 0.00
  • Wait 0.01 seconds
  • Unit - Order (Ordered unit) to Stop
  • Unit - Set (Ordered unit) movement speed to (Default movement speed of (Ordered unit))
Since there is no Unit Group Boolean Condition, I've tried with the Unit Group - Unit Group is empty, but then I realized it just won't work because it is empty... so I'm using the Unit Group is in Rect, creating a new rect... Please tell me if there's another way to make it. The condition must have the "Equal to True" so that it could work, and the only one with Unit Group options is in Boolean Comparison... I believe that this thing is possible because... where else can you use, Unit Group is in Rect???... I need a condition that is almost like the Unit is in range of Unit... the thing is that I need Unit Group is in range of Unit...

Please Help :vw_sad:
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
If squares size are 90x90 then loop towards the direction of the chess pieces every 90 distance picking units. If Number of units in the group is >0 then there's a unit in the path.
 
Level 28
Joined
Aug 7, 2011
Messages
1,638
The units in the group will always be more than 1 cuz the square itself is a unit... that's why the Empty Unit Group condition didn't work.

It works like that:
Lets say: Lich (the ordered unit) is in its white square (large as a Scout Tower), I order it to move to a random Square like lets say 6 squares forward or backward (doesn't matter), but on the square that the Lich was ordered to move there's a Footman (Player 1 Red). The Lich should stop moving as he stops moving when I order him to move 90 range around his own square but he just move to the footman. And he shouldn't. He shouldn't even move at his own square... just check the condition I will post my map for download to see it, but later cuz now I gotta go... will update soon.



BTW, can anyone tell me a condition that is just Unit Group equal to True or False... or something like that - I can get the trigger to work if only I could find a condition similar to this... cuz Unit Group is in Rect, Unit Group is dead or Unit Group is empty just don't work...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Lets think about a line of squares

A1
A2 <- There's a Lich Here
A3
A4
A5
A6 <- There's a Footman Here
A7
A8
A9 <- The Lich want's to move here
A10

You check every 90 range if there's a Unit... There won't be a unit in A3, A4 or A5... So, the lich stops moving at A5, or you display message "You can't move there because there's a unit in A6 square"
 
Level 28
Joined
Aug 7, 2011
Messages
1,638
You see the problem is that i made it a little bit different, some units blink to their square, some like a Dreadlord turn into a bat and fly to there, it's complicated and hmm... if I use what I think you're trying to say which is, the lich will move to the square next to the square of the targeted unit (like the Black Square or the White one), and I don't want him to move at all, if he's ordered a square on which there's another unit standing, I don't want him to move at all, like canceling his command. And with your trigger he will move to the square next to the targeted square (with a unit on it), if you know what I'm saying. And yes a condition Unit Group equal to True or False does seem strange, but if I choose the unit group in 90 range matching condition (owner of matching unit equal to, hmm doesn't matter player 1 red lets say) equal to True or False, it will be... a condition... it will be like - if the unit is in 90 range of the targeted square and is owned by player 1 red and that's equal to true, complete the actions. If the Unit Group doesn't match these conditions, don't do the actions... it does have a logic for such a condition to be real, but there is none... so if you know anything similar to that... please tell me, cuz Unit Group is in rect equal to True/False, doesn't help me... My unit group (the units owned by the enemy of the owner of ordered lich to click white square lets say) are in 90 range of the white targeted square is in 90,90 rect from position of targeted unit equal to true SHOULD work but it doesn't. So I need a condition that doesn't have the |unit group| is in rect. I need a condition without the "is in rect"... or something like Unit Group is in range of Unit (which is the targeted white square lets say)... but Unit is in range of Unit (which is exists) doesn't work for me, because it targets a specific unit, and I need a Unit Group matching condition 90 degrees from targeted unit (white square) and owned by player 1 or 2, since there are 2 players only (or I can just make it owner of enemy of owner of ordered unit (lich))... Soo,... yeah I guess you had a lot to read and I just... can't explain it shortly... If you want to check out the map, tell me how cuz I have no idea if I can even give you the map in here... can I? I've never actually written in the Hive Triggers & Scripts before... actually I've been downloading from this site models, skins and maps but I signed before a year or was it two? Nevermind... I strayed too much from the subject.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You check every 90 range if there's a Unit... There won't be a unit in A3, A4 or A5... So, the lich stops moving at A5, or you display message "You can't move there because there's a unit in A6 square"

What I told you is just to detect if there's something in the path. After that you can do whatever you want. And you can check any path type (2 Up, 1 Left, 1 Down, etc.)

If the unit Blinks to the square or turns to a bat, doesn't matter. Just don't check for obstacles in the path for this unit.

If you don't want it to move at all, well... DON'T MOVE IT AT ALL :) But for that you have to check if there's something in the path or in the selected square, and my method does that (tough there are some other ways to do it)

If squares size are 90x90 then loop towards the direction of the chess pieces every 90 distance picking units. If Number of units in the group is >0 then there's a unit in the path.
The red text means "There's something there = True" It's what you mean with "Unit Group = True" You just adjust WHAT unit group (Enemies, obstacles, allies, units, squares, etc.)

You don't need to find a unit group in a rect.. just UNIT in a rect, because one only unit is enough for what you want (move to kill or dont move). And you can use "Region contains unit".

Post your triggers as you did in the first post so we can give a look at them. It's easier for us to help that way.

Go to Advanced Message and use "Manage Attachments" There you can attach your map.
 
Level 28
Joined
Aug 7, 2011
Messages
1,638
EDITED (last written message, check down for results) Hmmm... you must be right, but you're using the Unit is range condition right? No, the Number of units in 90 range of targeted point, yes... Btw I upgraded my way by making an opposite of my idea, Conditions:

  • ((Units within 90.00 of (Position of (Target unit of issued order)) matching ((Unit-type of (Matching Unit)) Equal to Square - Black/White) is empty equal to False
That condition makes the lich not move on squares without units on them and move on squares which have no units on them. I need to change the trigger (yes I tried all, false, not equal to...) to its opposite. Because checking every square might not always be correct, because I'm not sure how exactly long is the range of a square, can't check it. I need like... lets say if the square is 120, 90 does the job fine, because units always stand in the middle of the square (did that with some other triggers)... and I don't want a ... the Horse can jump over units, and a Pawn can't. I don't care - that map isn't all rules, you just have to play fair soo... I won't be needing the "Pawn can't move because there's a unit in front of it". I just want the unit to stop if it has targeted the square under a unit and not the unit, because the when targeting an enemy unit (which is neutral, because you are allies) you attack it (with other triggers I made this) and when targeting the square under the unit - it happens quite often (because units have no selection circle displayed, I removed it so that they lose their hit points bar). And the square targeting area is bigger so I just don't want any, fails lets call it. It just wastes time to go to the square (player control is lost while moving or attacking) and return... and I don't like it. For the rules I may think later, I may not even make them because it will take a lot of time - each unit-type requires its own command and... I've got many races and etc. So just if you can post your condition with trigger order in advanced and I'll check it out, cuz I'm not 100% sure which conditions you use. I do have an idea but... anyway, if you can turn my condition upside-down, do its opposite, I'd be grateful.


Ooo, and btw I can't check the squares because I do not know which square exactly was targeted and all the squares between the Lich (ordered unit) and the White Square (target point of issued order)... just... post your condition... if you have time of course.



Diversion:
Btw, nice map (Gsu'h Will RPG) :thumbs_up:


EDIT
: Ha - ha - ha! I did it, man you're great +rep! Well I combined yours and my idea and I did it! It was so simple, I wonder how I could not see it! I guess checking more War3 Editor sites is better than being a self-taught...
 
Level 28
Joined
Aug 7, 2011
Messages
1,638
... I'm not a noob in triggers I've made it good... like you don't know - sometimes you just can't find some actions/conditions you need... and it doesn't lag... please, the thing that I signed in in 2011 and I have 1 rep, doesn't mean I can't make triggers or terraining... actually I'm pretty good at terraining, OK maybe not that good in Custom Scripts, but I CAN handle triggers. Don't insult me, reputation means nothing, skills do. I'm a self-taught, since I started using World Editor at early age and I never entered any sites. ... I was in the Hive from 5 or was it 6 years... just never joined - too lazy. Don't insult me, I've never had leaks... Anyway, thanks for helping me :vw_sleep:


Ooo, and btw the map does lag for 1 second after 10 seconds of the game, because I imported 2 musics...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Dude... cool off. I'm not insulting, sorry if I made you feel that way. I'm just asking you to post the triggers continue helping you improving your thing. I never mentiones Join Date, Posts or Rep xD I didn't even notice it untill now :p

  • ((Units within 90.00 of (Position of (Target unit of issued order)) matching ((Unit-type of (Matching Unit)) Equal to Square - Black/White) is empty equal to False
This leaks

  • (All units (Units within 90 of (Position of (Target unit of issued order)) matching ((Owner of Matching unit)) Equal to Player 1 Red are in (Rect centered at (Position of (Target unit of issued order)) with size (90, 90))
This leaks.
 
Level 28
Joined
Aug 7, 2011
Messages
1,638
I don't use these, I was just too desperate, trying to find a way to handle the picking, but now I have it and the other triggers are simple and it will kinda.. take a lot of time to post them so... I won't be doing it, sorry :D and I haven't used any rules like .. a horse can move through units and a pawn can't... I'm making this map to play with friends nothing serious... so we don't need rules just the turns and different attacks, like lich sometimes frost novas a unit and blinks to it, says some random sound... stuff like this, so the triggers are pretty simple - they do not require any... ok, maybe some JASS but no stuff that leak, I do now which things leak but the map is just so small that one leak trigger won't slow it at all... it doesn't even have terraining, just the squares and stuff... soo.. thanks for the help but I need none anymore :)

If you really insist on seeing these triggers tell me but... why? I will post some of them if you so much desire...




Actually, when I started to think of it, there is this thing, since you're better in triggers than me, still I am a terrainer - check this out:

  • Events - Player - Player 1 (Red) Selects a unit
  • Conditions - (Number of units in (Units currently selected by Player 1 (Red))) Greater than 1
  • Actions - Selection - Clear selection for Player 1 (Red)
It takes 1 second to clear the selection, any way I can reduce this second to 0? Cuz you can still make the units move if you're fast enough...
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
"A lot of time"?... Right Click -> Copy as Text -> Paste here between
  • tags
  • The only way to improve triggering speed is removing Bj's (Which requires a bit of JASS knowledge) and optimize every trigger in your map, so the general triggering is smooth and faster... But still shouldn't be 1 second.
  • [Trigger]
  • (Number of units in (Units currently selected by Player 1 (Red))) Greater than 1
This leaks. The game creates the Unit Group "(Units currently selected by Player 1 (Red)" just for one use, and it remains there as unusefull data that lags and reduces games performance.

Whenever you use a Unit Group do:
  • Set UnitGroupName = (Units currently selected by Player 1 (Red))
  • If (Number of units in UnitGroupName Greater than 1 then
  • Selection - Clear selection for Player 1 (Red)
  • Custom script: call DestroyGroup(udg_UnitGroupName)
As you can see, you declare the unit group in a variable, you do your thing with the group, and destroy it after using. It removes the leak.
 
Level 28
Joined
Aug 7, 2011
Messages
1,638
ok.. about the "a lot of time", there are many triggers... and I have no problems with them so there's no point posting them..

and about the leak, it does not leak - it normally does but not in such a weak map... don't worry about leaks, I just want to make it deselect them in 0 seconds like, making the player's maximum selection to 1 - if there's a way. And leaks aren't a problem to me, if they become too many maybe I will spare some time to make them with variables... just, when talking with me, forget about leaks :D just tell me if there's a way to make the max selection of a player to 1?



Ok... if you so much insist on seeing some triggers, here you go:
  • Preparing The List
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Units1U[1] = Pawn (Undead)
      • Set Units1U[2] = Rook (Undead)
      • Set Units1U[3] = Knight (Undead)
      • Set Units1U[4] = Officer (Undead)
      • Set Units1U[5] = Queen (Undead)
      • Set Units1O[1] = Pawn (Orc)
      • Set Units1O[2] = Rook (Orc)
      • Set Units1O[3] = Knight (Orc)
      • Set Units1O[4] = Officer (Orc)
      • Set Units1O[5] = Queen (Orc)
      • Set Units1NE[1] = Pawn (Night Elf)
      • Set Units1NE[2] = Rook (Night Elf)
      • Set Units1NE[3] = Knight (Night Elf)
      • Set Units1NE[4] = Officer (Night Elf)
      • Set Units1NE[5] = Queen (Night Elf)
      • Set Units1H[1] = Pawn (Human)
      • Set Units1H[2] = Rook (Human)
      • Set Units1H[3] = Knight (Human)
      • Set Units1H[4] = Officer (Human)
      • Set Units1H[5] = Queen (Human)
      • Set Units2U[1] = Pawn (Undead)
      • Set Units2U[2] = Rook (Undead)
      • Set Units2U[3] = Knight (Undead)
      • Set Units2U[4] = Officer (Undead)
      • Set Units2U[5] = Queen (Undead)
      • Set Units2O[1] = Pawn (Orc)
      • Set Units2O[2] = Rook (Orc)
      • Set Units2O[3] = Knight (Orc)
      • Set Units2O[4] = Officer (Orc)
      • Set Units2O[5] = Queen (Orc)
      • Set Units2NE[1] = Pawn (Night Elf)
      • Set Units2NE[2] = Rook (Night Elf)
      • Set Units2NE[3] = Knight (Night Elf)
      • Set Units2NE[4] = Officer (Night Elf)
      • Set Units2NE[5] = Queen (Night Elf)
      • Set Units2H[1] = Pawn (Human)
      • Set Units2H[2] = Rook (Human)
      • Set Units2H[3] = Knight (Human)
      • Set Units2H[4] = Officer (Human)
      • Set Units2H[5] = Queen (Human)
  • ChoosingTheUnit1U
    • Events
      • Unit - A unit enters Change Pawn 2 <gen>
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Unit-type of (Entering unit)) Equal to Pawn (Undead)
          • (Owner of (Entering unit)) Equal to Player 1 (Red)
    • Actions
      • Set EnteringPawn1 = (Entering unit)
      • Dialog - Clear Dialog1U
      • Dialog - Change the title of Dialog1U to Choose:
      • Dialog - Create a dialog button for Dialog1U labelled Pawn
      • Set DialogButtons1U[1] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog1U labelled Rook
      • Set DialogButtons1U[2] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog1U labelled Knight
      • Set DialogButtons1U[3] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog1U labelled Officer
      • Set DialogButtons1U[4] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog1U labelled Queen
      • Set DialogButtons1U[5] = (Last created dialog Button)
      • Player Group - Pick every player in (Player group((Owner of (Entering unit)))) and do (Actions)
        • Loop - Actions
          • Dialog - Show Dialog1U for (Picked player)
  • Choosing1U
    • Events
      • Dialog - A dialog button is clicked for Dialog1U
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to DialogButtons1U[(Integer A)]
            • Then - Actions
              • Unit - Create 1 Units1U[(Integer A)] for (Owner of EnteringPawn1) at (Position of EnteringPawn1) facing 270.00 degrees
              • Unit - Change color of (Last created unit) to Purple
              • Unit - Remove EnteringPawn1 from the game
            • Else - Actions
  • Face your angle 1
    • Events
      • Player - Player 1 (Red) types a chat message containing -angle as An exact match
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in Revealed <gen> owned by Player 1 (Red)) and do (Actions)
        • Loop - Actions
          • Unit - Make (Picked unit) face 270.00 over 0.60 seconds
      • Unit Group - Pick every unit in (Units in Revealed <gen> owned by Player 2 (Blue)) and do (Actions)
        • Loop - Actions
          • Unit - Make (Picked unit) face 90.00 over 0.60 seconds
  • Distance to Target
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • Camera - Set Player 1 (Red)'s camera Distance to target to 2300.00 over 0.00 seconds
      • Camera - Set Player 2 (Blue)'s camera Distance to target to 2300.00 over 0.00 seconds
  • Revealed
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across Revealed <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 2 (Blue) emitting Visibility across Revealed <gen>
      • Game - Disable pre-selection functionality (Disable pre-selection circles, life bars, and object info)
      • Game - Enable selection and deselection functionality (Disable selection circles)
      • Unit - Add Locust to Pawn (Orc) 0210 <gen>
      • Unit - Add Locust to Pawn (Human) 0206 <gen>
      • Unit - Add Locust to Pawn (Night Elf) 0208 <gen>
      • Unit - Add Locust to Pawn (Undead) 0209 <gen>
      • Player - Make Player 1 (Red) treat Player 2 (Blue) as an Neutral
      • Player - Make Player 2 (Blue) treat Player 1 (Red) as an Neutral
      • Camera - Lock camera target for Player 1 (Red) to Race 0038 <gen>, offset by (0.00, 0.00) using The unit's rotation
      • Camera - Lock camera target for Player 2 (Blue) to Race 0001 <gen>, offset by (0.00, 0.00) using Default rotation
      • Camera - Set Player 1 (Red)'s camera Distance to target to 2300.00 over 0.00 seconds
      • Camera - Set Player 2 (Blue)'s camera Distance to target to 2300.00 over 0.00 seconds
      • Unit - Change color of Race 0001 <gen> to Black
      • Unit - Change color of Race 0038 <gen> to Gray
      • Animation - Change Race 0001 <gen>'s vertex coloring to (0.00%, 0.00%, 0.00%) with 0.00% transparency
      • Unit - Change color of Circle of Power 0034 <gen> to Red
      • Unit - Change color of Circle of Power 0035 <gen> to Blue
      • Unit - Change color of Circle of Power 0036 <gen> to Green
      • Unit - Change color of Circle of Power 0037 <gen> to Purple
  • Vampire On The Move
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Unit-type of (Ordered unit)) Equal to King (Undead)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Target unit of issued order)) Equal to Square - White
          • (Unit-type of (Target unit of issued order)) Equal to Square - Black
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units within 90.00 of (Position of (Target unit of issued order)) matching (((Owner of (Matching unit)) Not equal to Neutral Passive) and ((Owner of (Matching unit)) Not equal to Player 12 (Brown))))) Greater than or equal to 1
        • Then - Actions
          • Cinematic - Disable user control for (All players)
          • Unit - Set (Ordered unit) movement speed to 0.00
          • Unit - Order (Ordered unit) to Stop
          • Wait 0.01 seconds
          • Unit - Order (Ordered unit) to Stop
          • Unit - Set (Ordered unit) movement speed to (Default movement speed of (Ordered unit))
          • Cinematic - Enable user control for (All players)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Number of units in (Units within 90.00 of (Position of (Target unit of issued order)) matching ((Owner of (Matching unit)) Equal to Player 1 (Red)))) Equal to 0
              • (Number of units in (Units within 90.00 of (Position of (Target unit of issued order)) matching ((Owner of (Matching unit)) Equal to Player 2 (Blue)))) Equal to 0
        • Then - Actions
          • Cinematic - Disable user control for (All players)
          • Set VampireOnTheMove = (Ordered unit)
          • Set TargetUnitofVampireO = (Target unit of issued order)
          • Unit - Set VampireOnTheMove movement speed to 0.00
          • Wait 0.01 seconds
          • Unit - Order VampireOnTheMove to Stop
          • Unit - Set VampireOnTheMove movement speed to (Default movement speed of VampireOnTheMove)
          • Unit - Add Bat Form to VampireOnTheMove
          • Unit - Order VampireOnTheMove to Special Medivh - Raven Form
          • Animation - Play VampireOnTheMove's spell third animation
          • Special Effect - Create a special effect attached to the origin of VampireOnTheMove using war3mapImported\EvilFog.mdx
          • Unit - Order VampireOnTheMove to Move To (Position of (Target unit of issued order))
          • Wait until ((VampireOnTheMove is in (Units within 45.00 of (Position of TargetUnitofVampireO))) Equal to True), checking every 0.10 seconds
          • Unit - Order VampireOnTheMove to Special Medivh - Human Form
          • Unit - Remove Bat Form from VampireOnTheMove
          • Animation - Play VampireOnTheMove's spell slam animation
          • Special Effect - Create a special effect attached to the origin of VampireOnTheMove using war3mapImported\EvilFog.mdx
          • Wait 0.20 seconds
          • Cinematic - Enable user control for (All players)
          • Wait 1.65 seconds
          • Animation - Reset VampireOnTheMove's animation
          • Unit - Make VampireAttacking face 270.00 over 0.60 seconds
        • Else - Actions

DON'T TELL ME ABOUT THE LEAKS, I KNOW THAT IT SHOULD NORMALLY LEAK BUT IT DOES NOT! So don't worry about leaks. Just forget about them.


Yes, if this was an RPG, or a bigger map, many triggers, units, leaking would be a problem. But now, it isn't, the map is tiny size, not many triggers and it does not leak...
 
Last edited:
Status
Not open for further replies.
Top