Generate Real value based on timed unit life

rogers

You can change this now in User CP.
Reaction score
1
I am allowing players to create units in different regions using an item and I set a Generic expiration timer to 60 seconds for that unit, and for that 60 seconds I want to generate a Real value of +0.05(RealAdd) and add it to another Real value variable (RealTotal) every 1 second, but I want to restrict the number of units they can create within a Region to 2 - what would be the best way to accomplish all of this?


Edit: I'm not looking for anyone to write out the triggers, moreless just answer what is the best way to accomplish this: best units/abilities to use, what the triggers should do, etc.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
So you want to limit the number of units they can summon, and you want to increment a variable every second for every summoned unit of that type? Is that correct?
Just trying to make sure.
 

rogers

You can change this now in User CP.
Reaction score
1
Yes.

I had considered doing this by checking each region every 60 seconds, and putting all of the units of a type (summoned) that are in those regions into a unit group, then for each of them, add the real value to the RealTotal variable, but what worries me is the lag that could create seeing as how there could be dozens of units in each of those regions and those selections could slow the game.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
It will cost a little bit of performance but its not that slow. Creating a unit group every second, picking all units of type and adding some values isnt that slow.

But of course, you can do it a little bit more efficient.
Code:
Event
 Unit - A unit is summoned
Condition
 Unit type of summoned unit == TheImportantUnit
Action
 if (Position of (Summoned unit)) is within SomeArea1
   Unit Group - Add summoned unit to SomeGroup1
 
 if (Position of (Summoned unit)) is within SomeArea2
   Unit Group - Add summoned unit to SomeGroup2
 
 if (Position of (Summoned unit)) is within SomeArea3
   Unit Group - Add summoned unit to SomeGroup3
 
 if (Position of (Summoned unit)) is within SomeArea4
   Unit Group - Add summoned unit to SomeGroup4

You can also check the number of units within that group and only add the newly summoned unit to it if its 0 or 1. Otherwise simply kill the unit.

But you need another trigger like this:
Code:
Event
 Unit - A unit dies
Condition
 Unit type of summoned unit == TheImportantUnit
Action
 Unit Group - Remove triggering unit from SomeGroup1
 Unit Group - Remove triggering unit from SomeGroup2
 Unit Group - Remove triggering unit from SomeGroup3
 Unit Group - Remove triggering unit from SomeGroup4
 

rogers

You can change this now in User CP.
Reaction score
1
I've noticed major performance issues when doing large groups of units. Perhaps my situation is unique, but it causes the game to pause for a second while it goes on.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
Then its either your computer or you are doing something else in a very inefficient way.
Just picking all units of a certain type within an area does not cause performance problems itself.
 

rogers

You can change this now in User CP.
Reaction score
1
Quick question on the subject of memory leaks: when that unit dies, are there any leaks? I shouldn't have to cycle that group ever-so-often, should I?
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
You are talking about the triggers I posted above? The second trigger does not leak; the first however leaks several positions.
 

rogers

You can change this now in User CP.
Reaction score
1
Then its either your computer or you are doing something else in a very inefficient way.
Just picking all units of a certain type within an area does not cause performance problems itself.

I've got a pretty good gaming system, so I don't think it's my system. It could've been that I wasn't using enough conditions when selecting the units in each region (e.g. units of a certain type) allowing it to ignore those that didn't match those conditions (e.g. I was putting every unit on the map into a unit group, then counting them to see how many were alive). It seemed to almost halt the game for at least 2 seconds. Some of my testers were complaining of much longer pauses.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
Please show the trigger. I can not talk about this without seeing exactly what you are doing.
 

rogers

You can change this now in User CP.
Reaction score
1
You are talking about the triggers I posted above? The second trigger does not leak; the first however leaks several positions.

First. I can't clear the group using the DestroyGroup, because that clears the group completely, right?
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
The group in that trigger must NOT be destroyed.
I do not create new unit groups there; I just add / remove units to / from a pre-existing group.
Destroying the group would make the triggers fail.
 

rogers

You can change this now in User CP.
Reaction score
1
Please show the trigger. I can not talk about this without seeing exactly what you are doing.

This trigger, when there are 600+ units on the map (props included), causes hiccups:

Code:
Count Alive Units
    Events
    Condititions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions (Unit-type of (Picked unit)) Equal to Footman
                Then - Actions
                    Set AliveUnitCount = (AliveUnitCount + 1)
                Else - Actions
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
Well thats obvious. 600+ units alone should cause lag; the wc3 engine is not supposed to handle this amount of units and gets pretty inefficient from a certain number onwards.

And yeah, not only are you leaking a group each time this trigger runs, its also pretty pretty inefficient. For one, you only want to check units in a certain area, no need to pick all units on the entire map then.
And second, you can specify a condition within the "pick all units" action.
Furthermore, this way you can simply "pick all units of type footman" instead of units on the map.

But I uploaded a test map as an attachment showing you how you could do it more efficiently.
 

Attachments

  • Elementals.w3x
    20.3 KB · Views: 165

rogers

You can change this now in User CP.
Reaction score
1
The only reason there are so many units, is because I use units as props that they can interact with for quests. 5-6 (or more) units required for each quest, with 80+ quests... it adds up quickly. I had considered using doodads, but there is a limit on doodads with the standard editor (plus, this map is old - from before I knew I could use the other editor).
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
Just get a third party program like "Jass New Gen" or "World edit unlimited" (which was already outdated even when I was still making maps, so...).
These programs remove the limit on doodads as well as several other limits in the editor.
 

rogers

You can change this now in User CP.
Reaction score
1
Just get a third party program like "Jass New Gen" or "World edit unlimited" (which was already outdated even when I was still making maps, so...).
These programs remove the limit on doodads as well as several other limits in the editor.

I don't think you realize what a major effort this would be. Entire regions would have to be rebuilt entirely and redesigned. It would be the equivalent of nearly rebuilding a 7-year old map, from the beginning.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
And the flip side? Lag and a badly made map?
I would pick work over living in shame.

But thats more of a personal preference.
 

rogers

You can change this now in User CP.
Reaction score
1
The map currently isn't laggy nor am I ashamed of it. This map is just massive with hundreds of triggers and custom units, and terrain that is almost completely custom (doodads, destructibles, etc). I'll have to do that slowly, as I redesign the map, because changing all of it at once would require 8-10 weeks working on it a minimum of 40 hours a week. Who has that much spare time? A hobby is not a full time job. Appreciate your input.
 
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