• 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.

[JASS] Strange error with ABC !

Status
Not open for further replies.
Hi all. Well, I am making a funny spell, called "Stupid penguin".
The idea is simple - we create a penguin, and because the penguin is really stupid and only wonders around the map .... we make him grow and kill him !! BOOMM damaging all nearby foes... (lol).
The more you channel the more damage you can deal .... stupid penguin =P
Problem is, I have this weird message error, and I dunno why =S
I am trying to finish the spell, to make it JESP, so the code is not much clean by now ....
I also notest only 1 unit gets affected .... and i don't know why ...

Can you guys help me out please ?
For the sake of the penguin !!! =P

JASS:
scope StupidPenguin initializer Init
   
   private struct Mystruct
        unit caster = GetTriggerUnit()
        unit penguin
        integer level
        real currentScale = 1
        timer t = CreateTimer()
        real grow
        trigger end = CreateTrigger()
        triggeraction endAction
        triggercondition endCondition
    endstruct
   
//!=========================================================================!\\
//!============================SETUP START==================================!\\
//!=========================================================================!\\

    globals
        private constant integer AID = 'A000'  //ability ID
        private constant integer UNITID = 'npng'
    endglobals
    
    
    
    private constant function GrowTime takes integer level returns integer time
        return 1 + (level * 0)
    endfunction
    
    private constant function Growth takes integer level returns real grow
        return 0.3 * level
    endfunction
    
    private constant function Radius takes integer level returns integer radius
        return 400 + (50 * level)
    endfunction
    
    private function Targets takes nothing returns boolean
        local Mystruct data = GetTriggerStructA(GetTriggeringTrigger()) //you should ignore this
        return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(data.caster))
    endfunction

//!=========================================================================!\\
//!============================SETUP END====================================!\\
//!=========================================================================!\\
    
//==========================================================================
    private function End_Conds takes nothing returns boolean
        return GetSpellAbilityId() == AID 
    endfunction
