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

[JASS] Fatal Error when map's start

Status
Not open for further replies.
Level 10
Joined
Jun 1, 2008
Messages
485
Umm, can I get some help from you guys?

Every time I test my map, before the map even loaded, wc3 will get fatal error.

I check my code, and nothing is wrong in my opinion.
I check the map's object editor stuff and dummy model, and still nothing seem wrong to me.

Anybody mind to help me?

P.S: The map
I use vJASS
Here's the code:
JASS:
scope ThunderBird initializer InitTrig_Initialize
    globals
        private constant integer SpellID        = 'A000'
        private constant integer DummyID        = 'n000'
        private constant string DummyAttach     = "chest"
        
        private constant real Duration          = 5.
        private constant real DurationIncr      = 5.
        private constant real EggDuration       = 1.
        private constant real EggDurationIncr   = 0.5
        
        private constant real BirdHeight        = 100
        private constant real PassingBirdHeight = 400
        
        private constant real Damage            = 50.
        private constant real DamageIncr        = 25.
        private constant real ManaDmg           = 50.
        private constant real ManaIncr          = 25.
        
        private constant real SlowAmount        = 0.25
        private constant real SlowIncr          = 0.1
        private constant real SlowDur           = 1.
        private constant real SlowDurIncr       = 0.5
        
        private constant integer BirdSum        = 3
        private constant integer BirdIncr       = 1
        
        private constant real AoE               = 250.
        private constant real AoEIncr           = 100.
        private constant real ManaAoE           = 100.
        private constant real ManaAoEIncr       = 25.
        
        private constant real MoveSpeed         = 50.
        private constant real AngSpeed          = 0.25
        
        private constant string BirdModel       = "Abilities\\Weapons\\KeeperGroveMissile\\KeeperGroveMissile.mdl"
        private constant string PassBirdModel   = "units\\human\\phoenix\\phoenix.mdl"
        private constant string EggModel        = "Units\\Human\\Phoenix\\PhoenixEgg.mdl"
        private constant string AttachEffect    = "Abilities\\Spells\\Orc\\Purge\\PurgeBuffTarget.mdl"
        private constant string DeathEffect     = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl"
        private constant string BirthEffect     = "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl"
        private constant string DmgEffect       = "Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl"
        private constant string ManaEffect      = "Abilities\\Weapons\\ProcMissile\\ProcMissile.mdl"
        private constant string BuffEffect      = "Abilities\\Spells\\Items\\AIlb\\AIlbSpecialArt.mdl"
        
        private constant real TimeOut           = 0.01
                                                
        private constant attacktype ATT         = ATTACK_TYPE_NORMAL
        private constant damagetype DGT         = DAMAGE_TYPE_NORMAL
        private constant weapontype WPT         = WEAPON_TYPE_WHOKNOWS
        
        private real array R
    endglobals
    private struct Struct3
        unit Affected
        real SlowAmount
        real TimeLeft
        effect Sfx
        
        static group Buffed
        
        static Struct3 array Index
        static integer Total
        static timer Timer
        
        static method Loop takes nothing returns nothing
            local Struct3 dat
            local integer i = 0
            loop
                exitwhen i >= Struct3.Total
                set dat = Struct3.Index[i]
                set dat.TimeLeft = dat.TimeLeft-TimeOut
                if dat.TimeLeft <= 0. then
                    call SetUnitMoveSpeed(dat.Affected,GetUnitMoveSpeed(dat.Affected)+dat.SlowAmount)
                    call DestroyEffect(dat.Sfx)
                    if IsUnitInGroup(dat.Affected,Struct3.Buffed) then
                        call GroupRemoveUnit(Struct3.Buffed,dat.Affected)
                    endif
                    call dat.destroy()
                    set Struct3.Total = Struct3.Total-1
                    set Struct3.Index[i] = Struct3.Index[Struct3.Total]
                    set i = i-1
                endif
                set i = i+1
            endloop
        endmethod
        
        static method Create takes unit u, real SlowAmount, real Duration, string Sfx returns nothing
            local Struct3 dat = Struct3.allocate()
            set dat.Affected = u
            call SetUnitMoveSpeed(u,GetUnitMoveSpeed(u)-SlowAmount)
            set dat.SlowAmount = SlowAmount
            set dat.TimeLeft = Duration
            set dat.Sfx = AddSpecialEffectTarget(Sfx,u,"chest")            
            if Struct3.Total == 0 then
                call TimerStart(Struct3.Timer,TimeOut,true,function Struct3.Loop)
            endif
            set Struct3.Index[Struct3.Total] = dat
            set Struct3.Total = Struct3.Total+1
        endmethod
    endstruct
    private struct Struct1
        unit Caster
        unit Bird
        unit Target
        real Angle
        real UnitX
        real UnitY
        real CentralX
        real CentralY
        real TimeLeft
        real HatchTime
        integer ActID
        integer level
        effect Sfx
        effect Sfx2
        
        static unit Temp
        
        static Struct1 array Index
        static integer Total
        static timer Timer
        
        static method IsEnemy takes nothing returns boolean
            return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(Struct1.Temp))
        endmethod
        
        static method Loop takes nothing returns nothing
            local Struct1 dat
            local integer i = 0
            local group g
            local unit u            
            loop
                exitwhen i >= Struct1.Total
                set dat = Struct1.Index[i]
                set dat.TimeLeft = dat.TimeLeft-TimeOut
                if dat.ActID == 0 then
                    set dat.HatchTime = dat.HatchTime-TimeOut
                    set Struct1.Temp = dat.Caster
                    call GroupEnumUnitsInRange(g,GetUnitX(dat.Bird),GetUnitY(dat.Bird),ManaAoE+(ManaAoEIncr*dat.level),Condition(function Struct1.IsEnemy))
                    loop
                        set u = FirstOfGroup(g)
                        exitwhen u == null
                        call GroupRemoveUnit(g,u)           
                        call SetUnitState(u,UNIT_STATE_MANA,GetUnitState(u,UNIT_STATE_MANA)-((ManaDmg+(ManaIncr*dat.level))*TimeOut))     
                        call AddSpecialEffect(ManaEffect,GetUnitX(u),GetUnitY(u))
                    endloop
                    set Struct1.Temp = null
                    if dat.HatchTime <= 0. then
                        call DestroyEffect(AddSpecialEffect(BirthEffect,GetUnitX(dat.Bird),GetUnitY(dat.Bird))) 
                        call DestroyEffect(dat.Sfx)
                        set dat.Sfx = AddSpecialEffectTarget(BirdModel,dat.Bird,DummyAttach)
                        set dat.Sfx2 = AddSpecialEffectTarget(AttachEffect,dat.Bird,DummyAttach)
                        call SetUnitFlyHeight(dat.Bird,BirdHeight,100.)
                        set dat.ActID = 1
                    endif
                elseif dat.ActID == 1 then
                    set R[0] = Atan2(dat.UnitY-GetUnitY(dat.Bird),dat.UnitX-GetUnitX(dat.Bird))    
                    set R[1] = GetUnitX(dat.Bird)+MoveSpeed*Cos(R[0])
                    set R[2] = GetUnitY(dat.Bird)+MoveSpeed*Cos(R[0])                    
                    call SetUnitX(dat.Bird,R[1])
                    call SetUnitY(dat.Bird,R[2])
                    call SetUnitFacing(dat.Bird,bj_RADTODEG*R[0])
                    set R[3] = R[1]-dat.UnitX
                    set R[4] = R[2]-dat.UnitY             
                    if  SquareRoot(R[3]*R[3]+R[4]*R[4]) <= 50. then
                        set dat.ActID = 2
                    endif
                elseif dat.ActID == 2 then
                    set dat.Angle = dat.Angle+AngSpeed
                    set dat.UnitX = dat.CentralX+(AoE+AoEIncr*dat.level)*Cos(dat.Angle*bj_DEGTORAD)
                    set dat.UnitY = dat.CentralY+(AoE+AoEIncr*dat.level)*Sin(dat.Angle*bj_DEGTORAD)            
                    call SetUnitX(dat.Bird,dat.UnitX)
                    call SetUnitY(dat.Bird,dat.UnitY)
                    call SetUnitFacing(dat.Bird,dat.Angle+90.)
                    set Struct1.Temp = dat.Caster
                    call GroupEnumUnitsInRange(g,dat.CentralX,dat.CentralY,AoE+(AoEIncr*dat.level),Condition(function Struct1.IsEnemy))
                    loop                        
                        set u = FirstOfGroup(g)
                        exitwhen u == null
                        call GroupRemoveUnit(g,u)
                        if not IsUnitInGroup(u,Struct3.Buffed) and dat.Target == null then
                            call GroupAddUnit(Struct3.Buffed,u)
                            set dat.Target = u
                            set dat.ActID = 3
                        endif
                    endloop
                    set Struct1.Temp = null
                    if dat.Angle >= 360. then
                        set dat.Angle = dat.Angle-360.
                    endif
                elseif dat.ActID == 3 then
                    set dat.Angle = dat.Angle+AngSpeed
                    set dat.UnitX = dat.CentralX+(AoE+AoEIncr*dat.level)*Cos(dat.Angle*bj_DEGTORAD)
                    set dat.UnitY = dat.CentralY+(AoE+AoEIncr*dat.level)*Sin(dat.Angle*bj_DEGTORAD)            
                    set R[0] = Atan2(GetUnitY(dat.Target)-GetUnitY(dat.Bird),GetUnitX(dat.Target)-GetUnitX(dat.Bird))
                    set R[1] = GetUnitX(dat.Bird)+MoveSpeed*Cos(R[0])
                    set R[2] = GetUnitY(dat.Bird)+MoveSpeed*Sin(R[0])
                    set R[3] = GetUnitX(dat.Target)-GetUnitX(dat.Bird)
                    set R[4] = GetUnitY(dat.Target)-GetUnitY(dat.Bird)
                    set R[5] = SquareRoot(R[3]*R[3]+R[4]*R[4])
                    call SetUnitX(dat.Bird,R[1])
                    call SetUnitY(dat.Bird,R[2])
                    call SetUnitFacing(dat.Bird,bj_RADTODEG*R[0])
                    if R[5] <= 100 then
                        call DestroyEffect(AddSpecialEffect(DmgEffect,GetUnitX(dat.Target),GetUnitY(dat.Target)))
                        call UnitDamageTarget(dat.Caster,dat.Target,Damage+(DamageIncr*dat.level),true,false,ATT,DGT,WPT)
                        call Struct3.Create(dat.Target,GetUnitMoveSpeed(dat.Target)*(SlowAmount+(SlowIncr*dat.level)),SlowDur+(SlowDurIncr*dat.level),BuffEffect)
                        set dat.Target = null
                        set dat.ActID = 4
                    endif
                    if dat.Angle >= 360. then
                        set dat.Angle = dat.Angle-360.
                    endif
                elseif dat.ActID == 4 then
                    set dat.Angle = dat.Angle+AngSpeed
                    set dat.UnitX = dat.CentralX+(AoE+AoEIncr*dat.level)*Cos(dat.Angle*bj_DEGTORAD)
                    set dat.UnitY = dat.CentralY+(AoE+AoEIncr*dat.level)*Sin(dat.Angle*bj_DEGTORAD)            
                    set R[0] = Atan2(GetUnitY(dat.Bird)-dat.UnitY,GetUnitX(dat.Bird)-dat.UnitX)
                    set R[1] = GetUnitX(dat.Bird)+MoveSpeed*Cos(R[0])
                    set R[2] = GetUnitY(dat.Bird)+MoveSpeed*Sin(R[0])
                    set R[3] = GetUnitX(dat.Bird)-dat.UnitX
                    set R[4] = GetUnitY(dat.Bird)-dat.UnitY
                    set R[5] = SquareRoot(R[3]*R[3]+R[4]*R[4])
                    call SetUnitX(dat.Bird,R[1])
                    call SetUnitY(dat.Bird,R[2])
                    call SetUnitFacing(dat.Bird,bj_RADTODEG*R[0])
                    if R[5] <= 100 then
                        call SetUnitX(dat.Bird,dat.UnitX)
                        call SetUnitY(dat.Bird,dat.UnitY)
                        call SetUnitFacing(dat.Bird,dat.Angle+90.)
                        set dat.ActID = 2
                    endif
                    if dat.Angle >= 360. then
                        set dat.Angle = dat.Angle-360.
                    endif
                endif
                if dat.TimeLeft <= 0 then
                    call DestroyEffect(AddSpecialEffectTarget(DeathEffect,dat.Bird,DummyAttach))
                    call DestroyEffect(dat.Sfx)
                    call DestroyEffect(dat.Sfx2)
                    set dat.Caster = null
                    set dat.Bird = null
                    set dat.Target = null
                    call RemoveUnit(dat.Bird)
                    call dat.destroy()
                    set Struct1.Total = Struct1.Total-1                    
                    set Struct1.Index[i] = Struct1.Index[Struct1.Total]                    
                    set i = i-1
                endif
                set i = i+1                 
            endloop
            set g = null
            set u = null
            if Struct1.Total == 0 then
                call PauseTimer(Struct1.Timer)
            endif
        endmethod
        
        static method Start takes unit Caster, real BirdSum, real Counter, real X, real Y, real Time, real Time2, integer level returns nothing
            local Struct1 dat = Struct1.allocate()
            set dat.Caster = Caster
            set dat.ActID = 0
            set dat.level = level
            set dat.Angle = (360/BirdSum)*Counter
            set dat.TimeLeft = Time
            set dat.HatchTime = Time2
            set dat.CentralX = X
            set dat.CentralY = Y
            set dat.UnitX = X+(AoE+AoEIncr*level)*Cos(dat.Angle*bj_DEGTORAD)
            set dat.UnitY = Y+(AoE+AoEIncr*level)*Sin(dat.Angle*bj_DEGTORAD)
            set R[1] = GetSpellTargetX()+GetRandomReal(0.,AoE+(AoEIncr*level))*Cos(GetRandomReal(0.,360.)*bj_DEGTORAD)
            set R[2] = GetSpellTargetY()+GetRandomReal(0.,AoE+(AoEIncr*level))*Sin(GetRandomReal(0.,360.)*bj_DEGTORAD)
            set dat.Bird = CreateUnit(GetOwningPlayer(Caster),DummyID,R[1],R[2],0.)
            call UnitAddAbility(dat.Bird,'Arav')
            call UnitRemoveAbility(dat.Bird,'Arav')
            call SetUnitFlyHeight(dat.Bird,0.,0.)
            set dat.Sfx = AddSpecialEffectTarget(EggModel,dat.Bird,DummyAttach)            
            if dat.Total == 0 then
                call TimerStart(Struct1.Timer, TimeOut, true, function Struct1.Loop)
            endif
            set Struct1.Index[Struct1.Total] = dat
            set Struct1.Total = Struct1.Total+1
        endmethod        
    endstruct
    
    private struct Struct2
        unit Caster
        unit PassingBird
        real CentralX
        real CentralY
        integer level
        real Time
        real Time2
        effect Sfx
        
        static Struct2 array Index
        static integer Total
        static timer Timer
        
        static method Loop takes nothing returns nothing
            local Struct2 dat
            local integer i = 0
            loop
                exitwhen i == Struct2.Total
                set dat = Struct2.Index[i]
                set R[0] = GetUnitFacing(dat.PassingBird)
                set R[1] = GetUnitX(dat.PassingBird)+MoveSpeed*Cos(R[0]*bj_DEGTORAD)
                set R[2] = GetUnitY(dat.PassingBird)+MoveSpeed*Sin(R[0]*bj_DEGTORAD)
                set R[3] = dat.CentralX-R[1]
                set R[4] = dat.CentralY-R[2]
                set R[5] = SquareRoot(R[3]*R[3]+R[4]*R[4])
                call SetUnitX(dat.PassingBird,R[1])
                call SetUnitY(dat.PassingBird,R[2])
                if R[5] <= 100. then
                    set R[7] = BirdSum+(BirdIncr*R[6])
                    set R[8] = 0
                    loop
                        exitwhen R[8] == R[9]
                        call Struct1.Start(dat.PassingBird,R[7],R[8],dat.CentralX,dat.CentralY,dat.Time,dat.Time2,dat.level)
                        set R[8] = R[8]+1
                    endloop
                    call DestroyEffect(AddSpecialEffectTarget(DeathEffect,dat.PassingBird,DummyAttach))
                    call DestroyEffect(dat.Sfx)
                    call RemoveUnit(dat.PassingBird)
                    call dat.destroy()
                    set Struct2.Total = Struct2.Total-1
                    set Struct2.Index[i] = Struct2.Index[Struct2.Total]
                    set i = i-1    
                endif
                set i = i+1
            endloop
            if Struct2.Total == 0 then
                call PauseTimer(Struct2.Timer)
            endif
        endmethod
        
        static method Create takes nothing returns nothing
            local Struct2 dat = Struct2.allocate()
            local unit u = GetTriggerUnit()
            set dat.Caster = u
            set dat.level = GetUnitAbilityLevel(u,SpellID)-1
            set dat.CentralX = GetSpellTargetX()
            set dat.CentralY = GetSpellTargetY()
            set dat.Time = Duration+(DurationIncr*dat.level)
            set dat.Time2 = EggDuration+(EggDurationIncr*R[0])
            set dat.PassingBird = CreateUnit(GetOwningPlayer(u),DummyID,GetUnitX(u),GetUnitY(u),0.)
            call UnitAddAbility(dat.PassingBird,'Arav')
            call UnitRemoveAbility(dat.PassingBird,'Arav')
            call SetUnitFlyHeight(dat.PassingBird,PassingBirdHeight,0.)
            set dat.Sfx = AddSpecialEffectTarget(PassBirdModel,dat.PassingBird,DummyAttach)
            call DestroyEffect(AddSpecialEffectTarget(BirthEffect,dat.PassingBird,DummyAttach))
            if dat.Total == 0 then
                call TimerStart(Struct2.Timer,TimeOut,true,function Struct2.Loop)
            endif
            set Struct2.Index[Struct2.Total] = dat
            set Struct2.Total = Struct2.Total+1
        endmethod      
    endstruct
    private function Conditions takes nothing returns boolean       
        return GetSpellAbilityId() == SpellID
    endfunction

    private function Actions takes nothing returns nothing
        call Struct2.Create()
    endfunction

    private function ReturnTrue takes nothing returns boolean
        return true
    endfunction
    
    private function InitTrig_Initialize takes nothing returns nothing
        local trigger t = CreateTrigger()         
        local integer index = 0
        loop
            exitwhen index == bj_MAX_PLAYER_SLOTS
            set index = index+1
            call TriggerRegisterPlayerUnitEvent(t,Player(index),EVENT_PLAYER_UNIT_SPELL_EFFECT,Filter(function ReturnTrue))
        endloop
        call TriggerAddCondition(t, Condition(function Conditions))
        call TriggerAddAction(t, function Actions)
    endfunction
