Showing Tower Range

BlackRabbit

New Member
Reaction score
3
I've seen some Tower Defense games online [like, flash games which, btw, don't cut it in comparison!] that show a tower's range in a circle around the tower. Is there any way to do that? Like, how a unit shows it's selection circle, would it be possible to either make the selection circle big enough [and stay accurate] or to find another way to do so?
 

TomTTT

New Member
Reaction score
44
You can simply change the selection circle's scale - it's in Art - Selection Scale. Just try and it will work out. You can also create a unit that it's model is either an Aura model or dowloaded selection-circle-like unit, and a player selects it, it appears. (simple trigger)
 

BlackRabbit

New Member
Reaction score
3
Mad props to you Tom for answering all my strange questions.

I tried the selection circle thing, but it makes it look crappy, makes the health bar for the tower GIANT, and I'm thinking about doing up an ability that shows a tower's range with just a short animation if you click to see it. Any ideas?
 

Moradiae

TH.net Regular
Reaction score
14
Just gonna throw out an idea of how I think they (like etd) did it here:

basically creating bunch of units (with locust) or special effects around selected unit when player type a certain command

I'll go with special effects here

Number of special effects placed along the circumference will depends on how big it is, which depends on the range.

for MUI version, see this post, it's basically done using the same formula, but different removing special effects method :p
Trigger:
  • create effect
    • Events
      • Player - Player 1 (Red) types a chat message containing -range as A substring
    • Conditions
    • Actions
      • Set range = (Real((Substring((Entered chat string), 8, 11))))
      • Set circumference = (3.14 x range)
      • Set spacing_constant = 50
      • -------- determine how far apart each special effects will be ALONG the circumference, the smaller the neater, but just don't set this to 0 --------
      • Set numberOfUnitAroundCirc = (((Integer(circumference)) / spacing_constant)
      • Set angle = (360.00 / ((circumference / Real(spacing_constant)))
      • -------- For the sake of minimizing rounding inaccuracies, angle is set with each term expressed as real number, so direct reference to numberOfUnitAroundCircle is not used here --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • range Less than or equal to 2000.00
        • Then - Actions
          • For each (Integer A) from 1 to numberOfUnitAroundCirc, do (Actions)
            • Loop - Actions
              • Special Effect - Create a special effect at (Position of (your unit)) offset by range towards (angle x (Real((Integer A)))) degrees) using (your effect)
              • Set rangeeffects[(Integer A)] = (Last created special effect)
              • Countdown Timer - Start rangeTimer as a One-shot timer that will expire in 4.00 seconds
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) the text: No more than 2000 r...
          • -------- just an error message when player asks too show a range too big --------


and destroy effect trigger:
Trigger:
  • des
    • Events
      • Time - rangeTimer expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to numberOfUnitAroundCirc, do (Actions)
        • Loop - Actions
          • Special Effect - Destroy rangeeffects[(Integer A)]

damn, I miss the wc3 tag :(

result:
both with special effect Spell Steal
-range 300 (spacing constant = 100)
attachment.php


-range 500 (spacing constant = 60)
attachment.php

note: these 2 screenshots are from the old codes (not available in this post now) with the special effect missing on the right
 

Attachments

  • 300.JPG
    300.JPG
    34.5 KB · Views: 387
  • 500.JPG
    500.JPG
    57.7 KB · Views: 416

BlackRabbit

New Member
Reaction score
3
That is precisely what I'm looking to do. Now, turn that from a chat substring to an ability [easily done] and one that automatically pulls the range of the tower's attack. If that's not possible, I'll just make the same ability for each range I have in the game.
 

Moradiae

TH.net Regular
Reaction score
14
that's not the best of triggers mind you :D
there's also a little problem with showing more than 1 at the same time
and there's the missing effects on the middle right part (2nd picture) (maybe fix by turning everything to real except numberOfUnitAroundCirc because there're already too much roundings and also the fact that real only handle up to 2 decimal places, thus 6.28 - -)
 

TomTTT

New Member
Reaction score
44
What Moradiae showed was awesome, I had no idea how to do this... But I guess what you need to show multiple ranges at once is create a hashtable. When the unit casts the ability, save all special effects made, set time (integer) to the time you want, and add the unit to a unit group. Then make a 1.00 second periodic that picks every unit in those units, set the time to Time - 1 and save it again in the hastable after changed. Then, check if time is equal to 0, if it is then destroy all special effects. If it's too much I can give it a try. I'm kinda bored :p
 

Moradiae

TH.net Regular
Reaction score
14
lol, was trying to figure out how to solve that but couldn't find a way, I guess I need to look into hashtables here
I am current in the stage of moving away from using the wait function although I think wait still wouldn't work here

