• 🏆 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!

[General] Spell Book How To add abilities or increase ability levels?

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,601
Hello.

I have a minor problem. I have a hero with a spell book and I want to add new abilities or increase level of an ability inside it. All the spells that will be added to the spell books are passive abilities.

So how I do that? With GUI please so that I can further improve the system I'm currently making.

Rep for the one who can help.
 

Attachments

  • SSB - Sexy Spell Book.w3x
    15.7 KB · Views: 182

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
This is your next lecture :D

For increasing abilities level you can use GUI action in units section:
  • Unit - Increase level of yourability for (Triggering unit)
  • Unit - Set level of yourability for (Triggering unit) to X
However, for efficiency you can use natives (since actions above sucks a bit) by custom scripts:
  • Custom script: call IncUnitAbilityLevel (udg_yourunit, udg_abilityId)
  • Custom script: call SetUnitAbilityLevel (udg_yourunit, udg_abilityId, level)
It's still GUI :p

Where yourunit is unit variable, abilityId is integer variable with rawcode of your ability, you can get it by clicking Ctrl + D in Object Editor ->Abilities section. Rawcode will replace ability's name. Egzample: 'AHtb' is id of thunderbolt.
'level' is just a number here, enter to which level given ability should be set.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
For increasing abilities level you can use GUI action in units section:
  • Unit - Increase level of yourability for (Triggering unit)
  • Unit - Set level of yourability for (Triggering unit) to X
However, for efficiency you can use natives (since actions above sucks a bit) by custom scripts:
  • Custom script: call IncUnitAbilityLevel (udg_yourunit, udg_abilityId)
  • Custom script: call SetUnitAbilityLevel (udg_yourunit, udg_abilityId, level)
It's still GUI :p

I think that is nonsense, it doesn't save any performance as it is run very rarely. Just keep it fully GUI.

Here's the system: http://www.hiveworkshop.com/forums/pastebin.php?id=211mrv
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
You have it disabled, that's why it doesn't show up. Enable it when you type "1".
Sorry Pharaoh_ this time miss =) It's about the fact that spellbooks with the same ID will collide and inherit spells.

------------------------------------------------------------
Ok man I see that author of that tutorial haven't told enought.
At first, you have to change base order Id field. When you select it, you gonna see that 'spellbook' doesn't exist, and it is true.
You have to change it to anything else, even: None.
Make sure both spellbooks have the same Id.

Now the next part. MAKE SURE that value in field Minimum amount of Spells in dummy spellbook IS THE SAME as amount of spells you want to add have in dummy spellbook. So you wanted to add 3 spells at once. Value in that field should be at least 3 so.
I updated your map. You can look that I've changed only things I had mentioned above.
I'm gonna write Spellbook tutorial, since that one seems to be outdated.

------------------------------------------------------------
@Maker don't tell me that natives aren't better option here, since you and most of community know that fact.
Both functions:
  • Unit - Increase level of yourability for (Triggering unit)
  • Unit - Set level of yourability for (Triggering unit) to X
Truely look like:
JASS:
// Increase level
function IncUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit returns integer
    return IncUnitAbilityLevel(whichUnit, abilcode)
endfunction
// Set level
function SetUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit, integer level returns integer
    return SetUnitAbilityLevel(whichUnit, abilcode, level)
endfunction
Both do the only, and the same thing: return other function with swapped variables, so considering that our buddy Aeroblyctos wanna move in future to more efficient coding, it would be nice to tell him that natives:
JASS:
// Increase level
native    IncUnitAbilityLevel takes unit whichUnit, integer abilcode returns integer
// Set level
native    SetUnitAbilityLevel takes unit whichUnit, integer abilcode, integer level returns integer
can be used in GUI by:
  • Custom script: call IncUnitAbilityLevel (udg_yourunit, udg_abilityId)
  • Custom script: call SetUnitAbilityLevel (udg_yourunit, udg_abilityId, level)
What cause (even if it's small amount), the improvement of efficiency in his code. I dont think that for him (Aeroblyctos) it generates any problem at all, if we consider first of all that amount of posts and reputation proves that he isn't new to Warcraft Editor and the fact that it's just writing few code lines via Custom script action.
 

Attachments

  • Spell Book.w3x
    16.8 KB · Views: 233
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
@Maker don't tell me that natives aren't better option here, since you and most of community know that fact.

What cause (even if it's small amount), the improvement of efficiency in his code. I dont think that for him (Aeroblyctos) it generates any problem at all, if we consider first of all that amount of posts and reputation proves that he isn't new to Warcraft Editor and the fact that it's just writing few code lines via Custom script action.

The difference is performance is non-existant here. The actions are called very rarely, so the performance doesn't matter.

The problem deals with GUI, and the original poster uses GUI.

Custom scripts are used to do something that can't be done with GUI. There's no reason to use custom script here.

If you want to save performance and skip bjs, just use JASS, not GUI
 
Level 37
Joined
Aug 14, 2006
Messages
7,601
Aha! So here's a great battle between two mighty coders.

I've had very bad memories of a JASS spell book system from the past so I don't want go to that road again where I simply cannot understand anything and must rely on other people. Maker perhaps remembers how frustrating it was to fix that one system... I'm still thankful to you.

I wanted to get rid of the whole system, and made some drastic changes to the gameplay so that it will be more easier and enjoyable to play. Still I wanted to one very simple spell book system and that's why I'm here.

Now everything works and I'm doing good. Now I can even understand how the system works and that is relieving. Thanks so much Maker and Spinnaker.
 
Status
Not open for further replies.
Top