Post news RSS More Than Meets The Eye: Far Sight

The story behind the development of Far Sight. There is more to the ability than meets the eye.

Posted by on

Manifest is a turn-based game. Every feature I implement, every decision I make, has to consider the turn-based structure of the game. For example, spell durations are practically useless; they need be as long as a player's available time during a turn, but more importantly, most spell effects need to end when the next turn begins. More often than not, players complete turns by either depleting their available Action Points or by manually typing "End." Therefore, player's turns end long before the timer clocks out. Positive buffs need to be removed at the end of the turn so as to not be active during the enemies turn.

Fortunately, this is a fairly simple triggering task...usually. But every once in a while, I'll run into an ability or effect that simply refuses to work as I expect it to. Far Sight was one such case.

Far Sight is a seemingly simple ability. Upon casting, fog of war and black mask are removed within a radius of the targeted area (underneath a swirly special effect), showing enemy positions and revealing invisible units. The ability works just fine, except for that fact that I need the fog-removing effect and swirly special effect to terminate upon the next player's turn. So I tried setting variables. But as it turns out, the Far Sight effect is neither a visibility modifier nor a special effect. The swirly effect, for some reason, is actually under buffs.

My second method was to manually remove the fog of war and create the swirl via code. I would set variables to each part and, later, when the new turn is triggered, I would tell those variables to end. In advance, I apologize for the difficulty reading the code. I tried embedding images, but they are too wide, and when shrunk, too difficult to read.

    Events
        Unit - A unit Starts the effect of an ability

    Conditions
        (Ability being cast) Equal to Far Sight [Flame Strike]

    Actions
        Game - Display to (All players) the text: Far Sight Cast
        Set FarSightPoint = (Target point of ability being cast)
        Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Other\Andt\Andt.mdl
        Set FarSightEffect = (Last created special effect)

        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Far Sight [Flame Strike] for (Casting unit)) Equal to 1

            Then - Actions
                Visibility - Create an initially Enabled visibility modifier for (Owner of (Casting unit)) emitting Fog of war from (Target point of ability being cast) to a radius of 600.00
                Set VisibilityModifiers[1] = (Last created visibility modifier)
                Visibility - Create an initially Enabled visibility modifier for (Owner of (Casting unit)) emitting Black mask from (Target point of ability being cast) to a radius of 600.00
                Set VisibilityModifiers[2] = (Last created visibility modifier)
                Game - Display to (All players) the text: Far Sight Modifier ...

            Else - Actions

                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Level of Far Sight [Flame Strike] for (Casting unit)) Equal to 2

                    Then - Actions
                        Visibility - Create an initially Enabled visibility modifier for (Owner of (Casting unit)) emitting Fog of war from (Target point of ability being cast) to a radius of 900.00
                        Set VisibilityModifiers[1] = (Last created visibility modifier)
                        Visibility - Create an initially Enabled visibility modifier for (Owner of (Casting unit)) emitting Black mask from (Target point of ability being cast) to a radius of 900.00
                        Set VisibilityModifiers[2] = (Last created visibility modifier)

                    Else - Actions

                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Level of Far Sight [Flame Strike] for (Casting unit)) Equal to 3

                            Then - Actions
                                Set VisibilityModifiers[1] = (Last created visibility modifier)
                                Visibility - Create an initially Enabled visibility modifier for (Owner of (Casting unit)) emitting Fog of war from (Target point of ability being cast) to a radius of 1200.00
                                Set VisibilityModifiers[2] = (Last created visibility modifier)
                                Visibility - Create an initially Enabled visibility modifier for (Owner of (Casting unit)) emitting Black mask from (Target point of ability being cast) to a radius of 1200.00

                            Else - Actions
                                Do nothing

        Visibility - Enable VisibilityModifiers[1]
        Visibility - Enable VisibilityModifiers[2]

Spiffy, no? Unfortunately, the bugger didn't work. The fog of war would disappear, which is a start. But the black mask would not, at least not long-term, rendering this code useless. My next step was to visit the forums.

