| 04-06-2011, 04:20 PM | #1 |
Hello. I am trying to make an ability which can only be cast a limited amount of times (like the Sentinel), but I've ran into problems. First thing, to make it easy for the player to see how many casts of the ability is left, we've made separate icons with an integer on them representing just how many casts are left. To use these icons, I made one ability per icon. Object editor part done. As for coding, when you cast the first spell, it's removed and adds the one with the "next" icon and so on until you cast the ability with a "1" on it. Because when that's cast, the spell is removed from the unit and no other is added. This works just fine for one unit. When you've selected several units, though, and order them to cast this ability, they'll end up with different abilities because one has the one with a "2" on it, one has a "3" on it etc. This means if you select two units with a different amount of casts left, the ability won't show up in the command panel. I've tried stuff but I haven't gotten anywhere. Care to help? Thanks in advance. Edit: I should add that the spell should be point target, so basing it off of Sentinel won't work. |
| 04-06-2011, 07:27 PM | #2 |
I can't think of a perfect solution to the problem. Is there any other ability besides Sentinel that can have charges? I don't think so. Therefore, anything you do has to use the multiple-icons workaround. One possibility would be to display the charges with a separate passive icon, thus making the spell icon the same for all units, but that still leaves the problem of units that ran out of charges no longer having the ability. You could try hacking it by giving the same ability to all units currently selected, but that leads to terrible complications, not to mention that selection events are not instant. I really don't think this problem can be tackled in the WC3 engine. |
| 04-06-2011, 07:45 PM | #3 |
It is as I feared, then. Quite a pity. The passive might be a solution, albeit a cheap one that would be a bit flawed. I guess we'll see. I thank you anyway, Anitarf. |
| 04-06-2011, 11:33 PM | #4 |
I suppose you could do the passive approach and retain the active ability even when the passive reaches 0 and then use LastOrder to prevent units without charges from casting it. That way, all units would have the active ability, meaning you could use it while having multiple units selected. (of course, if a player issues an order to a group and the unit that tries to cast the spell is already out of charges, the code must look for all units with charges in the current selection, pick the one closest to the target point, and order it to cast the spell; only if such a unit is not found should you display an error message). |
| 04-07-2011, 02:10 AM | #5 |
could you do something like an item? i know items have uses but i don't know if you can use that. |
| 04-07-2011, 12:27 PM | #6 |
Items have several flaws. First of, the key binding will be on the numpad. Secondly, when you give a unit an item, it counts as a unit of its own, so to say. So if you target a whole bunch on the same unit, but they each have an item, you'll need to tab between each and every one of them. |
| 04-07-2011, 01:22 PM | #7 |
I'm fairly sure he meant to use an item ability as a regular ability. But that wont work since there wont be any charges. I like Anitarf's idea, though. |
| 04-07-2011, 01:39 PM | #8 |
You could make a unit sell a dummy item with its tooltip corrected to look like an ability. But that of course has problems with targettting etc. |
