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

Chess/checkers, Moving Unit via Spell?

Status
Not open for further replies.
Level 2
Joined
May 11, 2010
Messages
7
So I want to move units when they click on abilities (e.g. "Move East), for a chess/checkers like feel. The unit would be centered on a "random unit within range of the offset point". There are circles of power all over the checker/chessboard 12x18 map which the units attach themselves to. This basically, makes the ending position of the units more uniformed.

I made sure that it would only work if they were facing the right way, for example, needing to face 0 degrees to go east. And that they could not go into impassable terrain. It was working out finely until I came to needing to detect allied/enemy units in spaces.

Essentially, the problem is that units move into spaces that already contain other units. As a quick fix, I tried to create a dummy unit in the space, which would then block a units movement into an occupied space. But it doesn't work.

Thanks in advance!

  • Move East
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Move East
    • Actions
      • Set tempPt = (Position of (Triggering unit))
      • Set temPt2 = (tempPt offset by 275.00 towards 0.00 degrees)
      • Set tempGp1 = (Units within 25.00 of temPt2)
      • Set tempPt3 = (Position of (Random unit from tempGp1))
      • Set tempR1 = (Facing of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units within 50.00 of temPt2)) Greater than 1
        • Then - Actions
          • Unit - Create 1 dummy for (Owner of (Triggering unit)) at temPt2 facing Default building facing degrees
          • Set tempUni1 = (Last created unit)
        • Else - Actions
          • Do nothing
      • Set tempGp2 = (Units within 25.00 of temPt2)
      • If (((Terrain pathing at temPt2 of type Walkability is off) Equal to True) or (((tempUni1 is in tempGp2) Equal to True) or (tempR1 Not equal to 0.00))) then do (Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 1.00)) else do (Unit - Move (Triggering unit) instantly to tempPt3)
      • Custom script: call RemoveLocation(udg_tempPt)
      • Custom script: call RemoveLocation(udg_temPt2)
      • Custom script: call RemoveLocation(udg_tempPt3)
      • Custom script: call DestroyGroup(udg_tempGp1)
      • Custom script: call DestroyGroup(udg_tempGp2)
      • Custom script: call DestroyGroup(udg_tempGp3)
      • Custom script: call DestroyGroup(udg_tempGp4)
      • Custom script: call DestroyGroup(udg_tempGp5)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Use a Boolean check to see if there is a unit in the spot.

Also remove do nothing action it is completely useless and inefficient.
Anything used twice or more should be stored into a variable and the variable should be used. Example: store triggering unit into a tempUnit variable.
Also get rid of the destroy groups for the groups that aren't being used.
 
Level 2
Joined
May 11, 2010
Messages
7
Thanks for the comments.
I decided to make it a bit simpler, and I got it to work for units moving east.
  • Move East
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Move East
    • Actions
      • Wait 0.50 seconds
      • Set tempUni1 = (Target unit of ability being cast)
      • Set tempPt = (Position of tempUni1)
      • Set tempPt2 = ((Position of (Triggering unit)) offset by (260.00, 0.00))
      • Set tempUniG1 = (Units within 50.00 of tempPt2)
      • Set tempR1 = (Facing of (Triggering unit))
      • If (((Terrain pathing at tempPt of type Walkability is off) Equal to True) or ((tempR1 Not equal to 0.00) or ((tempUni1 is in tempUniG1) Equal to False))) then do (Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 1.00)) else do (Unit - Move (Triggering unit) instantly to tempPt)
      • Custom script: call RemoveLocation(udg_tempPt)
      • Custom script: call RemoveLocation(udg_tempPt2)
      • Custom script: call DestroyGroup(udg_tempUniG1)
