vJass struct, handle limit

--Thanatos--

New Member
Reaction score
33
It seems that my spells are all unspammable (0 sec cd)
Which in fact it only create around 50 handle per cast and each cast lasts around 3 seconds, it should only reach max handle of 250-300. The values between casts starts to go messed up and end up by Fatal Error.

Why is it? Because of my crazy struct? or.. ?
I got one example...
(Animation Cancel and re-cast fast to see)
 

Attachments

  • [Spell] Thunder Stream.w3x
    47.7 KB · Views: 203

wraithseeker

Tired.
Reaction score
122
You could try using art duration to stop them from spamming like mad.

And using Art - Attack, death and so on..
 

--Thanatos--

New Member
Reaction score
33
Yes, but...

When 5 heroes used the same ability at once, tada, it's messed. Have any other idea >_< ?
 

--Thanatos--

New Member
Reaction score
33
*sigh* :( I don't understand, it also fatal errors for some other spells I made

EDIT: solved. I quit structs and go HandleVars again -_-
 

--Thanatos--

New Member
Reaction score
33
Bugging Version:
JASS:
scope ThunderStream
//*****************************************************************************************
//*****************************************************************************************
//**                                                                                   //**
//**                               Name : Thunder Stream                               //**
//**                                                                                   //**
//**                               Author : --Thanatos--                               //**
//**                               <a href="mailto:[email protected]">[email protected]</a>                                //**
//**                                                                                   //**
//*****************************************************************************************
//*****************************************************************************************
//**                                                                                   //**
//** Credits: PandaMine&#039;s HSAS                                                         //**
//**                                                                                   //**
//*****************************************************************************************
//*****************************************************************************************

//#########################################################################################
//#####################################configurations######################################
//##                                                                                   //##
//##                 Change the part &quot;= ****&quot; with your configuration.                 //##
//##                                                                                   //##
globals                                                                                //##
//##                                                                                   //##
    private constant integer rawcode = &#039;A000&#039;                                          //##
//## Spell&#039;s Rawcode.                                                                  //##
//##                                                                                   //##
    private constant real timerPeriod = .03                                            //##
//## Period of the timer. Less means laggier but better resolution.                    //##
//##                                                                                   //##
    private constant real streamPeriod = .07                                           //##
//## Period between each streams.                                                      //##
//##                                                                                   //##
    private constant real distance = 96.                                               //##
//## Range between the caster and the stream.                                          //##
//##                                                                                   //##
    private constant real waveHeight = 128.                                            //##
//## Height of the stream.                                                             //##
//##                                                                                   //##
    private constant real speed = 900.                                                 //##
//## Missile Speed of the stream.                                                      //##
//##                                                                                   //##
    private constant real damage    = 220. // base                                     //##
    private constant real damageInc =  80. // base + level * this                      //##
//## Damage.                                                                           //##
//##                                                                                   //##
    private constant real swidth    = 160. // base                                     //##
    private constant real swidthInc =  40. // base + level * this                      //##
//## Starting width of the stream.                                                     //##
//##                                                                                   //##
    private constant real ewidth    = 440. // base                                     //##
    private constant real ewidthInc = 110. // base + level * this                      //##
//## Ending width of the stream.                                                       //##
//##                                                                                   //##
    private constant real range    = 600. // base                                      //##
    private constant real rangeInc = 100. // base + level * this                       //##
//## Cast range.                                                                       //##
//##                                                                                   //##
    private constant integer amount    = 8 // base                                     //##
    private constant integer amountInc = 0 // base + level * this                      //##
//## amount of waves.                                                                  //##
//##                                                                                   //##
    private constant string spellEffect = &quot;Abilities\\Spells\\Undead\\ReplenishMana\\ReplenishManaCasterOverhead.mdl&quot;//##
//## Special Effect that appears on cast.                                              //##
//##                                                                                   //##
endglobals                                                                             //##
//##                                                                                   //##
//#########################################################################################
//#########################################################################################

//***************************************conditions****************************************
//*                                                                                     //*
private function ActiveConditions takes nothing returns boolean                         //*
                                                                                        //*
    return GetSpellAbilityId () == rawcode                                              //*
                                                                                        //*
endfunction                                                                             //*
//*                                                                                     //*
//*****************************************************************************************

//*************************************spell&#039;s script*************************************

private struct Data
    unit      caster
    integer   level
    integer   data

    integer   amount

    real      castX
    real      castY
    real      castZ
    real      angle

    real      sDamage
    real      sSwidth
    real      sEwidth
    real      sIwidth
    real      sRange
    real      sAmount

    lightning light
    real      trvld
    real      width
    real      height
endstruct

private function TargetFilter takes nothing returns boolean

    local Data    sData     = GetAttachedStruct (GetExpiredTimer())
    local player  owner     = GetOwningPlayer   (sData.caster)
    local unit    target    = GetFilterUnit     ()
    local boolean returnVal = false

    if                         GetUnitAbilityLevel (target,Dummy_Ability_Rawcode)  &lt;= 0     then
        if                     IsUnitHidden        (target)                        == false then
            if                 GetWidgetLife       (target)                        &gt;  .405  then
                if             IsUnitEnemy         (target,owner)                           then
                    if         IsUnitVisible       (target,owner)                           then
                        if     IsUnitType          (target,UNIT_TYPE_STRUCTURE)    == false then
                            if IsUnitType          (target,UNIT_TYPE_MAGIC_IMMUNE) == false then
                                set returnVal = true
                            endif
                        endif
                    endif
                endif
            endif
        endif
    endif

    set owner  = null
    set target = null
    return returnVal

endfunction

private function Effect1 takes nothing returns nothing

    local timer xTimer = GetExpiredTimer   ()
    local Data  xData  = GetAttachedStruct (xTimer)
    local Data  sData  = xData.data

    local real     centX  = sData.castX + xData.trvld * Cos ( sData.angle     *(3.14159/180.))
    local real     centY  = sData.castY + xData.trvld * Sin ( sData.angle     *(3.14159/180.))
    local real     leftX  = centX + xData.width/2.    * Cos ((sData.angle+90.)*(3.14159/180.))
    local real     leftY  = centY + xData.width/2.    * Sin ((sData.angle+90.)*(3.14159/180.))
    local real     riteX  = centX + xData.width/2.    * Cos ((sData.angle-90.)*(3.14159/180.))
    local real     riteY  = centY + xData.width/2.    * Sin ((sData.angle-90.)*(3.14159/180.))
    local location center = Location     (centX,centY)
    local real     centZ  = GetLocationZ (center)

    call MoveLightningEx (xData.light,true,leftX,leftY,centZ+xData.height,riteX,riteY,centZ+xData.height)

    if     xData.trvld &lt; 0.           then
        set xData.trvld   = xData.trvld  + speed*timerPeriod/4.
        set xData.height  = xData.height + waveHeight*(timerPeriod/(distance/speed))/4.
    elseif xData.trvld &lt; sData.sRange then
        set xData.trvld   = xData.trvld  + speed*timerPeriod
        set xData.width   = xData.width  + sData.sIwidth
        set xData.height  = xData.height - waveHeight*(timerPeriod/(sData.sRange/speed))
    else
        call DestroyLightning (xData.light)
        if sData.amount &gt;= sData.sAmount then
            call Data.destroy (sData)
        endif
        call Data.destroy (xData)
        call PauseTimer   (xTimer)
        call DestroyTimer (xTimer)
    endif

    call RemoveLocation (center)
    set xTimer = null
    set center = null

endfunction

private function Effect takes nothing returns nothing

    local timer xTimer = CreateTimer       ()
    local timer sTimer = GetExpiredTimer   ()
    local Data  xData  = Data.create       ()
    local Data  sData  = GetAttachedStruct (sTimer)

    local real     centX  = sData.castX - distance   * Cos ( sData.angle     *(3.14159/180.))
    local real     centY  = sData.castY - distance   * Sin ( sData.angle     *(3.14159/180.))
    local real     leftX  = centX + sData.sSwidth/2. * Cos ((sData.angle+90.)*(3.14159/180.))
    local real     leftY  = centY + sData.sSwidth/2. * Sin ((sData.angle+90.)*(3.14159/180.))
    local real     riteX  = centX + sData.sSwidth/2. * Cos ((sData.angle-90.)*(3.14159/180.))
    local real     riteY  = centY + sData.sSwidth/2. * Sin ((sData.angle-90.)*(3.14159/180.))
    local location center = Location     (centX,centY)
    local real     centZ  = GetLocationZ (center)

    set sData.amount = sData.amount+1

    set xData.data = sData

    if sData.amount &lt;= sData.sAmount then
        set xData.light  = AddLightningEx (&quot;CHIM&quot;,true,leftX,leftY,centZ,riteX,riteY,centZ)
        set xData.trvld  = - distance
        set xData.width  = sData.sSwidth
        set xData.height = 0.
        call AttachStruct (xTimer,integer(xData))
        call TimerStart   (xTimer,timerPeriod,true,function Effect1)
    else
        call PauseTimer   (xTimer)
        call PauseTimer   (sTimer)
        call DestroyTimer (xTimer)
        call DestroyTimer (sTimer)
    endif

    call RemoveLocation (center)
    set xTimer = null
    set sTimer = null
    set center = null

endfunction

private function Active takes nothing returns nothing

    local timer sTimer = CreateTimer ()
    local Data  sData  = Data.create ()

    local location target = GetSpellTargetLoc ()
    local real     targX  = GetLocationX      (target)
    local real     targY  = GetLocationY      (target)

    local real diffX
    local real diffY
    local real iwidth

    set sData.caster  = GetTriggerUnit      ()
    set sData.level   = GetUnitAbilityLevel (sData.caster,rawcode)
    set sData.castX   = GetUnitX            (sData.caster)
    set sData.castY   = GetUnitY            (sData.caster)
    set sData.castZ   = GetUnitFlyHeight    (sData.caster)
    set diffX         = targX-sData.castX
    set diffY         = targY-sData.castY
    set sData.angle   = Atan2               (diffY,diffX) * (180./3.14159)
    set sData.sDamage = damage + sData.level*damageInc
    set sData.sSwidth = swidth + sData.level*swidthInc
    set sData.sEwidth = ewidth + sData.level*ewidthInc
    set sData.sAmount = amount + sData.level*amountInc
    set sData.sRange  = range  + sData.level*rangeInc
    set iwidth        = sData.sEwidth - sData.sSwidth
    set sData.sIwidth = SquareRoot (iwidth*iwidth) * (timerPeriod/(sData.sRange/speed))

    set sData.amount = 0

    call AttachStruct (sTimer,integer(sData))
    call TimerStart   (sTimer,streamPeriod,true,function Effect)

    call RemoveLocation (target)
    set sTimer = null
    set target = null

endfunction

//****************************************************************************************

//****************************************preloads*********************************************
//*                                                                                         //*
private function SpellPreload takes nothing returns nothing                                 //*
                                                                                            //*
    local player neutral  = Player     (PLAYER_NEUTRAL_PASSIVE)                             //*
    local unit   tempUnit = CreateUnit (neutral,Dummy_Unit_Rawcode,0.,0.,0.)                //*
    call DestroyEffect                 (AddSpecialEffectTarget(spellEffect,tempUnit,&quot;origin&quot;))//*
    call UnitAddAbility                (tempUnit,rawcode)                                   //*
    call RemoveUnit                    (tempUnit)                                           //*
    set neutral  = null                                                                     //*
    set tempUnit = null                                                                     //*
                                                                                            //*
endfunction                                                                                 //*
//*                                                                                         //*
//*********************************************************************************************

//===========================================================================

function InitTrig_ThunderStream takes nothing returns nothing
    local integer index = 0
    call SpellPreload                        ()
    set gg_trg_ThunderStream = CreateTrigger ()
    loop
        call TriggerRegisterPlayerUnitEvent (gg_trg_ThunderStream,Player(index),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function GetTrue))
        set index = index + 1
        exitwhen index == 16
    endloop
    call TriggerAddCondition                (gg_trg_ThunderStream,Condition(function ActiveConditions))
    call TriggerAddAction                   (gg_trg_ThunderStream,function Active)
endfunction
endscope

Mine already worked out (by using HandleVars), so this was actually solved.
 

Viikuna

No Marlo no game.
Reaction score
265
I have never used HSAS, but doesnt it require you to call some textmacro or something?

You can do it with Handle Vars too, just dont use I2H. Use SetHanldeInt and GetHandleInt to attach your struct to timer. ( Structs are integers )

You can also try a static timer loop and a struct array, its kinda nice way to do these things.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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