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

[vJASS] Can someone explain this?

Status
Not open for further replies.
Level 16
Joined
Jun 24, 2009
Messages
1,409
Dunno if JASS or vJASS or Zinc or something, but it's full of macros so I thought it's the second.
I have a few questions about the system I attached. It's an awesome skill tree system.
The questions are the following:
  • How can I make it to open and close the skill tree by pressing ESC instead of using an item?
  • How can I add more spells? I just understand a part of it.
  • How can I modify the position of the spells?
I think thats all for now.
View attachment Skilltree v0.05.w3x
Note: Don't know whose system is this :/
 
I just reviewed it fast, but I think I'm not wrong ^^' :

The position of the tree's spell is defined by 2 constant reals which are in the "SkilltreeInit" trigger.
JASS:
        constant    real                    SKILLTREE_POS_X         = -2200
        constant    real                    SKILLTREE_POS_Y         = 2400
For each spell, you create a structure with the extend SkillTemplate like those in the testing trigger directory.
JASS:
    struct Spell extends SkillTemplate
        string name                 = "Spell Name"
        // Position in the tree with (0, 0) being the bottom-left corner, I guess
        integer posX                = 2 
        integer posY                = 4 
        // A destructable with the model "iconbase.mdl" and the replaceable texture of the active button.
        integer icon                = 'SMSL' 
        // Same but for disabled button.
        integer icon_unknown        = 'SMSU'
        // Clear enough
        integer maxLevel            = 10
        integer skillpointsNeeded   = 1
        
        // The descriptions depending on the level and perhaps the unit-type.
        method setDescription takes unit u, Skill s, integer level returns nothing
            set s.description          = "Hurls a fiery bolt that stuns a target enemy unit."
            set s.stats                = "Damage: " + I2S(150 + 75 * (level - 1)) + ", Stun: 2.0s, " + "Manacost: 75" 
            set s.requirements         = "Requires Level " + I2S(level + 1)
            set s.statsNext            = "Damage: " + I2S(150 + 75 * level) + ", Stun: 2.0s, " + "Manacost: 75"
        endmethod
        
        // In most case, you just change the Ability ID in this.
        method learn takes unit u, Skill s, integer newLevel returns nothing
            if newLevel == 1 then
                call UnitAddAbility(u, 'Abil')
            else
                call SetUnitAbilityLevel(u, 'Abil', newLevel)
            endif
            call .setDescription(u, s, newLevel)
        endmethod
         
        // The condition for a skill to be learned/upgraded. The library automatically add 2 more conditions : "s.st.skillpoints >= s.skillpointsNeeded and s.level < s.maxLevel"
        method check takes unit u, Skill s, integer newLevel returns boolean
           return newLevel <= GetHeroLevel(s.st.u)
        endmethod
         
    endstruct

The event for opening/closing the tree is in the "Initialization" trigger.

So, there are 2 main objects :
the SkillTree which is related to 1 unit and that contains Skills,
and Skills themselves, which are children of the SkillTemplate interface.

It is obviously a system made for vJasser. You won't be able to get its full potential if you just copy/paste the examples. Still, I think it's a good practice to learn it if you have the basics.
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
Well, I've learned Java and Pascal for a year so I know the basics of the programing, but this thingie is just messy for me. Now I checked the template trigger again and I understand it. It's okay that the event is in the Init but how can I change it to the event player presses skips cinematic?
Also, another question. There is a disabled trigger called SkilltreeMacros. Is it necesseary to copy too?
 
JASS:
    private function OpenSkilltree takes nothing returns boolean
        
        call ShowSkilltreeSwitch(Skilltrees[GetPlayerId(GetTriggerPlayer())])
        
        return false
    endfunction
    
    private function onInit takes nothing returns nothing
        local trigger t     = CreateTrigger()
        local trigger t2    = CreateTrigger()
        local integer i=0
        call TriggerRegisterTimerEvent(t, 0.01, false)
        call TriggerAddAction(t, function initSkillTest)
        loop
            exitwhen i>=12
            call TriggerRegisterPlayerEvent( t2, Player(i), EVENT_PLAYER_END_CINEMATIC)
            set i=i+1
        endloop
        call TriggerAddCondition(t2, Condition(function OpenSkilltree))
        set fireball = Fireball.create()
        set immolation = Immolation.create()
        set t  = null
        set t2 = null
    endfunction
Just an example.

I suggest you to practice on something less complicated (personnaly, I don't think you can learn vJass without learning jass first). Try to get used to jass' syntax and, if it's not already done, extract your files "common.j" and "Blizzard.j" from your war3Patch.mpq with an MPQ browser.

EDIT : Yes, I forgot the "call "... Sorry.
 
Last edited:
I guess I was thinking about "knowing what the compiler does".

JassHelper is just an add-on. It translates vJass into jass but is not a basic language.
I can't imagine myself programing in vJass without knowing that some kind of code will be turned into some kind of proper jass sentence : my reference is jass because it's also W3's reference.

But surely everybody don't feel it that way. Plus I guess someone may learn both jass/vJass simultaneously but, in my mind, they have to learn the jass concepts that are involved in vJass before (I can't imagine someone learning methods before functions, for instance, it would be kind of "blind programing").

Hope I'm understandable, even if it's not really important...
 
But surely everybody don't feel it that way. Plus I guess someone may learn both jass/vJass simultaneously but, in my mind, they have to learn the jass concepts that are involved in vJass before (I can't imagine someone learning methods before functions, for instance, it would be kind of "blind programing").

Ofcourse, but when I learned about functions, I was simultaneously learning about struct methods :p
So, you can say that I went from GUI to Jass/vJASS :p
 
Level 13
Joined
Mar 16, 2008
Messages
941
JassHelper is just an add-on. It translates vJass into jass but is not a basic language.
I can't imagine myself programing in vJass without knowing that some kind of code will be turned into some kind of proper jass sentence : my reference is jass because it's also W3's reference.
JassHelper is not "just" an addon. Imagine jass would not exist and Blizzard had implemented vJass directly.
It would work without using the original Jass.
Learning Jass is an absolut waste of time. While learning functions learn methods. While learning arrays and variables learn structs (rather this befor functons). While learning about clean code learn scopes, libraries and global blocks. Tada, vJass done (mostly).
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
JassHelper is not "just" an addon. Imagine jass would not exist and Blizzard had implemented vJass directly.
It would work without using the original Jass.
Learning Jass is an absolut waste of time. While learning functions learn methods. While learning arrays and variables learn structs (rather this befor functons). While learning about clean code learn scopes, libraries and global blocks. Tada, vJass done (mostly).

I disagree and am totally with Tirlititi here, if you don't know how vJass is compiled in jass, that's the best way to make unbelievable pieces of shit code.
And since vjass is just jass with sugar syntax, i see nothing wrong to learn jass before, anyway it's not like there are many things to learn in jass ...
 
Status
Not open for further replies.
Top