• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Building Rotation

Status
Not open for further replies.
Level 3
Joined
Feb 21, 2009
Messages
41
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Substring((Entered chat string), 1, 3)) Equal to 'fa
        (Substring((Entered chat string), 4, 4)) Equal to  
    Then - Actions
        Unit Group - Pick every unit in a_tmpUnitGroup01[(Player number of (Triggering player))] and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked unit) is selected by (Triggering player)) Equal to True
                        (Unit-type of (Picked unit)) Not equal to RoTRP Spawner
                    Then - Actions
                        Unit - Make (Picked unit) face (Real((Substring((Entered chat string), 5, 7)))) over 1.00 seconds
                    Else - Actions
        Skip remaining actions
        Unit Group - Destroy unit group a_tmpUnitGroup01[(Player number of (Triggering player))]
    Else - Actions

This is the trigger. In theory, it should make it so if I type 'fa 90, it will rotate the building 90 degrees. The problem is, it doesn't quite do that. It rotates the building, but it does not appear to know where 90 degrees is.

I was wondering if anyone could help me make this work right. Thanks.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Use trigger tags:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Substring((Entered chat string), 1, 3)) Equal to 'fa
      • (Substring((Entered chat string), 4, 4)) Equal to
    • Then - Actions
      • Unit Group - Pick every unit in a_tmpUnitGroup01[(Player number of (Triggering player))] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is selected by (Triggering player)) Equal to True
              • (Unit-type of (Picked unit)) Not equal to RoTRP Spawner
            • Then - Actions
              • Unit - Make (Picked unit) face (Real((Substring((Entered chat string), 5, 7)))) over 1.00 seconds
            • Else - Actions
      • Skip remaining actions
      • Unit Group - Destroy unit group a_tmpUnitGroup01[(Player number of (Triggering player))]
    • Else - Actions
*Use only one condition, substring 1,4 == 'fa
-Add a space after the a
*Instead of 7, use length of entered chat string
You can try using Game - display text message and displaying the angle.

You can try rotating the building with this method:
JASS:
function SetImmovableUnitFacing takes unit u, real a returns nothing
    call SetUnitPosition(u, GetUnitX(u), GetUnitY(u))
    call SetUnitFacing(u, a)
endfunction

You can use those call xxx as custom scripts, replace u with GetEnumUnit()
GetEnumUnit() = picked unit
 
Level 3
Joined
Feb 21, 2009
Messages
41
It's for a RP map. the 'fa command is used to rotate unit and building alike to the entered chat string angle. At the moment, any angle used result in a +10 degrees variation. If I enter in-game command 'fa 0. The angle returned is actually 'fa -10. 'fa 10 will return 0 (facing east). To get 90, we need to enter 100 and so on for any angle from 0-360. We applied the changes suggested by Maker and we obtain similar result at a better pace.

Of course, lets say the barrack. Its 270 default angle is actually off the 270 angle of other building. The same applies to any unit and buildings.

What we want to do is fix the trigger in a way that it will return the correct values entered without needing to play with it a couple time to obtain the correct angles of buildings when players are trying to build.

Hope that explain the situation and thanks in advance for any help.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
im not sure you under stand. When you say "it will return" it means your printing Real2String(Facing of selected unit)?

If you're going based on eye all of the units facings are different, its not as if the entreance to the barracks HAS To be directly south on a default facing
 
Tried all of that, but the angles are still 10 degrees off. Any idea how to fix that?
Just substract that extra angle in the trigger then

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Substring((Entered chat string), 1, 3)) Equal to 'fa
      • (Substring((Entered chat string), 4, 4)) Equal to
    • Then - Actions
      • Unit Group - Pick every unit in a_tmpUnitGroup01[(Player number of (Triggering player))] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is selected by (Triggering player)) Equal to True
              • (Unit-type of (Picked unit)) Not equal to RoTRP Spawner
            • Then - Actions
              • Unit - Make (Picked unit) face (Real((Substring((Entered chat string), 5, 7))) - 10.00) over 1.00 seconds
            • Else - Actions
      • Skip remaining actions
      • Unit Group - Destroy unit group a_tmpUnitGroup01[(Player number of (Triggering player))]
    • Else - Actions
 
Status
Not open for further replies.
Top