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

How to make a unit tower

Status
Not open for further replies.
Level 9
Joined
Aug 1, 2008
Messages
453
If you've played crystal defenders you'll know what im talking about.

I don't know really how to explain what i want to do but ill give it a shot. Im trying to make a tower thats a melee unit. I want it to go to and go to and attack a units within X AoE and then return to its point when there is no more units left in its area. if you have any ideas on how to do this please let me know. Will +rep

Heres an example: crystal defenders - Google Video
 
Level 18
Joined
Mar 7, 2005
Messages
824
I don't know, but is there a way to place regions InGame? If so you could create some region that got the size of your radius, for example 300, if the melee unit leaves this region make it order to move to a random point within it, so it's inside that 300 range.

Another way would be checking the distance between the unit and the tower, so do a tower without a model, without collision size etc.. so you can only place it, and then create the melee unit manually and place it at position of the tower. so it looks like the Unit is the Tower and then just check the distance between the unit and the tower, when it's more than 300 order it to move back for about 0,5 seconds so it's again within the range..
 
Level 7
Joined
Oct 14, 2008
Messages
340
the whole move command would be ineffective, i'm thinking of using a setunitx/y, maybe even giving the unit locust so it can't be given orders.
 
Level 11
Joined
May 31, 2008
Messages
698
Make it a ward instead. That way you cant give it orders, but you can still select it and it can be vulnerable. I dont really see what you are talkin about when you say "I want it to go to and go to and attack a units within X AoE and then return to its point when there is no more units left in its area." Why dont you just make a tower with the desired range?
 
Level 7
Joined
Oct 14, 2008
Messages
340
Well if you'd watch the video he posted, you'd see what he means.. it's a pretty cool concept. Since it's a TD, i don't think the unit would need to be selected, or maybe: a selectable invisible dummy(the tower you built) at the center of his AoE would do the trick..
 
Level 11
Joined
Feb 14, 2009
Messages
884
Hm, I don't know if it works, but try this:

  • Events
    • Unit - A unit comes within 800.00 of <Your unit>
  • Conditions
    • (Owner of (Triggering unit)) Equal to <Enemy Player>
    • TowerBusy(<Tower Custom Value>) Equal to False
  • Actions
    • Set TowerTempLoc(<Tower Custom Value>) = <Your Tower's Location>
    • Set TowerBusy(<Tower Custom Value>) = True
    • Unit - Order <Your Tower> to Attack-Move To (<Location of Triggering Unit>)
This is for the attack. Now, order the tower to return to its position.

  • Events
    • Unit - A unit Dies
  • Conditions
    • (Owner of (Triggering unit)) Equal to <Enemy Player>
  • Actions
    • Unit - Order (Killing unit) to Attack-Move To TowerTempLoc(<Tower Custom Value>)
When the tower succesfully moves to its default location, then it's ready to attack again.

  • Events
    • Unit - A unit Enters TowerTempLoc(<Tower Custom Value>)
  • Conditions
    • (Owner of (Triggering unit)) Equal to <You>
  • Actions
    • Set TowerBusy(<Tower Custom Value>) = False
    • Unit - Make (Triggering Unit) face Default building facing over 1.00 seconds
As you can see, I'm using the Tower's custom value. You can make a trigger that specifies that value when a tower is created. For example, when your worker finishes the construction of a tower, then that tower's custom value is set to <Total custom values> + 1. That means that your first tower will have a custom value of 1. The second 2, and so on...

Again, I don't know if all this works, leaks, has problems and so on...
 
Level 9
Joined
Aug 1, 2008
Messages
453
Ok, i got it all setup but is there a condtion that checks if a unit is within X AoE of the unit? I need to add that condition to this trigger
  • Soldier Tower Attacking
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to |cffBB9910Lv. 1 Soldier (Actual)
    • Actions
      • Set Positionoftower[(Custom value of (Attacking unit))] = (Position of (Attacking unit))
      • Set Positionofenemy[(Custom value of (Attacking unit))] = (Position of (Attacked unit))
      • Unit - Move (Attacking unit) instantly to Positionofenemy[(Custom value of (Attacking unit))]
EDIT: Region needs to be a circle if it's possible.
 
Level 11
Joined
May 31, 2008
Messages
698
For your variables when you use the custom value of the unit you have to actually set the custom value of every unit that enters the map. I think the default custom value for al units is 100, so what i would do is make a trigger to set the custom value of every unit that enters the map. Event - a unit enters playable map area Actions - set x = x+1 Set custom value of entering unit to x. x should be integer variable i think, maybe real depending on what custom value is.
 
Level 11
Joined
Feb 14, 2009
Messages
884
Since he wants the towers to attack units in range y, a tower will attack any unit that is inside that range.
 
Level 11
Joined
May 31, 2008
Messages
698
that wasn't my question, i do got a trigger that does all that. Just I'm trying to only let a unit attack monsters that are within 300 AoE of a building.

I know that wasnt your question, im just saying that your variables will mess up if you dont set the custom value of the unit because i dont think that every unit naturally has a different custom value.
But for your question I think i have an idea:

  • Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to (==) *DummyTower*
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between (Position of (Attacking unit)) and (Position of Tower_Unit[(Custom value of (Attacking unit))])) Less than or equal to 300.00
        • Then - Actions
          • Unit - Order Tower_Unit[(Custom value of (Attacking unit))] to Attack (Attacked unit)
        • Else - Actions
          • Unit - Order Tower_Unit[(Custom value of (Attacking unit))] to Stop
  • Create
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set x = (x + 1)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Unit-type of (Constructed structure)) Equal to *Tower*
          • Then - Actions
            • Unit - Create 1 *TowerUnit* for (Owner of (Constructed Structure)) at (Position of (Constructed structure)) facing Default building facing (270.0) degrees
            • Unit - Set the custom value of (Constructed structure) to x
            • Set Tower_Unit[x] = (Last created unit)
          • Else - Actions
I havent tested it, but it might work.
 
Last edited:
Level 1
Joined
Mar 30, 2009
Messages
2
Makeing a unit a tower:

first you go down in the unit screen. Click "Is Building: No" To Yes. Change "Can Flee:Yes" To No. And then go down and find the thing about a size texture or something and change it to the one of a scout tower. There you go, hope this helps. :D
 
Status
Not open for further replies.
Top