now there's this(hash), and jass :p

edited

--> if you want to make this only visible to you, one option would be to create unit instead and give them locust and perma invis ;)
 

TomTTT

New Member
Reaction score
44
Ok, now it's official: I'M STUPID!!!
I was really about to finish that darn thing, and guess what - I was corious to find out what is in hashtable Hastable - Save Eventid handle
And guess what! THE BLOODY CRAP CRUSHED!!!! So I'm starting all over again now..

EDIT: HAHA!!! Made it :) I'm not sure if it was acctually necessery, but I was bored.
I made the ability, and caused the range to be the Point-Value of the unit, so remember to change it to the range.
 

Attachments

  • Show Range MUI.w3x
    18.5 KB · Views: 187

Moradiae

TH.net Regular
Reaction score
14
Improved (I think)

In the old trigger, somehow there's a lot of effects missing for some large values for range

screenshot attached, new code see 2nd post (i'll edit it right after I post this)

@TomTTT
although I have not a clue what you were saying there, I wouldn't put ignorance within the same category as stupidity :p
tho I can still rely on you for fixing the removing special effect issue here right?:eek:

edited:
neat! your map will be my first resource for learning hashtables :p
 

Attachments

  • new.jpg
    new.jpg
    120.3 KB · Views: 212

TomTTT

New Member
Reaction score
44
@Moradiae
Woah thanks! :D
After getting the concept of Hastables, it's really easy. all I'd tell you is that what you need is to understand WHAT it is and HOW does it work. Then, all what you need is a simple logic. (If you want me to tell you, I'll be glad to, because as I said before - I'm waaay to bored...)
 

Moradiae

TH.net Regular
Reaction score
14
Haha, ok,
just one question here (I don't think it deserves a new topic :p)

I just remember vaguely that one map can only hold one hashtable, is that true?

because I was looking at the variable and saw that Range_Hash is a variable hashtable, and when you add, you add it in Range_hash, so many hashtable per map make sense
 

TomTTT

New Member
Reaction score
44
Haha, ok,
just one question here (I don't think it deserves a new topic :p)

I just remember vaguely that one map can only hold one hashtable, is that true?

because I was looking at the variable and saw that Range_Hash is a variable hashtable, and when you add, you add it in Range_hash, so many hashtable per map make sense

Ahh In fact I think you can use up to 512 Hastable (lol) within 1 map. I think Ryushi once started a thread asking that, not sure. But anyway, you can more than one.
 

BlackRabbit

New Member
Reaction score
3
All this got way over my head real fast...
Just looking for an ability that does it, so if I happen to want to see the range of a tower, I just use it's ability. I don't want it to happen when a unit is selected or anything, and it doesn't really matter to me if it's shown to just the using player or to everyone. I'm not too concerned about that part. There was a tower defense that did this that I used to play a while back. Possibly gem TD? I'm not sure...
 

Moradiae

TH.net Regular
Reaction score
14
Well, that's what's exactly in TomTTT's map above, (I guess that 1 view is mine huh?)
Just take a look :D

that was a long maintenance just now but the site loads pretty damn fast now :)

==== edited

here's the same map but I just use a new formula which works a lot more nicely now

Just remember that Point-Value is used instead so set it equal to the tower's range
 

Attachments

  • Show Range MUI.w3x
    19.6 KB · Views: 204

BlackRabbit

New Member
Reaction score
3
To be honest, I completely thought ab out this thread, and just checked back in on it today XD I'll check out the map right now. Judging my setting it to the tower's range, I would have to create the same ability, only for different ranges? That doesn't bother me much, just wanted to be clear. -opens map editor and plugs away-
 

Moradiae

TH.net Regular
Reaction score
14
nope, you only need 1 ability "Show Range" for your whole map,
only that for every tower you have, you have to also set its Point-Value to the same as its range

because what the trigger does is simply
set Range = ((Point-Value) of Triggering Unit)
 

BlackRabbit

New Member
Reaction score
3
Sounds simple enough. You two have helped me significantly. I appreciate it! I'll check it out and see what I can do.

Edit: Just implemented this into my map. It works great, but interferes with my Sell Tower ability. It awards three quarters of said tower's point value [previously set to it's cost in gold, now set to its first attack's range] back when a tower is sold. Any way I can convert this to gold cost?
 

TomTTT

New Member
Reaction score
44

Does all of your towers have the same shooting range? If so, just set Range in the map I uploaded to that range, and set the point value to the amount you want. Otherwise, I would suggest maybe MP? (Though I'm not sure towers can have MP)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top