• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[vJASS] not mui

Status
Not open for further replies.
Level 5
Joined
Sep 16, 2008
Messages
47
Hi, i got a problem because spell i created is not mui for unknow reason and game is crashing sometimes.

here is code:

JASS:
scope Multishoot /* version 1.0
****************************************************************************************************************************************
*
*           Requires:
*          - GroupUtils
*
*
*
*
*
*
*
*
*
*
*
*
*
*
****************************************************************************************************************************************/

    globals
        private constant integer SPELL_CODE = 'A000'
        private constant integer DUMMY_CODE = 'u001'
        private constant integer AMMOUT = 7
       
        private constant real CREATE_DIST = 75
        private constant real ANGLE_MAX = 45
       
        private constant real DUMMY_HEIGHT = 75
        private constant real DUMMY_SIZE = 100
       
        private constant real DAMAGE_RANGE = 35
        private constant string DAMAGE_EFFECT_ATTACH = "chest"
        private constant string DAMAGE_EFFECT = "Abilities\\Spells\\Other\\BlackArrow\\BlackArrowMissile.mdl"
       
        private constant boolean COLLIDE = true
       
        private constant attacktype ATTACK_TYPE = ATTACK_TYPE_MAGIC
        private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_DEATH
    endglobals
   
/*********************************************************************************/
/*********************************************************************************/
   
    globals
        private constant real array M_DAMAGE
        private constant real array M_SPEED
        private constant real array M_DISTANCE
    endglobals
   
/*********************************************************************************/
/*********************************************************************************/
   
    private function onConfig takes nothing returns nothing
   
        set M_DAMAGE[1] = 15
        set M_DAMAGE[2] = 30
        set M_DAMAGE[3] = 45
       
        set M_DISTANCE[1] = 800
        set M_DISTANCE[2] = 900
        set M_DISTANCE[3] = 1000
       
        set M_SPEED[1] = 500
        set M_SPEED[2] = 550
        set M_SPEED[3] = 600
   
    endfunction
   
/*********************************************************************************/
/*********************************************************************************/
   
    globals
        private constant real INTERVAL = 0.031250
        private constant timer TIMER = CreateTimer()
    endglobals
   
