HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Tower Kills Question

08-09-2008, 06:14 AM#1
Xhorror
I might not be posting in the correct forum but here it goes.

I've created my own tower defense and playing some TD's like eeveTD and Sprout TD, I've noticed a nice feature. Once a tower reachs a certain amount of kills, it gains an aura/ability of some sorts. I've tried to replicate this using GUI to no avail. Can someone help me with this? Do I need to do this in JASS or can I do it in GUI?

Any help is appreciated! Thanks :D
08-09-2008, 05:45 PM#2
Tide-Arc Ephemera
It can be done in GUI but it's a whole lot better in Jass since they can store/index/whatever the term is units a whole lot better. I don't have World Editor with me but hopefully someone can post or lead to a code which would help.

Method, however goes along the lines of:
> Tower kills a unit
--- Add 1 to the tower's kills
--- Check number of tower's kills
---> Is the number of kills equal to X?
------ Give tower ABILITY

You could do it with an array in GUI, assuming there will NEVER be more than 8190 towers ('cause y'know, them mazers and their love to spam shitty towers around a single awesome one).

Also, if you check the number of kills on the tower... make sure it's always EQUAL to, never EQUAL TO OR GREATER THAN. If you make it EQUAL to, that will ensure it will only check once.

Alternatively you could do some booleans and unit groups but those are a bit non-basic.

So yeah, I hope that someone else will help out with triggering (assuming I don't get to WE any time soon).
08-09-2008, 10:53 PM#3
Askhati
What about turning the tower into a hero, which gains XP per kill and thus abilities?
08-09-2008, 11:02 PM#4
Askhati
Apologies for double post, but my browser won't let me edit my previous post.

Comment on what was said on the unit groups: let's say a tower needs 5 kills to gain a ability.
Create six unit groups, numbered #0 to # 5.
When the tower scores a kill, move it to the next higher #ed group - eg #2 to #3, or #4 to # 5.
If a kill is recorded while in the highest group, give the tower the ability and then move it down to group #0, from whence the cycle repeats.

Plausible?
08-09-2008, 11:12 PM#5
Tide-Arc Ephemera
I actually didn't think about that method to be honest, but why would you re-add it? However, that method could work yeah. It'll take some ingenuity.

Also, hero towers are a pain in the ass to make so don't ask me about them. I HAVE tried them, tried being the real keyword there.
08-11-2008, 04:52 AM#6
darkwulfv
Yeah, "hero" towers usually look shabby anyways. They are NOT easy to pull off, and you're way better off just storing how many kills a tower has and then if it has so many, add an ability.
08-11-2008, 04:55 AM#7
Blubb-Tec
Quote:
Originally Posted by darkwulfv
Yeah, "hero" towers usually look shabby anyways. They are NOT easy to pull off, and you're way better off just storing how many kills a tower has and then if it has so many, add an ability.

Why do you prefer that method over Askhati's? His one looks much simpler to me... especially when it's done in GUI.
08-11-2008, 05:08 AM#8
darkwulfv
Because I would be doing it in JASS, so it'd far easier my way. In GUI?... Still easier; you can get the custom values of a tower in like, 2 seconds. Same for setting it (as long as you don't already use custom values).

Which looks easier?

(I don't remember GUI, so...)

Detecting a kill
Getting custom value
Increasing custom value by 1
If custom value > 5, then add ability


OR

Detecting a kill
Checking all the groups for the unit
When finding the unit, finding what group it's in
Removing it from that group and using an if/then chain to find out what group to put it in next
If it's in group 5, add the ability and return it to group 0.


His idea is flawed in that you'd have to find out what group it was in... either by incrementing an ability, storing a custom value (why not just use method 1?), or by a long if/then chain.
08-11-2008, 08:33 AM#9
Askhati
Oh, I never even realised you could use the custom values for that. Much easier than the grouping method, then. Would also manage the increments better - get ability after 5 kills; get health boost after 8; get anti-air at 12; etc.
08-11-2008, 09:12 AM#10
darkwulfv
Yeah, custom values are literally just integers stashed on a unit.
08-11-2008, 10:19 AM#11
Blubb-Tec
yeah, but at some point he might want to use the custom value for something else.. and for the group-thingy, he could simply make an array of groups and just iterate until the group with the tower is found. Ofcourse that is harder than the custom value thingy, but as I said, he might want to use the custom value for something else.
08-11-2008, 10:47 AM#12
darkwulfv
And if he does, there's plenty of other methods. Iterating through groups and arrays is just too complicated (especially in GUI) and unnecessarily hard.

I mean he could even go so far as to attach integers and just detect when a tower dies and flush it (to prevent handlestack corruption).
08-14-2008, 08:23 AM#13
Karawasa
If you're not using mana but may need custom value in the future, mana is your friend.
08-15-2008, 04:29 AM#14
Blubb-Tec
Quote:
Originally Posted by darkwulfv
And if he does, there's plenty of other methods. Iterating through groups and arrays is just too complicated (especially in GUI) and unnecessarily hard.

I mean he could even go so far as to attach integers and just detect when a tower dies and flush it (to prevent handlestack corruption).

Iterating through an array of groups is too hard to do in GUI? I think it's much more complicated in jass, since it takes more lines of code. And I think, attaching in GUI is a lot more harder, atleast if you mean using the return-bug to attach things using the gamecache...
08-15-2008, 06:30 AM#15
darkwulfv
Quote:
Iterating through an array of groups is too hard to do in GUI?
It takes an amazing amount of clicks, as well as making the code look like shit.
(Start an For Each integer A loop, then you have to do individual group loops, and... yech.)

And no, iterating through arrays is not at all hard in JASS.
Collapse JASS:
local integer i = 0

loop
exitwhen i > maxarraynumber
  if blahblahblah == blehbleh then
    do stuff
  endif
  set i = i + 1
endloop


Amazing. 25 seconds to type.


The converted GUI code is retardedly long, including a full extra function just for the condition. Tell me again it's more lines of code.

Using the return bug is hard in GUI, yes. But using custom integers is NOT. Nor is using Mana, like Karawasa said. And no matter what, doing it in JASS is likely easiest and/or cleanest.