Frustration with this jass script

Status
Not open for further replies.

thevoden

New Member
Reaction score
5
I am getting this message everytime I use this custom spell in my map

"Double free of type: jData"

Here is the Jass Script
JASS:
//=====================================================================//
//                             Poison Javelin                          //
//=====================================================================//
//by emootootoo                                                        //
//                                                                     //
// Requires: vJass, CSData, CSSafety                                   //
//                                                                     //
// Things you need to copy:                                            //
// Abilities: Poison Javelin, PjavPoisonCloud                          //
// Units: JavelinDummy, Poison Cloud                                   //
// Buffs: Poisoned                                                     //
//                                                                     //
// Description: Throws a poisonous javelin that leaves a trail of      //
// poison, poisoning enemies in it. When the javelin hits an enemy,    //
// it stops and deals damage to them.                                  //
//=====================================================================//

scope PoisonJavelin

globals // Configuration

    private integer spellID='A009'
    //'Poison Javelin' Ability ID
    private integer PJcloudID='A00A'
    //'PJavPoisonCloud' Ability ID
    private integer dummyjavID='h001'
    //The 'JavelinDummy' unit's ID
    private integer dummycloudID='h002'
    //The 'Poison Cloud' unit's ID
    private string HitArt="Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
    //The art on the unit that gets hit by the javelin
    private real hSpeed=0.03
    //Speed javelin travels
    private real jDistance=1000
    //Distance the Javelin travels
    private real jCloudTime=5.
    //Amount of time poison clouds stay on the groudn before being removed
    private real jDamage=25
    //Damage per level of Impact Damage (not poison damage)
    //Note: Poison Damage and duration are altered in the ability 'PJavPoisonCloud'
    
endglobals // End configuration

//Code =====================================================================

struct jData
    public unit jUnit
    public unit jCaster
    public integer count
    public integer slvl
endstruct

function Trig_PoisonJavelin_Conditions takes nothing returns boolean
    return GetSpellAbilityId()==spellID
endfunction

function PoisonJavelinTimer takes nothing returns nothing
    local jData jD = GetCSData(GetExpiredTimer())
    local group g=CreateGroup()
    local unit u
    local unit tempu
    local integer tempint=0
    local location dummypos=GetUnitLoc(jD.jUnit)
    local real x=GetLocationX(dummypos)+20*Cos(GetUnitFacing(jD.jUnit)*bj_DEGTORAD)
    local real y=GetLocationY(dummypos)+20*Sin(GetUnitFacing(jD.jUnit)*bj_DEGTORAD)
    
    if jD.count<=jDistance/20 then
        call SetUnitPosition(jD.jUnit,x,y)
        set jD.count=jD.count+1
        if ModuloInteger(jD.count,2)==0 then
            set tempu=CreateUnit(GetOwningPlayer(jD.jCaster),dummycloudID,x,y,0)
            call UnitAddAbility(tempu,PJcloudID)
            call SetUnitAbilityLevel(tempu,PJcloudID,jD.slvl)
            call UnitApplyTimedLife(tempu,'BTLF',jCloudTime)
        endif
    else
        call jD.destroy()
        call ReleaseTimer(GetExpiredTimer())
        call RemoveUnit(jD.jUnit)
    endif
    
    
    call GroupEnumUnitsInRange(g,GetUnitX(jD.jUnit),GetUnitY(jD.jUnit),90,null)
    loop
        set u = FirstOfGroup(g)
        exitwhen u==null
        if IsUnitEnemy(u,GetOwningPlayer(jD.jCaster))==true and IsUnitType(u,UNIT_TYPE_STRUCTURE)==false and GetUnitState(u,UNIT_STATE_LIFE)>0 then
            set tempint=tempint+1
            call UnitDamageTarget(jD.jCaster,u,jDamage*jD.slvl,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_NORMAL,null)
            call AddSpecialEffectTarget(HitArt,u,"chest")
        endif
        call GroupRemoveUnit(g,u)
    endloop
    call DestroyGroup(g)
    set g = null
    
    if tempint>0 then
        set jD.count=R2I((jDistance/20))+1
    endif
    
    call RemoveLocation(dummypos)
    set dummypos=null
    set tempu=null
endfunction

function Trig_PoisonJavelin_Actions takes nothing returns nothing
    local jData jD=hData.create()
    local unit caster=GetTriggerUnit()
    local location tpoint=GetSpellTargetLoc()
    local location castpos=GetUnitLoc(caster)
    local real angle=bj_RADTODEG * Atan2(GetLocationY(tpoint) - GetLocationY(castpos), GetLocationX(tpoint) - GetLocationX(castpos))
    local timer t = NewTimer()
    local real x=GetLocationX(castpos)+50*Cos(angle*bj_DEGTORAD)
    local real y=GetLocationY(castpos)+50*Sin(angle*bj_DEGTORAD)
    local unit u=CreateUnit(GetOwningPlayer(caster),dummyjavID,x,y,angle)
    

    set jD.count=0
    set jD.slvl=GetUnitAbilityLevel(caster,spellID)
    set jD.jCaster=caster
    set jD.jUnit=u
    call SetUnitUserData(jD.jUnit, jD)
    
    call SetCSData(t,jD)
    call TimerStart(t,hSpeed,true,function PoisonJavelinTimer)
    
    set caster=null
    set u=null
    call RemoveLocation(tpoint)
    set tpoint=null
    call RemoveLocation(castpos)
    set castpos=null
    set t=null
