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: 207

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
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top