HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Laggy spell/lib

03-23-2008, 06:52 PM#1
notsoexpert
This spell lags horribly when it knocks back enemies, and I want to fix that.
Expand Charge:

I went ballsy and used the handle bug on code vars. If this is the problem then I'll have to find some way around it... here is Jazradel's "Jump" template, changed quite a bit (this is only a small part of it that doesn't include flyheights and such)
Thanks to him for making the sample.

Expand MoveUnit:

I'm using a modified version of emjlr3's knockback system for my knockback in the forgroup...
Thanks to him for letting me move units fluidly. Also to Cohadar for making the system possible. :)

Expand KnockbackSystem:

I guess I pain for death...?

Perhaps there is a reason this is lagging that isn't what I'm thinking (with the stored code value)?
What the spell is supposed to do is Charge toward the target unit, knocking away and damaging units along the way. (Eventually it'll have a neat finale, but that is for later.) However, I only want units to be knocked/damaged once, so I stored them in a Cohadar-friendly-PUI-using global group array. Realizing that this enabled me to exclude damaged units using the boolexpr itself, everything seemed in tip-top shape until I tested it. Now, everything works correctly, but it lags up pretty bad when the units start getting knocked away. I have other knockback spells and effects in my map using that system and none of them lag.

EDIT: Apparently, I can't make a damn spell without using at least two systems and at least 400 lines of code...
03-24-2008, 09:36 PM#2
notsoexpert
bump
Any ideas at all as to why it would lag/how to fix it?
03-25-2008, 12:28 AM#3
midiway
Collapse JASS:
private function C2I takes code c returns integer
    return c
    return 0
endfunction
private function I2C takes integer i returns code
    return i
    return null
endfunction

I'm not 100% sure, but I don't think you can treat code handles like you treat another handles like units, timers, ...
03-25-2008, 03:31 AM#4
notsoexpert
The functions work fine, and all calls are made correctly, but it just lags is all.
03-25-2008, 05:06 AM#5
Vexorian
how many enemies?
03-25-2008, 03:56 PM#6
notsoexpert
Uh..

I just tested it again, and I don't remember making any changes, but... the hero would forever follow and knockback one unit; when the unit is done being knocked, the hero would take it all on its own and charge again, knocking the same unit back again, in a forever loop of annoyance. I'll check my code again...

EARLIER, when it was working properly but laggily, it would lag up even if one unit was pushed. I've had 100 units being knocked back on this map without lag (on my computer) so something is fishy about it.

EDIT: Alright, it isn't lagging now, but the Warrior is still forever pushing until I order him to stop. I guess I'll just add a stop order to the bottom of my script, but I don't understand why its doing that.

Ok, the problem was that A:
Collapse JASS:
    if f != null then
        set d.g = NewGroup()
        set bj_groupRandomCurrentPick = d.u    
        call GroupEnumUnitsInRange(d.g,GetUnitX(d.u),GetUnitY(d.u),200.,d.filt)
        call ForGroup(d.g,f) // Lags horribly... may have something to do with storing the code?
        call ReleaseGroup(d.g)
        set d.g = null
    endif
...is inefficient and unnecessary. My solution? Initialized the group in the beginning, and use the same group while sliding.
Collapse JASS:
local unit e
//
//
    if f != null then
        set bj_groupRandomCurrentPick = d.u
        call GroupEnumUnitsInRange(d.g,GetUnitX(d.u),GetUnitY(d.u),200.,d.filt)
        call ForGroup(d.g,f)
        loop
            set e = FirstOfGroup(d.g)
            exitwhen e == null
            call GroupRemoveUnit(d.g,e)
        endloop
    endif
...so I'm only using one group during the sliding. The group is recycled when the struct is destroyed.
However, it still goes on forever, as if the guy is recasting the spell all on his own.
So... B:
The warrior was trying to knockback already knocked units several times before, and would stop from something other than my orders. The many, many knockbacks (must have been over 100, or perhaps emjlr's "inelastic collisions" are a bit laggier than normal knocks) lagged the game up unbearably.