The World Editor Helper forum is a magical place. The fantastic forum goers understand the World Editor like George Washington understood democracy. They're seriously on top of their game, all the time. Post a question, any question. Within minutes, you'll receive a number of responses, many of which, in all probability, solve whichever issue you are having. Though I've used the forums few times for Manifest in particular, the help from there throughout my many years modding is what allowed me to make this mod in the first place. The forum is really an Elysian field for all who enjoy Warcraft modding. I would highly recommend it.

Once again, the geniuses from the forum save the day. I posted my problem: How do I get Far Sight to end early, manually. And several clarification posts later, a user named SanKakU comes out of nowhere and completely solves the case.

SanKakU wrote: hmm...why can't you just make a dummy unit with (or perhaps without, depending on your visual effects needs) the model for the far sight effect and manipulate that? you can give the dummy unit true sight and create and remove him when necessary...


Of course! Why hadn't I thought of that? A few minutes later, the code is written.

Far Sight Dummy
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Far Sight [Custom]
    Actions
        Game - Display to (All players) the text: Far Sight Cast
        Set FarSightPoint = (Target point of ability being cast)
        Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Other\Andt\Andt.mdl
        Set FarSightSpecial[(Player number of (Owner of (Casting unit)))] = (Last created special effect)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Far Sight [Custom] for (Casting unit)) Equal to 1
            Then - Actions
                Unit - Create 1 FarSightUnit [Lvl 1 600 Sight] for (Owner of (Casting unit)) at FarSightPoint facing Default building facing degrees
                Set FarSightDummy[(Player number of (Owner of (Casting unit)))] = (Last created unit)
                Game - Display to (All players) the text: Far Sight Modifier ...
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Level of Far Sight [Custom] for (Casting unit)) Equal to 2
                    Then - Actions
                        Unit - Create 1 FarSightUnit [Lvl 2 900 Sight] for (Owner of (Casting unit)) at FarSightPoint facing Default building facing degrees
                        Set FarSightDummy[(Player number of (Owner of (Casting unit)))] = (Last created unit)
                        Game - Display to (All players) the text: Far Sight Modifier ...
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Level of Far Sight [Custom] for (Casting unit)) Equal to 3
                            Then - Actions
                                Unit - Create 1 FarSightUnit [Lvl 3 1200 Sight] for (Owner of (Casting unit)) at FarSightPoint facing Default building facing degrees
                                Set FarSightDummy[(Player number of (Owner of (Casting unit)))] = (Last created unit)
                                Game - Display to (All players) the text: Far Sight Modifier ...
                            Else - Actions
                                Do nothing

Let's walk through the code, shall we. Far Sight[Custom] is (as the name implies) a custom version of Far Sight. Far Sight was needed specifically so that the targeting cursor may be seen in the fog of war, an effect which is lost with other point-cast abilities such as Flame Strike. My custom version of Far Sight, has only a one second duration. I then create a variable, FarSightPoint, naming the point where Far Sight was cast. Technically, I can later refer to the target point as "target point of ability being cast" in each line of code, but a variable is much cleaner and easier to write. I also manually create the Far Sight special effect and name it with a variable so I may refer to it later.

Next, begins my If/Then/Else statement. The higher the level of Far Sight, the greater the radius revealed. So I first check the level of the ability in my conditions, then create the corresponding custom unit. For simplicity, I created three units called FarSightDummy, each identical and invisible save their sight radius. I set the Art - Model File of the custom units to " .blp". That's "spacebar.blp". This tricks the editor into the unit not having a unit model. I also give each unit the True Sight ability so that they may see invisible units. As usual, I set a variable to the created unit so that I may refer to it in a later trigger.

The final step takes place during my triggering of a new player's turn. Here, I simply kill the FarSightDummy and kill the Far Sight special effect, returning fog of war to the set area. To players, my custom Far Sight works exactly like the real ability, but little do they know of the extensive work taking place behind the scenes.

This is a good example of how I work through every issue I have: trial and error. Try your best to think of something that works. Test it out. It probably fails. Try again. And again. Until it works. (...it might be days...).

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

News
Tags
Dev Diary
Browse
News
New
Post news
Share
Related Games
Warcraft III: Frozen Throne
Warcraft III: Frozen Throne Real Time Strategy