Lag problems

Sirroelivan

Gunnerkrigg Court
Reaction score
95
I'm currently working on a stronghold crusader map. If you've played crusader, you know the concept of walkers. For example, the wheat farmer brings wheat to the stockpile, the miller takes it, grinds it into flour, which he deposits again etc...

Well, the problem is that at the moments the triggers run (they're periodic), the games freezes for a very short while (since there are triggers like this for every type of building), this is very disturbing and i've been looking for a solution.

Currently i'm using trigger's like these

Code:
Blacksmith 1
    Events
        Time - Every 5.00 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in Blacksmiths and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked unit) is alive) Equal to True
                        (Custom value of (Picked unit)) Equal to 0
                        Int_Iron[(Player number of (Owner of (Picked unit)))] Greater than or equal to 1
                    Then - Actions
                        Unit - Set the custom value of (Picked unit) to 1
                        Set Int_Iron[(Player number of (Owner of (Picked unit)))] = (Int_Iron[(Player number of (Owner of (Picked unit)))] - 1)
                        Multiboard - Set the text for Mlt_Resources item in column ((Player number of (Owner of (Picked unit))) + 1), row 4 to (String(Int_Iron[(Player number of (Owner of (Picked unit)))]))
                        Unit - Create 1 Blacksmith for (Owner of (Picked unit)) at Pnt_Deposit_Goods[(Player number of (Owner of (Picked unit)))] facing Default building facing degrees
                        Animation - Add the gold animation tag to (Last created unit)
                        Unit - Order (Last created unit) to Attack (Picked unit)
                    Else - Actions
                        Do nothing

Code:
Blacksmith 2
    Events
        Unit - A unit Is attacked
    Conditions
        (Unit-type of (Attacking unit)) Equal to Blacksmith
        (Unit-type of (Attacked unit)) Equal to Blacksmith
        (Owner of (Attacking unit)) Equal to (Owner of (Attacked unit))
    Actions
        Unit - Remove (Attacking unit) from the game
        Unit - Set the custom value of (Attacked unit) to 2

Code:
Blacksmith 3
    Events
        Time - Every 5.00 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in Blacksmiths and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked unit) is alive) Equal to True
                        (Custom value of (Picked unit)) Equal to 2
                        ((Picked unit) has buff Not Working ) Equal to False
                    Then - Actions
                        Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 1.00)
                    Else - Actions
                        Do nothing
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Integer((Mana of (Picked unit)))) Equal to 4
                        ((Picked unit) has buff Not Working ) Equal to False
                    Then - Actions
                        Unit - Set mana of (Picked unit) to 0.00
                        Set Point = (Position of (Picked unit))
                        Unit - Create 1 Blacksmith for (Owner of (Picked unit)) at Point facing Default building facing degrees
                        Custom script:   call RemoveLocation(udg_Point)
                        Unit - Set the custom value of (Picked unit) to 0
                        Unit - Set the custom value of (Last created unit) to 1
                        Animation - Add the gold animation tag to (Last created unit)
                        Unit - Order (Last created unit) to Move To Pnt_Deposit_Goods[(Player number of (Owner of (Last created unit)))]
                    Else - Actions
                        Do nothing

Is there any way of making them more efficient? I thought maybe, instead off adding mana via triggers, adding an ability when necessary that gives mana regeneration to the building and then using the event unit- mana becomes ...
(adding the event for every individual building when it is created) would be more efficient. But is it, i'd like to know before changing all my triggers.
 

Hero

─║╣ero─
Reaction score
250
Your creating Unit Group leaks every 5 second. Clean those up...and that should stop the lag....or at least most of it.
 

dannyboydude

Ultra Cool Member
Reaction score
33
by not removing it and each time you cast you override the data causing memory to be lost in " shape and space "

call removegroup ( udg_<yourgroup> ) i think im not good with leaks
 

cleeezzz

The Undead Ranger.
Reaction score
268
by not removing it and each time you cast you override the data causing memory to be lost in " shape and space "

call removegroup ( udg_<yourgroup> ) i think im not good with leaks

it doesn't leak, nothing is being overwritten/lost

you sure its not something else?
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
I know what you mean, but there aren't any unit groups created, can't you see that. "Blacksmiths" is a unit group that is determined before, not in these triggers. These triggers don't create any actual unit groups. I just want to find a way to make these more efficient, since 8 of these trigger-sets fire every 5 seconds, causing the screen to freeze. I just wanted to know if my suggestion would work. (This way, the third trigger wont be necessary, so less triggers would fire every 5 sec)
 

cleeezzz

The Undead Ranger.
Reaction score
268
wait theres 8 of them? post them all up xd

and about your mana thing, setting it by trigger shouldnt affect the performance
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
Yea, but they are all exactly the same form, by 8, i mean there are 8 sets of 3 triggers like the ones I posted
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
first:
Code:
        (Unit-type of (Attacking unit)) Equal to Blacksmith
        (Unit-type of (Attacked unit)) Equal to Blacksmith
        (Owner of (Attacking unit)) Equal to (Owner of (Attacked unit))
useless conditions which could be this:
Code:
        (Unit-type of (Attacking unit)) Equal to Blacksmith
and do the the same thing.

im not sure about the rest but try disbaling the 3rd trigger and see if there still a lag
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
@Doom-Angel

The blacksmith attacking unit is a unit (person), the attacked unit is a building.

But I'm going to finish my map first before trying to find a solution for the lag.
All Thanks for your time.
 
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