endfunction

endscope
//===========================================================================
function InitTrig_PoisonJavelin takes nothing returns nothing
    set gg_trg_PoisonJavelin = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_PoisonJavelin, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_PoisonJavelin, Condition( function Trig_PoisonJavelin_Conditions ) )
    call TriggerAddAction( gg_trg_PoisonJavelin, function Trig_PoisonJavelin_Actions )
endfunction


I cannot seem to find where I would remove that message.

Here are the other 3 triggers that seem to compliment it:

JASS:
//Just needs to be copied into your map if you don't already have it.

library CSData

    globals
        gamecache               cs_cache   = null
        integer array           cs_array
        gamecache               udg_cscache = null
    endglobals

    
    function CS_H2I takes handle h returns integer
        return h
        return 0
    endfunction

    
    function SetCSData takes handle h, integer v returns nothing
     local integer i=CS_H2I(h)-0x100000
        if (i>=8191) then
            call StoreInteger(cs_cache,"csdata",I2S(i),v)
        else
            set cs_array<i>=v
        endif
    endfunction

    function GetCSData takes handle h returns integer
     local integer i=CS_H2I(h)-0x100000
        if (i&gt;=8191) then
            return GetStoredInteger(cs_cache,&quot;csdata&quot;,I2S(i))
        endif
     return cs_array<i>
    endfunction
    
endlibrary</i></i>


JASS:
//Just needs to be copied into your map if you don&#039;t already have it.

library CSSafety

    globals
        private timer array T
        private integer N = 0
    endglobals

    
    function NewTimer takes nothing returns timer
        if (N==0) then
            return CreateTimer()
        endif
    set N=N-1
    return T[N]
    endfunction


    function ReleaseTimer takes timer t returns nothing
        call PauseTimer(t)
        if (N==8191) then
            call DestroyTimer(t)
        else
            set T[N]=t
            set N=N+1
        endif    
    endfunction

endlibrary

function InitTrig_CSSafety_Copy takes nothing returns nothing
endfunction


And for some odd reason, if I disable this trigger below; it won't let me save my map correctly.
JASS:
//=====================================================================//
//                             Hurricane                               //
//=====================================================================//
//by emootootoo                                                        //
//                                                                     //
// Requires: vJass, CSData, CSSafety                                   //
//                                                                     //
// Things you need to copy:                                            //
// Abilities: Hurricane, HurricaneDummySpell                           //
// Units: HurricaneDummy, DummyCaster                                  //
// Buffs: Chilled                                                      //
//                                                                     //
// Description: Summons a hurricane around the caster that damages and //
// slows enemy units that come within.                                 //
//=====================================================================//

scope Hurricane

globals // Configuration

    private integer spellID=&#039;A433&#039;
    //Hurricane Ability ID
    private integer dummycasterID=&#039;A433&#039;
    //The DummyCaster unit&#039;s ID
    private integer dummyunitID=&#039;A433&#039;
    //The HurricaneDummy unit&#039;s ID
    private real hInterval=0.5
    //Time between damaging units in the hurricane (eg. 1.0 damages every 1 second)
    //Note: Only use intervals of multiples of 0.05 (0.05, 0.4, 1.65, etc)
    private real hDuration=10.0
    //Duration of the spell
    private real hRadius=500
    //Radius of the Hurricane spell
    private real hDamage=25
    //Damage per level. Deals damage per interval to anyone in the huricane (eg. 50*lvl)
    private real hDistanceInterval=150
    //How far gusts of wind are apart from each other (max of 6 circles of wind around caster)
    //The circles are determined starting from the max radius inwards to keep it accurate
    
endglobals // End Configuration

//Code =====================================================================

struct hData
    public unit array hUnit[12]
    public real array hAngle[12]
    public real array hDist[12]
    public unit hCaster
    public integer  hNumber
    public integer count
    public integer slvl
endstruct

function Trig_Hurricane_Conditions takes nothing returns boolean
    return GetSpellAbilityId()==spellID
endfunction

