• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] player group giving income/sec if a unit is built

Status
Not open for further replies.
Level 6
Joined
Sep 24, 2015
Messages
174
  • Lumberbase 1 test
    • Event
      • Temps - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to* Lumber Base 1 (bug fix test)
        • Then- Actions
          • Player group - Pick every player in HumanGroup and do (Actions)
            • Loop - Actions
              • Player - Add 25 to (picked player) Current wood
        • Else - Actions
 
Last edited by a moderator:
Level 37
Joined
Jul 22, 2015
Messages
3,485
You should only request to remove a thread if you posted something that was against the rules. Its also not considerate to completely edit out your post without providing the solution and or find that solved your issue or concern. Can you imagine what its like for someone that has a similar situation as you did to stumble upon your post to find that you edited everything out?
 
Level 6
Joined
Sep 24, 2015
Messages
174
Well Dr Super Good helped me to fix this (he fixed it already)

JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function GetUnitsOfTypeIdAllFix takes integer unitid returns group
    local group   g      = CreateGroup()
    local integer index  = 0
    set bj_groupEnumTypeId = unitid
    set bj_groupAddGroupDest = CreateGroup()
    loop
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        call ForGroup(g, function GroupAddGroupEnum)
        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)
    set g = null
    return bj_groupAddGroupDest
endfunction

he implemented this on my map header and than he did this to my trigger:

  • lumberbase01
    • Event
      • Temps - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set RegTypeUA = Lumber Base 1 (bug fix test)
      • Custom script: set udg_RegGroupA = GetUnitsOfTypeIdAllFix(udg_RegTypeUA)
      • Custom script: set bj_wantDestroyGroup = true
      • Groupe unit - Pick every unit in RegGroupA and do (Actions)
        • Boucle - Actions
          • Joueur - Add 25 to (Owner of (Picked unit)) Current wood
Sorry about that guys :)
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
I'm glad you posted that. There's a different approach I wanted to show you that does it all in GUI, but creates/destroys more groups to do it:

  • lumberbase01
    • Events
      • Game - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each TempInteger from 1 to 12, do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Player(TempInteger))) 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 Lumber Base 1 (bug fix test)
                • Then - Actions
                  • Player - Add 25 to (Player(TempInteger)) Current lumber
                • Else - Actions
And this one, maybe the best way to do it of all of them as it only opens a new thread for units once instead of as many as 3 times:

  • Custom script: set bj_wantDestroyGroup = true
  • 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 Lumber Base 1 (bug fix test)
        • Then - Actions
          • Player - Add 25 to (Owner of (Picked unit)) Current lumber
        • Else - Actions
 
Level 6
Joined
Sep 24, 2015
Messages
174
yeah i did like exemple 2 at the beginning but somehow it gave only to player 1 the lumber and not to other players.

in fact, if i understood what dr super good told me :

GroupAddGroup processes your bj_wantDestroyGroup


GroupAddGroup is used by GetUnitsOfTypeIdAll

it destroys the local filter group

it destroyed my group and the built unit couldn't be see by the systeme...if i'm not wrong and if i understood it was like this (the problem) xD

but y like you did didn't work and i was about to redo all the map because i didn't know where the problem was :/

Thanks hive members !
 
Status
Not open for further replies.
Top