JASS help - Converting to native

B

Beider

Guest
Code:
function Trig_Deadly_Fire_Star_Effect_Actions takes nothing returns nothing
    local location LocalPointVariable=udg_PointVar
    local effect LocalTempEffect
    call TriggerSleepAction( GetRandomReal(0, 3.00) )
    // wait random delay (another trigger is another thread)
    call AddSpecialEffectLocBJ( LocalPointVariable, "Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeEmbers.mdl" )
    set LocalTempEffect = GetLastCreatedEffectBJ()

    call TriggerSleepAction( 10.00 )
    call RemoveLocation( LocalPointVariable )
    call DestroyEffect( LocalTempEffect )
    // Remove the point so it doesn't leak
    set LocalPointVariable = null
    set LocalTempEffect = null
    // Local variables leak if you don't set them to null
endfunction

//===========================================================================
function InitTrig_Deadly_Fire_Star_Effect takes nothing returns nothing
    set gg_trg_Deadly_Fire_Star_Effect = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Deadly_Fire_Star_Effect, function Trig_Deadly_Fire_Star_Effect_Actions )
endfunction


I read that using native functions instead of BJ functions is faster. I tried to convert it to use natives instead of the two BJ functions it uses now but I had no luck with it. The problem is when I make my effect everyone in the game DC even if they can't see it, but it single it works fine. (It creates 65 effects in less than 5 sec ^^) I was hoping converting to native functions might help.
 

SFilip

Gone but not forgotten
Reaction score
634
we have a jass help zone you know ;)
anyway i dont see anything wrong here. however since you mentioned that you create 65 special effects...that could really be the problem. you are removing them after 10 seconds which is long enough to leak lots of memory (enough for a server split perhaps).
and replacing bj functions is a good idea, but you probably wont even notice the diffrence.
 
B

Beider

Guest
well actually i just tried it with that function and it worked ok in a game with 65 effects. What used to disconnect was when i used vexorian for it.
 

SFilip

Gone but not forgotten
Reaction score
634
you mean his map optimizer? what options did you use?
 
B

Beider

Guest
no i mean his casting system. I used his default example for a firestar in his map. Everyone disconnected. So I converted it into just using effects and removing them and now some people just lagg.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Code:
function Trig_Deadly_Fire_Star_Effect_Actions takes nothing returns nothing
    local location LocalPointVariable=udg_PointVar
    local effect LocalTempEffect
    call PolledWait( GetRandomReal(0, 3.00) )
    // wait random delay (another trigger is another thread)
    set LocalTempEffect = AddSpecialEffectLoc( "Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeEmbers.mdl", LocalPointVariable )

    call PolledWait( 10.00 )
    call RemoveLocation( LocalPointVariable )
    call DestroyEffect( LocalTempEffect )
    // Remove the point so it doesn't leak
    set LocalPointVariable = null
    set LocalTempEffect = null
    // Local variables leak if you don't set them to null
endfunction

//======================================================================  =====
function InitTrig_Deadly_Fire_Star_Effect takes nothing returns nothing
    set gg_trg_Deadly_Fire_Star_Effect = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Deadly_Fire_Star_Effect, function Trig_Deadly_Fire_Star_Effect_Actions )
endfunction

The only thing that isn't native there is PolledWait, however PolledWait is better to use if you have lagg problems with the function.
The best solution to this is to not create so many effects at the same time.
 
B

Beider

Guest
Ok thanks for the help. I will try the function you posted now and also try to piff up the loop that initiate these spell effects. Hopefully it will speed up slightly more, and yeah i guess if this doesn't work i will reduce the amount of effects again.


Anyone know how many effects one maximum should use for a spell, to avoid for lagg i mean. I guess 65 is a bit much, but 30-40 should be fine?
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
There is always someone with 56k, 128MB ram and integrated gcard that is going to lag as soon there is one effect on the screen. Actually it's more important to choose the right effects, fire effects are laggy. Most projectiles are not so laggy.

Also, don't use alot of effects just to make the ability 'look cool', lagg isn't very funny. If you want a 'cool' ability on each hero make sure that it's only one on each hero and also make it the ultimate so it won't be cast as often as the others.

I think the most effects I ever had on a triggered spell was 1 per unit in an area + one earthquake effect. That was not very often above 15 effects in total.
 
B

Beider

Guest
Well it's an hero ultimate, and all effects are fire effects :p

But still, people used to disconnect even if they couldn't see the effect so it wasn't because of graphics being to laggy. Well i optimized it as much as i could myself so will test it.


If anyone is interested here is the code for the effect.

