• 🏆 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] I Use Struct for Indexing

Good or Bad?

  • Good

    Votes: 0 0.0%
  • Bad

    Votes: 0 0.0%

  • Total voters
    0
Status
Not open for further replies.
Level 14
Joined
Oct 19, 2014
Messages
187
I need your suggestion and thoughts if this kind of indexing is not bad.
probably I have to privatize the struct because they might have the same name of the others.
should I prefixed my structs?
is there a way to use a private struct?
JASS:
library thunder initializer init/*By JC Helas*/
    globals
        private unit target
        private trigger lt
        private items array it
    endglobals
    scope test
        struct items
            effect thunder
            real dur
        endstruct
        private struct node
            static integer i=0
            static method add takes nothing returns items
                set i=i+1
                set i:it=items.create()
                return i:it
            endmethod
            static method recycle takes items s returns nothing
                set s.dur=i:it.dur
                set s.thunder=i:it.thunder
                set s=i:it
                call s.destroy()
            endmethod
        endstruct
        function loops takes nothing returns nothing
            local integer l=1
            local items i
            loop
                exitwhen l>node.i
                set i=l:it
                set i.dur=i.dur-0.03125
                if i.dur<=0 then
                    call DestroyEffect(i.thunder)
                    call node.recycle(i)
                    set node.i=node.i-1
                    set l=l-1
                    if node.i==0 then
                        call DisableTrigger(lt)
                        call BJDebugMsg("it works men CheckDecode: "+I2S(node.i))
                    endif
                endif
                set l=l+1
            endloop
        endfunction
        function effects takes unit u,real x,real y returns nothing
            local items i=node.add()
            call BJDebugMsg("it works men CheckIncode: "+I2S(node.i))
            set i.dur=2
            set i.thunder=AddSpecialEffect("war3mapImported\\Lightnings Long.mdx",x,y)
            call DestroyEffect(AddSpecialEffect("war3mapImported\\NewDirtEXNofire.mdx",x,y))
            if node.i==1 then
                call EnableTrigger(lt)
                call BJDebugMsg("it works men CheckDur: "+R2S(it[1].dur))
            endif
        endfunction
        function test takes nothing returns nothing
            call effects(target,GetUnitX(target),GetUnitY(target))
        endfunction

        function init takes nothing returns nothing
            local trigger t=CreateTrigger()
            set target = CreateUnit(Player(0),'hpea',0,0,90)
            call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
            call TriggerAddAction(t,function test)
            set lt=CreateTrigger()
            call DisableTrigger(lt)
            call TriggerRegisterTimerEvent(lt,0.03125,true)
            call TriggerAddAction(lt,function loops)
        endfunction
    endscope
endlibrary
Credits to the owner of models.
test vjass.png
test vjass1.png

AND THIS ONE,, find my debug msg
JASS:
library stest initializer itest
    globals
        private unit target
        private trigger lp
    endglobals
    private struct stest
        private static unit u
        private static real d
        private static stest ix=0
        private static integer ixt=0
        private static method loops takes nothing returns nothing
            local real a
            local unit tu
            local stest i=1
            local integer it=1
            loop
                exitwhen it>ixt
                if i.d>0. then
                    set i.d=i.d-50.
                    set tu=i.u
                    set a=GetUnitFacing(tu)
                    call SetUnitX(tu,GetUnitX(tu)+50*Cos(a*bj_DEGTORAD))
                    call SetUnitY(tu,GetUnitY(tu)+50*Sin(a*bj_DEGTORAD))
                else
                    call RemoveUnit(i.u)
                    set i.u=ix.u
                    set i.d=ix.d
                    call BJDebugMsg(I2S(ix))
                    call BJDebugMsg(I2S(ixt))
                    set ixt=ixt-1
                    set ixt=ix-1
                    set it=it-1
                    set i=i-1
                    if ixt==0then
                        call DisableTrigger(lp)
                        call BJDebugMsg("fuck")
                    endif
                endif
                set it=it+1
            endloop
        endmethod
        private static method cal takes nothing returns nothing
            set ix=ix+1
            set ixt=ixt+1
            set ix.u=CreateUnit(Player(0),'hpea',GetUnitX(target),GetUnitY(target),GetUnitFacing(target))
            set ix.d=800
            if ixt==1then
                call EnableTrigger(lp)
            endif
        endmethod
        public static method init takes nothing returns nothing
            local trigger t=CreateTrigger()
            set lp=CreateTrigger()
            set target = CreateUnit(Player(0),'hpea',0,0,90)
            call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
            call TriggerAddAction(t,function stest.cal)
            call TriggerRegisterTimerEvent(lp,0.03125,true)
            call TriggerAddAction(lp,function stest.loops)
            call DisableTrigger(lp)
        endmethod
    endstruct
    private function itest takes nothing returns nothing
        call stest.init()
    endfunction
endlibrary
currently solving this,, hahays
 
Last edited:
Status
Not open for further replies.
Top