- Joined
- Jul 2, 2015
- Messages
- 878
Does anyone know how to add building rotation to maps? Like the ability to rotate buildings with like an ability of sorts?
It works fantastically! The only thing that annoys me a tad bit is that if I use 45 degrees, its off by a bit. Like 360 is supposed to be facing (Downward if from top down view) but its slightly off by a few degrees right. How'd I fix this?Edit: This is how you can rotate the facing angle of a building:
Note that if you Rotate it multiple times in a small time frame the angle will fall off and you'll end up with angles like 246.423 degrees instead of 90, 180, 270, 360. Also, for whatever reason, this trigger doesn't work the first time you do it.
- Rotate
- Events
- Player - Player 1 (Red) skips a cinematic sequence
- Conditions
- Actions
- -------- Set variables --------
- Set Building = Farm 0006 <gen>
- Set Point = (Position of Building)
- Set Angle = ((Facing of Building) + 90.00)
- -------- - --------
- -------- Adjust the angle. Note that "Make Unit face Angle" doesn't work otherwise I'd use it here. --------
- Unit - Move Building instantly to Point, facing Angle degrees
- -------- - --------
- -------- Clean up leaks --------
- Custom script: call RemoveLocation(udg_Point)
I attached a map with an example of how you can do this with an ability. From testing it appears as though 0.50 seconds is about as low of a cooldown you can have for the ability before running into the precision problems that I mentioned before. To fix this, I stored the degrees 1.00 to 360.00 in a Variable called Angles and reference this instead of doing Arithmetic like "Facing of building + 90.00". There's probably a better way of doing this but it works.
Yeah that's exactly what I did, I mean, I guess Oh well? My main concern rn is that fact that the Unit Indexer breaks the map with its 'compiling errors'. If I disable it map works fine, if I enable it, it doesn't.I'm still a bit confused as to what's going on myself. I have no idea why it doesn't Rotate the first time.
And keep in mind, if you use the system in the attached map then you will have to adjust the If Else Statement in the Rotate trigger to this:
By default your buildings AngleIndex[CV] will be equal to 270 (It's default angle). So when you cast the Rotate ability, I increase the AngleIndex[CV] by 45 (or however much you want to rotate). However, if you're already facing 360 degrees aka AngleIndex[CV] = 360 then we need to reset the angle to 45. If we don't reset it, then it would add 360 + 45 giving us an angle of 405.
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- AngleIndex[CV] Not equal to 360
- Then - Actions
- Set AngleIndex[CV] = (AngleIndex[CV] + 45)
- Else - Actions
- Set AngleIndex[CV] = 45
Version 1.31.1What patch are you on? I know there are older versions of Unit Indexer out there that you could import instead.
Auto create for Variables is on, and the map was made before the Lua update so I'm pretty sure its using Jass.Is Automatically create unknown variables on? Are you using Lua instead of Jass?
Problem hast occured | HIVEYeah, then you're definitely on Jass. Older maps seem to have weird problems even if you're up to date. What does the error say?
Where do you check/activate it?In your trigger editor under JassHelper at the top, do you have vJass enabled? All I have checked on is JassHelper and vJass.
vJass and JassHelper are both on.In your trigger editor under the window JassHelper located at the top
The problem is that you have 2 of the same unit indexer trigger, so it's trying to redeclare a function that already exists. One under Requirements > Unit Indexer and one under Buildings/Units > Rotate Building > Unit Indexer (Bribe) > Unit Indexer Copy. Delete one of them.
Thanks! Removed the old Indexer.Here's another version of the map. Still buggy and not working the way I want but with some slight improvements. For some reason the Building's ignore the first rotation... No clue why.
Also, the Unit Indexer you were using in the folder "Requirements" is outdated so I recommend using the one from my map.
Works fantastically! Many thanks sir!Oh, it adds the "Rotate" ability to all of your buildings. But that ability has a different id in your map so you end up getting Repair in this case. You have to change it/delete it from the "Initial Values" trigger.
It's really up to you in how you want to actually do the Rotation. You can easily edit the Rotate trigger to suit your needs. For example, if you don't want all of your buildings to have the Rotate ability then you could use a chat message like -rotate90 or maybe give some Commander unit the ability to Rotate a targeted building.