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

Spell Request

Status
Not open for further replies.
Level 22
Joined
Feb 3, 2009
Messages
3,292
Hello, this may sound very strange what I'm about to ask:

I've recently learned about using scopes for MUI, but the thing is I need some minor help which the tutorials didn't help me with:

I'm requesting the most basic spell in vJASS that you can come up with which uses scopes, the point of this would be, so I'll learn the whole proccess of the scope. The spell can do anything, but should be as simple as possible, but it should try and explain a little how scopes help it to be MUI.

If someone is nice enough to do this, the least I can do it +rep
 
Level 11
Joined
Sep 12, 2008
Messages
657
Hmm.. arent scopes used to ignore requirements?
since, basicly, scopes are getting the code to most top in the code line as possible..
so i doubt theres any use to that.. ;/
but if there is, ill be happy to see what it does too ;o
 
Level 11
Joined
Sep 12, 2008
Messages
657
librarys are allso used for index & hashtables..
heres a spell i made once:

JASS:
library Pull initializer OnInit
    
    globals
    
        private constant real           spellDamage     = 150
        private constant boolean        multiplyDamage  = true // if true, it will use this math:
        // damage * level of ability = damage dealt.
        // if false, damage will stay as it is.
        private constant real           kbSpeed         = 17
        private constant boolean        changeSpeed     = false // if true, it will use this math:
        private constant real           speedChanged    = 4.5
        // distance + (level of ability * speedchanged)  = distance traveled by the target.
        private constant boolean        multiplySpeed   = true // if true, it will use this math:
        // distance * level of ability = distance traveled by the target.
        private unit array              caster
        private unit array              target
        private real array              damage
        private real array              distance
        private integer                 maxCount     = 0
        private integer                 newCount     = 0
        private integer                 lc           = 0
        
    endglobals
    
    private function OnLoop takes nothing returns nothing
        local unit u     = null
        local unit t     = null
        local real x     = 0
        local real y     = 0
        local real x2    = 0
        local real y2    = 0
        local real x3    = 0
        local real y3    = 0
        local real dis   = 0
        local real dam   = 0
        local real ang   = 0
        if maxCount > 0 then
            set lc = 0
                loop
                set lc = lc + 1
                    set u = caster[lc]
                    set t = target[lc]
                    set x = GetUnitX(u)
                    set y = GetUnitY(u)
                    set x2 = GetUnitX(t)
                    set y2 = GetUnitY(t)
                    set dis = distance[lc]
                    set dam = damage[lc]
                        if DistanceBetweenPoints(Location(x2, y2), Location(x, y)) > 30 then
                            set ang = Atan2(y - y2, x - x2)
                            set x3 = x2 + dis * Cos (ang)
                            set y3 = y2 + dis * Sin (ang)
                            call SetUnitX(t, x3)
                            call SetUnitY(t, y3)
                        else
                            call PauseUnit(t, false)
                            call UnitDamageTarget(u, t, dam, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                            set distance[lc] = 0
                            set damage[lc] = 0
                            set caster[lc] = null
                            set target[lc] = null
                            set newCount = newCount - 1
                            if newCount == 0 then
                                set maxCount = 0
                                set newCount = 0
                                set lc       = 0
                            endif
                        endif
                exitwhen lc == maxCount
                endloop
        endif
    endfunction
    
    private function OnCast takes nothing returns nothing
        set maxCount = maxCount + 1
        set newCount = newCount + 1
        set caster[maxCount] = GetTriggerUnit()
        set target[maxCount] = GetSpellTargetUnit()
        call PauseUnit(target[maxCount], true)
            if multiplyDamage == true then
                set damage[maxCount] = spellDamage * GetUnitAbilityLevel(caster[maxCount], 'A005')
            else
                set damage[maxCount] = spellDamage
            endif
            
            if changeSpeed == true and multiplySpeed == true then
                call BJDebugMsg("|c00FF0000[Error]|r |c0000FF00 you must NOT put both changeSpeed, and multipleSpeed to true, cuz its impossible!|r")
            elseif changeSpeed == true then
                set distance[maxCount] = kbSpeed + (GetUnitAbilityLevel(caster[maxCount], 'A000') * speedChanged)
            elseif multiplySpeed == true then
                set distance[maxCount] = kbSpeed * GetUnitAbilityLevel(caster[maxCount], 'A000')
            elseif multiplySpeed == false and changeSpeed == false then
                set distance[maxCount] = kbSpeed
            endif
        
    endfunction
    
    private function OnCond takes nothing returns boolean
        return GetSpellAbilityId() == 'A000'
    endfunction
    
    private function OnInit takes nothing returns nothing
        local trigger DM = CreateTrigger()
            call TriggerRegisterAnyUnitEventBJ(DM, EVENT_PLAYER_UNIT_SPELL_EFFECT)
            call TriggerAddCondition(DM, Condition(function OnCond))
            call TriggerAddAction(DM, function OnCast)
                call TimerStart(CreateTimer(), 0.032, true, function OnLoop)
        set DM = null
    endfunction
endlibrary

it was as a request for some 1.

edit: oh yeah, its alot easier with structs, but theres a limit for structs because of the old crappy world editor =[
so i didnt bother using them, cuz he might reach the limit eventually, and this isnt a hard spell.
 
Status
Not open for further replies.
Top