• 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] Facing of unit problem

Status
Not open for further replies.
Level 4
Joined
Sep 11, 2018
Messages
74
My problem is switchguard doesn't face guardangleint after attacking switch. Any idea?
  • For each (Integer tempinte) from 1 to 8, do (Actions)
    • Loop - Actions
      • Set guardangleint[tempinte] = (Facing of switchguard[tempinte])
  • SwichGuards
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer switchguardint) from 1 to 8, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in allheroes and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (switches[switchguardint] is alive) Equal to True
                  • (outsidegate[switchguardint] contains (Picked unit)) Equal to True
                • Then - Actions
                  • Unit - Order switchguard[switchguardint] to Attack switches[switchguardint]
                  • Unit - Make switchguard[switchguardint] face guardangleint[switchguardint] over 2.00 seconds
                • Else - Actions
 
Level 5
Joined
Jul 27, 2017
Messages
73
So the switchguard is triggered to attack the switch?

My idea: the attack-order blocks the change facing. How about adding a little wait between those actions like 0.5 seconds or just a time that is long enough to await the attack. (i think that this only works when your region is very small)

If you don't need the attack animation, a dummy could be an option. (Although i doubt that this is the case)
 
Level 5
Joined
Jul 27, 2017
Messages
73
Ok sorry for the late answer. I made a test with this code:
  • test
    • Ereignisse
      • Spieler - Spieler 1 (Rot) types a chat message containing -test as Exakte Übereinstimmung
    • Bedingungen
    • Aktionen
      • Set unitangle = (Facing of Prisoner 0010 <gen>)
      • Spiel - Display to (All players) the text: (Angle of unit is: + (String(unitangle, 1, 2)))
      • Einheit - Order Prisoner 0010 <gen> to Angreifen Hebel 0668 <gen>
      • Spiel - Display to (All players) the text: Start setting angle
      • Wait 2.00 seconds
      • Einheit - Make Prisoner 0010 <gen> face unitangle over 2.00 seconds
      • -------- Make unit face this angle --------
      • Set unitangle = (Facing of Prisoner 0010 <gen>)
      • Spiel - Display to (All players) the text: (Angle of unit is: + (String(unitangle, 1, 2)))
Although it's a german version i think that this should be clear enough.

So what i did:

I have a unit (the Prisoner 0010) who is standing next to a leaver (Hebel 0668). He attacks the leaver in any case (and the leaver dies).

So where is the problem?

First i tried it without the wait 2.00 seconds part and the facing angle was not changed. So i added the waiting and it succeded.

Conclusion:
attacking interupts the facing but why is it like that?

What i assume:
The unit gets the order to attack the leaver. Then immediately the units facing is changed by the trigger but the unit has not attacked the leaver yet and the unit STILL has the order to attack that leaver. (The time between those 2 trigger action should be something like 1 millisecond if my c# experience can be adapted)
And now the unit breaks the change facing because it still wants to hit the leaver.

So what you need, if i haven't forgotten anything, is a wait for the attack of the leaver: I suggest to wait for a Destructable / Unit Dies Event (maybe a little bit harder if your target does not die by one attack)
There is also a function to wait for an event to occur.

I hope this helps.
 
Level 4
Joined
Sep 11, 2018
Messages
74
Thanks for the reply.
I solved it using this:
  • SwichGuardsFacing
    • Events
      • Time - Every 11.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer switchguardint) from 1 to 8, do (Actions)
        • Loop - Actions
          • Unit - Make switchguard[switchguardint] face guardangleint[switchguardint] over 1.00 seconds
 
Status
Not open for further replies.
Top