/*********************************************************************************/
/*********************************************************************************/
   
    private struct Multishoot
       
        private thistype next
        private thistype prev

        private static integer count = 0
       
        private static unit caster
        private static player owner
       
        private static real speed
        private static real damage
       
        private static integer left
       
        private static group IgnoreGroup
       
        private static unit array dummy
        private static real array distance
        private static real array angle
        private static group array DamageGroup
       
        private method onDestroy takes nothing returns nothing

            call this.deallocate()

            set this.next.prev = this.prev
            set this.prev.next = this.next

            set count = count - 1
            if count == 0 then
                call PauseTimer(TIMER)
            endif

        endmethod
       
        private static method onLoop takes nothing returns nothing
       
            local thistype this = thistype(0).next
           
            local integer i = 0
            local real dx
            local real dy
            local real mx
            local real my
            local unit D
           
            loop
           
                exitwhen this == 0
               
                loop
                    exitwhen i == AMMOUT
                   
                    set dx = GetUnitX(this.dummy[i])
                    set dy = GetUnitY(this.dummy[i])
                   
                    set mx = dx + this.speed * Cos(this.angle[i])
                    set my = dy + this.speed * Sin(this.angle[i])
                   
                    call SetUnitX(this.dummy[i], mx)
                    call SetUnitY(this.dummy[i], my)
                   
                    set this.DamageGroup[i] = NewGroup()
                   
                    call GroupUnitsInArea(this.DamageGroup[i], mx, my, DAMAGE_RANGE)
                   
                    loop
                   
                        set D = FirstOfGroup(this.DamageGroup[i])
                   
                        exitwhen D == null
                       
                        if IsUnitInGroup(D, this.IgnoreGroup) == false and IsUnitAlly(D, this.owner) == false then
                       
                            call UnitDamageTarget(this.caster, D, this.damage, false, true, ATTACK_TYPE, DAMAGE_TYPE, null)
                            call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, D, DAMAGE_EFFECT_ATTACH))
                            call GroupAddUnit(this.IgnoreGroup, D)
                           
                            if COLLIDE then
                           
                                set this.distance[i] = this.distance[i] - this.distance[i]
                           
                            endif
                       
                        endif
                       
                        call GroupRemoveUnit(this.DamageGroup[i], D)
                       
                    endloop
                   
                    call ReleaseGroup(this.DamageGroup[i])
                   
                    set this.distance[i] = this.distance[i] - this.speed
                   
                    if this.distance[i] <= 0 then
                   
                        call KillUnit(this.dummy[i])
                        set this.dummy[i] = null
                        set this.left = this.left - 1
                   
                    endif
                   
                    set i = i + 1
                   
                endloop
               
                if this.left == 0 then
               
                    call this.onDestroy()
                    set this.caster = null
                    call ReleaseGroup(this.IgnoreGroup)
               
                endif
               
                set this = this.next
               
            endloop
           
        endmethod
       
        private static method onCast takes nothing returns boolean
       
            local thistype this = thistype.allocate()
           
            local integer i = 0
            local integer level
            local real cx
            local real cy
            local real tx
            local real ty
            local real crx
            local real cry
            local real angles
            local real anglesinc
            local unit u

            set this.next = 0
            set this.prev = thistype(0).prev
            set thistype(0).prev.next = this
            set thistype(0).prev = this

            set count = count + 1
            if count == 1 then
                call TimerStart(TIMER, INTERVAL, true, function thistype.onLoop)
            endif
           
            set this.caster = GetTriggerUnit()
            set this.owner = GetOwningPlayer(this.caster)
            set level = GetUnitAbilityLevel(this.caster, SPELL_CODE)
           
            set this.damage = M_DAMAGE[level]
            set this.speed = M_SPEED[level] * INTERVAL
            set this.left = AMMOUT
            set this.IgnoreGroup = NewGroup()
           
            set cx = GetUnitX(this.caster)
            set cy = GetUnitY(this.caster)
            set tx = GetSpellTargetX()
            set ty = GetSpellTargetY()
           
            set angles = Atan2(ty - cy, tx- cx) - ANGLE_MAX
            set anglesinc = ANGLE_MAX * 2 / AMMOUT
           
            loop
           
                exitwhen i == AMMOUT
           
                set crx = cx + CREATE_DIST * Cos(angles)
                set cry = cy + CREATE_DIST * Sin(angles)
               
                set u = CreateUnit(this.owner, DUMMY_CODE, crx, cry, GetUnitFacing(this.caster) + angles)
               
                call SetUnitFlyHeight(u, DUMMY_HEIGHT, 0)
                call SetUnitScale(u, DUMMY_SIZE * 0.01, DUMMY_SIZE * 0.01, DUMMY_SIZE * 0.01)
               
                set this.dummy[i] = u
                set this.angle[i] = angles
                set this.distance[i] = M_DISTANCE[level]
               
                set angles = angles + anglesinc
               
                set i = i + 1
               
            endloop
       
            return false
       
        endmethod        
       
        private static method onInit takes nothing returns nothing
            local trigger t = CreateTrigger()
           
            call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
            call TriggerAddCondition(t, Condition(function thistype.onCast))
           
            call onConfig()
           
            set t = null
           
        endmethod
       
    endstruct
   
   
endscope
 
You're using static variables for all your data, and static arrays for dummy/angle/distance. Static variables are no different from a regular global variable, and a global variable (non-array) can only point to one value at a time. Each time the spell is cast, those values are replaced. Try removing the static keyword and adapting from there:
JASS:
        private unit caster
        private player owner
       
        private real speed
        private real damage
       
        private integer left
       
        private group IgnoreGroup
       
        private unit array dummy[AMMOUT]
        private real array distance[AMMOUT]
        private real array angle[AMMOUT]
        private group array DamageGroup[AMMOUT]
 
Status
Not open for further replies.
Top