Help with first real vjass attempt

BRUTAL

I'm working
Reaction score
118
well i decided to give jass another shot.
im trying to recreate my spell 'ice trap' in vjass, so far im getting there.
a few question though; in the loop function i put the sleep function so the units arent all created instantly, but its rather slow >< whys that?
so how do you make a like..periodic event type of function within the trigger cause ive noticed vjass spells are made in one trigger, like a meathook.
do i need to use a system like ,tt? whatever that is? ><
anyways heres my trigger
JASS:
scope IceTrap initializer Init

//   ________________________________________
// ||                                        ||
// || Modify below                           ||
// ||________________________________________||

globals
    private constant integer Spellid = &#039;A001&#039;      // Raw code of Ice Trap ability
    private constant integer Dummyid = &#039;h007&#039;     // Raw code of Ice Trap ability
    private constant real MaxUnits   = 360       // Number of units made to complete the circle
    private constant real AOE        = 290      //Base AOE of spell, each level AOE gets bigger
endglobals
  
//   ________________________________________
// ||                                        ||
// || Do not modify                          ||
// ||________________________________________||

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Spellid
endfunction

function Actions takes nothing returns nothing
    local unit ITCaster = GetSpellAbilityUnit()
    local real ITDuration = (6 + (3 * I2R(GetUnitAbilityLevelSwapped(&#039;A001&#039;, ITCaster))))
    local location ITTargetPoint = GetSpellTargetLoc()
    local real ITTimer = 0
    local real ITAngle = ( GetUnitFacing(ITCaster) + 140.00 )    
    local location ITTargetPos = PolarProjectionBJ(ITTargetPoint, ( AOE + ( I2R(GetUnitAbilityLevelSwapped(&#039;A001&#039;, ITCaster)) * 20.00 ) ), ITAngle)
    local rect ITCreateRect = RectFromCenterSizeBJ(ITTargetPoint, 100.00, 100.00)
    call SetUnitFacingToFaceLocTimed( ITCaster, ITTargetPoint, 0 )
    call AddWeatherEffectSaveLast( ITCreateRect, &#039;SNls&#039; )
    call EnableWeatherEffect( GetLastCreatedWeatherEffect(), true )
    call RemoveRect ( ITCreateRect )
    loop
        exitwhen ITTimer == MaxUnits
            set ITTimer = (ITTimer + 10)
            set ITTargetPos = PolarProjectionBJ(ITTargetPoint, ( AOE + ( I2R(GetUnitAbilityLevelSwapped(&#039;A001&#039;, ITCaster)) * 20.00 ) ), (ITAngle + ITTimer ))
            call CreateNUnitsAtLocFacingLocBJ( 1, Dummyid, GetOwningPlayer(ITCaster), ITTargetPos, ITTargetPoint )
            call UnitAddAbilityBJ( &#039;A002&#039;, GetLastCreatedUnit() )
            call SetUnitAbilityLevelSwapped( &#039;A002&#039;, GetLastCreatedUnit(), GetUnitAbilityLevelSwapped(&#039;A001&#039;, ITCaster) )
            call IssueImmediateOrderBJ( GetLastCreatedUnit(), &quot;immolation&quot; )
            call UnitApplyTimedLifeBJ( ( ITDuration), &#039;BTLF&#039;, GetLastCreatedUnit() )
            call SetTerrainPathableBJ( ITTargetPos, PATHING_TYPE_WALKABILITY, false )
            call TriggerSleepAction(0.01)
        endloop        
endfunction


//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction(t, function Actions)
endfunction

endscope


also, how would i go about making the pathing walkable after the amount of time it takes for the units created in a circle to die?

again this is my first attempt at jass, so if something is wrong help is welcome : o
 

Kenny

Back for now.
Reaction score
202
TriggerSleepActions dont go as low as 0.01 i believe. They stop at like 0.10 or something. If you want to create them one after another you will need a timer, and with that an attachment system, or you could use a static timer loop.

On another note: this spell seems very similar to my Earth Prison spell i just submitted, i would say check it out, but if you are just beginning jass you might not get too much out of it.

Oh and 360 units for a cirlce is freaking huge, and it may cause lag. I got it down to 25 as long as all units have 32 collision size.
 

BRUTAL

I'm working
Reaction score
118
oh i see
but i submitted this spell in gui in july D:
ah that actually is wrong, i didnt fix it really so people would think that
its actually 36 units cause;
JASS:
exitwhen ITTimer == MaxUnits
            set ITTimer = (ITTimer + 10)

:p

edit*
nvm, i thought when you referenced your spell you were saying i copied you or such XD but you ment to see how you did it, right? : o
 

Kenny

Back for now.
Reaction score
202
IMO TSA's and PolledWaits are gay, stay away from them, its just as easy to do everything via a timer if you know what you are doing. Also TSA's and PolledWaits are crap for online play because they wait through lag and delay or something like that. At least thats what i've heard.

EDIT:

No they are not accurate, well at least not very, while timers are very precise.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
They may be "gay", but some of us, I for one, find timers confusing (at least for now).
Although BRUTAL, you may want to get someone to help you attach a timer for this, as this is sort've dependant on that wait.
 

BRUTAL

I'm working
Reaction score
118
i see
i'll look into timers and such, but i just learned basic jass so its probably going to be confusing :p
but, how do you remove leaks from a local variable in jass, example a point variable
call RemoveLocation (name of local point variable) ?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I believe that's how you do it, yes (that's how I do it anyways :eek: ) .
Also, don't forget to null units ;) !
 
Reaction score
341
how do you remove leaks from a local variable in jass, example a point variable
call RemoveLocation (name of local point variable) ?

call RemoveLocation(localname)

Remember there is no udg_ unless it is a variable created by the GUI variable editor.

And you null pretty much any local variable that leaks at the end of your function.
 

Kenny

Back for now.
Reaction score
202
Also, don't forget to null units

Not just units, locations, effects, timers, destructables and much more.

Oh and:

nvm, i thought when you referenced your spell you were saying i copied you or such XD but you ment to see how you did it, right?

Yes i was just refering you too it because it may help.

EDIT:

Beat me too it...
 

BRUTAL

I'm working
Reaction score
118
yeayea, locals dont need udg_
i just got a syntax error for putting the 'call RemoveLocation ITTargetPos' inside the loop : s
JASS:
loop
        exitwhen ITTimer == MaxUnits
            set ITTimer = (ITTimer + 10)
            set ITTargetPos = PolarProjectionBJ(ITTargetPoint, ( AOE + ( I2R(GetUnitAbilityLevelSwapped(&#039;A001&#039;, ITCaster)) * 20.00 ) ), (ITAngle + ITTimer ))
            call CreateNUnitsAtLocFacingLocBJ( 1, Dummyid, GetOwningPlayer(ITCaster), ITTargetPos, ITTargetPoint )
            call UnitAddAbilityBJ( &#039;A002&#039;, GetLastCreatedUnit() )
            call SetUnitAbilityLevelSwapped( &#039;A002&#039;, GetLastCreatedUnit(), GetUnitAbilityLevelSwapped(&#039;A001&#039;, ITCaster) )
            call IssueImmediateOrderBJ( GetLastCreatedUnit(), &quot;immolation&quot; )
            call UnitApplyTimedLifeBJ( ( ITDuration), &#039;BTLF&#039;, GetLastCreatedUnit() )
            call SetTerrainPathableBJ( ITTargetPos, PATHING_TYPE_WALKABILITY, false )
            call RemoveLocation ITTargetPos 
            call TriggerSleepAction(0.01)
        endloop
 

WolfieeifloW

WEHZ Helper
Reaction score
372
You should look into changing all those BJ's into their natives also.
I could probably help you with some of that, if you want.
 
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