• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

My buildings lose abilities

Status
Not open for further replies.
Level 1
Joined
Jun 13, 2008
Messages
132
Because 100 levels of an abilitiy increase the loading time or lag if I load them at the loading screen / game start. 20 Abilities are way better and I could make 30 Abilities and re-create 1000 levels if necessary.
Also abilities represent a number, and looks very professional If you ask me.
 
Level 11
Joined
Jan 23, 2015
Messages
788
Are you trying to increase the damage of a building?

If so, make two or three abilities,

The first one will have 10 levels which increases damage by 0/1/2/3/4..../8/9

The second one will also have 9 levels, which will increase damage by 10/20/30/40...../80/90

The third one will have 9 levels, which increase damage by 100/200/300/400....../800/900

If you want to increase the units' damage to 132 for example, you just set the third ability to level 1, the second to level 3, and the first one to level 2

so the building will get +132 damage. Also, give these abilities to the building in object editor, they will take some time to load on loading screen, but that's better than having 20 different abilities and exchanging them....
 
Level 1
Joined
Jun 13, 2008
Messages
132
The buildings act like a spawn point for units, the units get the damage and hp boost from them, and this is calculated with the levels of the building, everything works as I want, I've made everything, but the problem is that when I upgrade the building, the abilities are lost, I am trying a system to store the abilities before upgrading and adding them after the upgrade but nothing happens...
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Do you add the spells via triggers?
If so, try doing "Custom Script: call UnitMakeAbilityPermanent(udg_Unit, true, udg_Ability)"
udg_Unit and udg_Ability should be global variables referring to your unit and ability respectively.
You have to do this for every time that you add an ability via triggers to avoid losing them on transformation like morphing abilities, upgrades, etc.
 
Level 1
Joined
Jun 13, 2008
Messages
132
Do you add the spells via triggers?
If so, try doing "Custom Script: call UnitMakeAbilityPermanent(udg_Unit, true, udg_Ability)"
udg_Unit and udg_Ability should be global variables referring to your unit and ability respectively.
You have to do this for every time that you add an ability via triggers to avoid losing them on transformation like morphing abilities, upgrades, etc.

How can I refer to "Picked units" in your udg_Unit.
I'm getting errors, I don't usually work with this, don't you have an example for me to practice or an ability on a tower go to the upgraded tower to see how it works ?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Picked unit is "GetEnumUnit()".
If you have to find any names of functions or variables in JASS, you can just make the script in GUI and then convert it to custom text.
Then you can see ho they are used.

For example, you create a new trigger and place as action "Unit - Kill Picked unit" (nothing else)
Then you convert it to custom text and you can see "call KillUnit(GetEnumUnit())"
Then you know that Picked unit is equal to GetEnumUnit().
 
How can I refer to "Picked units" in your udg_Unit.
I'm getting errors, I don't usually work with this, don't you have an example for me to practice or an ability on a tower go to the upgraded tower to see how it works ?

Or better yet
  • Set Unit = (picked unit)
Wietlol, is there really no way to 'get' a unit's abilities? If so, then you can store it as he wanted to do.

There must be a way to index it (or use hashtables). For example, a unit learns an ability -> set i=i+1, set learned ability = x, set unit = u. Then a unit finishes an upgrade. Loop for (loop i) from 1 to i. If triggering unit = u[loop i] then give triggering unit ability x[loop i]. Right?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
There is no way yo 'get' the abilities of a unit without storing them manually.
However, in here, you dont want to.
Instead of storing all abilities in a list and re-adding them to the unit, you want them to be permanent on the unit (all it does is make the unit keep his abilities on upgrade and morph).

If you want to store a unit's abilities, a hashtable seems to be too obvious to use ofcourse, but you would need more than "learns an ability". (Which in this case is not needed at all because the ability is not added via triggers.)
You would need something to write your own "UnitAddAbility" function (or use a hook) and store that ability in the hashtable... you also need a "SetUnitAbilityLevel" and all the others (increase level, decrease level, remove ability, engineering upgrade) to update it.
Basically... just make abilities permanent.
 
Did you try my method of creating a variable for the (picked unit)? Also, your ability ID does not look quite right. It should be just 'AHad' I beleive. Unless you created an undeclared global (udg). You want
  • Custom script: call UnitMakeAbilityPermanent (GetEnumUnit(), true, 'AHad')
I think. GetEnumUnit is not an udg. Niether is your ability ID unless you set it that way. I recommend setting the ability as a variable and setting the picked unit as a variable. Then use them in your custom script. (udg_YourPickedUnit, true, udg_YourAbility).

To get the ID of the ability, you can use a game message. So when someone learns and ability have it write the game ability name in a game message. I believe it is an integer not a script though. Here is how you get it: http://www.hiveworkshop.com/forums/...w-do-i-get-rawcode-ability-being-cast-227730/
 
Level 1
Joined
Jun 13, 2008
Messages
132
I am still getting the same error of a name was expected with:
  • Custom script: call UnitMakeAbilityPermanent ( GetEnumUnit(), true, A02K:AHad)
Also with your suggestion Legal_Ease, even with the short name, the error occurs.

My abilities' names are: "|r" with a the editor sufix of (one, unit), (two, unit) for example, so if the player hovers the mouse he isn't reading anything, but when I trigger the whole thing it is easy to make the calculations.
I thought I were supposed to use the code name of the ability instead of the name I used for it... What's next? I still have the problem of my buildings losing abilities when upgraded...
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
The id as you have written it down is a doubled id.
The first one is the id of your ability, the second one is the id of your base ability (the one where you based your ability from), the ":" in the center is just a separation mark.

You use object type id's in single quotes.
Charcodes in single quotes: ('a000', 'Hpal', 'AHbz', 'abil', etc) are converted to an integer using charcodes and baseX.
In any case, you will have: "..... true, 'A02K')"
 
Level 1
Joined
Jun 13, 2008
Messages
132
The id as you have written it down is a doubled id.
The first one is the id of your ability, the second one is the id of your base ability (the one where you based your ability from), the ":" in the center is just a separation mark.

You use object type id's in single quotes.
Charcodes in single quotes: ('a000', 'Hpal', 'AHbz', 'abil', etc) are converted to an integer using charcodes and baseX.
In any case, you will have: "..... true, 'A02K')"

It works!, the only thing my trigger needed is the single quotationg mark, now the skills remain in the buildings when you upgrade them, thank you so much.
 
Status
Not open for further replies.
Top