Code:
function Trig_Infernal_Nuke_org_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A016' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Infernal_Nuke_org_Func006C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetTriggerUnit()) == 2 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Infernal_Nuke_org_Func014Func002C takes nothing returns boolean
    if ( not ( ModuloInteger(GetForLoopIndexA(), 24) == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Infernal_Nuke_org_Func015Func002C takes nothing returns boolean
    if ( not ( ModuloInteger(GetForLoopIndexA(), 24) == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Infernal_Nuke_org_Func015Func003C takes nothing returns boolean
    if ( not ( ModuloInteger(GetForLoopIndexA(), 72) == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Infernal_Nuke_org_Actions takes nothing returns nothing
    local location LocalPointVariable=GetUnitLoc(GetTriggerUnit())
    call PauseUnitBJ( true, GetTriggerUnit() )
    call CreateNUnitsAtLoc( 1, 'h00B', GetTriggerPlayer(), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
    call UnitApplyTimedLifeBJ( 5.00, 'BTLF', GetLastCreatedUnit() )
    call UnitAddAbilityBJ( 'A007', GetLastCreatedUnit() )
    if ( Trig_Infernal_Nuke_org_Func006C() ) then
        call SetUnitAbilityLevelSwapped( 'A007', GetLastCreatedUnit(), 2 )
        set udg_RealVar = 1200.00
    else
        set udg_RealVar = 800.00
    endif
    call IssuePointOrderLocBJ( GetLastCreatedUnit(), "flamestrike", GetUnitLoc(GetTriggerUnit()) )
    call PlaySoundAtPointBJ( gg_snd_FlameStrikeBirth1, 100, GetUnitLoc(GetTriggerUnit()), 0 )
    call TriggerSleepAction( 1.00 )
    // RealVar determines the area of effect
    set udg_RealVar2 = 20.00
    // RealVar2 determines the area damage
    set udg_PointVar = OffsetLocation(LocalPointVariable, -50.00, -100.00)
    set bj_forLoopAIndex = -360
    set bj_forLoopAIndexEnd = -1
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        // For is Negative so the star appars inverted
        if ( Trig_Infernal_Nuke_org_Func014Func002C() ) then
            set udg_PointVar = PolarProjectionBJ(OffsetLocation(LocalPointVariable, -50.00, -100.00), ( udg_RealVar / 2.00 ), I2R(GetForLoopIndexA()))
            call ConditionalTriggerExecute( gg_trg_Deadly_Fire_Star_Effect2 )
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set bj_forLoopAIndex = -360
    set bj_forLoopAIndexEnd = -1
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        // For is Negative so the star appars inverted
        if ( Trig_Infernal_Nuke_org_Func015Func002C() ) then
            set udg_PointVar = PolarProjectionBJ(OffsetLocation(LocalPointVariable, -50.00, -100.00), ( udg_RealVar / 2.00 ), I2R(GetForLoopIndexA()))
            call ConditionalTriggerExecute( gg_trg_Deadly_Fire_Star_Effect )
        else
        endif
        if ( Trig_Infernal_Nuke_org_Func015Func003C() ) then
            set udg_PointVar2 = PolarProjectionBJ(OffsetLocation(LocalPointVariable, -50.00, -100.00), ( udg_RealVar / 2.00 ), I2R(GetForLoopIndexA()))
            set bj_forLoopBIndex = 1
            set bj_forLoopBIndexEnd = 7
            loop
                exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
                set udg_PointVar = PolarProjectionBJ(udg_PointVar2, ( I2R(GetForLoopIndexB()) * ( udg_RealVar / 8.00 ) ), ( I2R(GetForLoopIndexA()) + 162.00 ))
                call ConditionalTriggerExecute( gg_trg_Deadly_Fire_Star_Effect )
                set bj_forLoopBIndex = bj_forLoopBIndex + 1
            endloop
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call TriggerSleepAction( 1.80 )
    call PauseUnitBJ( false, GetTriggerUnit() )
    call RemoveLocation( LocalPointVariable )
    set LocalPointVariable = null
endfunction

//===========================================================================
function InitTrig_Infernal_Nuke_org takes nothing returns nothing
    set gg_trg_Infernal_Nuke_org = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Infernal_Nuke_org, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Infernal_Nuke_org, Condition( function Trig_Infernal_Nuke_org_Conditions ) )
    call TriggerAddAction( gg_trg_Infernal_Nuke_org, function Trig_Infernal_Nuke_org_Actions )
endfunction


And here are the two spell effect functions.

Code:
function Trig_Deadly_Fire_Star_Effect_Actions takes nothing returns nothing
    local location LocalPointVariable=udg_PointVar
    // To make the fire star appearance faster, I made it so there is a random delay,
    // each part of the star will have its own moment to appear,
    local effect LocalTempEffect
    call PolledWait( GetRandomReal(0, 3.00) )
    // wait random delay (another trigger is another thread)
    set LocalTempEffect = AddSpecialEffectLoc( "Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeEmbers.mdl", LocalPointVariable )
    call PolledWait( 10.00 )
    call RemoveLocation( LocalPointVariable )
    call DestroyEffect( LocalTempEffect )
    // Remove the point so it doesn't leak
    set LocalPointVariable = null
    set LocalTempEffect = null
    // Local variables leak if you don't set them to null
endfunction

//===========================================================================
function InitTrig_Deadly_Fire_Star_Effect takes nothing returns nothing
    set gg_trg_Deadly_Fire_Star_Effect = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Deadly_Fire_Star_Effect, function Trig_Deadly_Fire_Star_Effect_Actions )
endfunction


Code:
function Trig_Deadly_Fire_Star_Effect2_Actions takes nothing returns nothing
    local location LocalPointVariable=udg_PointVar
    // To make the fire star appearance faster, I made it so there is a random delay,
    // each part of the star will have its own moment to appear,
    local effect LocalTempEffect
    call PolledWait( GetRandomReal(0, 1.00) )
    // wait random delay (another trigger is another thread)
    set LocalTempEffect = AddSpecialEffectLoc( "Objects\\Spawnmodels\\Human\\SmallFlameSpawn\\SmallFlameSpawn.mdl", LocalPointVariable )
    call PolledWait( 10.00 )
    call RemoveLocation( LocalPointVariable )
    call DestroyEffect( LocalTempEffect )
    // Remove the point so it doesn't leak
    set LocalPointVariable = null
    set LocalTempEffect = null
    // Local variables leak if you don't set them to null
endfunction

//===========================================================================
function InitTrig_Deadly_Fire_Star_Effect2 takes nothing returns nothing
    set gg_trg_Deadly_Fire_Star_Effect2 = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Deadly_Fire_Star_Effect2, function Trig_Deadly_Fire_Star_Effect2_Actions )
endfunction
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Beider said:
But still, people used to disconnect even if they couldn't see the effect so it wasn't because of graphics being to laggy.
That is probably because the TriggerSleepAction, it can cause desyncs if a player laggs. Well, someone told me that once. I have never encountered it myself, mainly because I almost never uses TriggerSleepAction.

Here is 2 things that will help you optimize that alot more
http://www.thehelper.net/forums/showthread.php?t=28321
http://www.thehelper.net/forums/showthread.php?t=28217
 
B

Beider

Guest
well i decided to just strip out the burning pentagram on the ground. Even though it looked awesome it used 50 fire effects ^^

So now it's just the first loop and 15 fire effects and it works quite well. At least I don't think anyone disconnect or lagg from it anymore.

Thanks for all the help.
 

Vexorian

Why no custom sig?
Reaction score
187
Code:
set udg_PointVar = PolarProjectionBJ(OffsetLocation(LocalPointVariable, -50.00, -100.00), ( udg_RealVar / 2.00 ), I2R(GetForLoopIndexA()))
...
set udg_PointVar2 = PolarProjectionBJ(OffsetLocation(LocalPointVariable, -50.00, -100.00), ( udg_RealVar / 2.00 ), I2R(GetForLoopIndexA()))
...
set udg_PointVar = PolarProjectionBJ(udg_PointVar2, ( I2R(GetForLoopIndexB()) * ( udg_RealVar / 8.00 ) ), ( I2R(GetForLoopIndexA()) + 162.00 ))

those 3 memory leaks happen in very periodic parts of the spell, so just using it once would eat all the memory.

- The caster system map's samples are not meant to be actually used.
- I only made the pentagram because in those times the only spells that got into the top downloads in wc3search were pentagram spells.

You have to be crazy to use the pentagram spell in multiplayer
 
B

Beider

Guest
Well I did remove over half the effects the original used, but well, never made a spell before so didn't know how many effects you could have. And the pentagram fit the theme of the map / hero very well, but oh well.

At least I learned something about jass and spell making ^^
 

Vexorian

Why no custom sig?
Reaction score
187
If you really want a pentagram you can easily draw one with lightning effects, you can use semi transparent aerial shackles lightning effect to make it look like fire.
 

SFilip

Gone but not forgotten
Reaction score
634
probably not because you wouldn't need as many lightning effect.
and btw functions like this
Code:
function Trig_Infernal_Nuke_org_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A016' ) ) then
        return false
    endif
    return true
endfunction
should be
Code:
function Trig_Infernal_Nuke_org_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A016'
endfunction
 
B

Beider

Guest
I see, thanks. Well actually I didn't convert that function to JASS, it's just made from the UI. I guess i will see if i can do it with a few lightning effects then.
 

SFilip

Gone but not forgotten
Reaction score
634
yeah i know...the problem is that gui usually makes more code than you need. thats why its a good idea to convert to jass and "do it yourself" ;)
 
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

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top