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,463
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,463
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,463
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,463
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,463
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,463
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,463
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: 164

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,463
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,463
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.
  • 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

      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