• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Problem with lag for spells

Status
Not open for further replies.
Level 10
Joined
Apr 9, 2004
Messages
502
On the spells i'm making i often find that when some are in effect; the game slows down dramatically and i don't know why? I first figured it was because of leask but i don't know what else to fix.

Here are my 2 problem spells with a bit of JASS custom script in them.

1 this one's the carrier ability i sent out to make; it still doesn't work smoothly when everyone else is in action and i've removed the custom points so i still don't know what to do? here's the code for the carrying portion of the ability.

Code:
Keep sentinel 1 housed
    Events
        Time - Every 0.01 seconds of game time
    Conditions
        (Distance between (Position of Mobile Crypt Machine Pilot 0051 <gen>) and (Position of Sentinel[1])) Less than or equal to 140.00
    Actions
        Unit - Set life of Sentinel[1] to ((Life of Sentinel[1]) + (0.03 x (Real((Level of Manufacture Sentinels  for Mobile Crypt Machine Pilot 0051 <gen>)))))
        Set SentinelPoint[1] = ((Position of Mobile Crypt Machine Pilot 0051 <gen>) offset by 90.00 towards ((Facing of Mobile Crypt Machine Pilot 0051 <gen>) - 150.00) degrees)
        Unit - Move Sentinel[1] instantly to SentinelPoint[1], facing ((Facing of Mobile Crypt Machine Pilot 0051 <gen>) + 180.00) degrees
        Custom script:   call RemoveLocation(udg_SentinelPoint[1])

The triggers supposed to constantly move the unit to a fixed polar location on my hero. I also added in a feature to heal. There'ds also a bit to detect range so that they can reload. anyways it's only while their on the hero that it slows down.


And then there's this one too.

Code:
Increase Area of effect
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Set WebGrowingVaraible = (WebGrowingVaraible + 0.50)
        Unit - Set Level of Slwoing Units in web (Neutral Hostile) for WebBuffer to (Integer(((Real((Integer(WebGrowingVaraible)))) / 10.00)))
        For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                Set UltMainWebPoints[(Integer A)] = (UltWebChannelPoint offset by WebGrowingVaraible towards ((Real((Integer A))) x 45.00) degrees)
                Lightning - Move UltWebMain[(Integer A)] UltWebChannelPoint UltMainWebPoints[(Integer A)]
                Custom script:   call RemoveLocation(udg_UltMainWebPoints[GetForLoopIndexA()])
        For each (Integer A) from 1 to 9, do (Actions)
            Loop - Actions
                Set UltFirstWebPoints[(Integer A)] = (UltWebChannelPoint offset by (WebGrowingVaraible / (1000.00 / 900.00)) towards ((Real((Integer A))) x 45.00) degrees)
        For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                Lightning - Move UltWebfirst[(Integer A)] UltFirstWebPoints[(Integer A)] UltFirstWebPoints[((Integer A) + 1)]
        For each (Integer A) from 1 to 9, do (Actions)
            Loop - Actions
                Custom script:   call RemoveLocation(udg_UltFirstWebPoints[GetForLoopIndexA()])
        For each (Integer A) from 1 to 9, do (Actions)
            Loop - Actions
                Set UltSecondWebPoints[(Integer A)] = (UltWebChannelPoint offset by (WebGrowingVaraible / (1000.00 / 600.00)) towards ((Real((Integer A))) x 45.00) degrees)
        For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                Lightning - Move UltWebfirstsecond[(Integer A)] UltSecondWebPoints[(Integer A)] UltSecondWebPoints[((Integer A) + 1)]
        For each (Integer A) from 1 to 9, do (Actions)
            Loop - Actions
                Custom script:   call RemoveLocation(udg_UltSecondWebPoints[GetForLoopIndexA()])
        For each (Integer A) from 1 to 9, do (Actions)
            Loop - Actions
                Set UltThirdWebPoints[(Integer A)] = (UltWebChannelPoint offset by (WebGrowingVaraible / (1000.00 / 300.00)) towards ((Real((Integer A))) x 45.00) degrees)
        For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                Lightning - Move UltWebfirstthird[(Integer A)] UltThirdWebPoints[(Integer A)] UltThirdWebPoints[((Integer A) + 1)]
        For each (Integer A) from 1 to 9, do (Actions)
            Loop - Actions
                Custom script:   call RemoveLocation(udg_UltThirdWebPoints[GetForLoopIndexA()])

It creates a growing web pattern made out of lightning effects. I have another one to setup the lightning and another to remove it.

Is there a way to keep these from lagging? (i also tried to condense the functions as much as possible (there's still a bit more i can condense but it's pretty much aas compact as i can think of getting it.))

What other things must i clean up in order to fix the extreme slowdown/lag brought on by these abilities?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
There are 2 major things that causes lag.
1. Memory leakage
2. Processor overloading

Your spell seems like it would leak minimaly if not none at all so thats not the cause.
Your demanding thoughs actions to be run 100 times a second!?
The lag your getting is most probably caused by your comoputer not being able to compute all thoughs functions at the given rate.
I recomend you change the event for both the triggers to.

Time-Every0.03 seconds of game time

This is just to show you how many times per second a trigger is fired if the event is set to one of theses times.
0.01 = 100*
0.02 = 50*
0.03 = 33*
0.04 = 25*
0.05 = 20*
So if it is set to 0.02 it should lag only halfe as much.
Thats why the recomended trigger fire rate is 0.03 because the human eye cant notice the diffrence between that and 0.01 and it lags 66% less.

Theses should drasticaly reduce your lag problem.
 
Status
Not open for further replies.
Top