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

(Jass) Libraries, scopes and calling functions inside them

Status
Not open for further replies.
Level 5
Joined
Dec 20, 2008
Messages
67
Hi, I'm posting this because i would like to make good spell system, however:
I have a library, where are functions which runs everytime some spell of the pack is cast, because all of them uses same functions. I need every single spell to have own library or scope or something, with functions, which will be called from the basic spell library.
The problem is that, I don't know how to let the function (in base library) know which spell did it, so it can call the right scope (all scopes has the same functions)
Ask if you do not understand me :xxd:

Thanks for all tips and comments
+rep for help
 
Level 5
Joined
Dec 20, 2008
Messages
67
I tried to pass them CODE, but i dont know how to convert code to function :(

JASS:
    function Effect takes unit caster, unit u, code ef, code dmg returns nothing
        call UnitDamageTarget(caster, u, dmg, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        call ef (caster, u)
    endfunction

//...........................

function Wave1 takes unit caster, integer n1, code u1, code ef1, code dmg1 returns nothing
        local unit u
        local group gr     // i will put some units to the group later ... do not care
        
        loop 
            exitwhen(gr == null)
            u=FirstOfGroup(gr)
            if u1(u)==TRUE then
                call Effect( caster, u, ef1, dmg1)
            endif
            GroupRemoveUnit(gr, u)                
        endloop
    endfunction

I need somthing like a link variable, which can point to my function.
From C programming language I know that, we can use Pointers, is there such a thing? If yes, i could just pass the function pointer to functions i need to run...
 
Last edited:
I am not sure exactly what you're trying to do. =\

So you have a base spell thing. And then it extends to call different scopes based on what spell it is? Can't you just use GetSpellAbilityId() == Rawcode 'xxxx'?

Or am I missing something...

For that function, you can only use code if it doesn't take arguments. If you can't explain the problem, you can try posting an example of the libraries that you want to call or something. Are you trying to pass arguments through to a different function?
 
Status
Not open for further replies.
Top