function HurricaneTimer takes nothing returns nothing
    local hData hD = GetCSData(GetExpiredTimer())
    local group g=CreateGroup()
    local unit u
    local unit tempu
    local real x
    local real y
    local location loc=GetUnitLoc(hD.hCaster)
    local integer intcount=R2I(hInterval/0.05)
    local integer tempint=0
    local integer int=0
    
    
    if GetUnitState(hD.hCaster,UNIT_STATE_LIFE)&gt;0 then
    else
        set hD.count=R2I(hDuration/0.05)+1
    endif
    
        
    if hD.count&lt;=R2I(hDuration/0.05) then
        set hD.count=hD.count+1
        loop
        exitwhen tempint&gt;hD.hNumber
            set tempint=tempint+1
            set hD.hAngle[tempint]=hD.hAngle[tempint]+8
            set x=GetLocationX(loc)+hD.hDist[tempint]*Cos(hD.hAngle[tempint]*bj_DEGTORAD)
            set y=GetLocationY(loc)+hD.hDist[tempint]*Sin(hD.hAngle[tempint]*bj_DEGTORAD)
            call SetUnitPosition(hD.hUnit[tempint],x,y)
        endloop

        
        if ModuloInteger(hD.count,intcount)==0 then
            call GroupEnumUnitsInRange(g,GetUnitX(hD.hCaster),GetUnitY(hD.hCaster),hRadius,null)
            loop
                set u = FirstOfGroup(g)
                exitwhen u==null
                    if IsUnitEnemy(u,GetOwningPlayer(hD.hCaster))==true and IsUnitType(u,UNIT_TYPE_STRUCTURE)==false and GetUnitState(u,UNIT_STATE_LIFE)&gt;0 then
                        call UnitDamageTarget(hD.hCaster,u,hDamage*hD.slvl,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_NORMAL,null)
                        set tempu=CreateUnit(GetOwningPlayer(hD.hCaster),dummycasterID,GetUnitX(u),GetUnitY(u),0)
                        call IssueTargetOrder(tempu,&quot;slow&quot;,u)
                        call UnitApplyTimedLife(tempu,&#039;BTLF&#039;,0.75)
                    endif
                call GroupRemoveUnit(g,u)
            endloop
            call DestroyGroup(g)
            set g = null
        endif
    else
        call hD.destroy()
        call ReleaseTimer(GetExpiredTimer())
        loop
            exitwhen int&gt;hD.hNumber
                set int=int+1
                call RemoveUnit(hD.hUnit[int])
                set hD.hUnit[int]=null
        endloop
    endif
    
    call RemoveLocation(loc)
    set loc=null
    set u=null
    set tempu=null
endfunction

function Trig_Hurricane_Actions takes nothing returns nothing
    local hData hD=hData.create()
    local unit caster=GetTriggerUnit()
    local real angle=GetUnitFacing(caster)
    local real tempangle
    local location cloc=GetUnitLoc(caster)
    local location tloc=null
    local timer t = NewTimer()
    local real x
    local real y
    local integer radnum=R2I((hRadius*2)/hDistanceInterval)
    local integer tempint=2
    local integer int=0
    local integer bsint=0
    
    if radnum&lt;1 then
        set radnum=1
    endif
    if radnum&gt;12 then
        set radnum=12
    endif
    
    loop
        exitwhen int&gt;radnum
            loop
                exitwhen tempint&lt;1
                if tempint==2 then
                    set tempangle=angle-90
                else
                    set tempangle=angle+90
                endif
                set int=int+1 
                set tloc=GetUnitLoc(caster)
                set x=GetLocationX(tloc)+(hRadius-(bsint*hDistanceInterval))*Cos(tempangle*bj_DEGTORAD)
                set y=GetLocationY(tloc)+(hRadius-(bsint*hDistanceInterval))*Sin(tempangle*bj_DEGTORAD)
                set hD.hUnit[int]=CreateUnit(GetOwningPlayer(caster),dummyunitID,x,y,0)
                call RemoveLocation(tloc)
                set tloc=Location(x,y)
                call SetUnitVertexColor(hD.hUnit[int],255,255,255,0)
                set hD.hAngle[int]=tempangle
                set hD.hDist[int]=DistanceBetweenPoints(cloc,tloc)
                set tempint=tempint-1
                call RemoveLocation(tloc)
            endloop
        set bsint=bsint+1
        set tempint=2            
    endloop
    

    set hD.count=0
    set hD.slvl=GetUnitAbilityLevel(caster,spellID)
    set hD.hCaster=caster
    set hD.hNumber=int
    call SetUnitUserData(hD.hUnit[hD.hNumber], hD)
    
    call SetCSData(t,hD)
    call TimerStart(t,0.05,true,function HurricaneTimer)
    
    set caster=null
    call RemoveLocation(cloc)
    set cloc=null
    set tloc=null
    set t=null
endfunction

endscope
//===========================================================================
function InitTrig_Hurricane takes nothing returns nothing
    set gg_trg_Hurricane = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Hurricane, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Hurricane, Condition( function Trig_Hurricane_Conditions ) )
    call TriggerAddAction( gg_trg_Hurricane, function Trig_Hurricane_Actions )
endfunction
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top