So a unit, by selecting on markers on the ground, can only move to the east. I then copied the trigger and changed the offset values for Move South and Move West. But it keeps refunding the mana cost of the spell, which means the trigger is not getting through this part. Any idea what the problem is?

  • If (((Terrain pathing at tempPt of type Walkability is off) Equal to True) or ((tempR1 Not equal to 270.00) or ((tempUni1 is in tempUniG1) Equal to False))) then do (Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 1.00)) else do (Unit - Move (Triggering unit) instantly to tempPt)
  • Move South
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Move South
    • Actions
      • Wait 0.50 seconds
      • Set tempUni1 = (Target unit of ability being cast)
      • Set tempPt = (Position of tempUni1)
      • Set tempPt2 = ((Position of (Triggering unit)) offset by (0.00, -260.00))
      • Set tempUniG1 = (Units within 50.00 of tempPt2)
      • Set tempR1 = (Facing of (Triggering unit))
      • If (((Terrain pathing at tempPt of type Walkability is off) Equal to True) or ((tempR1 Not equal to 270.00) or ((tempUni1 is in tempUniG1) Equal to False))) then do (Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 1.00)) else do (Unit - Move (Triggering unit) instantly to tempPt)
      • Custom script: call RemoveLocation(udg_tempPt)
      • Custom script: call RemoveLocation(udg_tempPt2)
      • Custom script: call DestroyGroup(udg_tempUniG1)
 
Level 2
Joined
May 11, 2010
Messages
7
Still having troubles with this one :S

What I am basically doing is checking that the unit is facing a certain angle to the N, S, E or W, and that the position of the spell is to the N, S, E, or W. If both conditions are met, the unit moves to the new position.

It works perfectly for this trigger
  • Move East Copy
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Move East
    • Actions
      • Wait 0.50 seconds
      • Set EASTuni1 = (Triggering unit)
      • Set EASTuni2 = (Target unit of ability being cast)
      • Set EASTpt1 = (Position of EASTuni2)
      • Set EASTpt2 = ((Position of EASTuni1) offset by (260.00, 0.00))
      • Set EASTunig1 = (Units within 50.00 of EASTpt2)
      • Set EASTr1 = (Facing of EASTuni1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EASTr1 Not equal to 0.00
        • Then - Actions
          • Unit - Set mana of EASTuni1 to ((Mana of EASTuni1) + 1.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (EASTuni2 is in EASTunig1) Equal to False
            • Then - Actions
              • Unit - Set mana of EASTuni1 to ((Mana of EASTuni1) + 1.00)
            • Else - Actions
              • Unit - Move EASTuni1 instantly to EASTpt1
      • Custom script: call RemoveLocation(udg_EASTpt1)
      • Custom script: call RemoveLocation(udg_EASTpt2)
      • Custom script: call DestroyGroup(udg_EASTunig1)
But if I just replace the values for the "Move West" trigger, nothing happens. It must be a value, but it looks alright to me... I made new variables (not sure if that would help), made sure that they were different ability strings (storm bolt and deathcoil)

  • Move West Copy
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Move West
    • Actions
      • Wait 0.50 seconds
      • Set WESTuni1 = (Triggering unit)
      • Set WESTuni2 = (Target unit of ability being cast)
      • Set WESTpt1 = (Position of WESTuni2)
      • Set WESTpt2 = ((Position of WESTuni1) offset by (-260.00, 0.00)) [B] <--- changed this[/B]
      • Set WESTunig1 = (Units within 50.00 of WESTpt2)
      • Set WESTr1 = (Facing of WESTuni1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WESTr1 Not equal to 180.00 [B]<--- and changed thi[/B]s
        • Then - Actions
          • Unit - Set mana of WESTuni1 to ((Mana of WESTuni1) + 1.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (WESTuni2 is in WESTunig1) Equal to False
            • Then - Actions
              • Unit - Set mana of WESTuni1 to ((Mana of WESTuni1) + 1.00)
            • Else - Actions
              • Unit - Move WESTuni1 instantly to WESTpt1
      • Custom script: call RemoveLocation(udg_WESTpt1)
      • Custom script: call RemoveLocation(udg_WESTpt2)
      • Custom script: call DestroyGroup(udg_WESTunig1)
Anyone see the problem?
 
Status
Not open for further replies.
Top