1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.
IcemanBo
Joined:
Sep 6, 2013
Messages:
6,532
Media:
100
Albums:
10

Awarded Medals 1

    1. GywGod133
      GywGod133
      hehe

      Btw, what happen in Mini Mapping Contest #9?
      :/
    2. GywGod133
      GywGod133
      I want to know which one is better, smoother

      I want to use this on my SPELL
      :( I dont wanna use Move Action (cuz laggy)

      EDIT:
      Maybe Knockback 3d lot of features hehehe

      Btw Thanks for reply :)
    3. GywGod133
    4. Bannar
      Bannar
      K, updated my post to reflect the point.
    5. Bannar
      Bannar
      "dy" seems to be missing. Or I'm just plain wrong? :P
    6. BPower
      BPower
      Ich hab keine Zeit mehr dafür bzw ich verbringe sie andersweitig.
      Es war einfach an der Zeit aufzuhören :)
    7. Mythic
      Mythic
      Hey, tell me when you get 446 rep.
    8. Kyrbi0
      Kyrbi0
      ----------
      If you want to loop through all units go with a unit indexer. So you will just be able to loop through all existing indices and make your checks.
      ----------
      Alright! If that's a good solution for the whole map & several different iterations, I'll give it a try & let you know! Thanks.


      ----------
      But frankly, you want add a temp ability? Much easier is just to run a timer, and then to remove the ability when the timer expires. Use hashtable to attach unit/abilityId to the timer.
      ----------
      Eeesh... Not sure I/you wanna open that particular can of worms. I've heard of 'hashtables' (both online & in my programming classes @ college) & get the general idea of 'multidimensional arrays with keys'... But no clue how to use them. Not sure I wanna bug you, since I'm sure there are tutorials on the subject.
    9. Kyrbi0
      Kyrbi0
      First of all, just want to apologize that it took me so long to respond; I wasn't ignoring you or ungrateful, but I had to think about what you said & that took time (time which, unfortunately, is in very short supply nowadays :<...). That being said:


      ----------
      Why not make these actiosn to target unit directly after casting? So you have to do checks/actions once, and then completly forget about this unit.


      ----------
      Hmm... So it sounds that the "Pick All Units" is too 'costly' (in terms of what, ping? Or computational/processing speed?), but using a global "UnitGroup" variable would be a decent alternative that would allow it?
      (But whether I "pick all units matching X, Y, Z..." or create a UnitGroup variable which does the same thing (having to check the map to add/remove the necessary units from the Group), it seems like that's the same amount of work. Maybe I don't understand)
      ----------
      I make an example. I will show 2 methods to get all units in Region1.

      1. One global UnitGroup, that never gets destroyed. (good)
      2. Creating/destroying a UnitGroup each time.
      Method 1

      Method 2

      I hope you can see the difference. Method 1 needs 3 triggers but is more efficient.
      ----------
      Ok, so you're telling me it's not always the number of triggers that = more/less efficient, but what happens in them? Because yeah, I would've said "3>1!! Less efficient".


      ----------
      In my example I only pick units in Region1, and now imagine you pick every single unit in whole map. If map is very big / or you have many units it is just an enmormous operation, that should be avoided.
      ----------
      Alright, so in order to help you see what I'm trying to accomplish, full disclosure: mainly what I do is work on custom heroes & factions for what is essentially "altered melee"; 5th-race-addition, tavern-addition/replacement, 4-race-replacement, etc.

      That being the setting, the "thing" I'm trying to accomplish is (probably 90% of the time) simple trigger-enhanced abilities. Specifically I was using things like "periodic timers" to detect the presence of certain buffs on units & add/remove certain abilities because of it, dynamically.

      (example being: "Vicious Roar: a roar that increases allied attack damage & gives them Lifesteal for 30 seconds" (i.e. modified Roar ability, then a periodic trigger that, detecting the presence/absence of the "roar" buff, adds/removes a hidden "lifesteal" ability to the affected unit))

      That all being said, it should be clear that this will be cycling through every possible unit on the map (except, perhaps, buildings & trees & such), and should be updating reasonably fast (at least as fast as an Aura; hence .3/.5 seconds...). The map size, of course, may be as small as 1v1 or as large as 6v6. The actual "triggers" are quite 'lite' I would think ("add/remove ability" is pretty much it, so far).

      I realized early on, though, that having a whole bunch of triggers like that would (probably) be a problem. Hence my question.


      ----------
      Now I should method 3, without UnitGroup. Units will be indexed and I will use loop to catch them:
      Method 3

      You see in this method exists no UnitGroup. The reason is, because it's a lot faster.
      In the 'Else - Actions' part the unit has left the region, so we have to deindex properly.
      The method I used is called dynamic indexing because it avoids letting an empty index in my unit[array] variable. (once a unit leaves, it would be null)

      For GUI and looping each 0.50 secnds metho 1 would absolutly do the job without any problem. For bigger situations and/or more complex systems indexing is definitly faster and more efficient.

      EDIT:

      Added "maxIndex = maxIndex - 1" in the deindex part in method 3!
      ----------
      <span style="font-size: 9px">(So wait, "Method 3 doesn't use Unit Group because Method 3 is faster"? Or "Method 3 is faster because it doesn't use Unit Group"?)</span>

      Alright, so I'm trying to understand the coding here... So I think I finally understand the "indexing" bit (you're not using Custom Value, you're just creating a massive array with (potentially) each unit on the map on it, that fits my criteria (in this case, "(T/F) Has this Buff")).

      But given what I have said above about what my needs are (variable (often large) map-size, picking every map unit, reasonable updating frequency, simple triggers, etc), are you suggesting that Method 3 is usable for this/these tasks? And if so, how many can I use before it too becomes a problem (i.e. 1-5, 5-10, 10-20, etc)?

      Thanks again for your thoughts. Sorry it took me so long.

      Respectfully,

      Kyrbi0
    10. Chaosy
      Chaosy
      I will try! xD
    11. Chaosy
      Chaosy
      I just don't like it all. But I think I will go along and use the following system instead.
      http://www.wc3c.net/showthread.php?t=103604

      problem is.. the documentation doesn't show how to get a value from a certain position..
    12. Chaosy
      Chaosy
      Right, that was simple enough.

      I kinda copied your trigger from my old thread. However I don't get how to loop through it. If possible please show me how to do it from another trigger/function, I didn't really like the timer solution you used before.
      struct patrol
      static integer arraySize = 10

      private thistype prev // these are that you don't let a gap in your periodic loop
      private thistype next
      static thistype first = 0

      integer locCount
      real array x [10]
      real array y [10]
      unit u
      public static method create takes unit u returns thistype
      local thistype this = allocate()
      local integer i = 1
      set this.u = u
      set this.locCount = udg_patrolCount
      loop
      exitwhen i > udg_patrolCount
      set x[i] = GetLocationX(udg_patrolPoint[i])
      set y[i] = GetLocationY(udg_patrolPoint[i])
      set i = i + 1
      endloop
      set next = first
      set first.prev = this
      set first = this
      set prev = 0
      return this
      endmethod

      method update takes nothing returns nothing
      local location array loc
      local integer i = 1
      loop
      exitwhen i > this.locCount
      set loc[i] = Location(this.x[i], this.y[i])
      if DistanceBetweenPoints(loc[i],GetUnitLoc(this.u)) < 50 then
      if i >= this.locCount then
      call IssuePointOrder(u, "attack", this.x[1], this.y[1])
      else
      call IssuePointOrder(u, "attack", this.x[i + 1], this.y[i + 1])
      endif

      endif
      set i = i + 1
      endloop
      endmethod

      method destroy takes nothing returns nothing
      call deallocate()
      if this == first then
      set first = next
      endif
      set next.prev = prev
      set prev.next = next
      endmethod
      endstruct
    13. Chaosy
      Chaosy
      Well, then I wonder.. can I use arrays inside a struct?
    14. Chaosy
      Chaosy
      I wanted to avoid that :P then I am stuck with the indexing problem again, if you recall.

      *cough* #chaosysolutions *cough*
    15. Chaosy
      Chaosy
      function patrol takes unit u, integer locCount returns nothing
      local integer id = GetHandleId(u)
      local integer i = 1
      call GroupAddUnit(patrolUnits, u)
      loop
      exitwhen i > locCount
      call SaveReal(hash, id, i, GetLocationX(udg_patrolPoint[i]))
      call SaveReal(hash, id, -i, GetLocationY(udg_patrolPoint[i]))
      set i = i + 1
      endloop
      call SaveInteger(hash, id, 0, locCount)

      call IssuePointOrder(u, "attack", LoadReal(hash, id, 1), LoadReal(hash, id, -1))
      endfunction

      because of the event.
      event
      Events
      Game - patrol_event becomes Equal to 1.00
      Conditions
      Actions
      Game - Display to (All players) the text: ((Name of patrolUnit) + has reached an waypoint!)


      I know that. I attempted to null it instead, but it didn't work. It gave errors.

      Isn't that almost the exact method linked list uses? I never truly understood the logic.
    16. Chaosy
      Chaosy
      Yeah I knew it was something along those lines.

      Anyway, I tried to add.
      function RemoveWaypoint takes integer id, unit u returns nothing
      local integer i = GetHandleId(u)
      call SaveReal(hash, i, id, 0)
      call SaveReal(hash, i, -id, 0)
      endfunction

      if xNew != 0 and yNew != 0 then

      but it doesn't work.. I try to remove waypoint 1, and once he reaches waypoint 1 he runs to the middle which means he is moving to the 0,0 coordinates.

      the whole thing..
      function Group takes nothing returns nothing
      local unit u = GetEnumUnit()
      local integer id = GetHandleId(u)
      local real xUnit = GetUnitX(u)
      local real yUnit = GetUnitY(u)
      local real xNew
      local real yNew
      local integer i = 1
      local integer maxCount = LoadInteger(hash, id, 0)

      loop
      exitwhen i > maxCount

      set xNew = LoadReal(hash, id, i)
      set yNew = LoadReal(hash, id, -i)

      if xNew != 0 and yNew != 0 then
      if SquareRoot((xNew - xUnit)*(xNew - xUnit) + (yNew - yUnit)*(yNew - yUnit)) < 50 then
      set udg_patrol_event = 1
      set udg_patrol_event = 0
      set udg_patrolUnit = u
      if i == maxCount then
      call IssuePointOrder(u, "attack", LoadReal(hash, id, 1), LoadReal(hash, id, -1))
      else
      call IssuePointOrder(u, "attack", LoadReal(hash, id, i+1), LoadReal(hash, id, -i-1))
      endif
      endif
      endif
      set i = i + 1
      endloop
      set u = null
      endfunction

      I am very sorry for being an annoyance for you btw.
    17. Chaosy
      Chaosy
      No, I used reals since I noticed most people hate locations.
    18. Chaosy
      Chaosy
      Yes I want to remove a certain patrol point / way point.

      If I flat out remove the location there will be bugs since the unit will try to move to location that doesn't exist.

      You mean that one should check if the location isn't null when ordering the unit to move?
    19. Chaosy
      Chaosy
      hm...
      function RemoveWaypoint takes integer id, unit u returns nothing
      local integer i = GetHandleId(u)
      local integer count = LoadInteger(hash, i, 0)
      local integer loopCount = id + 1
      loop
      exitwhen loopCount > LoadInteger(hash, id, 0)
      call SaveReal(hash, i, loopCount, LoadReal(hash, i, loopCount - 1))
      call SaveReal(hash, i, -loopCount, LoadReal(hash, i, -loopCount + 1))
      set loopCount = loopCount + 1
      endloop
      call SaveInteger(hash, i, 0, count - 1)
      endfunction

      any clue on why this wont work?
    20. Chaosy
      Chaosy
      I never considered that as an option. I will consider it :)
  • Loading...
  • Loading...
  • Interact

    Signature

  • Loading...
  • Loading...
  • Loading...
  • Loading...