//==========================================================================
    private function End_Acts takes nothing returns nothing
        //catches the trigger and runs this function
        local Mystruct data = GetTriggerStructA(GetTriggeringTrigger())
        local group g = CreateGroup()
        local unit f
        local boolexpr b = Condition(function Targets) 
      
        call KillUnit(data.penguin)
        call GroupEnumUnitsInRange(g, GetUnitX(data.penguin), GetUnitY(data.penguin), Radius(data.level), b)
            
        loop
            set f = FirstOfGroup(g)
            exitwhen (f == null)
            call UnitDamageTarget(data.penguin, f, data.currentScale + 100, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
        endloop
            
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set b = null
        set g = null
        
        //removes the created trigger in the Code_acts function
        call TriggerRemoveCondition(data.end,data.endCondition)
        call TriggerRemoveAction(data.end,data.endAction)
        call DestroyTrigger(data.end)
        call ClearTriggerStructA(data.end)

        //stops the repeator timer and ends the spell once and for all
        call PauseTimer(data.t)
        call DestroyTimer(data.t)
        
        call ClearTimerStructA(data.t)
        call data.destroy()
    endfunction
//==========================================================================
    private function Size takes nothing returns nothing
        //catches the expired timer and runs this function
        local Mystruct data = GetTimerStructA(GetExpiredTimer())
        
        local group g
        local unit f
        local boolexpr b = Condition(function Targets) 
        
        if(GetWidgetLife(data.penguin) > 0.405) then
            call SetUnitScale(data.penguin, data.currentScale + data.grow, data.currentScale + data.grow, data.currentScale + data.grow) 
            set data.currentScale = data.currentScale + data.grow
        else
            set g = CreateGroup()
            call GroupEnumUnitsInRange(g, GetUnitX(data.penguin), GetUnitY(data.penguin), Radius(data.level), b)
            
            loop
                set f = FirstOfGroup(g)
                exitwhen (f == null)
                call UnitDamageTarget(data.penguin, f, data.currentScale + 100, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
            endloop
            
            call DestroyGroup(g)
        endif
        
        call DestroyBoolExpr(b)
        set b = null
        set g = null
    endfunction
//==========================================================================
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == AID
    endfunction
//===========================================================================
    private function Actions takes nothing returns nothing
        local Mystruct data = Mystruct.create()
        local location loc = GetSpellTargetLoc()
        
        set data.grow = Growth(GetUnitAbilityLevel(data.caster, AID))
        set data.penguin = CreateUnit(GetOwningPlayer(data.caster), UNITID, GetLocationX(loc), GetLocationY(loc), 0)
        set data.level = GetUnitAbilityLevel(data.caster, AID)
        
        call SetTimerStructA(data.t, data)
        call TimerStart(data.t, GrowTime(GetUnitAbilityLevel(data.caster, AID)), true, function Size)
        
        call RemoveLocation(loc)
        set loc = null
        
        //creates the trigger that will end the spell when the hero stops channeling
        call SetTriggerStructA(data.end, data)
        call TriggerRegisterAnyUnitEventBJ( data.end, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
        set data.endCondition = TriggerAddCondition( data.end, Condition( function End_Conds ) )
        set data.endAction = TriggerAddAction( data.end, function End_Acts )
    endfunction
//===========================================================================
    private function Init takes nothing returns nothing
        set gg_trg_Stupid_Penguin = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Stupid_Penguin, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
        call TriggerAddCondition( gg_trg_Stupid_Penguin, Condition( function Conditions ) )
        call TriggerAddAction( gg_trg_Stupid_Penguin, function Actions )
    endfunction
endscope

Oh, and I have this error screen shot =S

problem.jpg

Can you guys help me out please ?
 
Level 11
Joined
Apr 6, 2008
Messages
760
that not ABC error its from JNGP, happens (as i'v seen it, prolly for something else 2) when u dont exit a loop.

like here, u dont remove f from the group :p

JASS:
loop
    set f = FirstOfGroup(g)
    exitwhen (f == null)
    call UnitDamageTarget(data.penguin, f, data.currentScale + 100, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
endloop
 
Level 11
Joined
Apr 6, 2008
Messages
760
and wth is
JASS:
    private constant function GrowTime takes integer level returns integer time
        return 1 + (level * 0)
    endfunction
X*0 = 0 ^^

p.s can u find any problem with this spell? Spellzor


hey u stole ma //!=========================================================================!\\ xD
 
hey u stole ma
Lol, yes i kinda stoled it from you =P
But I gotta give credit, it is very useful to clean things up.

Btw, now I have other problem.
If you stop channeling the spell before it ends, I get a critical error and the program shuts down ='(
Help please !

JASS:
scope StupidPenguin initializer Init
   
   private struct Mystruct
        unit caster = GetTriggerUnit()
        unit penguin
        integer level
        real currentScale = 1
        timer t = CreateTimer()
        real grow
        trigger end = CreateTrigger()
        triggeraction endAction
        triggercondition endCondition
    endstruct
   
//!=========================================================================!\\
//!============================SETUP START==================================!\\
//!=========================================================================!\\

    globals
        private constant integer AID = 'A000'  //ability ID
        private constant integer UNITID = 'npng'
    endglobals
    
    
    
    private constant function GrowTime takes integer level returns integer time
        return 1 + (level * 0)
    endfunction
    
    private constant function Growth takes integer level returns real grow
        return 0.3 * level
    endfunction
    
    private constant function Radius takes integer level returns integer radius
        return 400 + (50 * level)
    endfunction
    
    private function Targets takes nothing returns boolean
        local Mystruct data = GetTriggerStructA(GetTriggeringTrigger()) //you should ignore this
        return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(data.caster))
    endfunction

//!=========================================================================!\\
//!============================SETUP END====================================!\\
//!=========================================================================!\\
    
//==========================================================================
    private function End_Conds takes nothing returns boolean
        return GetSpellAbilityId() == AID 
    endfunction
//==========================================================================
    private function End_Acts takes nothing returns nothing
        //catches the trigger and runs this function
        local Mystruct data = GetTriggerStructA(GetTriggeringTrigger())
        local group g = CreateGroup()
        local unit f
        local boolexpr b = Condition(function Targets) 
      
        if(GetWidgetLife(data.penguin) > 0.405) then
            call KillUnit(data.penguin)
        endif
        
        call GroupEnumUnitsInRange(g, GetUnitX(data.penguin), GetUnitY(data.penguin), Radius(data.level), b)
            
        loop
            set f = FirstOfGroup(g)
            exitwhen (f == null)
            call GroupRemoveUnit(g, f)
            call UnitDamageTarget(data.penguin, f, data.currentScale + 100, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
        endloop
            
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set b = null
        set g = null
        
        //removes the created trigger in the Code_acts function
        call TriggerRemoveCondition(data.end,data.endCondition)
        call TriggerRemoveAction(data.end,data.endAction)
        call DestroyTrigger(data.end)
        call ClearTriggerStructA(data.end)

        //stops the repeator timer and ends the spell once and for all
        call PauseTimer(data.t)
        call DestroyTimer(data.t)
        
        call ClearTimerStructA(data.t)
        call data.destroy()
    endfunction
//==========================================================================
    private function Size takes nothing returns nothing
        //catches the expired timer and runs this function
        local Mystruct data = GetTimerStructA(GetExpiredTimer())
        
        if(GetWidgetLife(data.penguin) > 0.405) then
            call SetUnitScale(data.penguin, data.currentScale + data.grow, data.currentScale + data.grow, data.currentScale + data.grow) 
            set data.currentScale = data.currentScale + data.grow
        else
            call IssueImmediateOrder(data.caster, "stop")
        endif
        
    endfunction
//==========================================================================
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == AID
    endfunction
//===========================================================================
    private function Actions takes nothing returns nothing
        local Mystruct data = Mystruct.create()
        local location loc = GetSpellTargetLoc()
        
        set data.grow = Growth(GetUnitAbilityLevel(data.caster, AID))
        set data.penguin = CreateUnit(GetOwningPlayer(data.caster), UNITID, GetLocationX(loc), GetLocationY(loc), 0)
        set data.level = GetUnitAbilityLevel(data.caster, AID)
        
        call SetTimerStructA(data.t, data)
        call TimerStart(data.t, GrowTime(GetUnitAbilityLevel(data.caster, AID)), true, function Size)
        
        call RemoveLocation(loc)
        set loc = null
        
        //creates the trigger that will end the spell when the hero stops channeling
        call SetTriggerStructA(data.end, data)
        call TriggerRegisterAnyUnitEventBJ( data.end, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
        set data.endCondition = TriggerAddCondition( data.end, Condition( function End_Conds ) )
        set data.endAction = TriggerAddAction( data.end, function End_Acts )
    endfunction
//===========================================================================
    private function Init takes nothing returns nothing
        set gg_trg_Stupid_Penguin = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Stupid_Penguin, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
        call TriggerAddCondition( gg_trg_Stupid_Penguin, Condition( function Conditions ) )
        call TriggerAddAction( gg_trg_Stupid_Penguin, function Actions )
    endfunction
endscope

Can you guys find here any reason for me to have a critical error "Memory could not be read" when i end the spell before time ??
I don't know what can possibly be wrong...
 
np, so how's your map coming up? anything i can do since im like bored :>?

Oh God ... so much work to do ....
Well, I still have to end the travel, reward, tourney systems, and I wanna complete the multiboard ...

This are the complex tasks ... However after I finish this I have to create a Baby seal spell for my hero dwarf ....
Tell me what you have in mind, and I may pick something good for you to do (you'll get credits)

strange work's just fine for me :/

also ur dmg dont increase the long you channel
You mean it doesn't crash for you ? strange ... i hope its not chache corruption again ...
Btw, the damage increases with channel ... thing is it increases 0.3 damage ... which is very very small, and people won't see it ... I gotta fix that soon, but right now, i really wanna make this not crash ...

I will post map your to test.
Please stop the channel by killing the penguin (press "k") before its normal time.
 

Attachments

  • SP.w3x
    36.3 KB · Views: 51
Level 9
Joined
Mar 25, 2005
Messages
252
The spell crashes because you based it off of Earthquake and removed it's Stats - Effects fields in the object editor. In other words the crash has nothing to do with your code. If you reset those fields to normal the spell won't crash.

Btw ordering the caster to stop screws up shift orders given to it. To fix that you can instead remove the spell from the caster and then give it back as well as reset it's level.
 
Status
Not open for further replies.
Top