| 09-29-2004, 09:45 PM | #1 |
Okay, I have a small problem. Basically, I want a unit to be able to retain certain abilities when it upgrades to another unit. The abilities the units are to retain can vary between units since they are given through triggers, but it would be possible to make an array of all possible abilities and check to see if it is a qualifying ability. The problem I have is that I don't know how to go about seeing if an upgraded unit had the ability before. If I could just do a custom value or something, that would be great, but I already use that. I also use flying height, mana, and point value, so those wouldn't be a possibility either, even though I don't think those carry over anyways. So.... what I need, it seems, is a way to check if a unit has an ability before it is upgraded, and if so, then re-give it to the unit after it is upgraded. I have been at this for a while, so someone please make me feel stupid and come up with a quick easy solution ^_^ Oh, and if need be, I can make it so units can only have one of these type of abilities (though I would prefer not to), in case the only option anyone can come up with is some kind of carry-over booleon that will only allow for a "has it" or "not" check, rather than a "what did it have" check. |
| 09-30-2004, 12:59 PM | #2 |
Ahh, u can use custom values, u can use an alghtheriom (or however its spelled) to make it work. What you would do is first asign the following numbers to certin ability types: 1 = ability 1 2 ability 2 4= ability 3 8= ability 4 16 = ability 5 32 = ability 6 64 = ability 7 128 = ability 8 256 = ability 9 512 =ability 10 So On. then use if then else so like if unit has ability 1 then set custom value of the unit to custom value + 1, if they got ability 10 then set custom value + 512. Then you will have 1 final number, there is only 1 way this number can be broken down. So if the final number is like 29 then the only way that u can make up 29 without using the same number twice would be to add 1 + 4 + 8 + 16. So after u got this final number and ur checking to c if they got ceritn abilitys, take the number and c if its greater then or = to the higest value (512 in this example) so lets say its more then 512, if it is then you would set an array slot to be like TRUE so that it saves the info that he does have ability 10, then subtract the 512 from the number, then check and c if the remainder is greater then or equal to 256, if its greater then it would set a variable and subtract 256, keep doing this until it reaches 0, then when the remainder value = 0 then use if then else to check if a variable was set and if it was then give the unit that ability, its sorta complicated, but its a vary neat and efficent system. |
| 09-30-2004, 01:09 PM | #3 | |
Quote:
Checked how Call to arms work in melee? only the first townhall has that ability, blizzard uses unit add ability to add the call to arms ability to the first townhall, how do they keep the ability if you go to upgrade to keep but cancel the upgrade? Easy, it is because of Code:
native UnitMakeAbilityPermanent takes unit whichUnit, boolean permanent, integer abilityId returns boolean in other words you have an ability whose rawcode is A000 , and you want an unit saved in a ThisUnit variable to keep that ability after upgrades. Code:
Custom Script : call UnitMakeAbilityPermanent( udg_ThisUnit,true, 'A000') |
| 09-30-2004, 05:28 PM | #4 |
Woo Hoo, right on, I thought it was going to be impossible... Now I just have to go and try it out and make sure I can get it to work And BTW, I mentioned in the first post that I already use custom value for something else, so that wouldn't have worked anyways... but thanks for trying :) |
| 09-30-2004, 09:57 PM | #5 |
i was going to say make a custom script that set an integer variable to an ability, arnen't(whatever...) abilitie (damn, i'm really off today) types saved as integers? Or like Ninga said, you could enumerate the abilities, except i'd just use normal integers, no reason to go to powers of 2's. And save them to a variable for purchasing unit or something. |
| 10-01-2004, 01:28 AM | #6 |
Okay Vex, I can't seem to get this to work. Here is a cut/paste trigger that has all the relevent parts from my non-working one, if you could point out the mistakes or problems, I would appreciate it. The only thing I could think of was to maybe store the ability in a string, then use the string variable instead of the ability one, but I don't know if that would work either. Code:
Example Trigger
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Automatize
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Blah Blah
Then - Actions
Set i = (Random integer number between 2 and 3)
Unit - Add AutomatonAbilites[i] to (Target unit of ability being cast)
Set AutomatonAbilites[0] = AutomatonAbilites[i]
Else - Actions
Unit - Add Roar to (Target unit of ability being cast)
Set AutomatonAbilites[0] = Roar
Custom script: call UnitMakeAbilityPermanent( GetSpellTargetUnit(), true, udg_AutomatonAbilites[0])
|
