• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] switching units problem

Status
Not open for further replies.
Level 3
Joined
Feb 6, 2009
Messages
50
  • test a picking
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Custom value of (Picked unit)) Equal to 0
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to (Center of p1 dont leave <gen>)
          • Unit - Unpause (Triggering unit)
          • Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of (Picked unit)) Equal to 1
                • Then - Actions
                  • Unit - Set the custom value of (Picked unit) to 0
                  • Unit - Set the custom value of (Triggering unit) to 1
                  • Unit - Move (Picked unit) instantly to (Center of alterchar p1 <gen>)
                  • Unit - Pause (Picked unit)
                • Else - Actions
          • Region - Center p1 dont leave <gen> on (Position of (Triggering unit))
        • Else - Actions

So I HAD this working at one point, then I guess after a bit of modifications it eventually started not working.
Now I can select the same unit and it will move to the switching area (alterchar p1) and suddenly I have a major problem...


The idea is that I have 20 some odd units, as they each level they affect eachothers stats and abilities, however each player can switch them out at will (not that it will make them live longer duringa pvp fight...I mean the health stays the same.)


Also how would you go about switching inventories? (Originally I was going to make it where each unit controled their own items and did not switch...but I don't like that idea anymore.)
 
what is the major problem ? also u have location leaks and group leaks.

this should be moved outside the group loop. also using custom value isnt a good idea u cant use any unit indexer and changed custom value is slower than using an array.
  • Unit - Set the custom value of (Triggering unit) to 1
to switch inventories you pick each item in units inventory and give it to the unit ur switching it to.

ur problem may be this
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Custom value of (Picked unit)) Equal to 0
right in the beginning it should be triggering unit not picked unit
 
Level 3
Joined
Feb 6, 2009
Messages
50
The major problem is that I can select the active unit and have it switch into the switching area (meaning I pretty much can no longer play, unless I want to rn arond the area or do some mad instant character switching, sometimes glitching the picked character to being paused)
sorry I swore I typed all that out.

edit: Ill fix what you have said and then report back however.


alright fixed, now I just need to fix those leaks.
I could have sworn I had that outside the group loop already...well okay...I blame the coffee...
and I believe my problem was that exactly...I'm suprised it even did anything at all...

I might switch to using arrays...not sure why I didn't think of that in the first place....
curse you my beloved coffee...you have foiled me again...
 
Status
Not open for further replies.
Top