endscope

~Mage_Goo
 
Level 15
Joined
Aug 11, 2009
Messages
1,606
There are 2 possible causes...
1st) A corrupted imported file,which leads to crash.
2nd) There are a few errors in code that should be avoided,judging from the point you mentioned that you get your crash in the loading screen it's probably a trigger's fault that is running on map initialization.

Oh by the way,make sure you test it in other computers,too.
 
Level 10
Joined
Jun 1, 2008
Messages
485
There are 2 possible causes...
1st) A corrupted imported file,which leads to crash.
well, I've try disable my spell's trigger and it start normally, so the problem is the trigger.

2nd) There are a few errors in code that should be avoided,judging from the point you mentioned that you get your crash in the loading screen it's probably a trigger's fault that is running on map initialization.
maybe you're right, but I'm just can't find anything wrong in my code.:con:

Oh by the way,make sure you test it in other computers,too.
well, can you do that for me:cute:?
I currently can't test it on my other PC.:sad:
 
Level 13
Joined
Mar 16, 2008
Messages
941
  • local integer index = 0
    • loop
      • exitwhen index == bj_MAX_PLAYER_SLOTS
      • set index = index+1
      • call TriggerRegisterPlayerUnitEvent(t,Player(index)...
This reaches player(16) and causes the crash. (Players are from 0-15)
  • local integer index = 0
    • loop
      • call TriggerRegisterPlayerUnitEvent(t,Player(index)...
      • set index = index+1
      • exitwhen index == bj_MAX_PLAYER_SLOTS
Use this one :)
 
Status
Not open for further replies.
Top